akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -Wno-tabs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[l, r, d] <- readIntToList <$> BS.getLine
	print $ (r `div` d) - ((l - 1) `div` d)


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
    int R[MAX],n;

    cin>>n;
    for(int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for(int j = 1; j < n; j++){
        maxv = max(maxv,R[j] - minv);
        minv = min(minv,R[j]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3876
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz size()
#define all(x) x.begin(), x.end()
#define forn(x) for(ll i=1;i<=x;i++) 
#define sforn(x, y) for(ll i=1;i<=x;i++)for(ll j=1;j<=y;j++)
#define pii pair<ll, ll>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK
 
    PIHALITI
 
 */
ll t[200100];
ll id[200100];

bool cmp(ll a, ll b){
    return t[a] < t[b];
}

int main(){ speed;
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++){
        cin >> t[i];
        id[i] = i;
    }
    sort(id + 1, id + 1 + n, &cmp);
    for(ll i=1;i<=n;i++){
        cout << id[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
import java.util.*;
import java.awt.geom.Point2D.Double;

public class Main {
    private static final int    MAX = 500000;
    private static final int    SENTINEL = 2000000000;
    private static int[]        L = new int[MAX / 2 + 2];
    private static int[]        R = new int[MAX / 2 + 2];
    private static int          count = 0;

    static void merge(int A[], int n, int left, int mid, int right) {
        // 部分配列を用意する
        int n1 = mid - left;        // 左側の個数
        int n2 = right - mid;       // 右側の個数
        for (int i = 0; i < n1; i++) L[i] = A[left + i];
        for (int i = 0; i < n2; i++) R[i] = A[mid + i];
        L[n1] = R[n2] = SENTINEL;       // 番兵

        // マージ
        int litr = 0;
        int ritr = 0;
        for (int i = left; i < right; i++) {
            count++;
            // 小さい方からもとの配列を上書きしていく
            if (L[litr] <= R[ritr]) {
                A[i] = L[litr++];
            } else {
                A[i] = R[ritr++];
            }
        }
    }

    static void mergeSort(int[] A, int n, int left, int right) {
        if (left + 1 < right) {
            // leftは部分配列の先頭。rightは末尾+1
            int     mid = (left + right) / 2;
            mergeSort(A, n, left , mid);
            mergeSort(A, n, mid, right);
            merge(A, n, left, mid, right);
        }
    }
    public static void main(String[] args) throws Exception {
            // 入力
            int[]   A = new int[MAX];
            int     n;
            Scanner sc = new Scanner(System.in);
            n = Integer.parseInt(sc.nextLine());
            for (int i = 0; i < n; i++) {
                A[i] = Integer.parseInt(sc.next());
            }
            sc.close();

            // マージソート
            mergeSort(A, n, 0, n);

            // 出力
            for (int i = 0; i < n; i++) {
                if (i > 0) System.out.print(" ");
                System.out.print(A[i]);
            }
            System.out.println();

            System.out.println(count);
    }
}



Measured memory_bytes: 113648
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<cstdio>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){
    int n,m;
    cin>>n>>m;
    
    int P[100000],Y[100000];
    vector<int> v[100001];
    
    rep(i,m){
        cin>>P[i]>>Y[i];
        v[P[i]].push_back(Y[i]);
    }
   /* rep(i,m){
        scanf("%d%d",&P[i],&Y[i]);
    v[P[i]].push_back(Y[i]);
    }*/
    
    //rep(i,n) sort(v[i+1].begin(),v[i+1].end());
    
    rep(i,n)sort(v[i+1].begin(),v[i+1].end());
    
  /*  rep(i,m){
        printf("%06d",P[i]);
        for(int j=0;j<v[P[i]].size();j++){
            u++;
            if(v[P[i]][j]==Y[i]){
                break;
            }
        }
        int u=int(lower_bound(v[P[i]]. begin(),v[P[i]].end(),Y[i])-v[P[i]].begin())+1;
        printf("%06d",u);
        cout<<endl;
    }*/

    rep(i,m){
        printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(v[P[i]]. begin(),v[P[i]].end(),Y[i])-v[P[i]].begin())+1);}

return 0;
}


Measured memory_bytes: 7808
#include<cstdio>
#include<cstring>
using namespace std;
int sqa[55][55];
int sqb[55][55];
int n,m;
bool check(int x,int y)
{
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(sqa[i+x-1][j+y-1]!=sqb[i][j])
			{
				return false;
			}
		}
	}
	return true;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		char ch[55];
		scanf("%s",ch);
		for(int j=1;j<=n;j++)
		{
			sqa[i][j]=ch[j-1]-48;
		}
	}
	for(int i=1;i<=m;i++)
	{
		char ch[55];
		scanf("%s",ch);
		for(int j=1;j<=m;j++)
		{
			sqb[i][j]=ch[j-1]-48;
		}
	}
	for(int i=1;i<=n-m+1;i++)
	{
		for(int j=1;j<=n-m+1;j++)
		{
			if(check(i,j))
			{
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

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

int main() {
  
  int n, k;
  cin >> n >> k;
  int ans = 0;
  
  rep(i, n) {
    int a;
    cin >> a;
    if (a >= k) ans++;    
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			string s = Console.ReadLine();

			long sum = 0;
			foreach (var c in s) {
				sum += long.Parse(c.ToString());
			}
			if (sum % 9 == 0) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}

		}
	}
}


Measured memory_bytes: 32744
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
  int x=0,f=1;
  char ch=getchar();
  while(ch<'0'||ch>'9')
  {
    if(ch=='-')
      f=-1;
    ch=getchar();
  }
  while(ch>='0'&&ch<='9')
  {
    x=(x<<1)+(x<<3)+(ch^48);
    ch=getchar();
  }
  return x*f;
}
int main()
{
  int a[4];
  for(int i=1; i<=3; i++)
  {
    a[i]=read();
  }
  sort(a+1,a+4);
  if((a[1]==a[2])&&a[2]!=a[3])
  {
    printf("Yes\n");
    return 0;
  }
  if((a[1]!=a[2])&&a[2]==a[3])
  {
    printf("Yes\n");
    return 0;
  }
  else
  {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
a1=float('inf')
a2=-float('inf')
a3=float('inf')
a4=-float('inf')

for i in range(n):
    cnt=a[i][0]+a[i][1]
    cnt1=a[i][0]-a[i][1]
    a1=min(a1,cnt)
    a2=max(a2,cnt)
    a3=min(cnt1,a3)
    a4=max(cnt1,a4)


print(max(a2-a1,a4-a3))

Measured memory_bytes: 102244
n = int(input())
a = int(100 / 4)
b = int(100 / 7)
flag = False
for i in range(a+1):
    for j in range(b+1):
        if (i) * 4 + (j) * 7 == n:
            flag = True
            break
    else:
        continue
    break
if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 2002
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int a[N];
int dist[N][N];
int cnt[N]={0};
signed main()
{
    
    speed
    int n,x,y;
    cin>>n>>x>>y;
    rep(i,1,n){
        rep(j,i+1,n){
            dist[i][j]=(j-i);
            dist[j][i]=j-i;
            if(i<=x && j>=x && j<=y){
                dist[i][j]=min(dist[i][j],(x-i)+1+(y-j));
                dist[j][i]=dist[i][j];
            }
            if(i<=y && i>=x && j>=y){
                dist[i][j]=min(dist[i][j],(i-x)+1+(j-y));
                dist[j][i]=dist[i][j];
            }
            if(i<=x && j>=y){
                dist[i][j]=min(dist[i][j],(x-i)+1+(j-y));
            }
            if(i>=x && j<=y){
                dist[i][j]=min(dist[i][j],(i-x)+1+(y-j));
            }
            dist[j][i]=dist[i][j];

        }
    }
    rep(i,1,n){
        rep(j,1,n){
            //cout<<dist[i][j]<<" ";
            cnt[dist[i][j]]+=1;
        }
        //cout<<endl;
    }
    rep(i,1,n-1)cout<<cnt[i]/2<<endl;





    
    


    return 0;
}


Measured memory_bytes: 31616
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N, M;
    in2(N, M);

    ll C;
    in(C);

    vll B(M);
    rep(i, M) in(B[i]);

    int count = 0;
    rep(_, N)
    {
        vll A(M);
        rep(i, M) in(A[i]);

        ll tmp = 0;
        rep(i, M) tmp += A[i] * B[i];

        if (tmp + C > 0) count++;
    }

    outl(count);

    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	string S; cin >> S;
	int res = 0;
	int cnt = 0;
	forn(i,0,3){
		if(S[i] == 'S'){
			cnt = 0;
			continue;
		}
		cnt++;
		res = max(res,cnt);
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    
    var charA = s[0]
    var charB = '-'
    var charACount = 0
    var charBCount = 0
    
    for (c in s) {
        if (c == charA) {
            charACount++
            continue
        }
        if (charB == '-') {
            charB = c
            charBCount = 1
            continue
        }
        if (c == charB) {
            charBCount++
            continue
        }
        println("No")
        return
    }
    
    if (charACount == 2 && charBCount == 2) {
        println("Yes")
    } else {
        println("No")
    }
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 33476
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B
// Combinatorial - 0-1 Knapsack Problem
// status: []

#define SUBMIT

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100;
const int MAX_W = 10000;

int N, W;
int v[MAX_N];
int w[MAX_N];

// dp[i][j] iまでの品物を選んで重さがjを超えないようにしたときの価値の最大値
int dp[MAX_N + 1][MAX_W + 1];

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(4 5
4 2
5 2
2 1
8 3
)";
    stringstream stream(program_input_str);
#endif
    stream >> N >> W;
    for (int i = 0; i < N; ++i) {
        stream >> v[i] >> w[i];
    }

    // 1つも品物を選んでいないときは重さによらず価値は0
    for (int j = 0; j <= MAX_W; ++j) dp[0][j] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j >= w[i]) dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            else dp[i + 1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7032
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int M = sc.nextInt();
      if(N<=M){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}
      

Measured memory_bytes: 35608
#include <iostream>
//#include <cstring>
//#include <algorithm>
//#include <climits>
//#include <string>
#include <vector>

using namespace std;
//bがaより大きければaに代入
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b; return 1;}return 0;}
//bがaより小さければaに代入
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b; return 1;}return 0;}
const long long INF = 1LL<<60;

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

    vector<int> A(N), B(N);
    for(int i=0;i<N;i++)cin>>A[i]>>B[i];

    // 最初のi種類の魔法でダメージを与える場合の最小の消費体力
    vector<vector<long long> > dp(N+1, vector<long long>(H+1, INF));
    dp[0][0] = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=H;j++){
            //i番目の魔法を使わない：既にある値と、そのままおろした値のどちらか小さいほうを適用
            chmin(dp[i+1][j], dp[i][j]);
            //i番目の魔法を使う：（i番目の魔法のダメージを加算した位置の値）と（そのまま下した値にi番目の魔法の消費体力を追加した値）の小さいほう
            chmin(dp[i+1][min(j+A[i], H)], dp[i+1][j] + B[i]);
        }
    }
    cout << dp[N][H] << endl;
}

Measured memory_bytes: 78592
[<EntryPoint>]
let main argv =
    //printfn "Make it!" 
    let abc = System.Console.ReadLine().Split()
    let a = abc.[0]
    let b = abc.[1]
    let c = abc.[2]
    let ans = if a.[a.Length-1] = b.[0] && b.[b.Length-1] = c.[0] then "YES" else "NO"
    printfn "%s" ans
    0

Measured memory_bytes: 14032
from collections import defaultdict
d = defaultdict(int)

N = int(input())
a = list(input() for i in range(N))
M = int(input())
b = list(input() for i in range(M))

for i in range(N):
  d[str(a[i])] += 1

for i in range(M):
  d[b[i]] -= 1
print(max(d.values()) if max(d.values()) > 0 else 0) 


Measured memory_bytes: 3316
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout <<"No" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 500001

int a[N],h;

int left(int i){return 2*i;}
int right(int i){return 2*i+1;}


void ex(int i,int j)
{
  int t;
  t=a[i];
  a[i]=a[j];
  a[j]=t;
}

void max(int i){
  int l,r,largest;
  l=left(i);
  r=right(i);
  if(l<=h&&a[l]>a[i])
    largest=l;
  else
    largest=i;
  if(r<=h&&a[r]>a[largest])
    largest=r;

  if (largest!=i){
    ex(i,largest);
    max(largest);
  }
  
}


void buildMaxHeap(){
  int i;
  for(i=h/2;i>=1;i--)
    max(i);
}




int main(){
 int i;

  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);
  }
  buildMaxHeap();

  for(i=1;i<=h;i++){
    printf(" %d",a[i]);
  }
  printf("\n");

  
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 120;
const ll inf = 2e18, mod = 1e9 + 7;

int n, a[maxn];
ll dp[maxn][maxn][maxn];

void solve() {
	int l = n - 1, r = n - 1;
	dp[n - 1][1][0] = 1;
	for (int i = n - 1; i > 0; i--) {
		for (int options = 1; options < maxn; options++) {
			for (int pos = 0; pos < options; pos++) {
				if (dp[i][options][pos]) {
					int nextOptions = options, tmpPos = pos;
					ll val = dp[i][options][pos];

					if (a[l] != a[l - 1]) {
						nextOptions++;
						tmpPos++;
					}
					if (a[r] != a[r + 1]) {
						nextOptions++;
					}

					for (int nextPos = 0; nextPos < nextOptions; nextPos++) {
						if (tmpPos > nextPos) {
							dp[i - 1][nextOptions - abs(tmpPos - nextPos) + 1][nextPos] += val;
							dp[i - 1][nextOptions - abs(tmpPos - nextPos) + 1][nextPos] %= mod;
						}
						else if (tmpPos == nextPos) {
							dp[i - 1][nextOptions][nextPos] += val;
							dp[i - 1][nextOptions][nextPos] %= mod;
						}
						else {
							dp[i - 1][nextOptions - abs(tmpPos - nextPos) + 1][tmpPos + 1] += val;
							dp[i - 1][nextOptions - abs(tmpPos - nextPos) + 1][tmpPos + 1] %= mod;
						}
					}
				}
			}
		}
		l--;
		r++;
	}
}

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

	cin >> n;
	for (int i = 0; i < 2 * n - 1; i++) {
		cin >> a[i];
	}
	sort(a, a + 2 * n - 1);

	solve();

	ll ans = 0;
	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < maxn; j++) {
			ans = (ans + dp[0][i][j]) % mod;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 6072
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<algorithm>
//#include"cxx-prettyprint/prettyprint.hpp"
#include<math.h>
using namespace std;



int main(int argc,char *argv[]){
    
    int n;
    vector<double> v(50);
    double ans=0.0;

    cin>>n;
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end(),greater<double>());
    
    for(int i=0;i<n;i++){
        if(i==n-1)ans+=v[i]/pow(2.0,(double)n-1.0);
        else ans+=v[i]/pow(2.0,(double)i+1.0);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

string s;

void solve()
{
	const int N = s.length();
	ll res = 0;
	for(int i=0; i<(1<<(N-1));++i){ // add + after i's character
		int pre=0;
		for(int j=0; j< (N-1);++j){
			if(i>>j&1){ // there is + sign after j pos
                res += stoll(s.substr(pre, j-pre+1));
                pre = j+1;
			}
		}
		res += stoll(s.substr(pre));
	}
	cout << res << endl;
}

int main()
{
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    xs = list(map(int, input().split()))
    C.append(xs[0])
    A.append(xs[1:])

min_price = None
for t in range(2 ** N):
    price = 0
    values = [0] * M
    for i in range(N):
        if (1 << i) & t:
            price += C[i]
            for j in range(M):
                values[j] += A[i][j]
    if all(X <= v for v in values) and (min_price is None or price < min_price):
        min_price = price
print(min_price if min_price is not None else -1)

Measured memory_bytes: 9224
N, K = map(int, input().split())
A = list(map(int, input().split()))

cumA = [0] * (N + 1)
for i in range(1, N + 1):
    cumA[i] = cumA[i - 1] + A[i - 1]

beauty = []
for left in range(N):
    for right in range(left + 1, N + 1):
        b = cumA[right] - cumA[left]
        beauty.append(b)

ans = 0
M = max(beauty).bit_length()

for digit in range(M)[:: -1]:
    new = ans + (1 << digit)
    cnt = 0
    for b in beauty:
        if b & new == new:
            cnt += 1
    if cnt >= K:
        ans = new

print(ans)

Measured memory_bytes: 22964
#include <stdio.h>
#include <math.h>

int main(void) {
  int n; // 与えられる数値の数
  int count = 0; // 素数の数
  int i;
  
  scanf("%d", &n);

  for (i=0; i<n; i++) {
    int num;
    int j;
    int limit;
    
    scanf("%d", &num);

    limit = (int)(sqrt((double)num)) + 1;

    for(j=2; j<limit; j++) {
      if (num % j == 0)
	break;
    }

    if (j == limit)
      count++;
  }

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

  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        S = S.replaceAll("eraser",  "-");
        S = S.replaceAll("erase",   "-");
        S = S.replaceAll("dreamer", "-");
        S = S.replaceAll("dream",   "-");
        S = S.replaceAll("-", "");
        if (S.length() == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

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

using namespace std;

typedef pair<int,int> pii;
int n, k, l;
vector<int> lis[200100];
vector<int> ris[200100];
int lab[200100], rab[200100];
map<pii,int> ma;

void dfs(int here, const vector<int> lis[], int lab[], int t) {
    lab[here] = t;
    for (auto &there:lis[here]) {
        if (lab[there]) continue;
        dfs(there,lis,lab,t);
    }
}

int main() {
    int i;

    scanf("%d%d%d",&n,&k,&l);
    for (i=0;i<k;i++) {
        int a, b;
        scanf("%d%d",&a,&b); --a; --b;
        lis[a].push_back(b);
        lis[b].push_back(a);
    }
    for (i=0;i<l;i++) {
        int a, b;
        scanf("%d%d",&a,&b); --a; --b;
        ris[a].push_back(b);
        ris[b].push_back(a);
    }
    int cnt = 1;
    for (i=0;i<n;i++) {
        if (lab[i]) continue;
        dfs(i,lis,lab,cnt++);
    }
    cnt = 1;
    for (i=0;i<n;i++) {
        if (rab[i]) continue;
        dfs(i,ris,rab,cnt++);
    }
    for (i=0;i<n;i++) {
        if (ma.find(pii(lab[i],rab[i]))==ma.end()) ma[pii(lab[i],rab[i])] = 1;
        else ma[pii(lab[i],rab[i])]++;
    }
    for (i=0;i<n;i++) {
        printf("%d ",ma[pii(lab[i],rab[i])]);
    }
    printf("\n");

    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(e, x) for (auto &e : x)
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int N = 1 << 10;
int a[N];

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

	int n, k; cin >> n >> k;
	rep(i, 0, n) cin >> a[i];
	sort(a, a + n);
	int s = 0;
	rep(i, 0, k) s += a[i];
	cout << s;	
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <ctype.h>

int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	char S[12];
	scanf("%s", S);

	int i;
	for (i = 0; i < A + B + 1; i++) {
		if (i >= 0 && i < A&&isdigit(S[i]) == 0) {
			break;
		}

		if (i == A && S[i] != '-') {
			break;
		}

		if (i > A&&i < A + B + 1 && isdigit(S[i]) == 0) {
			break;
		}
	}

	if (i == A + B + 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
import math


def main():
    a, b, x = map(int, input().split())
    if (a*b)*a/2 >= x:
        y = 2*x/(a*b)
        ans = math.degrees(math.atan((b/y)))
    else:
        y = (2*(a**2*b - x))/(a**2)
        ans = math.degrees(math.atan(y/a))
    print(ans)


if __name__ == "__main__":
    main()


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

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

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;

    cout << N / 3 << endl;
}

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

    solve();

    return 0;
}


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

using namespace std;

#define int long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=(G).Head[x]; i; i=(G).Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N = 1e5+5,M = 2e5 + 5,mod = 99999997;

bool MOP1;

struct Link_list {
	int Tot,Head[N],Nxt[M<<1],to[M<<1],cost[M<<1];
	inline void clear(void) {
		memset(Head,0,sizeof Head),Tot=0;
	}
	inline void AddEdge(int a,int b,int c) {
		to[++Tot]=b,cost[Tot]=c,Nxt[Tot]=Head[a],Head[a]=Tot;
	}
} G,E;

int n,m,p,vis1[N],vis2[N],vis[N],Q[N];

int d[N],v[N],c[N];

bool spfa() {
	queue<int> q;
	memset(d,126,sizeof d);
	memset(c, 0, sizeof(c));
	q.push(1),v[1]=1,d[1]=0,c[1]=1;
	while (q.size()) {
		int x = q.front();
		q.pop();
		v[x] = 0;
		for (int i = G.Head[x]; i; i = G.Nxt[i]) {
			int y = G.to[i];
			if(!vis[y])continue;
			if (d[y] > d[x] + G.cost[i]) {
				d[y] = d[x] + G.cost[i];
				if (!v[y]) {
					if (++c[y] >= n) return 1;
					q.push(y),v[y] = 1;
				}
			}
		}
	}
	return 0;
}

bool MOP2;

inline void _main(void) {
	n=Raed(),m=Raed(),p=Raed();
	rep(i,1,m) {
		int x=Raed(),y=Raed(),z=Read();
		G.AddEdge(x,y,p-z);
		E.AddEdge(y,x,p-z);
	}
	int L=0,R=0;
	Q[++R]=n,vis1[n]=1;
	while(L<R) {
		int x=Q[++L];
		erep(i,E,x) {
			int y=E.to[i];
			if(vis1[y])continue;
			vis1[y]=1,Q[++R]=y;
		}
	}
	L=0,R=0;
	Q[++R]=1,vis2[1]=1;
	while(L<R) {
		int x=Q[++L];
		erep(i,G,x) {
			int y=G.to[i];
			if(vis2[y])continue;
			vis2[y]=1,Q[++R]=y;
		}
	}
	rep(i,1,n)if(vis1[i]&&vis2[i])vis[i]=1;
	if(!vis[1]||spfa()) {
		puts("-1");
		return;
	}
	if(-d[n]<0)d[n]=0;
	printf("%lld",-d[n]);
}

signed main() {
#define offline1
#ifdef offline
	freopen("truck.in", "r", stdin);
	freopen("truck.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Measured memory_bytes: 19968
N,D,A = map(int,input().split())
enemies = [list(map(int,input().split())) for _ in range(N)]
enemies.sort(key=lambda x:x[0])
ans = 0
from collections import deque
damage = deque()
dmg = 0
for x,h in enemies:
    if len(damage) == 0:
        bomb = -(-h//A)
        damage.append([x+2*D,bomb])
        dmg += bomb*A
        ans += bomb
    else:
        while len(damage) > 0:
            d,bomb = damage.popleft()
            if x > d:
                dmg -= bomb*A
            else:
                damage.appendleft([d,bomb])
                break
        if h > dmg:
            bomb = -(-(h-dmg)//A)
            dmg += bomb*A
            damage.append([x+2*D,bomb])
            ans += bomb

print(ans)


Measured memory_bytes: 66392
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(array[k-1])

Measured memory_bytes: 3316
def amida_counter(H_i_amida_list):
    counter = 0

    for amida_bin in range(2**len(H_i_amida_list)):
        if (("11" in format(amida_bin, "b")) == False):
            counter += 1

    return counter

def amida_number(left_amida, right_amida):
    left_counter = amida_counter(left_amida) if(len(left_amida) > 0) else 1
    right_counter = amida_counter(right_amida) if(len(right_amida) > 0) else 1

    return (left_counter * right_counter)

def X_amida_number(W, W_i):
    x_amida = "0" * (W - 1)
    left_x_amida = x_amida[:(W_i-2)] if(W_i-2 >= 0) else ""
    right_x_amida = x_amida[(W_i+1):]

    return amida_number(left_x_amida, right_x_amida)

def Y_amida_number(W, W_i):
    y_amida = "0" * (W - 1)
    left_y_amida = y_amida[:W_i-1] if(W_i-1 >= 0) else ""
    right_y_amida = y_amida[W_i+1:]

    return amida_number(left_y_amida, right_y_amida)

def Z_amida_number(W, W_i):
    z_amida = "0" * (W - 1)
    left_z_amida = z_amida[:W_i-1] if(W_i-1 >= 0) else ""
    right_z_amida = z_amida[W_i+2:]

    return amida_number(left_z_amida, right_z_amida)

H, W, K = map(int, input().split())
seed_dp_array = [0 for i in range(W)]
dp_array = [list(seed_dp_array) for i in range(H + 1)]
dp_array[0][0] = 1

for H_i in range(1, H + 1):
    for W_i in range(W):
        if (W_i == 0):
            if(W == 1):
                dp_array[H_i][0] = dp_array[H_i - 1][W_i] * Y_amida_number(W, W_i)
            else:
                dp_array[H_i][0] = dp_array[H_i - 1][W_i] * Y_amida_number(W, W_i) + dp_array[H_i - 1][W_i + 1] * Z_amida_number(W, W_i)
        elif (W_i == (W - 1)):
            dp_array[H_i][W - 1] = dp_array[H_i - 1][W_i - 1] * X_amida_number(W, W_i) + dp_array[H_i - 1][W_i] * Y_amida_number(W, W_i)
        else:
            dp_array[H_i][W_i] = dp_array[H_i - 1][W_i - 1] * X_amida_number(W, W_i) + dp_array[H_i - 1][W_i] * Y_amida_number(W, W_i) + dp_array[H_i - 1][W_i + 1] * Z_amida_number(W, W_i)

print(dp_array[H][K - 1] % 1000000007)

Measured memory_bytes: 3192
until (n = $<.gets.to_i).zero?
  e = n.times.map {$<.gets.split.map(&:to_i)}
  edges = (e.map {|a, b, c| [[a, b], c]} + e.map {|a, b, c| [[b, a], c]}).to_h
  h = Hash.new([])
  edges.keys.each {|a, b| h[a] += [b]}
  
  try = ->(start) {
    shortest = Hash.new(Float::INFINITY)
    done = h.keys.map {|k| [k, false]}.to_h
    shortest[start] = 0
    
    loop do
      u = nil
      h.each_key do |node|
        next if done[node]
        u = node if !u or shortest[node] < shortest[u]
      end
      break unless u
      done[u] = true
      
      h[u].each do |v|
        if (a = shortest[u] + edges[[u, v]]) < shortest[v]
          shortest[v] = a
        end
      end
    end
    
    shortest.values.sum
  }
  puts h.keys.map {|k| [try.(k), k]}.sort.first.reverse.join(" ")
end


Measured memory_bytes: 6904
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        if (s.length() != a + b + 1){
            System.out.println("No");
        }

        String s1 = s.substring(0, a);
        char s2 = s.charAt(a);
        String s3 = s.substring(a+1);

        if (!s1.matches("[0-9]*")) {
            System.out.println("No");
            return;
        }
        if (s2 != '-') {
            System.out.println("No");
            return;
        }

        if (s3.matches("[0-9]*")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 35640
// contest.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
using namespace std;

int main()
{
	string S;
	cin >> S;
	int flag = 1;
	for (int i = 0; i < S.size(); i++)
	{
		if (i % 2 == 0 ) {
			if (!(S[i] == 'h' && S[i + 1] == 'i')) {
				flag = 0;
			}
			if (i + 1 >= S.size()) {
				flag = 0;
			}
		}

	}
	if (flag == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int x;int h;
  scanf("%d",&x);
  if(x==0)
  {h=0;
    printf("%d",h);}
  else
  {
    int r500=x/500;
    x=x%500;
    int r5=x/5;
    h=(r500*1000)+(r5*5);
    printf("%d",h);
  }
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)

	for x := 1; x <= N; x++ {
		if int(math.Trunc(float64(x)*1.08)) == N {
			fmt.Println(x)
			return
		}
	}
	fmt.Println(":(")
}


Measured memory_bytes: 512
#!/usr/bin/env pypy3

import itertools


def det_rect_area(n, k, points):
    area = float("inf")
    # 点の直積から2点選んで，それを長方形の対角とする
    xs = (p[0] for p in points)
    ys = (p[1] for p in points)
    all_points = itertools.product(xs, ys)
    for (x1, y1), (x2, y2) in itertools.combinations(all_points, 2):
        min_x, max_x = min(x1, x2), max(x1, x2)
        min_y, max_y = min(y1, y2), max(y1, y2)
        # その中にk個以上の点が入るか？
        num_inc_rects = 0
        for x, y in points:
            if min_x <= x <= max_x and min_y <= y <= max_y:
                num_inc_rects += 1
        if num_inc_rects >= k:
            area = min(area, (max_x - min_x) * (max_y - min_y))
    return area


def main():
    n, k = (int(x) for x in input().split())
    points = [tuple(int(x) for x in input().split()) for _ in range(n)]
    print(det_rect_area(n, k, points))


if __name__ == '__main__':
    main()


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

using namespace std;

priority_queue<int> pq;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)
    {
        int a;
        scanf("%d",&a);
        pq.push(a);
    }
    int ma1 = INT_MIN;
    int ma2 = INT_MIN;
    while(ma1 == INT_MIN && !pq.empty())
    {
        int tmp;
        if(!pq.empty()){
            tmp = pq.top();
            pq.pop();
        }
        if(!pq.empty())
        {
            if(tmp == pq.top())
            {
                ma1 = tmp;
                pq.pop();
            }
        }
    }
    while(ma2 == INT_MIN && !pq.empty())
    {
        int tmp;
        if(!pq.empty()){
            tmp = pq.top();
            pq.pop();
        }
        if(!pq.empty())
        {
            if(tmp == pq.top())
            {
                ma2 = tmp;
                pq.pop();
            }
        }
    }
    long long result = 1;
    result *= ma1;
    result *= ma2;
    if(ma1 > 0 && ma2 > 0)
    printf("%lld",result);
    else
    printf("0");
}


Measured memory_bytes: 892
#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; }

ll calc(string s){
    ll ret = 0;
    ll n = s.length();
    REP(i,n-1){
        if (s[i] == s[i+1]){
            ret++;
            i++;
        }
    }
    return ret;
}

int main() {
    string s;
    ll n, k;
    cin >> s >> k;
    n = s.length();

    ll ans = 0;
    if (s == string(n, s[0])){
        ans = n * k / 2;
    }else{
        ans = calc(s) * k;
        if (s[0] == s[n - 1]){
            ll c1 = 0, c2 = 0;
            REP(i,n){
                if (s[i] == s[0]) c1++;
                else break;
            }
            FORR(i,n-1,0){
                if (s[i] == s[n - 1]) c2++;
                else break;
            }
            if (c1 % 2 == 1 && c2 % 2 == 1){
                ans += k - 1;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c, m = max(a, max(b, c));
    if(sum-m==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
typedef long long ll;
#define FOR(i,n) for(int i=0;i<n;i++)

int main(){
  int n,ans=0;
  string s;
  cin >> n;
  cin >> s;
  char tmp;
  tmp = s[0];
  for(int i=1;i<n;i++){
    if(tmp == s[i]){
    }
    else{
      tmp = s[i];
      ans++;
    }
  }
  cout << ans+1;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;

  if (regex_match(S, regex("(dream|dreamer|erase|eraser)*"))) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

   return 0;
}

Measured memory_bytes: 39808
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;

int main(){
  int N;
  while(~scanf("%d",&N)){
    ll c_left = 0;
    ll c_right = 0;
    for(int i=0;i<N;i++){
      
      int pos,insert_num;
      char insert_char[2];
      scanf("%d %s %d",&pos,insert_char,&insert_num);
      if(insert_char[0] == '(') c_left += insert_num;
      else if(insert_char[0] == ')') c_right += insert_num;
      
      printf("%s\n",(c_left == c_right ? "Yes" : "No"));
    }
  }
}

Measured memory_bytes: 1172
n,m=map(int,input().split())

graph=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
    
def dfs(s,a,b):
    flag[s]=1
    for v in graph[s]:
        if s==a and v==b or s==b and v==a:
            continue
        if flag[v]==1:
            continue
        dfs(v,a,b)

ans=0
for i in range(n):
    for v in graph[i]:
        flag=[0 for i in range(n)]
        dfs(0,i,v)
        num=0
        for j in flag:
            if j==0:
                num=1
        if num==1:
            ans+=1
print(ans//2)

Measured memory_bytes: 3316
using System;

class Program
{
    static void Main()
    {
        int i;
        for (i = 0; i < 7; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            Console.WriteLine(a - b);
        }
    }
}

Measured memory_bytes: 5608
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N = int(input())
    v = list(map(int, input().split()))

    v.sort()
    ans = v[0]
    for i in range(1, N):
        ans = (ans+v[i])/2
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (sx, sy, tx, ty) = readLine()!!.split(' ').map { it.toInt() }
    print("U".repeat(ty - sy))
    print("R".repeat(tx - sx))
    print("D".repeat(ty - sy))
    print("L".repeat(tx - sx))
    print("L")
    print("U".repeat(ty - sy + 1))
    print("R".repeat(tx - sx + 1))
    print("D")
    print("R")
    print("D".repeat(ty - sy + 1))
    print("L".repeat(tx - sx + 1))
    print("U")
    println()
}


Measured memory_bytes: 38176
#include<iostream>
#include<cstdio>

int main(){
	
	double r,S,L;
	double pi = 3.14159265358979323846  ;
	
	std::cin >>r;
	S=pi*r*r, L=2*pi*r;	
	printf("%.8f %.8f",S,L);
	
	return 0;
	
}

Measured memory_bytes: 1240
list1=[]
for b in range(1,33):
    for p in range(2,11):
        if b**p not in list1 and b**p<=1000:
            list1.append(b**p)
        elif b**p>1000:
            break
list1.sort()
N=int(input())
ans=0
for i in range(len(list1)):
    if list1[i]<=N:
        ans=list1[i]
    else:
        break
print(ans)
        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const double PI = acos(-1);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double j = (double)2*PI*double((h*60+m)/(60*12));
    double f = (double)2*PI*double(m/60);
    double d = abs(j-f);
    if(d >= PI) d = PI*2-d;
    double ans = (double)a*a+b*b-2*a*b*cos(d);
    cout << fixed << setprecision(12) << sqrt(ans) << endl;
}


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

using ll = long long int;

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

const ll MAX_A = (int)(6e5 + 5);

int n;

vector<bool> primes(MAX_A);

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

  for (ll i = 0; i < MAX_A; ++i) {
    primes[i] = true;
  }

  for (ll i = 2; i * i < MAX_A; ++i) {
    if (!primes[i]) continue;

    for (ll j = i * i; j < MAX_A; j += i) {
      // printf("%d %d\n", i, j);

      primes[j] = false;
    }
  }

  int cnt = 0;

  for (ll i = 2; i < MAX_A; ++i) {
    if (cnt == n) break;

    if (primes[i] && i % 5 == 1) {
      printf("%d ", i);
      cnt += 1;
    }
  }

  printf("\n");

  return 0;
}


Measured memory_bytes: 384