akhauriyash/Code-Regression huggingface dataset:
N, Ma, Mb = map(int, input().split())
abc = []
for i in range(N):
    a, b, c = map(int, input().split())
    abc.append([a, b, c])

W = max([Ma, Mb])*(N+1)
C = 100*(N+1)

dp = [[[10000]*W for _ in range(W)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(1, N+1):
    a, b, c = abc[i-1]
    for j in range(W):
        for k in range(W):
            if (j-a) < 0 or (k-b) < 0:
                dp[i][j][k] = dp[i-1][j][k]
            else:
                dp[i][j][k] = min([
                    dp[i-1][j][k],
                    dp[i-1][j-a][k-b]+c
                ])

ans = C
ma, mb = Ma, Mb
while ma < W and mb < W:
    t = dp[N][ma][mb]
    if t < ans:
        ans = t
    ma += Ma
    mb += Mb

print(ans if ans < C else -1)


Measured memory_bytes: 97372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n, m, c, ans=0;cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    vector<int> a(m);
    for(int j=0;j<m;j++)cin>>a[j];
    int judge=0;
    for(int j=0;j<m;j++)judge+=a[j]*b[j];
    if(judge+c>0)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 //stringstream num(c);
    //        num >> x;
using namespace std;
//long double value(double a)
//{
////    long  p=100;
////    double r=0.01;
////   long  n=12;
//   long double t,x;
//   t=ceil(log(a/100))/ceil(log(1+(0.01)));
//   round(t);
//    return  t;
//}
//int main()
//{
//   long double a;
//   cin>>a;
////   long double p=100;
////   long double r=1/00;
////   long double n=12;
//   long double t;
//   //a=p(1+r/n)^nt;
//  // t=log(a)/(log(p)+log(1+(r/n)))*n
//  long double x = value(a);
//   cout<<x;
//
//
//    return 0;
//}
//// double valueE(double d)
////{
////    return log(d)/(log(p)+log(1+(r/n)))*n;
////}
////
////// function to evaluate logarithm base-10
////double value10(double d)
////{
////    return log10(d);
////}
////
////// driver program to test the above function
////int main()
////{
////    double d = 100;
////    cout << "The logarithm value(base-e) of " << d
////         << " is " << valueE(d) << endl;
////    cout << "The logarithm value(base-10) of " << d
////         << " is " << value10(d) << endl;
////    return 0;
////}

int main()
{

    string s,t;
    cin>>s>>t;
    int x=0;
    for(int i=0;i<s.size();i++)
    {

        if(s[i]==t[i])
        {
            x++;
        }
        else
            break;
    }
    //cout<<x<<"\n";
    if(x==s.size())
    {
        cout<<"Yes";
    }
    else
        cout<<"No";

}


Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	passwordMap := map[string]bool{}
	var count int
	leftNumMap := map[string]bool{}
	for i := 0; i < n-2; i++ {
		if len(leftNumMap) == 10 {
			break
		}

		leftNum := s[i : i+1]
		if leftNumMap[leftNum] {
			continue
		}
		leftNumMap[leftNum] = true

		middleNumMap := map[string]bool{}
		for j := i + 1; j < n-1; j++ {
			if len(middleNumMap) == 10 {
				break
			}

			middleNum := s[j : j+1]
			if middleNumMap[middleNum] {
				continue
			}
			middleNumMap[middleNum] = true

			rightNumMap := map[string]bool{}
			for k := j + 1; k < n; k++ {
				if len(rightNumMap) == 10 {
					break
				}

				rightNum := s[k : k+1]
				password := leftNum + middleNum + rightNum
				if passwordMap[password] {
					continue
				}
				rightNumMap[rightNum] = true
				passwordMap[password] = true
				count++
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 4736
import sys
for x in sys.stdin.readlines():
    n = [float(y) for y in x.split()]

    print "%.3f %.3f" % ((n[2]*n[4]-n[1]*n[5])/(n[0]*n[4]-n[1]*n[3])+0,(n[5]*n[0]-n[2]*n[3])/(n[0]*n[4]-n[3]*n[1])+0)

Measured memory_bytes: 5948
while True:
    H,W=map(int, input().split())
    if H == 0 and W == 0:
        break

    for i in range(H):
        for j in range(W):
            if (i+j+1)%2 == 0:
                print(".", end="")
            else:
                print("#", end="")
        print("")
    print("")

Measured memory_bytes: 6808
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
template <typename CT, typename T> inline void reset_container(CT &c, int sz, T v){c.resize(sz); for(auto &x: c) x=v;}
#define taskname "A"
bool ra[200002];
bool rb[200002];
bool rc[200002];
bool rd[200002];
int a, b, c, d;
string s;
int n;
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    cin>>n>>a>>b>>c>>d>>s;
    s='0'+s;
    ra[a]=1;
    FOR(i, a+1, n) if(s[i]=='.') ra[i]=ra[i-1]||ra[i-2];
    rb[b]=1;
    FOR(i, b+1, n) if(s[i]=='.') rb[i]=rb[i-1]||rb[i-2];
    rc[c]=1;
    DFOR(i, c-1, 1) if(s[i]=='.') rc[i]=rc[i+1]||rc[i+2];
    rd[d]=1;
    DFOR(i, d-1, 1) if(s[i]=='.') rd[i]=rd[i+1]||rd[i+2];
    if(c<d){
        if(ra[c]&&rb[d]) puts("Yes");
        else puts("No");
    }
    else{
        FOR(i, b, d) if(rb[i]&&rd[i]){
            if(ra[i-1]&&rc[i+1]){
                puts("Yes");
                return 0;
            }
        }
        puts("No");
    }

}

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

namespace ConsoleApp11
{
    class Class72
    {
        static void Main()
        {
            string s = Console.ReadLine();
            List<char> c = new List<char>();
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] == '0')
                {
                    c.Add('0');
                }
                else if (s[i] == '1')
                {
                    c.Add('1');
                }
                else
                {
                    if (c.Count() == 0)
                    {
                        continue;
                    }
                    else
                    {
                        c = c.Where((ch, index) => index < c.Count() - 1).ToList();
                    }
                }
            }
            Console.WriteLine(new string(c.ToArray()));
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#define rep(i,n) for (long int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    long int N;
    cin>>N;
    long long A[N],ans=1;
    long long INF=1000000000000000000;
    rep(i,N){
        cin>>A[i];
        if (A[i]==0) ans=0;
    }
    bool x=false;
    rep(i,N){
        long long aa=1;
        while(A[i]>=aa){
            if (ans*aa>INF){
                x=true;
                break;
            }
            aa=aa*10;
        }
        ans=ans*A[i];
        if (ans>INF){
            x=true;
            break;
        }
    }
    if (x) cout<<"-1"<<endl;
    else{
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
#define endl '\n'
#define N 200123

using namespace std;

int n, m, ans[N], v[N];

int main(){ 
    ios_base::sync_with_stdio(0);

    cin >> n;

    for(int i=2; i <= n; ++i) {
        cin >> v[i];
        ans[v[i]]++;
    }


    for(int i=1; i <= n; ++i) {
        cout << ans[i] << endl;
    }


    return 0;
}



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


using namespace std;


template<typename T>
class UF
{
public:
	UF() {
		size = 0;
	}

	//値を挿入する
	void push( T a ) {
		M[a] = size;
		V.push_back( size );
		rank.push_back( 0 );
		C.push_back( 1 );
		size++;
	}

	//同じグループにする
	void unite( T a, T b ) {
		long long int x = find( M[a] );
		long long int y = find( M[b] );
		if( x == y )return;
		if( rank[x] < rank[y] ) {
			V[x] = y;
			C[y] += C[x];
		} else {
			V[y] = x;
			C[x] += C[y];
			if( rank[x] == rank[y] )rank[x]++;
		}
	}

	void merge( T a, T b ) {
		unite( a, b );
	}

	//同じグループにいるかどうか判定する
	bool same( T a, T b ) {
		return find( M[a] ) == find( M[b] );
	}

	//今何グループあるか数を返す
	long long int group() {
		set<long long int >S;
		for( long long int i = 0; i < V.size(); i++ ) {
			S.insert( find( V[i] ) );
		}
		return S.size();
	}

	//グループに属している数を返す
	long long int count( T a ) {
		return C[find( M[a] )];
	}


	//今属しているグループのIDを返す
	long long int groupID( T a ) {
		return find( M[a] );
	}
private:
	vector<long long int>
		C, V, rank;
	map < T, long long int>M;
	long long int size;

	//祖先までたどる
	long long int find( long long int x ) {
		if( V[x] == x )return x;
		else return V[x] = find( V[x] );
	}
};

int main() {
	long long int N, K, L;
	cin >> N >> K >> L;
	UF<long long int>uf1, uf2;
	for( size_t i = 0; i < N; i++ ) {
		uf1.push( i );
		uf2.push( i );
	}
	for( size_t i = 0; i < K; i++ ) {
		long long int p, q;
		cin >> p >> q;
		p--; q--;
		uf1.merge( p, q );
	}
	for( size_t i = 0; i < L; i++ ) {
		long long int r, s;
		cin >> r >> s;
		r--; s--;
		uf2.merge( r, s );
	}
	map<long long int, map<long long int, long long int>>ansmap;
	for( size_t i = 0; i < N; i++ ) {
		ansmap[uf1.groupID( i )][uf2.groupID(i)]++;
	}
	for( size_t i = 0; i < N; i++ ) {
		cout << ansmap[uf1.groupID( i )][uf2.groupID( i )] << (i == N - 1 ? "\n" : " ");
	}
}

Measured memory_bytes: 62120
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn solve(h: u32, w: u32) -> u32 {
    let a = w / 3;
    let b = h / 2;

    if h % 2 == 1 {
        if w % 3 == 1 {
            min(max(a, 2 * b + 1), max(2 * a + 1, a + b + 1))
        } else {
            min(max(a, 2 * b + 1), max(2 * a + 1, a + b + 1))
        }
    } else {
        b
    }
}

use std::cmp::{max, min};

fn main() {
    let v: Vec<u32> = read_vec();
    let h = v[0];
    let w = v[1];
    if h % 3 == 0 || w % 3 == 0 {
        println!("0");
    } else {
        println!("{}", min(solve(h, w), solve(w, h)));
    }
}


Measured memory_bytes: 4352
A,B,C = [int(i) for i in input().split()]

if A%2 == 0 and B%2 == 0 and C%2 == 0:
    if A==B and B==C:
        print(-1)
        exit()

    ans = 0
    while True:
        if A%2 == 0 and B%2 == 0 and C%2 == 0:
            ans += 1
            A,B,C = [(A+B)/2, (B+C)/2, (C+A)/2]
        else:
            print(ans)
            exit()
else:
    print(0)


Measured memory_bytes: 38384
def gcd(a,b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a %b)

def gcdlist(l):
    if len(l) == 2:
        return gcd(l[0], l[1])
    f = l.pop()
    s = l.pop()
    m = gcd(f, s)
    l.append(m)
    return gcdlist(l)


def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        try:
            max_ = gcdlist(dis)
        except:
            max_ = 1
    print(max_)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
N = int(input()) 
pre_t = 0
pre_x = 0
pre_y = 0

for i in range(N):
    now_t,now_x,now_y = list(map(int,input().split()))
    d = abs(now_x - pre_x) + abs(now_y - pre_y)
    t = now_t - pre_t
    if d <= t and t % 2 == d % 2:
        flg = 1
    else:
        flg = 0
        break

if flg == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    string s,t;
    cin >> s;
    cin >> t;

    vector<int> scnt(26,0);
    vector<int> tcnt(26,0);
    REP(i,s.size()){
        scnt[s[i] - 'a']++;
    }

    REP(i,t.size()){
        tcnt[t[i] - 'a']++;
    }

    sort(all(scnt));
    sort(all(tcnt));

    REP(i,scnt.size()){
        if(scnt[i] != tcnt[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

ll dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, W;
	cin >> n >> W;
	rep(i, n){
		int w;
		ll v;
		cin >> w >> v;
		for(int j = W - w; j >= 0; j--){
			dp[j + w] = max(dp[j + w], dp[j] + v);
		} 

	}
	cout << dp[W] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

vector<vector<map<ll,ll>>> table;
vector<vector<pair<ll,ll>>> grid;

ll dp(ll n,ll x,ll d,ll m){
  if(m<0) return INF;
  if(n==0) return 0;
  if(n==1&&m>=1) return 0;
  if(table.at(m).at(n).count(x)) return table.at(m).at(n).at(x);
  
  table.at(m).at(n)[x]=INF;
  //n-1からの移動
  for(auto p:grid.at(n-1)){
    ll px,pd; tie(px,pd)=p;
    chmin(table.at(m).at(n).at(x),dp(n-1,px,pd,m)+(d+pd)*abs(x-px));
  }
  
  if(n<2||m<1) return table.at(m).at(n).at(x);
  //n-2からの移動
  for(auto p:grid.at(n-2)){
    ll px,pd; tie(px,pd)=p;
    chmin(table.at(m).at(n).at(x),dp(n-2,px,pd,m-1)+(d+pd)*abs(x-px));
  }
  
  return table.at(m).at(n).at(x);
}


int main()
{
  while(true){
    ll N,M; cin>>N>>M; if(N==0&&M==0) break;
    grid=vector<vector<pair<ll,ll>>>(N,vector<pair<ll,ll>>(0));
    rep(i,N){
      ll k; cin>>k;
      rep(j,k){
        ll x,d; cin>>x>>d; x--;
        grid.at(i).push_back({x,d});
      }
    }
    
    //dp
    table=vector<vector<map<ll,ll>>>(M+1,vector<map<ll,ll>>(N));
    ll ans=INF;
    for(auto p:grid.at(N-1)){
      ll x,d;tie(x,d)=p;
      chmin(ans,dp(N-1,x,d,M));
    }
    
    if(M<1) {cout<<ans<<endl; continue;}
    
    for(auto p:grid.at(N-2)){
      ll x,d; tie(x,d)=p;
      chmin(ans,dp(N-2,x,d,M-1));
    }
    
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 7316
#include<stdio.h>
int main(){
    int a[3];
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    for(int i=0;i<2;i++){
        for(int j=i+1;j<3;j++){
            if(a[i]>a[j]){
                int box=a[i];
                a[i]=a[j];
                a[j]=box;
            }
        }
    }
    printf("%d %d %d",a[0],a[1],a[2]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2036
import java.util.*;

public class Main {
	  public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int K = scan.nextInt();
            int S = scan.nextInt();
            
            int x, y, z;
            int ans = 0;
            
            for( x = 0 ; x <= K ; x++ ){
            	for( y = 0 ; y <= K ; y++ ){
                	z = S - x - y;
                    if( z >= 0 && z <= K )ans++;
                }
            }
      
		    System.out.println(ans);
		  }
}

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

using ll = long long;

int main() {

	ll x, y;
	cin >> x >> y;

	for (ll i = 2; i < 100; i++) {
		if ((x * i) % y != 0){
			cout << x * i;
			return 0;
		}
	}

	cout << "-1";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a, b, x, y;
	while(scanf("%d%d",&x,&y)!=EOF) {
		switch(x) {
			case 1: a = 1;break;
			case 3: a = 1;break;
			case 5: a = 1;break;
			case 7: a = 1;break;
			case 8: a = 1;break;
			case 10: a = 1;break;
			case 12: a = 1;break;
			case 2: a = 2;break;
			case 4: a = 3;break;
			case 6: a = 3;break;
			case 9: a = 3;break;
			case 11: a = 3;break;
		}
		b = a;
		switch(y) {
			case 1: a = 1;break;
			case 3: a = 1;break;
			case 5: a = 1;break;
			case 7: a = 1;break;
			case 8: a = 1;break;
			case 10: a = 1;break;
			case 12: a = 1;break;
			case 2: a = 2;break;
			case 4: a = 3;break;
			case 6: a = 3;break;
			case 9: a = 3;break;
			case 11: a = 3;break;
		}
		if(a==b) {
			printf("Yes\n");
		}
		else printf("No\n");
	}
}

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

namespace ABC115 {
	class Program {
		static void Main(string[] args) {
			int D = int.Parse(Console.ReadLine());
			Console.WriteLine(isChristmas(D));
		}

		private static string isChristmas(int day) {
			string line = "Christmas";
			for (int i = day; i < 25; i++) line += " Eve";
			return line;
		}
	}
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();
		if(S.charAt(0) != 'A') {
			System.out.println("WA");
			System.exit(0);
		}
		int cnt = 0;
		for(int i = 2; i < S.length() - 1; i++) {
			char c = S.charAt(i);
			if(c == 'C') {
				cnt++;
			}
		}
		if(cnt != 1) {
			System.out.println("WA");
			System.exit(0);
		}
		for(int i = 0; i < S.length(); i++) {
			char c = S.charAt(i);
			if(c != 'A' && c != 'C') {
				if(!(c >= 'a' && c <= 'z')) {
					System.out.println("WA");
					System.exit(0);
				}
			}
		}
		System.out.println("AC");
	}
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    ll n,i,j,k;
    vector<ipair>a;

    cin>>n;
    SIZE(a,n);
    rep(i,n){
        cin>>j;
        a[i]=make_pair(j,i);
    }
    SORT(a);
    rep(i,n){
        cout<<a[i].second+1<<" ";
    }
	
	return 0;
}


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

int main(){
  string s;
  cin>>s;
  int len=s.length();
  int max=s.length()/2;
  int counter=0;
  for(int i=0;i<max;i++){
    if(s[i]!=s[len-1-i]){
      counter++;
    }
  
  }
  cout<<counter<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
int main()
{
    int N;
    std::cin >> N;
    std::map<ll, int> mp, mp2;
    std::vector<ll> D(N);
    for (int i = 0; i < N; i++) { std::cin >> D[i], mp[D[i]] = i; }
    std::sort(D.begin(), D.end(), std::greater<ll>{});
    for (int i = 0; i < N; i++) { mp2[D[i]] = i; }
    std::vector<std::vector<int>> edge(N);
    std::vector<int> sub(N, 1);
    for (int i = 0; i < N - 1; i++) {
        const ll obj = D[i] - (N - 2 * sub[i]);
        if (obj == D[i] or mp2.find(obj) == mp2.end()) { return std::cout << -1 << std::endl, 0; }
        const int prev = mp2[obj];
        edge[mp[obj]].push_back(mp[D[i]]), sub[prev] += sub[i];
    }
    ll sum = 0;
    auto check = [&](auto&& self, const int s, const int d) -> void {
        sum += d;
        for (const int to : edge[s]) { self(self, to, d + 1); }
    };
    check(check, mp[D[N - 1]], 0);
    if (D[N - 1] == sum) {
        for (int i = 0; i < N; i++) {
            for (const int to : edge[i]) {
                std::cout << i + 1 << " " << to + 1 << std::endl;
            }
        }
    } else {
        std::cout << -1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 22016
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	int a, b;
	cin >> a >> b;

	cout << (double)a / b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll po(ll a, ll b) {
    ll c = 1;
    while (b) {
        if (b & 1) c = c * a % 998244353;
        a = a * a % 998244353;
        b >>= 1;
    }
    return c;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m, k;
    ll f[1000006] = {1}, g[1000006] = {}, z = 0;
    for (int i = 1; i <= 1000000; i++) f[i] = f[i - 1] * i % 998244353;
    g[1000000] = po(f[1000000], 998244351);
    for (int i = 999999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % 998244353;
    cin >> n >> m >> k;
    for (int i = 1; i <= k + 1; i++) {
        z = (z + m * po(m - 1, n - i) % 998244353 * f[n - 1] % 998244353 * g[i - 1] % 998244353 * g[n - i]) % 998244353;
    }
    cout << z;
}


Measured memory_bytes: 19272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e15+7;
const ll MOD=1e9+7;

int main(){
	string s;
	cin >> s;
	if(s<="2019/04/30")cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    ll N, T;
    cin >> N >> T;
    vector<ll> time(N);
    for (int i = 0; i < N; i++) {
        cin >> time[i];
    }

    ll ans=T;
    for (int i = 0; i < N-1; i++) {
        ans += min(T, time[i+1] - time[i]);
    }

    cout << ans << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 998244353;
const ll mod1 = 2e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
const int inf = 0x3f3f3f3f;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int t;
struct node
{
	int l, r;
	bool operator<(const node b)const
	{
		if (this->l == b.l)return this->r < b.r;
		return this->l > b.l;
	}
};
int a[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n, x;
	while (cin >> n)
	{
		f(i, 1, n)scanf("%d", &a[i]);
		sort(a + 1, a + 1 + n, greater<int>());
		multiset<node> st;
		ll ans = a[1];
		st.insert({ a[2],a[1] });
		st.insert({ a[2],a[1] });
		f(i, 3, n)
		{
			auto it = st.begin();
			ans += it->l;
			int le = it->l, re = it->r;
			st.erase(it);
			st.insert({ a[i],le });
			st.insert({a[i], re});
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 13844
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <set>

using namespace std; 

string solve(string s, bool flag){
	int l, p, c, d;
	string b, z, t;
	bool e1, e2, e3;
	multiset<int> r;

	t=s;
	z="";
	e1=false; e2=false; e3=false;
	l = s.length();
	d=0;
	for(int j=0; j<l; j++,d++){
		b = s.substr(j,1);
		if((b=="[")||(j==l-1)){
			if((e2)||(j==l-1)){
				multiset<int>::iterator it = r.begin();
				int sum=0;
				for(int k=0; k <= r.size()/2; it++,k++){
					if(flag){sum = sum + ((*it)/2)+1;}
					else{sum = sum+(*it);}
				}
				r.clear();
				ostringstream os;
				os << sum;
				t.insert(c-1, os.str());
				d = d + (os.str()).length();
			}
			e1=false;e2=false;
		}
		else if(b=="]"){
			if(z!=""){
				p = atoi(z.c_str());
				r.insert(p);
				z="";
				t.erase(c-1,d-c+2); e3=false;
				d=c-2;
			}
			if(e1){e2=true;}
			e1=true;
		}
		else{z=z+b; if(!e3){c=d; e3=true;}}
	}

	if(t.substr(1,1)=="["){ return solve(t,false);}
	else {return t.substr(1,t.length()-2);}
}

int main()
{
	int n;
	string s;

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s;
		cout << solve(s,true) << endl;
	}

	return 0;
}

Measured memory_bytes: 1420
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
int main()
{
	char a[10],b[10];
	scanf("%s%*c%s",a,b);
	if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0])
	{
		printf("YES\n");
	}
	else 
		printf("NO\n");
		return 0;
}

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

int n, x, y, z;
int a[100010];
map<int, int>mp;
signed main() {
	scanf("%lld", &n);
	rep(i, n) {
		scanf("%lld", &a[i]);
		mp[a[i]]++;
	}
	sort(a, a + n);
	x = a[0], y = a[n / 3], z = a[n - 1];
	int x1 = mp[x], y1 = mp[y], z1 = mp[z];
	if (z == 0) cout << "Yes" << endl;
	else if (n % 3 != 0) cout << "No" << endl;
	else if (mp.size() == 2 && x == 0 && y == z && x1 == n / 3) cout << "Yes" << endl;
	else if (mp.size() == 3 && (x xor y xor z) == 0 && x != y && y != z && x != z && x1 == y1 && y1 == z1 && x1 == n / 3) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 300005

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll n,a[N],i;
	cin>>n;

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

	ll ans=0;
	for(i=3*n-2;i>=n;i-=2){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d;
  set<int> mochi;
  for(int i = 0;i < n;i++) {
    cin >> d;
    mochi.insert(d);
  }
  cout << mochi.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); rep(i, H) cin >> S[i];

    const int dw[8] = {-1, 0, +1, -1, +1, -1, 0, +1};
    const int dh[8] = {-1, -1, -1, 0, 0, +1, +1, +1};

    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '.') {
                int cnt = 0;
                rep(k, 8) {
                    int ni = i + dh[k];
                    int nj = j + dw[k];
                    if (nj < 0 || nj >= W) continue;
                    if (ni < 0 || ni >= H) continue;
                    if (S[ni][nj] == '#') cnt++;
                }
                S[i][j] = '0' + cnt; // int を char に変換
            }
        }
    }
    
    rep(i, H) {
        cout << S[i] << endl;    
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> H(N);
  rep(i,0,N) cin >> H[i];
  H.push_back(0);

  vector<vector<vector<i64>>> dp(
      N + 1,vector<vector<i64>>(
      K + 1,vector<i64>(
      N + 1, 1e18
    )));

  dp[0][0][N] = 0;

  rep(i,0,N) {
    rep(k,0,K + 1) {
      rep(b, 0, N + 1) {
        //not move
        {
          i64 cost = H[i] - H[b];
          if(cost < 0) cost = 0;
          dp[i + 1][k][i] = min(dp[i + 1][k][i], dp[i][k][b] + cost);
        }
        //move
        if(k + 1 <= K){
          dp[i + 1][k + 1][b] = min(dp[i + 1][k + 1][b], dp[i][k][b]);
        }
      }
    }
  }

  i64 ans = 1e18;

  rep(k,0,K + 1) rep(b,0,N + 1) {
    ans = min(ans, dp[N][k][b]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 216832
#include<stdio.h>

int main() {
	int a, b;
	int a1, b1;
	int g;
	long int l;
	while (scanf("%d %d",&a,&b)!=EOF) {
		a1 = a;
		b1 = b;
		while (a1!=b1) {
			if (a1 > b1) {
				a1 = a1 - b1;
			}
			else {
				b1 = b1 - a1;
			}
		}
		g = a1;
		l = a/g*b;
		printf("%d %ld\n", g, l);
	}
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 500005;

int n, ql, qr, cur, lim, x[MAXN];
double ret, y[MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), lim = Read(), ql = 1;
	for (int i = 1; i <= n; i ++)
	{
		int t = Read(), v = Read();
		while (cur + v > lim)
			if (cur + v - x[ql] >= lim)
				cur -= x[ql], ret -= y[ql], ql ++;
			else
			{
				int t = cur + v - lim;
				double r = y[ql] / x[ql];
				x[ql] -= t, y[ql] -= t * r;
				cur -= t, ret -= t * r;
			}
		cur += v;
		ret += 1LL * v * t;
		printf("%lf\n", ret / cur);
		qr ++, x[qr] = v, y[qr] = 1LL * v * t;
		while (ql < qr && y[qr] * x[qr - 1] < y[qr - 1] * x[qr])
			x[qr - 1] += x[qr], y[qr - 1] += y[qr], qr --;
	}
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long x, ans = 0; cin >> x;
  ans += 2 * (x / 11);
  x %= 11;
  if(x > 0 && x <= 6) ans++;
  else if(x > 0) ans += 2;
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int h, w;
	scanf("%d %d", &h, &w);
	int i, j;
	char a[1003][1003];
	for (i = 0; i < h; i++)
		scanf("%s", a[i]);
	long long int p = 1e9 + 7;
	long long int dp[1003][1003];
	for (i = 0; i <= h; i++)
		for (j = 0; j <= w; j++)
			dp[i][j] = 0;
	dp[1][1] = 1;
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			if (a[i][j] == '.')
				dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i + 1][j] + dp[i][j + 1]) % p;
	printf("%lld\n", dp[h][w]);
	return 0;
}

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

while K:
  if A>=B:
    B*=2
    K-=1
  elif B>=C:
    C*=2
    K-=1
  else:
    break
  
#print(A,B,C)  
if A<B<C:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;


int main(){
    ll h, w, x, y;
    cin>>h>>w>>x>>y;

    if((h*w)%2!=0 && (x+y)%2!=0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

    ll n;
    cin >> n;
    vector<double> x(n);
    double sum = 0.0;
    rep(i,n){
        cin >> x[i];
        sum += x[i];
    }

    sum /= n;
    ll ave = (ll)sum; 
    if(sum - ave >= 0.5) ave++;

    ll ans = 0;
    rep(i,n){
        ans += (x[i] - ave)*(x[i] - ave);
    }

    cout << ans << endl;



    return 0;
}  


Measured memory_bytes: 256
# 写経AC
N,M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
Q = int(input())
VDC = [[int(i) for i in input().split()] for _ in range(Q)]

for i in range(Q):
    VDC[i][0] -= 1

color = [0] * N
# visited[v][d]: 頂点vから距離d以下は塗装済みか
visited = [[False] * 11 for _ in range(N)]

for v,d,c in reversed(VDC):
    if visited[v][d]: # 既に塗装済み
        continue
    if color[v] == 0:
        color[v] = c
    for dist in range(d + 1):
        # 距離d以下は塗装済み
        visited[v][dist] = True
    
    q = [v]
    for t in range(d - 1, -1, -1):
        qq = []
        for v in q:
            for w in edge[v]:
                if visited[w][t]:
                    continue
                for dist in range(t + 1):
                    visited[w][dist] = True
                if color[w] == 0:
                    color[w] = c
                qq.append(w)
        q = qq

print(*color, sep="\n")

Measured memory_bytes: 58444
#include <stdio.h>

int main(void){
  int takoyakis = 0; // たこ焼きの個数
  int delicious_points_list[50]; // おいしさの値を格納する配列
  int sum_heal_points = 0; // 回復量の総和

  // たこ焼きの個数を設定する
  scanf("%d", &takoyakis);

  // たこ焼き達においしさ値を設定する
  for(int i = 0;i < takoyakis; i++) {
    scanf("%d", &delicious_points_list[i]);
  }

  // 各たこ焼き同士の回復量を総当たり方式で計算する
  for(int i = 0; i < takoyakis * takoyakis; i++) {
    int base = i / takoyakis;
    int sec = i % takoyakis;

    // 一度計算した組み合わせ、同じたこ焼きどうしの計算を回避
    if(sec >= base) continue;

    sum_heal_points += delicious_points_list[base] * delicious_points_list[sec];
  }

  // 出力
  printf("%d\n", sum_heal_points);

  return 0;
}


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

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

        public static void Solve()
        {
            var (A, B) = Scanner.Scan<ulong, string>();
            var b = 0UL;
            for (var i = 0; i < B.Length; i++)
            {
                if (B[i] == '.') continue;
                b *= 10;
                b += (ulong)(B[i] - '0');
            }
            Console.WriteLine(A * b / 100);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28308
N=int(input())

G=[[] for i in range(N+1)]

if N%2==0:
    S=N+1
else:
    S=N

cnt=0

for i in range(1,N+1):
    for j in range(i+1,N+1):
        if i+j != S:
            G[i].append(j)
            cnt+=1

print(cnt)
for i in range(1,N+1):
    for j in range(len(G[i])):
        print(i,G[i][j])


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
ll h = 0;
vector<ll> a(0);
void maxHeapify(ll i) {
	ll l = 2 * i + 1, r = 2 * i + 2, largest;
	if (l < h && a[l] > a[i]) largest = l;
	else largest = i;
	if (r < h && a[r] > a[largest]) largest = r;

	if (largest != i) {
		swap(a[i], a[largest]);
		maxHeapify(largest);
	}
}
void pushHeap() {
	ll p = h - 1;
	while (p && a[p] > a[(p - 1) / 2]) {
		swap(a[p], a[(p - 1) / 2]);
		p = (p - 1) / 2;
	}
}
int main() {
	while (1) {
		string s;
		cin >> s;
		if (s == "insert") {
			ll k;
			scanf("%lld", &k);
			h++;
			a.push_back(k);
			pushHeap();
		}
		else if (s == "extract") {
			cout << a[0] << endl;
			a[0] = a[a.size() - 1];
			a.pop_back();
			h--;
			maxHeapify(0);
		}
		else break;
	}
}



Measured memory_bytes: 11376
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// Educational DP/DPまとめコンテスト C-Vacation
// dp[i][j] := i日目にjを行ったときの最大の幸福度
// 2020.5.31

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> a(N, 0), b(N, 0), c(N, 0);
  REP(i, N){
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<int> > dp(N+5, vector<int>(3, 0));
  REP(i, N){
    REP(j, 3){
      if(j == 0){
        chmax(dp[i+1][j], max(dp[i][1], dp[i][2])+a[i]);
      }else if(j == 1){
        chmax(dp[i+1][j], max(dp[i][0], dp[i][2])+b[i]);
      }else{
        chmax(dp[i+1][j], max(dp[i][1], dp[i][0])+c[i]);
      }
    }
  }
  int ans = max({dp[N][0], dp[N][1], dp[N][2]});
  cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int arrow[9] = {0,1,2,0,-1,2,0,1,2};

ll step(string s, ll f){
  // f = 1なら右足をだす
  ll left=0,right=0;
  if(f == 1){
    right = arrow[s[0] - '0' - 1];
    left = arrow[s[1] - '0' - 1];
  }
  else{
    right = arrow[s[1] - '0' - 1];
    left = arrow[s[0] - '0' - 1];
  }
  ll tmp = right;
  if(right<left){
    right = left;
    left = tmp;
    f = (f+1)%2;
  }
  ll res = 0;
  FOR(i,2,s.size()){
    ll foot = arrow[s[i] - '0' - 1];
  //  cout<<"("<<left <<","<< right<<")"<<f<<" "<<foot<<endl;
    if(f == 1){
      if(left <= foot){
        f = 0;
        right = foot;
      }
      else{
        left = foot;
        res++;
      }
    }
    else{
      if(foot <= right){
        f = 1;
        left = foot;
      }
      else{
        right = foot;
        res++;
      }
    }
  }
//  cout<<"answer is "<<res<<endl;
  return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    while(s != "#"){
      if(s.size()<=2){
        cout<<0<<endl;
      }
      else{
        cout<<min(step(s,0), step(s,1))<<endl;
      }
      cin>>s;
    }
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<bool> a(n + 1, false);
    vector<int> penalty(n + 1, 0);
    for (int i = 0; i < m; ++ i) {
        int p;
        cin >> p;
        string v;
        cin >> v;
        if (a[p]) continue;
        if (v == "AC") {
            a[p] = true;
        }
        else {
            penalty[p] ++;
        }
    }
    int cntac = 0, cntwa = 0;
    for (int i = 1; i <= n; ++ i) {
        if (a[i]) {
            cntac ++;
            cntwa += penalty[i];
        }
    }
    cout << cntac << ' ' << cntwa;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N;
double L,s[87000],t[87000],u[87000];

int main(){
	while(cin>>N>>L&&N){
		t[0]=u[N+1]=0,s[N+1]=t[N+1]=86400;
		rep(i,N)cin>>s[i+1]>>t[i+1]>>u[i+1];
		double lo=0,hi=1e6;
		rep(h,50){
			double mi=(lo+hi)/2,l=L,x;
			int ok=1;
			rep(i,2){
				rep2(j,1,N+2){
					l=min(L,l+mi*(s[j]-t[j-1]));
					l=min(L,l+(mi-u[j])*(t[j]-s[j]));
					if(l<=0){ok=0;break;}
				}
				if(!ok)break;
				if(!i)x=l;
				else ok&=l+EPS>x;
			}
			ok?hi=mi:lo=mi;
		}
		printf("%.7f\n",(lo+hi)/2);
	}
}

Measured memory_bytes: 3004
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var cnt, ans int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	H := make([]int, N)
	for i := 0; i < N; i++ {
		H[i], _ = strconv.Atoi(read())
	}
	for i := N - 1; 0 < i; i-- {
		if H[i] < H[i-1] {
			H[i-1]--
		}

		if H[i] < H[i-1] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] < a[j][0]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


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

namespace ABC132C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] d = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
            List<int> d_List = new List<int>();
            d_List = d.ToList();
            d_List.Sort();

            int max = d_List[N / 2];
            int min = d_List[N / 2 - 1];

            int ans = max - min;
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 20320