akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

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

int Q;
int dp[64][64][64];

int dfs(int c, int a, int n){
  if(dp[c][a][n] >= 0) return dp[c][a][n];
  int res = 0;
  if(c > 0 && a > 0 && n > 0) res = max(res, dfs(c-1, a-1, n-1)+1);
  if(c > 1 && a > 0) res = max(res, dfs(c-2, a-1, n)+1);
  if(c > 2) res = max(res, dfs(c-3, a, n)+1);
  return dp[c][a][n] = res;
}

int main(){
  cin >> Q;
  rep(i, Q){
    memset(dp, -1, sizeof(dp));
    int c, a, n;
    cin >> c >> a >> n;
    int res = 0;
    while(c > 10 && a > 5 && n > 0){
      res++;
      c--;
      a--;
      n--;
    }

    while(c > 10 && a > 5){
      res++;
      c-=2;
      a--;
    }

    while(c > 10){
      res++;
      c-=3;
    }
    res += dfs(c, a, n);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long N, std::vector<long long> A){
	auto B = A;
	DESC(B);
	ll max = B[0];
	ll premax = B[1];
	REP(i, N) {
		if (A[i]==max) cout << premax << "\n";
		else cout << max << "\n";
	}
}

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


Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

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

  int cost = 0;
  for (int i = 1; i < N; i++) {
    if (s[i] == 'E') {
      cost++;
    }
  }

  int m = cost;
  for (int i = 1; i < N; i++) {
    if (s[i] == 'E') {
      cost--;
    }
    if (s[i-1] == 'W') {
      cost++;
    }
    m = min(m, cost);
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 900
# coding: utf-8
import sys


def main(argv=sys.argv):
  n, a, b = map(int, input().split())
 
  total = 0
  
  for i in range(1, n + 1):
    sum = 0
    for j in range(len(str(i))):
      i = str(i)
      sum += int(i[j])
      
    if sum >= a and sum <= b:
      total += int(i)
  
  print(total)
      
  return 0


if __name__ == '__main__':
  sys.exit(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	for(int n_rou,n,n_ev;scanf("%d%d%d",&n_rou,&n,&n_ev),n;){
		int rou[4];
		rep(i,n_rou) scanf("%d",rou+i);

		int type[51]={},val[51];
		rep(i,n_ev){
			int a,b,c; scanf("%d%d%d",&a,&b,&c);
			type[a]=b;
			val[a]=c;
		}

		double dp[51][5001]={};
		dp[0][0]=1;
		rep(x,n) rep(a,5001) {
			rep(i,n_rou){
				int x2=min(x+rou[i],n),a2=a;
				if     (type[x2]==1) x2=min(x2+val[x2],n);
				else if(type[x2]==2) a2+=val[x2];
				else if(type[x2]==3) a2=max(a2-val[x2],0);
				dp[x2][a2]+=1.0/n_rou*dp[x][a];
			}
		}

		double ex=0;
		rep(a,5001) ex+=a*dp[n][a];
		printf("%d\n",(int)(ex+1e-9));
	}

	return 0;
}

Measured memory_bytes: 2756
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn sorted_str(s : String) -> String {
    let mut v = s.into_bytes();
    v.sort();
    return String::from_utf8(v).unwrap();
}

fn rev_sorted_str(s : String) -> String {
    let mut v = s.into_bytes();
    v.sort_by(|x, y| y.cmp(x));
    return String::from_utf8(v).unwrap();
}


fn main() {
    let s = read_line();
    let t = read_line();
    let s2 = sorted_str(s);
    let t2 = rev_sorted_str(t);
    if s2 < t2 {
        println!("Yes");
    }
    else{
        println!("No");
    }
}


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

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

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int T[] = {0, 3, 2, 1};
const int INF = 1 << 28;

int w, h;
int s[30][30];
int c[4];

int dist[30][30][4];

struct State {
	int x, y, dir, sum;
	bool operator < (const State &rhs) const {
		return sum > rhs.sum;
	}
};

int solve()
{
	fill_n(**dist, 30 * 30 * 4, INF);
	
	priority_queue<State> pq;
	
	dist[0][0][3] = 0;
	pq.push({0, 0, 3, 0});
	
	while (pq.size()){
		State cur = pq.top(); pq.pop();
		if (dist[cur.x][cur.y][cur.dir] < cur.sum) continue;
		if (cur.x == h - 1 && cur.y == w - 1) return cur.sum;
		
		for (int i = 0; i < 4; i++){
			int ndir = (cur.dir + T[i]) % 4;
			int nx = cur.x + dx[ndir];
			int ny = cur.y + dy[ndir];
			int nsum = cur.sum + (i != s[cur.x][cur.y] ? c[i] : 0);
			if (nx < 0 || h <= nx) continue;
			if (ny < 0 || w <= ny) continue;
			if (dist[nx][ny][ndir] <= nsum) continue;
			dist[nx][ny][ndir] = nsum;
			pq.push({nx, ny, ndir, nsum});
		}
	}
}

int main()
{
	while (scanf("%d %d", &w, &h), w){
		rep(i, h) rep(j, w) scanf("%d", &s[i][j]);
		rep(i, 4) scanf("%d", c + i);
		printf("%d\n", solve());
	}
}

Measured memory_bytes: 1324
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    ans = 0
    integer = 1
    for j in range(n):
        if a_list[j] == integer:
            integer += 1
        else:
            ans += 1
    if integer == 1:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24744
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;

Node treeMinimum(Node x){
while(x->left!=NIL){
x=x->left;
}
return x;
}

Node treeSearch(Node u, int k){
Node x;  
if(u==NIL || k==x->key){
return x;
}
if(k<x->key){
return treeSearch(x->left,k);
}
 else{
return treeSearch(x->right,k);
}

}

Node treeSuccessor(Node x){
Node y;  
if(x->right!=NIL){
return treeMinimum(x->right);
}
y=x->parent;
while(y!=NIL && x==y->right){
x=y;
y=y->parent;
}
return y;
}

void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
if(z->left==NIL || z->right==NIL){
y=z;
}
 else{
y=treeSuccessor(z);
}
if(y->left!=NIL){
x=y->left;
}
 else{
x=y->right;
}
if(x!=NIL){
x->parent=y->parent;
}
if(y->parent==NIL){
root=x;
}
 else if(y==y->parent->left){
y->parent->left=x;
}
 else{
y->parent->right=x;
}
if(y!=z){
z->key=y->key;
}


}

void insert(int k){
Node y = NIL;
Node x = root;
Node z;

z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x!=NIL){
y=x;
if(z->key < x->key){
x=x->left;
}
 else{
x=x->right;
}
z->parent=y;
}
if(y==NIL){
root=z;
}
 else if(z->key < y->key){
y->left=z;
}
 else{
y->right=z;
}
}

void inorder(Node u){
if(u!=NIL){
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
}
void preorder(Node u){
if(u!=NIL){
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
}


int main(){
int n, i, x;
char com[20];
scanf("%d", &n);

for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
 else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);

}
}

return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<long long> dp(n+1,0),po(n+1,1);
	dp[0] = 1;
	dp[1] = 2;
	int ans = 0;
	for (int i = 1;i < n;i++) {
		if (s[i] == '0')
			dp[i+1] = dp[i];
		else {
			dp[i+1] = dp[i] * 2 % 1000000007;
		}
	}
	ans = dp[n];
	for (int i = 0;i < n;i++) {
		if (i)
			po[i] = (po[i - 1] * 3) % 1000000007;
		if (s[n-i-1] == '1')
			ans = (ans + po[i] * dp[n-i-1]) % 1000000007;
	}
	cout << ans << endl;
	/*for (int i = 0;i < n+1;i++) {
		cout << dp[i] << ' ' << po[i] << endl;
	}*/
}


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

int main() {
  int K;
  std::string S,str;
  cin >> K >> S;
  if(S.length() <= K){
  	cout << S << endl;
  }else{
  	str = S.substr(0,K)+ "...";
   	cout << str << endl;
  }
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> NN = new ArrayList<Integer>();
		ArrayList<Integer> XX = new ArrayList<Integer>();
		int n=1;
		int x=1;
		int kumi =0;
		while(n != 0 || x!= 0){
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		}
//		System.out.println("finir");
		for (int i=0;i<NN.size()-1;i++){
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		}
	}
}

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

int main() {
  int s;
  vector<bool> checked(1000010, false);
  cin >> s;
  int now = s;
  int ans=1;
  while (!checked[now]) {
		checked[now]=true;
    now = ((now % 2) ? 3 * now + 1 : now / 2);
		ans++;
  }
	cout<<ans<<endl;
}


Measured memory_bytes: 384
x = int(input())
if 1800 <= x and x <= 1999:
    print(1)
elif 1600 <= x and x <= 1799:
    print(2)
elif 1400 <= x and x <= 1599:
    print(3)
elif 1200 <= x and x <= 1399:
    print(4)
elif 1000 <= x and x <= 1199:
    print(5)
elif 800 <= x and x <= 999:
    print(6)
elif 600 <= x and x <= 799:
    print(7)
else:
    print(8)


Measured memory_bytes: 9176
#include <stdio.h>
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    int ans = 1;
    int i;
    for(i = 0; i < n; i++){
        ans += (ans + k > 2 * ans)? ans : k;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#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 a, b, c;
    cin >> a >> b >> c;

    int res = 0;

    if (c <= a + b)
    {
        res += c;
    }
    else
    {
        res += a + b + 1;
    }

    res += b;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            var K = int.Parse(Console.ReadLine());
            var DP = new long[N.Length + 1, K + 2, 2];
            DP[0, 0, 1] = 1;
            for (int digit = 1; digit < N.Length + 1; digit++)
            {
                var d = int.Parse(N[digit - 1].ToString());
                for (int countNot0 = 0; countNot0 < K + 1; countNot0++)
                {
                    if (d == 0)
                    {
                        DP[digit, countNot0, 1] += DP[digit - 1, countNot0, 1];
                    }
                    else
                    {
                        DP[digit, countNot0 + 1, 1] += DP[digit - 1, countNot0, 1];
                        DP[digit, countNot0, 0] += DP[digit - 1, countNot0, 1];
                        DP[digit, countNot0 + 1, 0] += DP[digit - 1, countNot0, 1] * (d - 1);
                    }
                    DP[digit, countNot0 + 1, 0] += DP[digit - 1, countNot0, 0] * 9;
                    DP[digit, countNot0, 0] += DP[digit - 1, countNot0, 0];
                }
            }
            Console.WriteLine(DP[N.Length, K, 1] + DP[N.Length, K, 0]);
        }
    }
}


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

int n;
vector<vector<int>> a(20, vector<int>(20, -1));

int main()
{
    cin >> n;
    rep(i, n)
    {
        int b;
        cin >> b;
        rep(j, b)
        {
            int x, y;
            cin >> x >> y;
            x--;
            a[i][x] = y;
        }
    }

    int res = 0;
    for(int S = 0; S < (1 << n); S++)
    {
        bool flag = true;
        rep(i, n)
        {
            if(((S >> i) & 1) == 0) continue;
            rep(j, n)
            {
                if(a[i][j] != -1 && a[i][j] != ((S >> j) & 1))
                {
                    flag = false;
                    break;
                }
            }
            if(!flag) break;
        }
        if(!flag) continue;
        res = max(res, __builtin_popcount(S));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N, K; cin >> N >> K;
    ll cz = 0;
    vector<ll> P, M; 
    for(int i = 0; i < N; i++) {
        ll x; cin >> x;
        if(x >= 0) { 
            if(x == 0) cz++;
            P.push_back(x);
        }
        else M.push_back(abs(x));
    }
    ll ans = 1;
    sort(P.rbegin(), P.rend());
    sort(M.rbegin(), M.rend());
    ll cnt = 0, idp = 0, idm = 0;
    if((P.size() > 0 && N == K && M.size() % 2 == 0) || 
       (P.size() > 0 && N > K) || 
       (P.size() == 0 && K % 2 == 0)){
        if(K % 2 == 1){
            ans *= P[idp];
            ans %= MOD;
            idp++;
            cnt++;
        }
        while(cnt != K){
            ll p = -1, m = -1;
            if(idp+1 < P.size()) p = P[idp]*P[idp+1];
            if(idm+1 < M.size()) m = M[idm]*M[idm+1];
            if(p < m){
                ans *= M[idm];
                ans %= MOD;
                ans *= M[idm+1];
                ans %= MOD;
                idm+=2;
            }
            else {
                ans *= P[idp];
                ans %= MOD;
                ans *= P[idp+1];
                ans %= MOD;
                idp+=2;
            }
            cnt+=2;
        }
        cout << ans << endl;
    }
    else {
        vector<ll> V = P;
        for(auto x : M) V.push_back(x);
        sort(V.begin(), V.end());
        for(; cnt < K; cnt++){
            ans *= V[cnt];
            ans %= MOD;
        }
        ans *= -1;
        ans += MOD;
        ans %= MOD;
        if(cz) cout << 0 << endl;
        else cout << ans << endl;
    }


} 

Measured memory_bytes: 8008
#include<bits/stdc++.h>
int main(){
    int n;std::cin>>n;
    std::vector<long long>a(n+2);
    for(int i=0;i<n;i++){
        std::cin>>a.at(1+i);
    }
    std::vector<int>ord(n);
    std::iota(ord.begin(),ord.end(),1);
    std::sort(ord.begin(),ord.end(),[&a](int x,int y){return a.at(x)>a.at(y);});

    std::multiset<int>set;
    set.insert(0);
    set.insert(0);
    set.insert(n+1);
    set.insert(n+1);
    long long ans=0;
    for(int i:ord){
        auto it=set.insert(i);
        auto l1=std::prev(it);
        auto l0=std::prev(l1);
        auto r0=std::next(it);
        auto r1=std::next(r0);
        ans+=a.at(i)*((*l1-*l0)*(*r0-i)+(i-*l1)*(*r1-*r0));
    }
    std::cout<<ans<<std::endl;
}



Measured memory_bytes: 6144
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val xs: MutableList<Pair<Int, Int>> = mutableListOf()
    for (i in 1..m) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        xs.add(Pair(a, b))
    }

    xs.sortBy { it.second }

    var count = 0
    var prev = 0
    if (xs.isNotEmpty()) {
        count = 1
        prev = xs[0].second - 1
    }

    for (i in 1 until xs.size) {
        val pair = xs[i]
        if (pair.first <= prev) {
            continue
        }

        count++
        prev = pair.second - 1
    }

    println(count)
}

Measured memory_bytes: 81628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main(){
  cin >> s;
  if(s.size()%2==1){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0 ; i<s.size() ; i++){
    if(i%2 == 0){
      if(s[i]!='h'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i]!='i'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def selection_sort(A):
    swap = 0
    for i in range(len(A)):
        minj = i
        for j in range(i,len(A)):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i],A[minj] = A[minj],A[i]
            swap += 1
    return swap

if __name__=='__main__':
   N=int(input()) 
   A=list(map(int,input().split()))
   swap = selection_sort(A)
   print(*A)
   print(swap)

Measured memory_bytes: 7732
#include<stdio.h>
#include<string.h>

int main(void){
	char data[100];
	char s1[]="the",
		 s2[]="this",
		 s3[]="that";
	int i,cnt=0;
	char *p;

	while((fgets(data,100,stdin))){
		while(cnt<26){
			p=strstr(data,s1);
			if(p)
				break;
			p=strstr(data,s2);
			if(p)
				break;
			p=strstr(data,s3);
			if(p)
				break;
			for(i=0;i<100;i++){
				if(data[i]=='\0')
					break;
				if('a'<=data[i] && data[i]<='y')
					data[i]++;
				else if('z'==data[i])
					data[i]='a';
			}
			cnt++;
		}
		cnt=0;
		printf("%s",data);
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
s = list(input())
character = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(len(s)):
  for j in range(len(character)):
    if s[i]==character[j]:
      num = (j+n)%len(character)
      s[i] = character[num]
      break
print("".join(s))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define foreach(i,c) for(__typeof(c.begin())i=c.begin();i!=(c).end();i++)
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
using namespace std;
string s;
int check(int x,int y){
	string s1="",t1="";
	for(int i=0;i<x;i++)s1+=s[i];
	for(int j=x;j<x+y;j++)t1+=s[j];
	int cnt=2;
	for(int i=x+y-1;i<s.size();i++){
		if(i==s.size()-1){
			if(s1==t1){
				cnt--;
			}
			break;
		}
		if(s1==t1){
			t1+=s[i+1];
		}
		else{
			s1=t1;
			t1="";
			t1+=s[i+1];
			cnt++;
		}
	}
	return cnt;
}
int main(){
	cin>>s;
	int mx=0;
	mx=max(mx,check(1,1));
	mx=max(mx,check(1,2));
	mx=max(mx,check(2,1));
	mx=max(mx,check(2,2));
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#define INIT_CAP 10
#define INF 1000000000

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[10000];
PNumDis heap[10000];
int hsize;
int d[10000], idx[10000];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx) {
		heap[i] = heap[nextIdx];
		idx[heap[i].num] = i;
	}
	heap[i] = last;
	idx[last.num] = i;

	return root;
}

inline void decreaseKey(int num, int d) {
	int i;

	for (i = idx[num]; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1) {
		heap[i] = heap[i - 1 >> 1];
		idx[heap[i].num] = i;
	}
	heap[i] = (PNumDis){num, d};
	idx[num] = i;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++) {
		heap[i] = (PNumDis){i, INF};
		d[i] = INF;
		idx[i] = i;
	}
	hsize = n;

	d[s] = 0;
	decreaseKey(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();
		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				decreaseKey(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i;
	int n;

	scanf("%d", &n);

	init(n);
	for (i = 0; i < n; i++) {
		int u, k;
		scanf("%d %d", &u, &k);
		while (k--) {
			int v, c;
			scanf("%d %d", &v, &c);
			add(u, v, c);
		}
	}

	dijkstra(n, 0);

	for (i = 0; i < n; i++)
		printf("%d %d\n", i, d[i]);

	return 0;
}

Measured memory_bytes: 5664
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int> > 
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define ll long long 
#define sz(a) int(a.size())
#define forn(i,n) for(int i = 0 ; i < int(n) ; i++)
#define all(x) x.begin(),x.end()
#define vpl vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define len(s) s.length()
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
#define modulo 998244353ll
#define mod 1000000007ll
#define MAXN  1000001 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}




void solve()
{
    vi a(3,0);
    forn(i,3)
    cin>>a[i];
    sort(all(a));
    cout<<a[0]+a[1]<<endl;
}


int main()
{
    fast();
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3612
SIZE=4*10**5+1; MOD=10**9+7 #998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

def chofuku(ball,box): # nHk mod MOD の計算
    return choose(box+ball-1,box)

# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())

n,k = [int(i) for i in read().split()]


#print(choose(2*n-1,n))

ans = 0
M = min(k,n)

for j in range(M+1):
    ans += choose(n,j)*choose(n-1,j)%MOD

print(ans%MOD)

















Measured memory_bytes: 52564
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  ll x,y; cin >> x >> y;
  if(abs(x-y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;

  return 0;
}

Measured memory_bytes: 384
n, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf")] * (n + 110)
dp[0] = 0
for i in range(n):
    for k in range(1, 1 + K):
        if i + k < n:
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]))
print(dp[n - 1])

Measured memory_bytes: 55264
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 1e6 + 5;
const int oo = 1e9 + 5;
const LL ooll = 1e18 + 5;
 
// clock_t start = clock();

string s;
int suf[N];
void solve() {
	int n;
	cin >> n;
	cin >> s;
	suf[n] = 0;
	for (int i=n-1;i>=0;--i) {
		suf[i] = suf[i+1] + (s[i] == 'R');
	}
	int ans = suf[0], cur = 0;
	for (int i=0;i<n;++i) {
		if (s[i] == 'W') ++cur;
		ans = min(ans, max(suf[i+1], cur));
	}
	cout << ans << '\n';
}
 
int main() {
	FASTIO;
	int T = 1;
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
	return 0;
} 

Measured memory_bytes: 4544
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-03 17:35:02
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
#define y1 gfvtydvtd
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    w,h,n = LI()
    board = [[1]*h for _ in range(w)]

    for _ in range(n):
        x,y,a = LI()
        if a == 1:
            for i in range(x):
                board[i] = [0 for _ in range(h)]
        elif a == 2:
            for i in range(x,w):
                board[i] = [0 for _ in range(h)]
        elif a == 3:
            for i in range(w):
                for j in range(y):
                    board[i][j] = 0
        elif a == 4:
            for i in range(w):
                for j in range(y,h):
                    board[i][j] = 0

    ans = 0
    for line in board:
        ans += sum(line)

    print(ans)

    # print(*board,sep="\n")
main()            


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

int x[111];
uint ans=1e9, ans2=0;
int main(){
    int n;
    std::cin >> n;
    for (int i=0;i<n;i++)
        std::cin >> x[i];
    for(int p=1;p<=100;p++){
        ans2=0;
        for(int i=0;i<n;i++){
            int y=abs(x[i]-p);
            y=y*y;
            ans2+=y;
        }
        ans=std::min(ans,ans2);
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] l = new int[n];
			IntStream.range(0, n).forEach(i -> l[i] = scanner.nextInt());
			int count = 0;
			for (int i = 0; i < n - 2; i++) {
				for (int j = i + 1; j < n - 1; j++) {
					if (l[i] != l[j]) {
						for (int k = j + 1; k < n; k++) {
							if ((l[k] != l[i]) && (l[k] != l[j])) {
								if ((l[i] < (l[j] + l[k])) && (l[j] < (l[i] + l[k])) && (l[k] < (l[i] + l[j]))) {
									count++;
								}
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 36996
// mod 組み合わせ計算　縦列も
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

// 自動でmodを取ってくれる整数型
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// nが大きすぎると遅い 10^7くらいまで
// Cを何回も計算する場合に有利
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) { // コロン以下は初期化子リスト
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv(); // fact[i]の逆元
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    int k;
    string s;
    cin>>k>>s;
    int n=s.size();
    mint ans=0;
    combination c(n+k);
    rep(i,k+1){
        mint now=mint(26).pow(k-i);
        now*=mint(25).pow(i);
        now*=c(((n-1)+i),n-1); // ((n-1)+i)C(n-1)
        ans+=now;
    }
    cout<<ans.x<<endl;
}

Measured memory_bytes: 35580
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;



struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int main() {
	int N;cin>>N;
	int ans=0;
	vector<int>v{ 0 };
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		while (!v.empty()) {
			int num=v.back();
			if (num>a) {
				v.pop_back();
			}
			else if (num==a) {
				break;
			}
			else {
				v.push_back(a);
				ans++;
			}
		}
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 3812
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] list = new long[n];

        for (int i = 0; i < n; i++) {
            list[i] = sc.nextLong();
        }

        Arrays.sort(list);

        long sum = 0;

        for (int i = n - 1 - k; i >= 0; i--) {
            sum += list[i];
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 93524
import copy

class Solver:
    def __init__(self, _s):
        self.prefix = _s[0:2]
        self.suffix = _s[2:4]

        self.solve()
    
    def solve(self):
        isPrefixYY = False
        isPrefixMM = False
        isSuffixYY = False
        isSuffixMM = False

        intPrefix = int(self.prefix)
        intSuffix = int(self.suffix)

        if intPrefix >= 1 and intPrefix <= 12:
            isPrefixMM = True
        if intSuffix >= 1 and intSuffix <= 12:
            isSuffixMM = True
        if intPrefix >= 0 and intPrefix <= 99:
            isPrefixYY = True
        if intSuffix >= 0 and intSuffix <= 99:
            isSuffixYY = True

        if isPrefixMM == True and isPrefixYY == True and isSuffixMM == True and isSuffixYY == True:
            print("AMBIGUOUS")
        elif isPrefixMM == True and isSuffixYY == True:
            print("MMYY")
        elif isPrefixYY == True and isSuffixMM == True:
            print("YYMM")
        else:
            print("NA")

def main():
    s=input()
    Solver(s)



if __name__ == "__main__":
    main()

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

const int N = 110;
typedef long long ll;

char s[N];

int main(){
    int k;
    scanf("%s%d", s, &k);
    int n = strlen(s);
    bool flag = true;
    for (int i = 1; i < n; ++ i){
        if (s[i] != s[0]){
            flag = false;
            break;
        }
    }
    if (flag){
        printf("%lld\n", 1ll * n * k / 2);
        return 0;
    }
    int begin = 0, end = 0;
    for (int i = 0; i < n; ++ i){
        if (s[i] != s[0]){
            begin = i;
            break;
        }
    }
    for (int i = n - 1; i >= 0; -- i){
        if (s[i] != s[n - 1]){
            end = i;
            break;
        }
    }
    ll ans = 0;
    int pre = begin - 1;
    for (int i = begin; i <= end; ++ i){
        if (i == end || s[i] != s[i + 1]){
            int x = i - pre;
            pre = i;
            ans += 1ll * (x / 2) * k;
        }
    }
    int lenbegin = begin - 0, lenend = n - 1 - end;
    if (s[0] == s[n - 1]){
        ans += 1ll * (k - 1) * ((lenbegin + lenend) / 2) + lenbegin / 2 + lenend / 2;
    }
    else{
        ans += 1ll * k * (lenbegin / 2 + lenend / 2);
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main(void) {
long long K, A, B;
cin >> K >> A >> B;
long long num = (K - A + 1) / 2;
long long inc = B - A - 2;
long long ans;
if (inc < 0) ans = K + 1;
else ans = K + 1+ num * inc;

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll minCost(vector<ll> heights)
{
    if(heights.size()==0)
        return 0;
    else if(heights.size()==1)
        return abs(heights[0]-heights[1]);
    vector<ll> dp(heights.size(),0);
    dp[0]=0;
    dp[1] = abs(heights[1]-heights[0]);
    for(ll i=2;i<heights.size();i++)
        dp[i]=min(dp[i-1]+abs(heights[i]-heights[i-1]),dp[i-2]+abs(heights[i]-heights[i-2]));
    
    return dp[heights.size()-1];
}
int main()
{
    ll n,temp;
    cin>>n;
    vector<ll> inpArr;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        inpArr.push_back(temp);
    }
    cout<<minCost(inpArr)<<endl;
    return 0;
}

Measured memory_bytes: 2676
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <array>
#include <memory>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf(" %d", list[i]);
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
    // CompleteBinaryTree
    int n;
    scanf("%d", &n);
    vector<int> tree(n+1);
    for(int i = 1; i <= n; i++){
        int v;
        scanf("%d", &v);
        tree[i] = v;
    }
    for(int i = 1; i <= n; i++){
        printf("node %d: ", i);
        printf("key = %d, ", tree[i]);
        if (1 != i) printf("parent key = %d, ", tree[i/2]);
        if (i * 2 <= n) printf("left key = %d, ", tree[i*2]);
        if (i * 2 + 1 <= n) printf("right key = %d, ", tree[i*2+1]);
        printf("\n");
    }
        
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    solve();
    return 0;
}


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

int main() {
	int a,b,c,tmp;
	cin >> a >> b >> c;
	
	if(a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	cout << a << " " << b << " " << c << endl;
	return 0;
}


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

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

	int t;
	cin>>t;
	map<string, int> v;
	while(t--){
		string s;
		cin>>s;
		v[s] +=1;
	}
	// sort(v.rbegin(),v.rend());
	int max_=INT_MIN
	;
	
	for(auto x: v){
		if(x.second > max_)
			max_ = x.second;
	}
	for(auto x: v){
		if(x.second == max_)
			cout<<x.first<<"\n";
	}

	return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <algorithm>
#include <cmath>

#define MAX 55

using namespace std;


int main(void){

  int n,y,b,r,t;

  while(cin >> n && n != 0){
    double bank[MAX];

    for(int i = 0;i < MAX;i++)
      bank[i] = -1; 

    cin >> y;
    
    for(int i = 0;i < n;i++){
      cin >> b >> r >> t;
      if(t == 1)
	bank[b] = 1 + y * ((double)r / 100);
      if(t == 2)
	bank[b] = pow((double)( 1 + ((double)r / 100) ), (double)y); 
    }

    double max = 0;
    int ans;
    for(int i = 0;i < MAX;i++){
      //cout << i << " "<< bank[i] << endl;
      if(max < bank[i]){
	max = bank[i];
	ans = i;
      }
    }

    cout << ans << endl;
  }

  return 0;
}

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

int main(){
    int K,tmp;
    cin >> K;
    
    if (K%2==0){
        cout << (K/2)*(K/2) << endl;
    }
    else{
        K-=1;
        cout << (K/2+1)*(K/2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
var
  a:array[1..1000,1..1000]of longint;
  n,k,i,m,j,t,ans,b,c,d:longint;
  p,q,o,x,y:real;
  s:string;
function max(a,b:longint):longint;
begin
  if a>b then max:=b
  else max:=a;
end;
begin
  readln(c,n,m);
  for i:=1 to c do
  begin
    readln(a[i,1],a[i,2]);
    ans:=ans+max(a[i,1] div n,a[i,2] div m);
  end;
  writeln(ans);
end.

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

int main(){
  string s;

  cin >> s;

  if(s[1]==s[2]){
    if(s[0]==s[1]||s[2]==s[3]){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long

using namespace std;

signed main() {
    vector<int> As;
    for(auto i = 0; i< 9; i++){
        int t;
        cin >> t;
        As.push_back(t);
    }
    int N;
    cin >> N;
    for(auto i = 0LL; i < N; i++){
        int b;
        cin >> b;
        for(auto j = As.begin(); j != As.end(); j++){
            if(*j == b){
                *j = -1;
            }
        }
    }
    if(As[0] == -1 && As[1] == -1 && As[2] == -1){
        cout << "Yes" << endl;
    }else if(As[3] == -1 && As[4] == -1 && As[5] == -1){
        cout << "Yes" << endl;
    }else if(As[6] == -1 && As[7] == -1 && As[8] == -1){
        cout << "Yes" << endl;
    }else if(As[0] == -1 && As[3] == -1 && As[6] == -1){
        cout << "Yes" << endl;
    }else if(As[1] == -1 && As[4] == -1 && As[7] == -1){
        cout << "Yes" << endl;
    }else if(As[2] == -1 && As[5] == -1 && As[8] == -1){
        cout << "Yes" << endl;
    }else if(As[0] == -1 && As[4] == -1 && As[8] == -1){
        cout << "Yes" << endl;
    }else if(As[2] == -1 && As[4] == -1 && As[6] == -1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int p[30]={0};
    int n=0;
    int count=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d", &p[i]);
    }
    for(int j=0;j<n-2;j++){
        if(p[j+1]>p[j]&&p[j+1]<p[j+2]){
            count++;
        }
        else if(p[j+1]<p[j]&&p[j+1]>p[j+2]){
            count++;
        }
    }
    
    printf("%d\n",count);
    return 0;
}

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

namespace atcoder01
{
    class Program
    {
        static void Main(string[] args)
        {
            int outO = 0;

            int[] inArr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int W = inArr[0];
            int H = inArr[1];
            int N = inArr[2];

            int[] arrX = new int[N];
            int[] arrY = new int[N];
            int[] arrA = new int[N];

            int x1 = 0;
            int x2 = W;
            int y1 = 0;
            int y2 = H;

            for (int i = 0; i < N; i++)
            {
                int[] inArr1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (inArr1[2] == 1) x1 = (x1 > inArr1[0]) ? x1 : inArr1[0];
                if (inArr1[2] == 2) x2 = (x2 < inArr1[0]) ? x2 : inArr1[0];
                if (inArr1[2] == 3) y1 = (y1 > inArr1[1]) ? y1 : inArr1[1];
                if (inArr1[2] == 4) y2 = (y2 < inArr1[1]) ? y2 : inArr1[1];
            }

            if (x2 > x1 && y2 > y1) outO = (x2 - x1) * (y2 - y1);

            Console.WriteLine(outO);
        }
    }
}

Measured memory_bytes: 13396
a, b, c = map(int, input().split())
if a == b == c and a%2==0:
  print("-1")
else:
  ans = 0
  while True:
    if a%2 or b%2 or c%2:
      print(ans)
      break
    at, bt, ct = a, b, c
    a = bt//2 + ct//2
    b = ct//2 + at//2
    c = at//2 + bt//2
    ans += 1

Measured memory_bytes: 3064