akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
import java.util.TreeMap;
//import org.apache.commons.lang3.StringUtils;
 
 
/**
 *
 * @author aj
 */
public class Main {
    
    public static void main(String[] args){
        try {
            //Scanner sc = new Scanner(System.in);
            BufferedInputStream bf = new BufferedInputStream(System.in);
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(bf, StandardCharsets.UTF_8));
            OutputStream out = new BufferedOutputStream ( System.out );
            String[] nmc = in.readLine().split(" ");
            int n = Integer.parseInt(nmc[0]);
            int m = Integer.parseInt(nmc[1]);
            int c = Integer.parseInt(nmc[2]);
            
            String[] sb = in.readLine().split(" ");
            int r = 0;
            for(int i=0;i<n;i++){
                int s = c;
                String[] sa = in.readLine().split(" ");
                for(int j=0;j<m;j++){
                    s += Integer.parseInt(sa[j]) * Integer.parseInt(sb[j]);
                }
                if (s>0) r++;
            }
            out.write((r+"\n").getBytes());
            out.flush();
        }catch(Exception ex){
            ex.printStackTrace();
        }
        
    }
    
    
    
}

Measured memory_bytes: 21972
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

// fn c_to_i(c:char) -> i32 {
//     c as i32 - 48
// }

fn s_to_i(s:&str) -> i32 {
    s.parse().unwrap()
}

fn main() {
    // loop {
    //     let v:Vec<char> = read_vec();
    //     match v[1] {
    //         '+' => { println!("{}", c_to_i(v[0]) + c_to_i(v[2]) ) }
    //         '-' => { println!("{}", c_to_i(v[0]) - c_to_i(v[2]) ) }
    //         '*' => { println!("{}", c_to_i(v[0]) * c_to_i(v[2]) ) }
    //         '/' => { println!("{}", c_to_i(v[0]) / c_to_i(v[2]) ) }
    //         '?' => break,
    //         _ => println!("match error")
    //     }
    // }
    loop {
        let v:Vec<String> = read_vec();
        // println!("{}", v[1]);
        let op: &str = &v[1];

        match op {
            "+" => { println!("{}", s_to_i(&v[0]) + s_to_i(&v[2]) ) }
            "-" => { println!("{}", s_to_i(&v[0]) - s_to_i(&v[2]) ) }
            "*" => { println!("{}", s_to_i(&v[0]) * s_to_i(&v[2]) ) }
            "/" => { println!("{}", s_to_i(&v[0]) / s_to_i(&v[2]) ) }
            "?" => break,
            _ => println!("match error")            
        }
    }
}


Measured memory_bytes: 5032
#include <iostream>
#include <algorithm>

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

    int a, b, c;
    std::cin >> a >> b >> c;
    int cnt = 0;
    for(int i=a; i<=b; ++i){
        if(c%i==0) ++cnt;
    }
    std::cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{ long long a,b,k;
 cin>>a>>b>>k;
 if(a>=1)
 {
   if(a<=k)
   {
     
     if(b>=(k-a))
     b=b-(k-a);
     else
       b=0;
     a=0;
   }
  else
    a=a-k;
 }
 else
 if(b>=k)
   b=b-k;
 else
   b=0;
 cout<<a<<" "<<b;
}



Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main()
{
    int n;
    int s[] = { 0,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 };
    cin>>n;
    cout << n[s];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(RALL(a));
    if (n == 1) {
        cout << (a[0] % 2 ? "first" : "second") << endl;
    } else {
        bool f = false;
        REPF(i, 1, n) {
            f |= a[i] % 2;
        }
        cout << (f ? "first" : "second") << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 1024
#include <stdio.h>

main(){
  
  int A[100],N,i,j,v;
  
  scanf("%d",&N);
  for(i=0 ; i<N ; i++){
    scanf("%d",&A[i]);
    printf("%d",A[i]);
      if(i<N-1)printf(" ");
  }

    printf("\n");

  for( i=1 ; i<N ; i++){
    v=A[i];
    j=i-1;
    while( j>=0 && A[j]>v){   
      A[j+1] = A[j];
      j--;
    }

    A[j+1] = v;

    for( v=0 ; v<N ; v++){
      printf("%d",A[v]);
      if(v<N-1)printf(" ");
    }
          printf("\n");

  } 
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int n;
    cin >> n;
    string ans = "";
    while(n != 0 ) {
        if ( n % 2 != 0 ) {
            n--;
            ans = "1" + ans;
        }
        else ans = "0" + ans;
        n /= -2;
    }
    if ( ans == "" ) cout << "0" << endl;
    else             cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

t = []
k = 0
r = 10
for i in range(5):
    v = int(input())
    tmp = v % 10
    if tmp != 0 and tmp < r:
        r = tmp
        k = i
    t.append(v)

tt = 0
for i in range(5):
    if i == k or t[i] % 10 == 0:
        tt = tt+t[i]
    else:
        tt = tt + 10 * math.ceil(t[i]/10)

print(tt)


Measured memory_bytes: 3064
integer :: piyo(3),i,p(2)
read*,piyo(1),piyo(2),piyo(3)

p = 0
do i = 1,3
  if(piyo(i)==5) p(1) = p(1) + 1
  if(piyo(i)==7) p(2) = p(2) + 1
end do

if( p(1)==2.and.p(2)==1 )then
  print*,'YES'
else
  print*,'NO'
end if
end

Measured memory_bytes: 256
a[99]={1,4,12,38};main(i,n,m){scanf("%d%d",&n,&m);
	if(m==1)for(;i<101;i++)a[i]=2*a[i-1]%1000000;
	else for(i=4;i<101;i++)a[i]=(4*a[i-1]-3*a[i-2]+2*a[i-3]+a[i-4]+3000000)%1000000;
	printf("%d\n",a[n]);exit(0);
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
    long long X;
    cin >> X;

    long long ans = 1;
    for (int i = 1; i < X; ++i) {
        for (int j = 2; j < X; ++j) {
            long long beki = pow(i, j);
            if (beki <= X) {
                ans = max(ans, beki);
            }
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    double a,b,C;
    double S,L,h;
    double PI = acos(-1);
    scanf("%lf %lf %lf",&a,&b,&C);
    S = a*b*sin(C*PI/180)*0.5;
    L = a+b +sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(C*PI/180));
    h = b*sin(C*PI/180);
    printf("%lf\n",S);
    printf("%lf\n",L);
    printf("%lf\n",h);
    return 0;
}



Measured memory_bytes: 3032
using System;
using System.Linq;

namespace _0045
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0;
            int a = 0;
            int b = 0;
            while (true)
            {
                string s = Console.ReadLine();
                if (s == null)
                {
                    break;
                }
                int[] x = s.Split(',').Select(int.Parse).ToArray();
                a += x[0] * x[1];
                b += x[1];
                n++;
            }
            Console.WriteLine(a);
            if (b % n != 0)
            {
                Console.WriteLine(b / n + 1);
            }
            else
            {
                Console.WriteLine(b / n);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9612
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
 
 
void solve()
{
    int n;cin>>n;
 
    int a[3][n];
 
    for(int j = 0 ; j < n; j++)
    {
        for(int  i = 0 ; i < 3 ; i++)
        {
            cin>>a[i][j];
        }
    }
    
    
    
    for(int j = 1 ; j < n; j++)
    {
        for(int i = 0 ; i < 3 ; i++)
        a[i][j] += max(a[(i+2)%3][j-1] , a[(i+1)%3][j-1]);
    }
 
 
    int mx = INT_MIN;
 
    for(int i = 0 ; i < 3 ; i++)
    {
        mx = max(mx ,a[i][n-1]);
    }
    
    
    cout<<mx<<endl;
    return;
    
}
 
 
 
int32_t main()
{
    solve();
    return 0;
}

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


int main(){
	int N, D;
	
	scanf("%d", &N);
	scanf("%d", &D);
	
	
	int x[11][11];
	for(int i=0; i<N; i++){
		for(int j=0; j<D; j++){
			scanf("%d", &x[i][j]);
		}
	}
	
	int ans = 0;
	for(int i=0; i<N-1; i++){
		for(int j=i+1; j<N; j++){
			double Ld = 0;
			for(int k=0; k<D; k++){
				Ld += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			Ld = sqrt(Ld);
			int Li = Ld;
			if(Li == Ld){
				ans++;
			}
		}
	}
	
	
	printf("%d\n", ans);
	
	return 0;
}



Measured memory_bytes: 128
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,j,h,w;
	while(1)	{
		scanf("%d %d",&h,&w);
		if(h==0 && w==0)	break;
		for(i=0;i<h;i++)	{
			for(j=0;j<w;j++)	{
				if(i==0 || i==h-1 || j==0 || j==w-1)	{
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2512
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

int itr(int s, set<int> st, int count){
    int result;
    count++;
    st.insert(s);
    if(s%2 == 0){
        result = s/2;
    }else{
        result = 3 * s + 1;
    }

    if(st.count(result) == 0){
        return itr(result, st, count);
    }else{
        return count;
    }

}

int main(){
    int s;
    cin >> s;
    int result;

    set<int> st;
    
    result = itr(s, st, 1);

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    double ans = 0;
    vector<int> per;
    rep(i, n) per.push_back(i);

    do {
        rep(i, n-1){
            double dx = (x[per[i]] - x[per[i+1]]) * (x[per[i]] - x[per[i+1]]);
            double dy = (y[per[i]] - y[per[i+1]]) * (y[per[i]] - y[per[i+1]]);
            ans += sqrt(dx + dy);
        }
    } while(next_permutation(all(per)));

    double fact = 1;
    for(int i=1; i<=n; i++) fact *= i;
    cout << setprecision(9) << ans/fact << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p=-1){
  for (int u : to[v]){
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main(){
  int N, Q;
  cin >> N >> Q;
  REP(i, N-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(N);
  REP(i, Q){
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  REP(i, N){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 23424
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());

    boolean b = false;
    while(b==false){
      b = checkNum(N);
      N++;
    }
    System.out.print(N-1);
  }
  
  static boolean checkNum(int num){
    for(int i=2;i<= num/2;i++){
      if(num%i==0){
        return false;
      }
    }
    return true;
  }
}



Measured memory_bytes: 21972
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]

l.sort(key=lambda x: x[1])

res = 0
pos = 0
for a, b in l:
    if (a - pos) * (b - pos) > 0:
        res += 1
        pos = b - 0.5

print(res)

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

int main() {
	string s;
	cin >> s;
	int left = 0, right = s.size();
	while (left < right) {
		int mid = (left + right) / 2;
		bool flag = false;
		for (int base = 0; !flag && base <= 1; base++) {
			int low = base;
			int high = mid;
			if ((high - low) & 1) {
				high--;
			}
			bool ok = high >= low;
			for (int i = 0; ok && i < s.size(); i++) {
				if (s[i] == '1' || low < 1) {
					low++;
				}
				else {
					low--;
				}
				if (s[i] == '0' || high > mid - 1) {
					high--;
				}
				else {
					high++;
				}
				ok = high >= low;
			}
			flag = ok;
		}
		if (flag) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}
	cout << left << endl;
}

Measured memory_bytes: 4560
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :x, :y, :s ,:t

  def initialize
    @w,@h,@n = gets.to_s.split.map{ |v| v.to_i }
    @x,@y,@a = Array.new(n){ gets.to_s.split.map{ |v| v.to_i } }.transpose
  end

  def solve
    return 0 if minx >= maxx
    return 0 if miny >= maxy
    (maxy - miny) * (maxx - minx)
  end

  def minx
    n.times.select{|i|a[i] == 1}.map{|i| x[i]}.max || 0
  end

  def maxx
    n.times.select{|i|a[i] == 2}.map{|i| x[i]}.min || w
  end

  def miny
    n.times.select{|i|a[i] == 3}.map{|i| y[i]}.max || 0
  end

  def maxy
    n.times.select{|i|a[i] == 4}.map{|i| y[i]}.min || h
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14364
# Problem D - Preparing Boxes

# input and initialization
N = int(input())
a_list = list(map(int, input().split()))
current_num = [0]*N

M = 0
b_list = []
is_equivalent = True

for i in reversed(range(1,N+1)):
    num = 1
    for j in range(i,N+1,i):
        if current_num[j-1]==1:
            num = num + 1
    if num%2==a_list[i-1]:
        current_num[i-1] = 1

for i in range(N):
    if current_num[i]>=1:
        M = M + 1
        b_list.append(i+1)

# output process
print(M)
for b in b_list:
    print(b, end=" ")


Measured memory_bytes: 12084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	reverse(all(s));
	V<ll> md13(13);
	md13[0]++;
	int k = 1;
	rep(i, s.size()) {
		
		V<ll> trans(13);

		if (0 <= s[i] - '0' && s[i] - '0' <= 9) {
			int l = (s[i] - '0') * k;
			rep(j, 13)trans[(l + j) % 13] = md13[j];
		}
		else {
			rep(j, 13)rep(p, 10) {
				trans[(p*k + j) % 13] += md13[j];
				trans[(p * k + j) % 13] %= MOD;
			}
		}
		md13 = trans;
		k *= 10;
		k %= 13;
	}

	cout << md13[5] << endl;

}

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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 100 * 1000 + 9;

int n;
ll a[maxN];
pair<ll, ll> f[maxN];

pair<ll, ll> operator - (const pair<ll, ll> &lhs, const pair<ll, ll> &rhs){
	return make_pair(lhs.first - rhs.first, lhs.second - rhs.second);
}

pair<ll, ll> operator + (const pair<ll, ll> &lhs, const pair<ll, ll> &rhs){
	return make_pair(lhs.first + rhs.first, lhs.second + rhs.second);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	f[1] = make_pair(0, 1);
	
	for(int i = 1; i + 1 <= n; i++){
		f[i + 1] = (make_pair(2 * a[i], 0) - f[i]);
	}
	
	pair<ll, ll> foo = f[1] + f[n];
	ll x1 = (2 * a[n] - foo.first) / foo.second;
	
	cout << x1 << ' ';
	for(int i = 1; i + 1 <= n; i++){
		cout << f[i + 1].first + f[i + 1].second * x1 << ' ';
	}
	cout << '\n';

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int r, g, b;
  cin >> r >> g >> b;
  cout << ((100*r+10*g+b)%4==0?"YES":"NO") << endl;

  return 0;
}


Measured memory_bytes: 256
x,k,d=map(int,input().split())
if x<0:
    x=-x

if x>=k*d:
    print(x-k*d)
else:
    c=x//d
    x_r=x-d*c
    x_l=x-d*(c+1)
    k=k-c
    if k%2==1:
        print(abs(x_l))
    else:
        print(x_r)

Measured memory_bytes: 9164
#include <stdio.h>

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

void maxHeapify(int A[], int H, int i) {
  int l = left(i);
  int r = right(i);

  int 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) {
    int tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, H, largest);
  }
}

void buildMaxHeap(int A[], int H) {
  for (int i = H / 2; i >= 1; i--) {
    maxHeapify(A, H, i);
  }
}

int main() {
  int H;
  scanf("%d", &H);

  int A[H+1];

  for (int i = 1; i <= H; i++) {
    scanf("%d", &A[i]);
  }

  buildMaxHeap(A, H);

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



Measured memory_bytes: 3656
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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 a[505][505];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	rep(i,h)rep(j,w) cin >> a[i][j];
	vector<pair<P,P>> ans;
	for(int i = 0; i < h; ++i){
		if(i%2 == 0){
			for(int j = 0; j < w-1; ++j){
				if(a[i][j]%2 != 0){
					a[i][j]--;
					a[i][j+1]++;
					ans.emplace_back(P(i,j),P(i,j+1));
				}
			}
			if(i == h-1) continue;
			if(a[i][w-1]%2 != 0){
				a[i][w-1]--;
				a[i+1][w-1]++;
				ans.emplace_back(P(i,w-1),P(i+1,w-1));
			}
		}
		else{
			for(int j = w-1; j > 0; --j){
				if(a[i][j]%2 != 0){
					a[i][j]--;
					a[i][j-1]++;
					ans.emplace_back(P(i,j),P(i,j-1));
				}
			}
			if(i == h-1) continue;
			if(a[i][0]%2 != 0){
				a[i][0]--;
				a[i+1][0]++;
				ans.emplace_back(P(i,0),P(i+1,0));
			}
		}
	}
	cout << ans.size() << endl;
	for(auto p : ans){
		cout << p.first.first+1 << " " << p.first.second+1 << " ";
		cout << p.second.first+1 << " " << p.second.second+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 7280
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
    long long r, d, x;
    int i;
    cin >> r >> d >> x;
    for(i = 1; i <= 10; i++)
    {
        x = r*x-d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  if(n==1) {
   cout<<"Hello World"<<endl;
    return 0;
  }
  int a,b;
  cin>>a>>b;
  cout<<a+b<<endl;
}









Measured memory_bytes: 3612
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,a[205],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	while(1){
		bool flag=1;
		for(int i=1;i<=n;i++){
			if(a[i]%2==1){flag=0;break;}
			a[i]/=2;
		}
		if(flag)ans++;
		else break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B, C;
  cin >> N >> A >> B;
  C = A * N;
  if (C > B) {
    cout << B << endl;
  }
  else if (C < B) {
    cout << C << endl;
  }
  else {
    cout << C << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
arr = list(map(lambda a: int(a), input().split()))
ordered_arr = sorted(arr)
total_a, total_b = 0, 0

for n in range(N):
    if n%2 == 0:
        total_a += ordered_arr[n]
    else:
        total_b += ordered_arr[n]

print(abs(total_a-total_b))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int H, W;
    for (;;) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        rep(h, H) {
            rep(w, W) { cout << "#"; }
            cout << "\n";
        }
        cout << "\n";
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3136
#include <iostream>
#include <cmath>
#include<cstdio>
#include <cstring>
#include <algorithm>
#define ll long long int

using namespace std;
ll weight[200];
ll cost[200];
ll make,cap,n;
ll dp[101][100000];
ll call(int i,ll amount)
{
    if(i == n)
        return 0;
    if(dp[i][amount] != -1)
        return dp[i][amount];
    if(amount + weight[i]> cap)
        return call(i+1,amount);
    else
    {
        dp[i][amount] = max(call(i+1,amount),cost[i]+call(i+1,amount+weight[i]));
        return dp[i][amount];
    }
}
int main()
{
    cin>>n>>cap;
    for(int i=0;i<n;i++)
        cin>>weight[i]>>cost[i];
    memset(dp,-1,sizeof(dp));
    cout<<call(0,0);
}

Measured memory_bytes: 79104
n, y = map(int, input().split())
y //= 1000

for a in range(n + 1):
    b = (y - n - 9 * a) // 4
    c = n - a - b
    if 10 * a + 5 * b + c == y and b >= 0 and c >= 0:
        print(a, b, c)
        exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
      
      	String x = sc.next();
      	char[] x_chars = x.toCharArray();
      	Arrays.sort(x_chars);
      	String x_asc = new String(x_chars);
      
        String y = sc.next();
      	char[] y_chars = y.toCharArray();
      	Arrays.sort(y_chars);
      	String y_asc = new String(y_chars);  
      	String y_desc = new StringBuilder(y_asc).reverse().toString();
      
     	if(x_asc.compareTo(y_desc) < 0)
          System.out.println("Yes");
      	else
          System.out.println("No");

	}
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i=0; i<n; i++) cin >> a.at(i);
  cout << a.at(n-1);
  for (ll i=n-3; i>=0; i-=2)
    cout << ' ' << a.at(i);
  for (ll i=(n%2)?1:0; i<n; i+=2)
    cout << ' ' << a.at(i);
  cout << endl;
}

Measured memory_bytes: 3712
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int S;
	// char ;

	cin >> S;
	
	int h, m ,s;
	
	s = S % 60;
	S /= 60;
	m = S % 60;
	h = S / 60;
	

	cout <<h <<":" << m<<":"<<s <<endl;

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string s, t;
  cin >> s >> t;
  cout << (s[0] == t[2] && s[1] == t[1] && s[2] == t[0] ? "YES" : "NO") << "\n";
}

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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    rep(i, s.length())
    {
        cout << (char)((s[i] + n - 'A') % 26 + 'A');
    }
    cout << endl;
    return 0;
}

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

typedef long long ll;
ll T, a, b;

int main() {
    scanf("%lld", &T);
    while (T--) {
        ll ans = 0;
        scanf("%lld%lld", &a, &b);
        if (a == b) ans = 2 * (a - 1);
        else {
            ll tmp = sqrt(a * b);
            if (tmp * tmp == a * b) tmp--;
            if (tmp * (tmp + 1) >= a * b) ans = 2 * (tmp - 1);
            else ans = 2 * tmp - 1;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


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

int main()
{
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int i,j;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if((i<b&&j<a)||(i>=b&&j>=a))cout<<1;
            else cout<<0;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1280
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

s =s()
a = Counter(s)
if len(a)==2:
    for i in a.values():
        if i==2:
            pass
        else:
            print("No")
            sys.exit()
else:
    print("No")
    sys.exit()

print("Yes")


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define ab(a) max((a),-(a))

typedef long long LL;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  int ans=1000000000;
  for(int i=0;i+k-1<n;i++){
    ans=min(ans,x[i+k-1]-x[i]+min(ab(x[i+k-1]),ab(x[i])));
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
    int n, ans = 1;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());
    for(int i = 1; i < n; i++){
        if(s[i-1] != s[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;
int main()
{
    int x,a,b,c,s=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
    {
    	for(int j=0;j<=b;j++)
    	{
	    	for(int k=0;k<=c;k++)
	    	{
	    		if((i*500+j*100+k*50)==x)s++;
	    	}
	    }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int x, y, z;
    while(true){
        scanf("%d %d", &x, &y);
        if(x == 0 & y == 0){
        break;
        }
        if(x > y){
            z = x;
            x = y;
            y = z;
        }
        printf("%d %d\n", x, y);
    }
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
int n, a[11], b[11], perm[11];
int main(){
    cin>>n;
    for(int i = 1;i <= n; i++)cin>>a[i];
    for(int i = 1;i <= n; i++)cin>>b[i], perm[i] = i;
    int A = 1, B = 1, now = 2;
    while(next_permutation(perm + 1, perm + 1 + n)){
        bool fl1 = 1, fl2 = 1;
        for(int i = 1;i <= n; i++){
            if(a[i] != perm[i]){
                fl1 = 0;
            }
            if(b[i] != perm[i]){
                fl2 = 0;
            }
        }
        if(fl1)A = now;
        if(fl2)B = now;
        now++;
    }
    printf("%d\n", abs(A - B));
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
least = -1
for ai in a:
    ans += b[ai - 1]
    if ai - 1 == least:
        ans += c[least - 1]
    least = ai
print(ans)

Measured memory_bytes: 38256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextLong() }

  val aLen = a.sum()
  val revA = a.reversed()

  var countF = 0L
  var indexF = 0
  for (i in 0 until n) {
    countF += a[i]
    if (countF > aLen / 2) {
      indexF = i
      break
    }
  }

  var countB = 0L
  var indexB = 0
  for (i in 0 until n) {
    countB += revA[i]
    if (countB > aLen / 2) {
      indexB = i
      break
    }
  }

  var sumF = 0L
  for (i in 0 until indexF) {
    sumF += a[i]
  }
  var sumB = 0L
  for (i in 0 until indexB) {
    sumB += revA[i]
  }

  if (indexF + indexB == n && sumF == sumB) {
    println(0)
    return
  }

  if (countF < countB) {
    var last = (countF + a[indexF]) - countB
    println(last)
  } else {
    var last = (countB + revA[indexB]) - countF
    println(last)
  }

}


Measured memory_bytes: 78384
#include <stdio.h>
char S[55][55];
int main() {
  int N, M, i, j, k, c, cnt, row;
  scanf("%d%d", &N, &M);
  for (i = 0; i < N; i++) {
    scanf("%s", S[i]);
  }
  int ans = 999999;
  for (i = 1; i <= N-2; i++) {
    for (j = 1; i+j <= N-1; j++) {
      cnt = 0;
      row = 0;
      for (k = 0; k < i; k++) {
        for (c = 0; c < M; c++) {
          if (S[row][c] != 'W') cnt++;
        }
        row++;
      }
      for (k = 0; k < j; k++) {
        for (c = 0; c < M; c++) {
          if (S[row][c] != 'B') cnt++;
        }
        row++;
      }
      for (k = 0; k < N-i-j; k++) {
        for (c = 0; c < M; c++) {
          if (S[row][c] != 'R') cnt++;
        }
        row++;
      }
      if (cnt < ans) ans = cnt;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2720
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;


main()
{
    int h,w,k; cin>>h>>w>>k;
    string s[10];
    for(int i=0; i<h; ++i)
    {
        cin>>s[i];
    }
    int ans2=h+w;
    for(int i=0;i<(1<<(h-1));++i)
    {
        vector<int> l;
        l.push_back(0);
        for(int j=0; j<h-1; ++j)
        {
            if(i>>j&1)
            {
                l.push_back(j+1);
            }
        }
        int m=l.size();
        int ans=m-1;
        vector<int> now(m);
        l.push_back(h);
        bool imp=false;
        for(int j=0;j<w and !imp;++j)
        {
            bool cut=false;
            vector<int> tmp(m);
            for(int z=0,x=0;z<h;++z)
            {
                if(l[x+1]<=z) ++x;
                tmp[x]+=s[z][j]-'0';
                if(now[x]+tmp[x]>k) cut=true;
            }
            if(cut)
            {
                for(int x=0;x<m;++x)
                {
                    if(tmp[x]>k) imp=true;
                }
                swap(now,tmp);
                ++ans;
            }
            else
            {
                for(int x=0;x<m;++x) now[x]+=tmp[x];
            }
        }
        if(!imp) ans2=min(ans,ans2);
    }
    cout << ans2 << "\n";
}

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}

int n, m;
vector<int> adj[N];
vector<int> p(N), h(N), a(N), g(N);
bool ok = true;

// in an undirected graph, use dfs(child, parent)
void dfs(int v, int ancestor=-1) {
    a[v] = p[v];
    int sumG = 0;
    for(auto next : adj[v]) {
        if(next != ancestor) {
            // 从下到上 dfs
            dfs(next, v);
            sumG += g[next];
            a[v] += a[next];
        }
    }
    // 三个条件
    if(!((a[v] + h[v]) % 2 == 0)) ok = false;
    g[v] = (a[v] + h[v]) / 2;
    if(!(0 <= g[v] && g[v] <= a[v])) ok = false;
    if(!(sumG <= g[v])) ok = false;
}

void solve() {
    int n;
    ll d;
    cin >> n >> d;
    int res = 0;
    for(int i=0;i<n;i++) {
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) res++;
    }
    cout << res << endl;
    return;
} 

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


Measured memory_bytes: 11044
N=int(input())
A=[int(x) for x in input().split()]

S=[0]*(N-1)
T=[0]*(N-1)

S[0]=A[0]
for i in range(1,len(A)-1):
	S[i]=A[i]+S[i-1]

T[-1]=A[-1]
for i in range(len(A)-2)[::-1]:
	T[i]=A[i+1]+T[i+1]

ans=-1
for i,j in zip(S,T):
	if ans==-1:ans=abs(i-j)
	else:ans=min(ans,abs(i-j))
print(ans)

Measured memory_bytes: 28656
#include<bits/stdc++.h>
using namespace std;
using lld = long long int;
using ld = long int;
int main()
{
    lld n,k,i;
    cin >> n >> k;
    vector <lld> vec(n);
    for(i=0;i<n;i++)
    {
        cin >> vec[i];
    }
    for(i=0;i+k<n;i++)
    {
        if(vec[i]<vec[i+k])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 4784
#include <bits/stdc++.h> 
using namespace std;  
long INF=1000000000000000;
int main() {
    long N,M;
    cin>>N>>M;
    
    vector<pair<long,long>> job(N+1);
    job.at(N).first=INF;
    job.at(N).second=-INF;
    for(int i=0;i<N;i++) cin>>job.at(i).first>>job.at(i).second;
    
    sort(job.begin(),job.end());
    //cout<<job.at(3).first<<endl;
    
    long poi=0,ans=0;
    multiset<long> rew;
    for(int i=1;i<=M;i++){
        while(job.at(poi).first<=i) {
            rew.insert(job.at(poi).second);
            poi++;
        }
        if(rew.size()!=0){
            auto ite=rew.end();
            --ite;
            ans+=*ite;
            rew.erase(ite);
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 6400
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

struct Trie
{
	char charactor;
	Trie* child[2];
	Trie(char c = '\0') : charactor(c)
	{
		rep(i, 2) child[i] = NULL;
	}
	
	void insert(const char* str, char c)
	{
		if(str[0] == '\0')
			charactor = c;
		else{
			int n = str[0] - '0';
			if(!child[n])
				child[n] = new Trie();
			child[n]->insert(str+1, c);
		}
	}
	
	pair<char, int> get(const char* str)
	{
		if(charactor != '\0')
			return make_pair(charactor, 0);
		else{
			if(str[0] == '\0' || !child[str[0]-'0'])
				return make_pair('\0', -1);
			
			pair<char, int> pci = child[str[0]-'0']->get(str+1);
			return make_pair(pci.first, pci.second+1);
		}
	}
};

void disposeTrie(Trie* t)
{
	rep(i, 2){
		if(t->child[i] != NULL){
			disposeTrie(t->child[i]);
			delete t->child[i];
			t->child[i] = NULL;
		}
	}
}

int main()
{
	const char* chas = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const char* strs[] = {"101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000", "0110", "00100", "10011001", "10011110", "00101", "111", "10011111", "1000", "00110", "00111", "10011100", "10011101", "000010", "10010010", "10010011", "10010000"};
	
	Trie root;
	rep(i, strlen(chas)){
		root.insert(strs[i], chas[i]);
	}
	
	map<char, const char*> table;
	table['A'] = "00000";
	table['B'] = "00001";
	table['C'] = "00010";
	table['D'] = "00011";
	table['E'] = "00100";
	table['F'] = "00101";
	table['G'] = "00110";
	table['H'] = "00111";
	table['I'] = "01000";
	table['J'] = "01001";
	table['K'] = "01010";
	table['L'] = "01011";
	table['M'] = "01100";
	table['N'] = "01101";
	table['O'] = "01110";
	table['P'] = "01111";
	table['Q'] = "10000";
	table['R'] = "10001";
	table['S'] = "10010";
	table['T'] = "10011";
	table['U'] = "10100";
	table['V'] = "10101";
	table['W'] = "10110";
	table['X'] = "10111";
	table['Y'] = "11000";
	table['Z'] = "11001";
	table[' '] = "11010";
	table['.'] = "11011";
	table[','] = "11100";
	table['-'] = "11101";
	table['\''] = "11110";
	table['?'] = "11111";
	
	char str[256];
	while(fgets(str, 1024, stdin)){
		char binary[2048];
		int n = strlen(str);
		if(str[n-1] == '\n')
			str[--n] = '\0';
		
		rep(i, n){
			const char* b = table[str[i]];
			rep(j, 5)
				binary[i*5+j] = b[j];
		}
		binary[n*5] = '\0';
		
		int pos = 0;
		while(pos < n*5){
			pair<char, int> pci = root.get(binary+pos);
			if(pci.first == '\0')
				break;
			putchar(pci.first);
			pos += pci.second;
		}
		putchar('\n');
	}

	disposeTrie(&root);
	return 0;
}

Measured memory_bytes: 0
n=int(input())
d={}
m=1
for i in range(n):
    s=input()
    if s in d:
        d[s]+=1
        m=max(m,d[s])
    else:
        d[s]=1
se=set()
for i in d:
    if d[i]==m:
        se.add(i)
se=list(se)
se.sort()
print(*se)

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(C<B){
    cout << C;
  }else{
    cout << B;
  }
  cout << " ";
  
  if((B+C-A)<0){
    cout << "0" << endl;
  }else{
    cout << B+C-A << endl;
  }

}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

nums = {}
nums[1] = 2
nums[2] = 5
nums[3] = 5
nums[4] = 4
nums[5] = 5
nums[6] = 6
nums[7] = 3
nums[8] = 7
nums[9] = 6

dp = [-float('inf')]*(N+1)
dp[0] = 0

for i in range(N+1):
    for a in A:
        if i-nums[a] >= 0:
            dp[i] = max(dp[i], dp[i-nums[a]]+1)

ans = ""
i = N
while i > 0:
    for a in A:
        if i >= nums[a] and dp[i]-1 == dp[i-nums[a]]:
            ans += str(a)
            i = i-nums[a]
            break
print(ans)


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    ll n = s.size();

    map<char, vector<ll>> indexMap; 
    REP(i, n)
    {
        char c = s[i];
        if (indexMap[c].size() >= 1)
        {
            ll prevPos = indexMap[c][indexMap[c].size() - 1];
            ll currentPos = i + 1;
            if (currentPos - prevPos <= 2)
            {
                cout << prevPos << " " << currentPos << endl;
                return 0;
            }
        }
        indexMap[c].push_back(i + 1);
    }

    cout << "-1 -1"<< endl;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

  int n = s.length();
  lint ans = 0;
  for(lint i=0; i<n; i++) {
    ans += s[i] != t[i];
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){

    long long a, b;
    cin >> a >> b;

    if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }
    else if(a > 0){
        cout << "Positive" << endl;
    }
    else{
        if( (b - a) % 2 == 1){
            cout << "Positive" << endl;
        }
        else{
            cout << "Negative" << endl;
        }
    }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0 && s[i] != '0')
        {
            cnt++;
        }
        else if (i % 2 != 0 && s[i] != '1')
        {
            cnt++;
        }
    }
    int count = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0 && s[i] != '1')
        {
            count++;
        }
        else if (i % 2 != 0 && s[i] != '0')
        {
            count++;
        }
    }

    cout << min(cnt, count) << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <tuple>
#include <functional>

using namespace std;

#define ll long long

int main() {
	int n, l;
	int a[300] = {};
	int ans = 0;
	bool t = false;
	cin >> n >> l;
	

	a[0] = l;
	for (int i = 1; i < n; i++) {
		a[i] = l + i;
		if (a[i] == 0) {
			t = true;
		}
	}
	
	
	if (t) {
		for (int i = 0; i < n; i++)
		{
			ans += a[i];
		}

		cout << ans << endl;
	}	else {

		for (int i = 0; i < n; i++)
		{
			ans += a[i];
		}

		if (l >= 0) {
			cout << ans - l << endl;
		}
		else {
			cout << ans - a[n - 1] << endl;
		}
	}
	

		


}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int i,j,l;
    	j=0;
    	for(i=0;i<n;i++){
    		l=sc.nextInt();
    		while(l%2==0){
    			l=l/2;
    			j++;
    		}
    	}
    	System.out.println(j);
    }
}

Measured memory_bytes: 34152
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32,
    }
    if (0..10).any(|a| (0..10).any(|b| a*b == n)) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  s.pop_back();
  while (sz(s)) {
    string l = s.substr(0, sz(s) / 2);
    string r = s.substr(sz(s) / 2, sz(s));
    if (l == r) {
      cout << sz(s) << endl;
      return 0;
    }
    s.pop_back();
  }
  return 0;
}

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

int main(){
  ll N; cin>>N;
  vector<ll> Q(5);
  for(int i=0;i<5;i++){
    cin>>Q[i];
  }
  sort(Q.begin(),Q.end());
  cout << (N-1)/Q[0]+5 << endl;
}

Measured memory_bytes: 256