akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  rep(i, 0, n) {
    int b;
    cin >> b;
    v[i] = make_pair(b, i+1);
  }
  sort(v.begin(), v.end());
  rep(i, 0, n) {
    cout << v[i].second << " ";
  }
}

Measured memory_bytes: 1536
#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 = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, k;
ll a[maxn], ans, sum[maxn], ps[maxn];

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

	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
	{
		if (i)
			sum[i] = sum[i - 1], ps[i] = ps[i - 1];
		if (a[i] > 0)
			sum[i] += a[i];
		ps[i] += a[i];
	}
	for (int i = 0; i < n - k + 1; i++)
	{
		ans = max(ans, sum[n - 1] - (sum[i + k - 1] - (i ? sum[i - 1] : 0)));
		ans = max(ans, (i ? sum[i - 1] : 0) + ps[i + k - 1] - (i ? ps[i - 1] : 0) + sum[n - 1] - sum[i + k - 1]);
	}
	cout << ans << endl;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector <int> road_city(2*m);
  vector <int> road_count(n);
  for (int i=0; i<2*m; i++)
  {
    cin >> road_city.at(i);
  }
  for (int i=0; i<2*m; i++)
  {
    road_count.at(road_city.at(i)-1)++;
  }
  for (int i=0; i<n; i++)
  {
    cout << road_count.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int r, g, b;

    cin >> r >> g >> b;

    if ((r * 100 + g * 10 + b) % 4)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
#s = {s():0 for _ in range(n)}

a = {}
for i in range(n):
	s = input()
	try:
		a[s] += 1
	except KeyError:
		a[s] = 1
b = sorted(a.items(),key = lambda x:x[0])

memo = max([i[1] for i in a.items()])
for i in b:
	"""print(i,"i")
	print(i[0],"i[0]")
	print(i[1],"i[1]")
	print(max(b)[0],"max(b)[0]")"""
	if i[1] == memo:
		print(i[0])


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    COMinit();
    ll n,k;cin >>n>>k;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ans+=(COM(i,k-1)*a[i])%mod;
        ans%=mod;
    }
    reverse(all(a));
    for (int i = 0; i < n; ++i) {
        ans-=(COM(i,k-1)*a[i])%mod;
        ans%=mod;
    }
    if(ans<0)ans+=mod;
    cout <<ans <<endl;
    return 0;
}



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

int main() {
    /*変数定義，入力*/
    int X, Y, Z;
    cin >> X >> Y >> Z;

    //ll A, B;cin >> A >> B;
    //vector<ll> a(N);  rep(i, N) cin >> a[i];
    
    /*演算*/
    


    /*出力*/
    cout << Z << endl;
    cout << X << endl;
    cout << Y << endl;

    //cout << "result" << endl;

    /*終了*/
    return 0;
}

Measured memory_bytes: 256
import string
t=input()
n=len(t)
ans=float("inf")
for i in string.ascii_lowercase:
    cnt=0
    s=list(t)
    while s.count(i)!=n-cnt:
        for j in range(1,len(s)):
            if s[j]==i or s[j-1]==i:
                s[j-1]=i
            else:
                s[j-1]=s[j-1]
        cnt+=1
        s.pop()
    ans=min(ans,cnt)
print(ans)


Measured memory_bytes: 3960
# Two Anagrams
import sys

s = list(input())
t = list(input())

# 昇順
s.sort()
# 降順
t.sort(reverse=True)

n = 0
if len(s) >= len(t) :
    n = len(t)
else :
    n = len(s)

for i in range(n) :
    if s[i] < t[i] :
        print('Yes')
        exit()
    elif s[i] > t[i] :
        print('No')
        exit()

if len(s) < len(t) :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,k,cnt,a[1000005];
vector<int>v[1000005];
map<int,int>mp;
void dfs(int x)
{
	for(int i=0;i<v[x].size();i++)
    	dfs(v[x][i]);
    cnt++;
	a[x]=cnt;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(i>k)
			mp.erase(a[i-k]);
		v[(mp.upper_bound(a[i]))->second].push_back(i);
		mp[a[i]]=i;
	}
	dfs(0);
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;

	return 0;
}

Measured memory_bytes: 61696
#include<bits/stdc++.h>
using namespace std;
int dp[1005][1005];
int const mod=1000000007;
int main(){
    int n,m;
    cin>>n>>m;

    char a[1005][1005];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)cin>>a[i][j];
    }
    for(int i=0;i<n;i++){
        if(a[0][i]=='#')break;
        else dp[0][i]=1;
    }
    for(int i=0;i<n;i++){
        if(a[i][0]=='#')break;
        else dp[i][0]=1;
    }

    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
          //  cout<<a[i][j]<<" ";
            if(a[i][j]=='#'){
              //  cout<<"sahil";
                dp[i][j]=0;
            }
            else{
                if(a[i-1][j]=='#');
                else dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;

                if(a[i][j-1]=='#');
                else dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
            }
        }
    }
 /*  for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[n-1][m-1];

}

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

using namespace std;

typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	ll N, W;
	cin >> N >> W;
	
	vector< pair<ll, ll> > obj(N);
	vector<ll> a, b, c, d;

	for (ll i = 0; i < N; i++)
		cin >> obj[i].first >> obj[i].second;
	
	sort(obj.begin(), obj.end());
	ll w1 = obj[0].first;
	for (ll i = 0; i < N; i++) {
		if (obj[i].first == w1) 
			a.push_back(obj[i].second);
		else if (obj[i].first == w1 + 1)
			b.push_back(obj[i].second);
		else if (obj[i].first == w1 + 2)
			c.push_back(obj[i].second);
		else
			d.push_back(obj[i].second);
	}
	
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	sort(d.rbegin(), d.rend());

	for (ll i = 1; i < (ll) a.size(); i++)
		a[i] += a[i-1];
	for (ll i = 1; i < (ll) b.size(); i++)
		b[i] += b[i-1];
	for (ll i = 1; i < (ll) c.size(); i++)
		c[i] += c[i-1];
	for (ll i = 1; i < (ll) d.size(); i++)
		d[i] += d[i-1];
    
	ll ans = 0;
	for (ll i = 0; i <= (ll) a.size(); i++) {
		for (ll j = 0; j <= (ll) b.size(); j++) {
			for (ll k = 0; k <= (ll) c.size(); k++) {
				ll cur_weight = w1*i + (w1+1)*j + (w1+2)*k;
				if (cur_weight > W) 
					continue;
				ll l = (W - cur_weight) / (w1+3);
				if ((ll) d.size() < l)
					l = (ll) d.size();	
				ll cur_value = 0;
				if (i != 0)
					cur_value += a[i - 1];
				if (j != 0)
					cur_value += b[j - 1];
				if (k != 0)
					cur_value += c[k - 1];
				if (l != 0)
					cur_value += d[l - 1];
				ans = max(ans, cur_value);
			}
		}
	}

	cout << ans << endl;
			
	


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main()
{
    int x;
    cin>>x;
    if(x>=400 && x<600)
        cout<<8<<endl;
    if(x>=600 && x<800)
        cout<<7<<endl;
    if(x>=800 && x<1000)
        cout<<6<<endl;
    if(x>=1000 && x<1200)
        cout<<5<<endl;
    if(x>=1200 && x<1400)
        cout<<4<<endl;
    if(x>=1400 && x<1600)
        cout<<3<<endl;
    if(x>=1600 && x<1800)
        cout<<2<<endl;
    if(x>=1800 && x<2000)
        cout<<1<<endl;


    return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str1 = lines[0];
        int mult = Integer.parseInt(str1); //K
        
        String str2 = lines[1];
        String[] str21 = str2.split(" ");
        int from = Integer.parseInt(str21[0]); //A
        int till = Integer.parseInt(str21[1]); //B

        for (int i = 1; i <= 1000 ; i++){
            int multiple = mult * i ;
            //System.out.println(multiple);
            if (multiple >= from && multiple <= till){
                System.out.println("OK");
                return;
            } else {
                multiple = mult; //=7
            }
        }

        System.out.println("NG");


   
    
    
        
    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}


Measured memory_bytes: 35708
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $s);
$x = $w = substr_count($s, '.');
if (!$w || $w == $n || preg_match('/^\.*#*$/', $s)) {
	exit('0');
}
$b = 0;
for ($i = 0; $i < $n; $i++) {
	if ($s[$i] == '#') {
		$b++;
	} else {
		$w--;
	}
	$x = min($x, $b + $w);
	if (!$w) break;
}
echo $x;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 1000000000000000000 //14

bool isPrime(ll x){
	double y = sqrt((double)x);
	ll b = y;
	FOR(i,2,b) if (!(x%i)) return false;
	return true;
}

vector<ll> exc={0,1,3,6,10,15,21,28,36,45};

ll kai(ll x){
	ll y = upper_bound(exc.begin(),exc.end(),x)-exc.begin()-1;
	return y;
}

int main(){
	ll n; cin >> n;
	vector<ll> pri;
	FOR(i,2,1000000){
		if (isPrime(i)) pri.pb(i);
	}
	ll cnter=0;
	ll maxlim = pri.size();
	vector<ll> pricnt(pri.size(),0);
	while(n>1){
		if(n%pri[cnter]==0){
			pricnt[cnter]++;
			n/=pri[cnter];
			//cout << pri[cnter] << " " << n << endl;
		}
		else{
			cnter++;
		}
		if (cnter==maxlim) break;
	}
	ll ans = 0;
	REP(i,pri.size()){
		ans+=kai(pricnt[i]);
		//if (pricnt[i]) cout << pri[i] << " " << pricnt[i] << " " << kai(pricnt[i]) << endl;
	}
	//cout << n << endl;
	if (n!=1) ans++;
	cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, W; cin >> H >> W;
    if (H == 1 || W == 1){
        cout << 1 << endl;
    } else {
        cout << ((W + 1) / 2) * ((H + 1) / 2) + (W / 2) * (H / 2) << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n; cin >> n;
    VL a(n); cin >> a;

    auto solve = [&](ll num) {
        each(i, a)num -= num % i;
        return num;
    };

    ll Min, Max;
    ll ok = LLINF, ng = 0;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        if (solve(mid) >= 2)ok = mid;
        else ng = mid;
    }
    Min = ok;

    ok = 0, ng = LLINF;
    while(ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        if (solve(mid) <= 2)ok = mid;
        else ng = mid;
    }
    Max = ok;

    if (Min > Max)cout << "-1\n";
    else cout << Min << " " << Max << "\n";
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    p=list(map(int,input().split()))
    c=0
    f=False
    for i in range(N):
        if p[i]==i+1:
            if f:
                f=False
            else:
                c+=1
                f=True
        else:
            f=False
    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 52332
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string a, b;
  cin >> a >> b;
  if(a == b ) cout << "EQUAL" << endl;
  else if(a.size() > b.size()) cout << "GREATER" << endl;
  else if(a.size() < b.size() ) cout << "LESS" << endl;
  else if( a.size() == b.size()){
    if(a > b) cout << "GREATER" << endl;
    else cout << "LESS" << endl;
  }
}

Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s[] = new int[n];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		Arrays.sort(s);
		for (int i = 0; i < n - 2; i++) {
			for (int o = i + 1; o < n - 1; o++) {
				// s[i]+s[o]
				for (int p = o + 1; p < n; p++) {
					if ((s[i] + s[o] > s[p])
							&& (Math.abs(s[i] - s[o]) < s[p])) {
						//System.out.println(s[i]+" "+s[o]+" "+s[p]);
						ans++;
					}
					if(s[i] + s[o] <= s[p]){
						break;
					}
				}

			}

		}
	System.out.println(ans);
	}
}

Measured memory_bytes: 28136
# TODO:実装
N, W = map(int, input().split())

DP = {0: 0}
for i in range(N):
    wi, vi = map(int, input().split())
    DP_dst = DP.copy()
    for j in DP:
        if j+wi <= W:
            DP_dst[j+wi] = max(DP.get(j+wi, 0), DP[j]+vi)
    DP = DP_dst
print(max((DP[x] for x in DP)))


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

		String s = sc.next();
		String t = sc.next();

		int g = 0;
		for ( int i=0; i<s.length(); i++ ) {
			char s1 = s.charAt(i);
			char t1 = t.charAt(i);
			if ( s1!=t1 ) g++;
		}


		System.out.println(g);
	}
}

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

#define MIN_X (-20)
#define MAX_X   20

int hgt[MAX_X - MIN_X];
#define height(x) (hgt[(x) - MIN_X])

double solve(int r)
{
  int x, x0;
  double y, t;
  double min = height(0); /* the time when the sunlight comes at x=0 */
  for (x = -r; x < r; x++) {
    x0 = (x < 0 ? x + 1 : x);
    y = sqrt(r * r - x0 * x0) - r; /* the top of the sun at x0 */
    t = height(x) - y;
    if (min > t) min = t;
  }
  return min;
}

int main()
{
  int r, n, h, i, x, x1, x2;
  for (;;) {
    scanf("%d%d", &r, &n);  /* radius, # of bld. */
    if (r == 0 && n == 0) break;

    for (x = MIN_X; x < MAX_X; x++) height(x) = 0; /* initialize */
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &x1, &x2, &h); /* left, right, height */
      for (x = x1; x < x2; x++) {
        if (height(x) < h) height(x) = h;
      }
    }
    printf("%.4f\n", solve(r));
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

int main() {
    int H;
    std::cin >> H;
    std::vector<int> heap(H);
    for (auto& e : heap) std::cin >> e;

    for (int i = H - 1; i >= 0; --i) {
        int j = i;
        while (j * 2 + 1 < H) {
            int ch = j * 2 + 1;
            if (j * 2 + 2 < H && heap[ch] < heap[j * 2 + 2]) ch = j * 2 + 2;

            if (heap[j] < heap[ch]) {
                std::swap(heap[j], heap[ch]);
                j = ch;
            } else {
                break;
            }
        }
    }

    for (auto e : heap) std::cout << " " << e;
    std::cout << std::endl;
    return 0;
}



Measured memory_bytes: 4596
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll k;cin>>k;
	ll sum=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int v=1;v<=k;v++){
				sum += __gcd(__gcd(i,j),v);
			}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n=0;
        n=sc.nextInt();
        String str = String.valueOf(n);
        String[] str2 = str.split("");
        int count=0;
        int []number = new int[3];
        

        for(int i=0;i<3;i++){
            number[i]=Integer.parseInt(str2[i]);
        }
        for(int i=0;i<3;i++){
            if(number[i]==7)
            count+=1;
        }
        if(count!=0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FOR(i, 1, n + 1)

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

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

//a,bの最大公約数
ll gcd(ll a, ll b)
{
	ll temp;
	while (a % b != 0)
	{
		temp = a;
		a %= b;
		b = temp;
	}
	return b;
}

//a,bの最小公倍数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}

const ll INF = 1LL << 60;
const int MAX_N = 1e5 + 10;

int n, ans;
int d[MAX_N];

int main()
{
	cin >> n;
	REP(i, n)
	{
		cin >> d[i];
	}
	sort(d, d + n);
	ans = d[n / 2] - d[n / 2 - 1];
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include<cmath>
#include<vector>
#include<tuple>
#include <ctime>
#include<algorithm>
#include <initializer_list>
#include <cstring> 
#include <queue>

using namespace std;
 
#define tii tuple<int,int>
#define vi vector<int>
#define vii vector<vi>
#define ll long long
#define vl vector<ll>
#define vll vector<vl>
 
#define mymod 1000000007
#define mx 99999999
#define mn -99999999
#define sz 200002

ll power(ll a, ll b, ll p)
{
    if(a<2)
    return a;
    ll ans = 1;
    while(b)
    {
        if(b%2)
        {
            ans *= a;
            ans %= p;
        }
        b = b/2;
        a = (a*a)%p;
    }
    return ans;
}

ll mgcd(ll a, ll b)
{
    if(a==0)
        return b;
    return mgcd(b%a,a);
}

int main() {
    clock_t tstart = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // Start
    string s;
    cin>>s;
    vector<char> v;
    for(auto x:s) {
        if(x=='0' || x=='1') v.push_back(x);
        else if(v.size()>0) v.pop_back();
    }
    for(auto x:v) cout<<x;
    // cout<<"\n\nTotal Time Taken : "<<(double)(-tstart + clock())/CLOCKS_PER_SEC<<"sec\n\n";
    return 0;
}
 


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N, long long M, std::vector<long long> A){
  int sum = 0;
  REP(i, M) sum += A.at(i);
  int days = N - sum;
  cout << (days > -1 ? days : -1) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, M, std::move(A));
}


Measured memory_bytes: 3772
import heapq

def main():
    N, Q = map(int, input().split())
    STX = [tuple(map(int, input().split())) for _ in range(N)]
    ev = []
    for s, t, x in STX:
        ev.append((s - x, True, x))
        ev.append((t - x, False, x))
    ev.sort(reverse=True)
    bar = []
    dead = {}

    for d in [int(input()) for _ in range(Q)]:
        while ev and ev[-1][0] <= d:
            t, a, x = ev.pop()
            if a:
                heapq.heappush(bar, x)
            else:
                dead[x] = dead.get(x, 0) + 1
                while bar and bar[0] in dead:
                    x = heapq.heappop(bar)
                    if dead[x] == 1:
                        del dead[x]
                    else:
                        dead[x] = dead[x] - 1
        print(bar[0] if bar else -1)

main()


Measured memory_bytes: 108692
#include<stdio.h>
int main(void){
int r,d,x[11];
  scanf("%d%d%d",&r,&d,&x[0]);
  for(int i=1;i<11;i++){
    x[i]=r*x[i-1]-d;
    printf("%d\n",x[i]);
  }
  return 0;
}

Measured memory_bytes: 128
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<std::vector<long long>> inp;
std::vector<long long> dp,cost;
long long solve()
{
	long long n;cin>>n;
	inp.resize(n,std::vector<long long>(n,0));
	REP(i,0,n-1)
	{
		REP(j,0,n-1)
		{
			cin>>inp[i][j];
		}
	}
	long long lim=((1<<n)-1);
	dp.resize((1<<n)+1,0);
	cost.resize(((1<<n)+1),0);
	REP(i,0,lim)
	{
		REP(j,0,n-1)
		{
			REP(k,j+1,n-1)
			{
				if(((i>>j)&1) && ((i>>k)&1))
				{
					cost[i]+=inp[j][k];
				}
			}
		}
	}
	REP(pres,0,lim)
	{
		for(long long j=pres;j>=0;j=pres&(j-1))
		{
			long long com=(j^pres);
			dp[pres]=MAX(dp[pres],(cost[j]+dp[com]));
			if(j==0){break;}
		}
	}
	cout<<dp[lim]<<"\n";
}
signed main(){
	speed
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    for(ll x = a; x <= b; ++x){
        if(x / 10000 == x % 10 &&
           ((x / 1000) % 10 == (x / 10) % 10)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
const int MAX_V=100000;
struct edge{int to,cost;};
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];
bool visited[MAX_V];
bool bfs(int s){
    queue<P> que;
    d[s]=0;
    visited[s]=true;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.front();que.pop();
        int v=p.se;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(visited[e.to]&&d[e.to]!=d[v]+e.cost){
                return false;
            }
            if(!visited[e.to]){
                visited[e.to]=true;
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
    return true;
}
int main(){
    cin>>V>>E;
    REP(i,E){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].pb({b,c});
        G[b].pb({a,-c});
    }
    REP(i,V){
        if(!visited[i]){
            if(!bfs(i)){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 9716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char s1 = s.charAt(0), s2 = s.charAt(s.length() - 1);
		System.out.print(s1);
		System.out.print(s.length() - 2);
		System.out.print(s2);
		sc.close();
	}
}


Measured memory_bytes: 25428
# Print a Rectangle

inputEnd = 0
while inputEnd == 0:
    n = [int(i) for i in input().rstrip().split()]
    h = n[0]
    w = n[1]
    if h == 0 and w == 0:
        inputEnd += 1
    else:
        for i in range(h):
            for j in range(w):
                print('#', end = "")
            print()
        print()



Measured memory_bytes: 7012
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int N, Q;
char s[202020];
char t[202020];
char d[202020];
int f[202020];
int check(int p){
    for(int i = 0; i < Q; i++){
        if(s[p] == t[i]){
            if(d[i]=='L')p--;
            else p++;
        }
        if(p < 1)return 1;
        if(p > N)return 3;
    }
    return 2;
}

int main(){

    cin >> N >> Q;
    for(int i = 1; i <= N; i++)cin >> s[i];
    for(int i = 0; i < Q; i++)cin >> t[i] >> d[i];
    f[0] = 1;
    f[N+1] = 3;
    int notR = 0, R = N + 1;
    while(notR + 1 < R){
        int p = (notR + R) / 2;
        if(check(p) == 3)R = p;
        else notR = p;
    }
    int L = 0, notL = N + 1;
    while(L + 1 < notL){
        int p = (L + notL) / 2;
        if(check(p) == 1)L = p;
        else notL = p;
    }
    cout << max(0, notR - notL + 1) << endl;

    return 0;
}


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


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  long long mymax = B[0];
  long long maxpos = A[0];
  for(long long i = 1; i < N; i++){
    if(mymax > B[i]) {
      mymax = B[i];
      maxpos = A[i];
    }
  }

  cout << (mymax+maxpos) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  if(A<=8 && B<= 8){
    cout << "Yay!" << endl;
  }else {
    cout << ":(" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		long a = nl();
		long b = nl();
		long c = nl();

		long d = c - a - b;

		if (d >= 0 && 4 * a * b < d * d) {

			out(Y);

		} else {
			out(N);
		}

	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + "AB".length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{
  for(int t = 1;; t++) {
    int h;
    cin >> h;
    if(h == 0) break;
    int fld[h][5];
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < 5; j++) {
        cin >> fld[i][j];
      }
    }
    auto print = [&]{
      for(int i = 0; i < h; i++) {
        for(int j = 0; j < 5; j++) {
          cerr << fld[i][j] << " ";
        }
        cerr << endl;
      }
      cerr << endl;
    };
      //if(t == 149) { cerr << h << endl; print(); }
    int sc = 0;
    for(;;) {
      bool vanished = false;
      //print();
      for(int i = 0; i < h; i++) {
        for(int j = 0; j < 3; j++) {
          int c = fld[i][j];
          if(c > 0) {
            int k = j + 1;
            for(; k < 5; k++) {
              if(fld[i][k] != c) break;
            }
            if(k - j >= 3) {
              vanished = true;
              for(int l = j; l < k; l++) {
                sc += fld[i][l];
                fld[i][l] = 0;
              }
            }
          }
        }
      }
      if(!vanished) break;
      for(int j = 0; j < 5; j++) {
        int ii = h - 1;
        int i = h - 1;
        for(;;) {
          while(fld[i][j] == 0 && i >= 0) i--;
          if(i < 0) break;
          fld[ii--][j] = fld[i--][j];
        }
        for(; ii >= 0; ii--) {
          fld[ii][j] = 0;
        }
      }
    }
    cout << sc << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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 ll INF=1e18;

int main(){
    int n;
    cin>>n;
    V<ll> a(n);
    ll x=0;
    rep(i,n){
        cin>>a[i];
        x^=a[i];
    }
    if(x==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long n;
  cin>>n;
  long long dsum=0;
  long long cnt=0;
  if(n>=3){
    dsum += n;
    cnt++;
  }
  for(long long i=2;i<=sqrt(n);i++){
    if(n%i==0){
      if(i<=n/i-2){
        dsum += n/i;
        cnt++;
      }
    }
  }
  long long ans;
  ans = dsum-cnt;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1000003;
int f[N], invf[N], lg[N], d[N], a[N];
int cnt;
vector < int > g[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int cnk(int n, int k){
    return f[n] * invf[n - k] % mod * invf[k] % mod;
}
void dfs(int v, int p = -1){
    cnt++;
    d[v] = a[cnt];
    for (auto u: g[v]){
        if (u != p) dfs(u, v);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, r, g, b;
    int ans = 0;
    cin >> b >> r >> g >> n;
    for (int i = 0; i <= n / r; i++){
        for (int j = 0; j <= (n - i * r) / b; j++){
            int x = n - i * r - j * b;
            if (x % g == 0) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 71936
#include <cstdio>
#include <utility>
#include <stack>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s){int c;
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	for (;;) {
		stack<char> s;
		bool world = true, b = false;
		for (char c; c = gcu(), c != '.'; b = true)
			if (world)
				switch(c) {
				case '(': s.push(')'); break;
				case '[': s.push(']'); break;
				case ')':
				case ']':
					if (s.empty() || s.top() != c)
						world = false;
					else
						s.pop();
					break;
				}
		if (b) {
			gcu();
			out(world && s.empty() ? "yes" : "no", '\n');
		} else
			break;
	}
}


Measured memory_bytes: 2496
"use strict"

function Main(input) {
    const K = parseInt(input[0], 10);
    const X = parseInt(input[1], 10);

    const min = X - (K - 1);
    const max = X + (K - 1);
    let result = '';

    for (let i = min; i <= max; i++) {
        result += i !== max ? `${i} ` : `${i}`;
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  long long int n;
  cin >> n;
  long long int temp = n;
  long long int sum = 0;
  while (temp>0) {
    sum += temp%10;
    temp /= 10;
  }
  if (n%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]
directions = [[0, 1], [1, 0], [0, -1], [-1, 0]]
 
ans = 0
for sh in range(H):
    for sw in range(W):
        # 通れないマスはスタートになり得ない
        if G[sh][sw] == '#':
            continue
 
        # BFS
        dist = [[-1] * W for i in range(H)]
        dist[sh][sw] = 0
        que = deque([[sh, sw]])
 
        while que:
            nh, nw = que.pop()
            for dh, dw in directions:
                # 迷路からはみ出す
                if not ((0 <= nh + dh < H) and (0 <= nw + dw < W)):
                    continue
 
                # 移動先が通れないマス
                if G[nh + dh][nw + dw] == '#':
                    continue
 
                # 探索済み
                if dist[nh + dh][nw + dw] != -1:
                    continue
 
                dist[nh + dh][nw + dw] = dist[nh][nw] + 1
                que.appendleft([nh + dh, nw + dw])
 
        ans = max(ans, max([max(d) for d in dist]))
 
print(ans)

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

using namespace std;

int main () {
  int N;
  int k;
  int h[1<<17];
  int m[1<<17];
  cin >> N >> k;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
    m[i] = 0x7fffffff;
  }
  m[0] = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= k; j++) {
      if (i-j < 0) continue;
      m[i] = min(m[i], m[i-j] + abs(h[i]-h[i-j]));
    }
  }
  cout << m[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int func(int n, int k, int t, int s)
{
  if(t == n){
    return 1;
  } else if(k <= 0 || t > n){
    return 0;
  }

  int v = 0;
  for(int i = s; i*i+t <= n; i++){
    v += func(n, k-1, t+i*i, i);
  }

  return v;
}

int main()
{
  int n;

  while(cin>>n && n){
    cout << func(n, 4, 0, 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

const int  mod = 1e9 + 7;
const int e = 2*1e5 + 69;
const int base = 311;

ll a[e];
ll dp[e];
ll n, k;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
   cin >> n >> k;
   ll s= 0;
   for(ll i=1; i<=n; i++)
   {
       cin >> a[i];
       a[i]--;
       dp[i] = (dp[i-1] + a[i])%k;
   }
   map<ll,ll>kt;
   ll ans = 0;
   for(ll i=0; i<=n; i++)
   {
       if(i >= k) kt[dp[i-k]]--;
       ans += kt[dp[i]];
       kt[dp[i]]++;
   }
   cout << ans;

}


Measured memory_bytes: 15872
n = int(input())
mtx = [list(map(int, list(input().split()))) for i in range(n)]

happy_list = [[0, 0, 0] for i in range(n)]

happy_list[0][0] = mtx[0][0]
happy_list[0][1] = mtx[0][1]
happy_list[0][2] = mtx[0][2]

for i in range(1, n):
    happy_list[i][0] = max(happy_list[i-1][1], happy_list[i-1][2]) + mtx[i][0]
    happy_list[i][1] = max(happy_list[i-1][0], happy_list[i-1][2]) + mtx[i][1]
    happy_list[i][2] = max(happy_list[i-1][0], happy_list[i-1][1]) + mtx[i][2]

print(max(happy_list[-1]))


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N,M;
int A[22],P[22];

vector<int> fast_mobius_transform(vector<int> f) {
    for (int i = 0; (1 << i) < f.size(); i++) {
        for (int j = 0; j < f.size(); j++) {
            if (j & 1 << i) {
                f[j] -= f[j ^ 1 << i];
            }
        }
    }
    return f;
}
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

signed main(){
    cin>>N>>M;
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>P[i];

    vector<int>f(1<<N);
    f[0]=1;
    for(int i=1;i<1<<N;i++){
        int p=32-__builtin_clz(i)-1;
        int x=f[i^(1<<p)];
        int g=gcd(x,A[p]);
        if(1.0*x*A[p]/g>M)f[i]=M+1;
        else f[i]=x/g*A[p];
    }

    for(int i=0;i<1<<N;i++)f[i]=M/f[i];
    f[0]=0;
    vector<int>g=fast_mobius_transform(f);

    double ans=0.0;
    rep(i,1<<N){
        double q=1.0;
        rep(j,N){
            if(i>>j&1){
                q*=P[j]/100.0;
            }
            else{
                q*=(100-P[j])/100.0;
            }
        }
        ans+=q*abs(g[i]);
    }
    printf("%.20f\n",ans);
    return 0;
}

Measured memory_bytes: 19240
#include <iostream>
using namespace std;
int main(){
  int N,i,cnt=0,Hmax=-1,h;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> h;
    if(h>=Hmax)cnt++;
    Hmax =max(h,Hmax);
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD (1e9 +7)
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)

#define ll long long
const long long iinf = 1e18;
const int inf = 1e9; 
using namespace std;


void solve()
{
    int c; cin >> c;
    c %= 10;
    
    if(c == 0 || c == 1 || c == 6 || c == 8) cout << "pon";
    else if(c == 3) cout << "bon";
    else cout << "hon";
    
    

}

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

    // int t; cin >> t;
    // int i = 1;
    // while(t--){
    //     //cout << "Case " << i++ << ": " ;
    //     solve();
    //     cout  << endl;
    // }
    solve();

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a==1)
    a+=13;
  if(b==1)
    b+=13;
  if(a<b)
    printf("Bob\n");
  else if(a>b)
    printf("Alice\n");
  else
    printf("Draw\n");
  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int all = 0;
            if (n % 2 != 0)
            {
                all++;
                n--;
            }

            all += n / 2;
            Console.WriteLine(all);

        }
    }
}


Measured memory_bytes: 11092