akhauriyash/Code-Regression huggingface dataset:
### constant

INF = 1 << 30

### main

loop do
  n = gets.to_i
  break if n == 0

  ctys = Array.new(n){gets.strip}
  #p ctys
  
  oks = Array.new(n){true}
  for i in (0...n)
    for j in (0...n)
      if i != j && oks[j] && ctys[j].include?(ctys[i])
        oks[i] = false
      end
    end
  end
  #p oks

  ctys = (0...n).select{|i| oks[i]}.map{|i| ctys[i]}
  n = ctys.length
  #p ctys

  plens = Array.new(n){Array.new(n){0}}
  for i in (0...n)
    ci = ctys[i]
    li = ci.length
    for j in (0...n)
      next if i == j
      cj = ctys[j]
      lj = cj.length

      k = (li < lj) ? li : lj
      while k > 0
        break if ci[li - k, k] == cj[0, k]
        k -= 1
      end
      plens[i][j] = lj - k
    end
  end
  #p plens

  dp = Array.new(1 << n){Array.new(n){INF}}
  for i in (0...n)
    dp[1 << i][i] = ctys[i].length
  end

  for bits in (1...(1 << n))
    for i in (0...n)
      bi = 1 << i
      if (bits & bi) != 0
        for j in (0...n)
          bj = 1 << j
          if (bits & bj) == 0
            bitsj = bits | bj
            ndp = dp[bits][i] + plens[i][j]
            dp[bitsj][j] = ndp if dp[bitsj][j] > ndp
          end
        end
      end
    end
  end

  puts dp[(1 << n) - 1].min
end

Measured memory_bytes: 9260
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int x[14];
bool r[14][100];
bool tempai(int num, int jan, int chou, bool make){
  for(int i=0; i<14; i++){
    if(!r[i][num]){
      if(jan == 1 && i<13){
	if(x[i] == x[i+1] && !(r[i+1][num])){
	  for(int j=0; j<14; j++){r[j][num+1] = r[j][num];}
	  r[i][num+1] = 1;
	  r[i+1][num+1] = 1;
	  make = tempai(num+1,0,chou,make);
	}
      }
      if(chou>0 && i<12){
	if(x[i] == x[i+1] && x[i+1] == x[i+2]&& !(r[i+1][num]) && !(r[i+2][num])){
	  for(int j=0; j<14; j++){r[j][num+1] = r[j][num];}
	  r[i][num+1] = 1;
	  r[i+1][num+1] = 1;
	  r[i+2][num+1] = 1;
	  make = tempai(num+1,jan,chou-1,make);
	}
      }
      if(chou>0 && x[i]<8){
	int a = -1,b = -1;
	for(int j=i+1; j<14; j++){
	  if(x[j] == x[i]+1 && !(r[j][num])){a = j;}
	  if(x[j] == x[i]+2 && !(r[j][num])){b = j;}
	}
	if(a!=-1 && b!=-1){
	  for(int j=0; j<14; j++){r[j][num+1] = r[j][num];}
	  r[i][num+1] = 1;
	  r[a][num+1] = 1;
	  r[b][num+1] = 1;
	  make = tempai(num+1,jan,chou-1,make);
	}
      }
    }
  }
  if(!(jan) && !(chou)){make = true;}
  return make;
}
int main(){
  bool ant = false;
  for(;;){
    int hai[14] = {0};
    vector<int> ans;
    for(int i=0; i<13; i++){
      if(scanf("%1d",&hai[i]) == EOF){ant = true;break;}
    }
    if(ant == true){break;}
    for(int i=1; i<10; i++){
      hai[13] = i;
      for(int j=0; j<14; j++){x[j] = hai[j];}
      sort(x,x+14);
      bool ax = false;
      for(int j=0,r=-1,cou=0; j<14; j++){
	if(r != x[j]){r = x[j];cou = 1;}
	else{cou++;}
	if(cou > 4){ax = true; break;}
      }
      if(!ax){
	bool f = tempai(0,1,4,false);
	if(f){ans.push_back(i);}
      }
    }
    if(ans.empty()){cout<<"0"<<endl;}
    else{
      for(int i=0; i<ans.size(); i++){
	if(!i){cout<<ans[i];}
	else{cout<<" "<<ans[i];}
      }
      cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int N;
   cin >> N;
   vector<int> V(N), C(N);
   for(int i = 0; i < N; i++){
      cin >> V[i];
   }
   for(int i = 0; i < N; i++){
      cin >> C[i];
   }

   int ans = 0;
   for(int i = 0; i < N; i++){
      if(V[i] - C[i] > 0){
         ans += V[i] - C[i];
      }
   }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int 					ll
#define ios	    				ios_base::sync_with_stdio(false); cin.tie(0)
#define hell 					1000000007
#define inf 					9e18

// Data Structures //
#define ull 					unsigned long long
#define ll 						long long
#define p_q 					priority_queue
#define pii         			pair<ll,ll>
#define vi          			vector<ll>
#define vii         			vector<pii>
#define mi          			map<ll,ll>
#define mii         			map<pii,ll>
// Functions //
#define pb 						push_back
#define ppb						pop_back
#define all(a)      			(a).begin(),(a).end()
#define gcd(a,b)    			__gcd((a),(b))
#define lcm(a,b)    			((a)*(b)) / gcd((a),(b))
#define mp 						make_pair
#define bs						binary_search
#define lb 						lower_bound
#define ub						upper_bound
#define F						first
#define S						second
#define take(a,n)				for(ll i=0;i<n;i++) cin>>a[i];
#define dbg(x) 					cout << #x << " = " << x << '\n'
#define endl					"\n"
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

#define N  1000005



void solve()
{
	ll n;
	cin>>n;
	vi v(n),dp(n+1);
	for(int i=0;i<n;i++) cin>>v[i];
	dp[1] = abs(v[1]-v[0]);
	for(int i=2;i<n;i++)
	{
		dp[i] = min(abs(v[i]-v[i-1]) + dp[i-1] , abs(v[i]-v[i-2]) + dp[i-2]); 
	}
	cout<<dp[n-1]<<endl;
	
}


signed main()
{
	ios;
	ll n,tests=1,prev=0,i=0;

	//cin>>tests;
	while(tests--)
	{
		solve();
	}
	time
	return 0;
}

Measured memory_bytes: 4748
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

public class Program
{
    public static void Main(string[] args)
    {
        new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
        var n = cin.ReadInt;
        var s = cin.ReadLine;
        var ret = "";
        foreach (var item in s)
        {
            var ans = item + n;
            if (90 < ans)
                ans -= 26;
            ret += (char)(ans);
        }
        WriteLine(ret);
        ReadKey();
    }
}

public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}


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

int main() {
    int a, b;
    cin >> a >> b;

    if (a * b % 2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    for(ll i=1;i*i<=m;i++){
        if(m%i!=0)continue;
        ll j=m/i;
        if(i*n<=m){
            ans=max(ans,i);
        }
        if(j*n<=m){
            ans=max(ans,j);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = input()
t = int(N[len(N)-1:])
if t == 2 or t == 4 or t == 5 or t == 7 or t == 9:
    print('hon')
elif t == 0 or t == 1 or t == 6 or  t == 8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9172
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
#define INF 1<<30
using namespace std;
int dx0[]={0,1,0,-1,-1,-1},dx1[]={1,1,1,0,-1,0},dy[]={-1,0,1,1,0,-1};
int md[100][100],td[100][100],s,t,sx[10],sy[10],tx[10],ty[10],m,n,tc,mc;
void rec(int x,int y,int a){
	td[x][y]=a;
	rep(d,6){
		int nx=x+(y%2?dx1[d]:dx0[d]),ny=y+dy[d];
		if(ck(nx,m)&&ck(ny,n)&&td[nx][ny]>a+1)rec(nx,ny,a+1);
	}
}
int main(){
	while(cin>>m>>n>>s,m){
		rep(i,m)rep(j,n)md[i][j]=INF;
		rep(i,s)cin>>sx[i]>>sy[i],sx[i]--,sy[i]--;
		cin>>t; rep(i,t)cin>>tx[i]>>ty[i],tx[i]--,ty[i]--;
		rep(i,s){
			rep(k,m)rep(l,n)td[k][l]=INF;
			rec(sx[i],sy[i],0);
			rep(k,m)rep(l,n)if(md[k][l]>td[k][l])md[k][l]=td[k][l];
		}
		mc=0; rep(i,t){
			tc=0;
			rep(k,m)rep(l,n)td[k][l]=INF;
			rec(tx[i],ty[i],0);
			rep(k,m)rep(l,n)if(md[k][l]>td[k][l])tc++;
			if(mc<tc)mc=tc;
		}
		cout<<mc<<endl;
	}
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	long long ans = 0;
	int N;
	cin >> N;

	vector<int> input[] = { vector<int>(N),vector<int>(N),vector<int>(N) };

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> input[i][j];
		}

		sort(input[i].begin(), input[i].end());
	}

	for (int i = 0; i < N; i++)
	{
		int x = input[1][i];
		
		long long a_count = lower_bound(input[0].begin(), input[0].end(), x) - input[0].begin();

		long long c_count = N - (upper_bound(input[2].begin(), input[2].end(), x) - input[2].begin());
		ans += a_count * c_count;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
while True:
    H,W = map(int,input().split())
    if W == 0 and H == 0:break
    for i in range(H):
        for j in range(W):
            if i%2 != 0 and j%2 != 0:
                print("#",end="")
            elif i%2 == 0 and j%2 != 0:
                print(".",end="")
            elif i%2 == 0 and j%2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t n;
    cin >> n;
    int64_t ans = 1;
    std::vector<int64_t> a(n);
    rep(i, n) {
        cin >> a[i];
        // ans *= a[i];
    }

    Sort(a);
    int64_t m = 1000000000000000000;
    if ( a[0] == 0 ) {
        ans = 0;
    } else {
        if ( a[n-1] > m ) {
            ans = -1;
        } else {
            rep(i, n) {
                ans *= a[i];
                m /= a[i];
                // cout << "a " << ans << " " << m << endl;
                if ( m < 1 ) {
                    ans = -1;
                    break;
                }
            }
        }

    }

    if ( ans > 1000000000000000000 ) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
A = [int(input()) for i in range(5)]
min_1 = 10
sum_v = -10

for num in A:
    dig1 = num % 10
    if dig1:
        min_1 = min(min_1, dig1)

    if dig1:
        sum_v += (num // 10) * 10 + 10
    else:
        sum_v += num

if min_1 != 10:
    print(sum_v + min_1)
else:
    print(sum_v + min_1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    } else {
            cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 190;

int n,m;
int sum[MAXN][MAXN];
int f[MAXN][MAXN][MAXN];
int g[MAXN][MAXN][MAXN];
int lazf[MAXN][MAXN][MAXN];
int lazg[MAXN][MAXN][MAXN];

char s[MAXN][MAXN];

int SUM(int xa,int ya,int xb,int yb)
{
	return sum[xb][yb] - sum[xa - 1][yb] - sum[xb][ya - 1] + sum[xa - 1][ya - 1];
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1;i <= n;i++)
		scanf("%s",s[i] + 1);
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++)
			sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + (s[i][j] == '#');
	for (int i = 1;i <= n;i++)
		for (int j = i;j <= n;j++)
			for (int k = 1,l = 0;k <= m;k++)
			{
				while (l + 1 <= m && (!SUM(i,k,j,l + 1) || SUM(i,k,j,l + 1) == (j - i + 1) * (l - k + 2)))
					l++;
				if (l < k - 1)
					l = k - 1;
				f[i][j][k] = l;
			}
	for (int i = 1;i <= m;i++)
		for (int j = i;j <= m;j++)
			for (int k = 1,l = 0;k <= n;k++)
			{
				while (l + 1 <= n && (!SUM(k,i,l + 1,j) || SUM(k,i,l + 1,j) == (l - k + 2) * (j - i + 1)))
					l++;
				if (l < k - 1)
					l = k - 1;
				g[i][j][k] = l;
			}
	if (f[1][n][1] == m)
	{
		printf("0\n");
		return 0;
	}
	for (int ans = 1;;ans++)
	{
		memset(lazf,0,sizeof(lazf));
		memset(lazg,0,sizeof(lazg));
		for (int i = 1;i <= n;i++)
			for (int j = i;j <= n;j++)
				for (int k = 1;k <= m && f[i][j][k] < m;k++)
					f[i][j][k] = f[i][j][f[i][j][k] + 1];
		for (int i = 1;i <= n;i++)
			for (int j = i;j <= n;j++)
				for (int k = 1;k <= m;k++)
					lazf[i][k][f[i][j][k]] = max(lazf[i][k][f[i][j][k]],j);
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= m;j++)
				for (int k = m - 1;k >= j;k--)
					lazf[i][j][k] = max(lazf[i][j][k],lazf[i][j][k + 1]);
		for (int i = 1;i <= m;i++)
			for (int j = i;j <= m;j++)
				for (int k = 1;k <= n && g[i][j][k] < n;k++)
					g[i][j][k] = g[i][j][g[i][j][k] + 1];
		for (int i = 1;i <= m;i++)
			for (int j = i;j <= m;j++)
				for (int k = 1;k <= n;k++)
					lazg[i][k][g[i][j][k]] = max(lazg[i][k][g[i][j][k]],j);
		for (int i = 1;i <= m;i++)
			for (int j = 1;j <= n;j++)
				for (int k = n - 1;k >= j;k--)
					lazg[i][j][k] = max(lazg[i][j][k],lazg[i][j][k + 1]);
		for (int i = 1;i <= n;i++)
			for (int j = i;j <= n;j++)
				for (int k = 1;k <= m;k++)
					f[i][j][k] = max(f[i][j][k],lazg[k][i][j]);
		for (int i = 1;i <= m;i++)
			for (int j = i;j <= m;j++)
				for (int k = 1;k <= n;k++)
					g[i][j][k] = max(g[i][j][k],lazf[k][i][j]);
		if (f[1][n][1] == m)
		{
			printf("%d\n",ans);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 106880
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	int n;
	cin >> n;
	vector<int> a, b, c;
	
	int x;
	rep(i,n) {
		cin >> x;
		a.push_back(x);
	}
	a.push_back(9999);
	rep(i, n) {
		cin >> x;
		b.push_back(x);
	}
	rep(i, n-1) {
		cin >> x;
		c.push_back(x);
	}
	int ans = 0;
	rep(i,n) {
		ans += b[a[i] - 1];
		if (a[i + 1] - a[i] == 1) ans += c[a[i] - 1];
		
	}
	cout << ans << endl;
}

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

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

    for(int i=0; i<N; ++i) {
        int p = K - (Q - cnt[i]);
        cout << (p > 0 ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1024
def solve(A, B, C, K):
    for k in range(0, K+1):
        for n in range(0, k+1):
            if A < (2**n)*B < (2**(k-n))*C:
                return True
    return False
A, B, C = map(int,input().split())
K = int(input())
if solve(A, B, C, K):
    print('Yes')
else:
    print('No')

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

ll A, B;
int N;
ll ret = 1LL << 60;

int main() {
	cin >> A >> B >> N;

	for (int i=1;i<=N;++i) {
		if (B%i!=0) continue;
		for (int j=1;j<=N;++j) {
			ll k = B/i*j;
			ret=min(ret,abs(k-A));
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>

int gcd(int p,int q){while(q){int t=p%q;p=q;q=t;}return p;}

int main(){
	int k;
	scanf("%d",&k);
	int ans=0;
	for(int a=1;a<=k;a++)for(int b=1;b<=k;b++)for(int c=1;c<=k;c++){
		ans+=gcd(a,gcd(b,c));
	}
	printf("%d",ans);
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <functional>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int p = 1 << n;
    vector<long> a(p);
    for (auto &ai:a) cin >> ai;
    int top2[p][2];
    fill(top2[0], top2[p], -1);
    for (int i=0; i<p; i++) top2[i][0] = i;
    for (int i=0; i<p; i++) {
        for (int j=0; j<n; j++) {
            if (!(i & (1 << j))) continue;
            int arr[] = {
                top2[i][0],
                top2[i][1],
                top2[i-(1<<j)][0],
                top2[i-(1<<j)][1]
            };
            sort(arr, arr+4, [&](int l, int r) {
                if (l == -1) return false;
                if (r == -1) return true;
                return a[l] > a[r];
            });
            auto pnt = arr;
            top2[i][0] = *arr;
            while (*pnt == arr[0]) pnt++;
            top2[i][1] = *pnt;
        }
    }
    set<int, function<bool(int, int)>> s([&](int l, int r) {
        if (l == -1) return false;
        if (r == -1) return true;
        return a[l] > a[r];
    });
    s.insert(6);
    s.insert(7);
    // cerr << s.size() << '\n';
    long ans = 0;
    for (int i=1; i<p; i++) {
        // cerr << top2[i][0] << ' ' << top2[i][1] << '\n';
        ans = max(ans, a[top2[i][0]] + a[top2[i][1]]);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define MAXSIZE 100005


ll dp[MAXSIZE][2]={0,};

ll solve(const string &s){
    ll len = s.size();
    for ( int i = 0; i < MAXSIZE; ++i ){
        for ( int j = 0; j < 2; ++j ){
            dp[i][j] = 0;
        }
    }
	dp[0][0] = 2;
    dp[0][1] = 1;

	for ( int i = 1; i < len; ++i ){
            dp[i][1] += dp[i-1][1]*3;

            if(s[i] == '1'){
                dp[i][1] += dp[i-1][0];

                dp[i][0] += 2*dp[i-1][0];
            }else{
                dp[i][0] += dp[i-1][0];
            }
            dp[i][0] %= MOD;
            dp[i][1] %= MOD;


	}


	return dp[len-1][0] + dp[len-1][1];
}

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

    cout << (solve(l))%MOD << endl;

    return 0;

}


Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX numeric_limits<ll>::max()
#define INT_MAX numeric_limits<int>::max()
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}



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

	ll sum = 0;
	int ma = 0;

	rep(i, N) {
		int tmp;
		cin >> tmp;
		ma = max(ma, tmp);
		sum += tmp;
	}

	cout << sum - ma / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] path = new char[h][w];
		for (int i = 0; i < h; i++) {
			path[i] = sc.next().toCharArray();
		}
		Deque<int[]> check = new ArrayDeque<>(h * w);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (path[i][j] == '#') {
					int[] start = { i, j, 0 };
					check.addLast(start);
				}
			}
		}
		int[] dx = { 1, 0, -1, 0 };
		int[] dy = { 0, 1, 0, -1 };
		int x = 0, y = 0;
		int time = 0;
		while (!check.isEmpty()) {
			int[] tmp = check.removeFirst();
			x = tmp[0];
			y = tmp[1];
			time = tmp[2];
			for (int i = 0; i < 4; i++) {
				int nx = x + dx[i];
				int ny = y + dy[i];
				if (0 <= nx && nx < h && 0 <= ny && ny < w && path[nx][ny] == '.') {
					int[] next = { nx, ny, time + 1 };
					check.addLast(next);
					path[nx][ny] = '#';
				}
			}
		}
		System.out.println(time);
	}
}


Measured memory_bytes: 70108
// Karm Karta ja, Phal Ki Chinta na Kar:)
#include <bits/stdc++.h>
using namespace std;
#include<stdio.h>
typedef long long int ll;
#define INF 1e18+3
#define M 1000000007
#define PI 3.14159265358979323846
int main()
{
   int n,i,j,k;
   string s;
   cin>>n>>s;
   int b[10]={0};
   int cnt[n+1][10];
   memset(cnt,0,sizeof(cnt));
   for(i=1;i<=n;i++)
   {
       cnt[i][s[i-1]-'0']++;
   }
   for(i=1;i<=n;i++)
   {
       for(j=0;j<10;j++)
       {
           cnt[i][j]+=cnt[i-1][j];
       }
   }
   int ans=0;
   for(i=1;i<=n-2;i++)
   {
       if(b[s[i-1]-'0']==0)
       {
           int c[10]={0};
           for(j=i+1;j<=n-1;j++)
           {
               if(c[s[j-1]-'0']==0)
               {
                   c[s[j-1]-'0']=1;
                   for(int k=0;k<10;k++)
                   {
                       int res=cnt[n][k]-cnt[j][k];
                       if(res!=0)
                       {
                           ans++;
                       }
                   }
               }
           }
           b[s[i-1]-'0']=1;
       }
   }
   cout<<ans;
}






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

namespace ABC133A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a * b < c)
                Console.WriteLine(a * b);
            else
                Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    string s;cin>>s;
    int n=(int)s.size();
    int ans=INF;
    rep(i,n-2){
        string now=s.substr(i,3);
        int tmp=abs(atoi(now.c_str())-753);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    constexpr double pi = acos(-1.0);

    double z0 = 0, z1 = pi * 0.5;
    while (z1 - z0 > 1e-12) {
        double z = (z0 + z1) * 0.5;
        double t = tan(z);
        double v;
        if (a * t <= b) {
            v = a * a * (b - (a * t * 0.5));
        } else {
            v = a * (b / t * 0.5) * b;
        }
        (v > x ? z0 : z1) = z;
    }

    printf("%.10f\n", (z0 + z1) * 0.5 * 180 / pi);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    long long N = inputValueLongLong();
    long long i = 0;
    long long A[N];
    A[0] = 0;
    long long buka[N];
    buka[0] = 0;
    long long counter = 0;
    for(i=0;i<N;i++){
        buka[i] = 0;
    }
    for(i=1;i<N;i++){
        A[i] = inputValueLongLong();
        buka[A[i]-1]++;
    }
    for(i=0;i<N;i++){
        cout << buka[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6776
sub f{my($u,$p)=@_;push@{--$|?b:c},$u;$_-$p&&f($_,$u)for@$u;--$|}$n=<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;$y=2*--$x;@a=($,=$",(f 1)x$n);@b>$n/3&@c>$n/3?(map$a[$_]=$x+=3,@b)+map$a[$_]=$y+=3,@c:map$a[$_]=$x+=$x%3,@b>@c?@b:@c;print map$_<=$n&&$_||3*++$z,@a

Measured memory_bytes: 269440
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


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

    P(180 * (n-2));
    
    return  0;
}


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

void Main() {
  int n,m;
  cin >> n >> m;
  vector<int> v[n];
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  int b[n-1];
  rep(i,n-1) b[i]=i+1;
  int ans=0;
  do {
    int x=0;
    bool f=1;
    rep(i,n-1) {
      bool ff=0;
      rep(j,v[x].size()) {
        if(v[x][j]==b[i]) ff=1;
      }
      if(!ff) f=0;
      x=b[i];
    }
    if(f) ans++;
  } while(next_permutation(b,b+n-1));
  pr(ans);
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
double dfs(vector< vector< int > > &G, vector< map< int, double > > &dp, int x, int p, int f) {
	if (dp[x].count(p))
		return dp[x][p];
	double ret = 0.0;
	if (f || p == -1) {
		for (auto j : G[x]) {
			if (j == p)
				continue;
			ret += dfs(G, dp, j, x, f);
		}
	} else {
		double a = dfs(G, dp, x, -1, f);
		double b = dfs(G, dp, p, x, f);
		int d = G[x].size();
		ret = (a - 1.0) * d - b;
	}
	int d = G[x].size() - (p != -1);
	if (d) {
		ret /= d;
		ret += 1.0;
	}
	return dp[x][p] = ret;
}
signed main() {
	cin >> N;
	vector< vector< int > > G(N);
	rep(i, N - 1) {
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	vector< map< int, double > > dp(N);
	dfs(G, dp, 0, -1, 1);
	rep(i, N) cout << dfs(G, dp, i, -1, 0) << endl;
	return 0;
}

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

int main(){
    int x, y;
    cin >> x >> y;

    vector<int> num = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    string res = num.at(x) == num.at(y) ? "Yes" : "No";
    cout << res << endl;
}

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

int		main(void)
{
	string s;

	cin >> s;
	while (!(s.empty()))
	{
		s.pop_back();
		s.pop_back();
		if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size() / 2))
		{
			cout << s.size() << endl;
			return (0);
		}
	}
	cout << 1 << endl;
}


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


int main(){
  int n, K;
  cin >> n >> K;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int res = 0;
  rep(i,n) {
    res += min(abs(a[i] - 0), abs(a[i] - K)) * 2;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(111111);
vi deg(111111);
vi ans(111111);
bool used[111111];
ll cnt=0;
void dfs(ll now,ll par){
  for(int i=0;i<E[now].size();i++){
    if(E[now][i]==par)continue;
    cnt+=min(ans[now],ans[E[now][i]]);
    dfs(E[now][i],now);
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  //for(int i=0;i<111111;i++)deg[i]=mp(0,i);
  for(int i=0;i<n-1;i++){
    ll a,b;cin>>a>>b;
    E[--a].pb(--b);
    E[b].pb(a);
    deg[a]++;
    deg[b]++;
  }
  vi hoge(n);
  for(int i=0;i<n;i++){cin>>hoge[i];}
  sort(ALL(hoge));
  for(int i=0;i<n;i++){
    ll ma=llINF;
    ll po=-1;
    for(int j=0;j<n;j++){
      if(used[j]==false&&ma>deg[j]){
	ma=deg[j];
	po=j;
      }
    }
    used[po]=true;
    for(int j=0;j<E[po].size();j++){
      deg[E[po][j]]--;
    }
    ans[po]=hoge[i];
  }
  dfs(0,-1);
  cout<<cnt<<endl;
  for(int i=0;i<n;i++)cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 5504
# -*- coding: utf-8 -*-

from heapq import heappush, heappop

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

que=[]
while True:
    instr=input()
    if instr.startswith('insert'):
        _,n=instr.split()
        heappush(que, -int(n))
    elif instr.startswith('extract'):
        print(-heappop(que))
    else:
        break



Measured memory_bytes: 45568
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	string ans = "No";
	int m;
	m = n - 90;
	if(0<=m && m<=9){
		ans = "Yes";
	}
	int k;
	k = n - 9;
	if(k%10==0){
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
    long long N;
    cin>>N;
    vector<long long>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    long long count=N-1,ans=0;
    if(N==2){
        cout<<A[0]<<endl;
        exit(0);
    }
    ans+=A[0];
    count--;
    for(int i=1;i<N-1;i++){
        ans+=A[i]*2;
        count-=2;
        if(count==0){
            break;
        }else if(count==-1){
            ans-=A[i];
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4836
#include<cstdio>
using namespace std;
int main()
{
	int n,m,d,i,j,k,cnt,flg;
	char a[100][101];
	scanf("%d %d %d",&n,&m,&d);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
	// for(i=0;i<n;i++){
		// for(j=0;j<m;j++){
			// printf("%c",a[i][j]);
		// }
		// printf("\n");
	// }
	cnt=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(j+d-1<m){
				flg=0;
				for(k=0;k<d;k++){
					// printf("i=%d j+k=%d a[i][j+k]=%c\n",i,j+k,a[i][j+k]);
					if(a[i][j+k]=='#'){
						flg=1;
					}
				}
				if(flg==0){
					cnt++;
					// printf("i=%d j=%d cnt=%d\n",i,j,cnt);
				}
			}
			// printf("W i=%d j=%d j+k=%d flg=%d cnt=%d\n",i,j,j+k,flg,cnt);
			if(i+d-1<n){
				flg=0;
				for(k=0;k<d;k++){
					// printf("i+k=%d j=%d a[i+k][j]=%c\n",i+k,j,a[i+k][j]);
					if(a[i+k][j]=='#'){
						flg=1;
					}
				}
				if(flg==0){
					cnt++;
					// printf("i=%d j=%d cnt=%d\n",i,j,cnt);
				}
				// printf("H i=%d j=%d i+k=%d flg=%d cnt=%d\n",i,j,i+k,flg,cnt);
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}



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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a);
	vector<int> q(b);
	vector<int> r(c);
	
	for(int &x : p)
		cin >> x;
	for(int &x : q)
		cin >> x;
	for(int &x : r)
		cin >> x;
	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());
	sort(r.begin(), r.end(), greater<int>());
	
	priority_queue<int, vector<int>, greater<int>> pq;
	for(int i = 0; i < x; ++ i)
		pq.push(p[i]);
	for(int i = 0; i < y; ++ i)
		pq.push(q[i]);
	for(int i = 0; i < c; ++ i)
	{
		if(pq.top() < r[i])
		{
			pq.pop();
			pq.push(r[i]);
		}
	}
	
	int ans = 0;
	while(!pq.empty())
	{
		ans += pq.top();
		pq.pop();
	}
	cout << ans << '\n';
	
	return 0;
}






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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b == c || a + c == b || b + c == a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
int main(void){
  bool m[100][100];

  int h,w,n,x,y,a;
  cin>>w>>h>>n;
  rep(i,h)rep(j,w)m[i][j] = false;
  rep(q,n){
    cin>>x>>y>>a;

    switch(a){
      case 1:
        rep(i,h)rep(j,x)m[i][j] = true;      
        break;
      case 2:
        rep(i,h)loop(j,x,w)m[i][j] = true;      
        break;
      case 3:
        rep(i,y)rep(j,w)m[i][j] = true;      
        break;
      case 4:
        loop(i,y,h)rep(j,w)m[i][j] = true;      
        break;
    }
  }
  int cnt = 0;
  rep(i,h){rep(j,w)
      if(!m[i][j])cnt++;
  }
  cout<<cnt<<endl;
}

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

#define pb(x) push_back(x);
#define all(v) v.begin(),v.end()

using ll = long long int;
using ul = unsigned long long int;
using vi = vector<int>;
ll max(ll x,ll y){
    if(x>y)
        return x;
    else
        return y;
}
ll min(ll x,ll y){
    if(x>y)
        return y;
    else
        return x;
}

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(k>(b-a)/2){
        while(a<=b){
            cout<<a<<endl;
            a++;
        }
    }else {
        for (int i = 0; i < k; i++) {
            cout << a + i << endl;
        }
        for (int i = k - 1; i >= 0; i--) {
            cout << b - i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
def frog_1(arr, n, k):

    dp = [0] * (n + 1)
    dp[1] = 0

    for i in range(2, n+1):
        dp[i] = float("inf")
        for j in range(1, k+1):
            if i - j >= 1:
                dp[i] = min(dp[i], dp[i - j] + abs(arr[i - 1] - arr[i - j - 1]))

    return dp[n]






n = int(input())
arr = list(map(int, input().split()))

print(frog_1(arr, n, 2))

Measured memory_bytes: 13980
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
	cpp();
	ll n;
	cin >> n;
	vector<double> v(n);
	for (ll i = 0; i < n; i++) cin >> v[i];
	vector<vector<double> > dp(n + 1, vector<double>(n + 1, 0));
	for (ll i = 0; i <= n; i++) {
		dp[i][0] = 1;
	}
	dp[0][0] = 1;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= n; j++) {
			dp[i][j] = dp[i - 1][j] * (1 - v[i - 1]) + dp[i - 1][j - 1] * (v[i - 1]);
		}
	}
	cout << ps(dp[n][(n + 1) / 2], 9) << endl;
	return 0;
}




Measured memory_bytes: 70784
x,y = map(int,input().split())
 
if x == 2 or y == 2:
  print("No")
  exit()
elif x == 4 or x == 6 or x == 9 or x == 11:
  if y == 6 or y == 9 or y == 11:
    print("Yes")
  else:
    print("No")
else:
  if y == 3 or y== 5 or y==7 or y==8 or y==10 or y==12:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3064