akhauriyash/Code-Regression huggingface dataset:
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-int:defconstant-eqx OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))
    #'equal)
  #+swank (ql:quickload '(:cl-debug-print :fiveam) :silent t)
  #-swank (set-dispatch-macro-character
           #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil nil t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;;;
;;; Body
;;;

(defvar *set1*)
(defvar *set2*)
(defvar *set3*)

(defun initialize-sets ()
  (setf *set1* (loop for x from 3 to 30000 by 6 collect x)
        *set2* (loop for x from 2 to 30000 by 6 append (list x (+ x 2)))
        *set3* (loop for x from 6 to 30000 by 6 collect x)))

(defun main ()
  (let* ((n (read))
         res
         (count 0))
    (declare (uint32 n count))
    (when (= n 3)
      (write-line "2 5 63")
      (return-from main))
    (initialize-sets)
    (labels ((push1 ()
               (push (pop *set1*) res)
               (push (pop *set1*) res)
               (incf count 2))
             (push2 ()
               (push (pop *set2*) res)
               (push (pop *set2*) res)
               (incf count 2))
             (push3 ()
               (push (pop *set3*) res)
               (incf count)))
      (push1)
      (push2)
      (loop (when (= count n)
              (return))
            (cond ((= (+ count 1) n)
                   (push3))
                  (*set1* (push1))
                  (*set2* (push2))
                  (*set3* (push3))
                  (t (error "Huh?"))))
      (loop with init = t
            for x in res
            do (if init
                   (setq init nil)
                   (write-char #\ ))
               (princ x))
      (terpri))))

#-swank (main)


Measured memory_bytes: 17252
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string oUpper(string s){
    string t=s;
    for (int i=0; i<s.size(); i++){
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    string target,source;
    
    cin >> target;
    target = oUpper(target);
    
    int cnt = 0;
    while(1){
        cin >> source;
        if (source == "END_OF_TEXT") break;
        source = oUpper(source);
        if (target == source) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3144
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    string T,S; cin >> S >> T;
    map<char,int> mapS;
    map<char,int> mapT;
    int oS = 1;
    int oT = 1;
    rep(i,T.size()){
        
        if (mapS[S[i]] != mapT[T[i]]){
            cout << "No"; rn 0;
        }
        if (mapS[S[i]] == 0){
            mapS[S[i]] = oS;
            oS++;
        }
        if (mapT[T[i]] == 0){
            mapT[T[i]] = oT;
            oT++;
        }
    }
    cout << "Yes"; rn 0;
}

Measured memory_bytes: 776
H, W = [int(x) for x in input().split()]
a_list = [[int(x) for x in input().split()] for _ in range(H)]
cnt = 0
ope = []
for x in range(W):
    for y in range(H-1):
        if (a_list[y][x] % 2):
            a_list[y][x] -= 1
            a_list[y+1][x] += 1
            cnt += 1
            ope.append([y+1, x+1, y+2, x+1])
y = H-1
for x in range(W-1):
    if (a_list[y][x] % 2):
        a_list[y][x] -= 1
        a_list[y][x+1] += 1
        cnt += 1
        ope.append([y+1, x+1, y+1, x+2])
print(cnt)
lst = [" ".join(map(str, o)) for o in ope]
for ans in lst:
    print(ans)    

Measured memory_bytes: 80604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n,k; cin >> n >> k;
  vector<int> a(n,-1);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.rbegin(),a.rend());
  int amax = a.at(0);
  int gcd = amax;
  for(int i=1;i<n;i++){
    gcd = __gcd(gcd,a.at(i));
  }
  if(k>amax){
    cout <<"IMPOSSIBLE" << endl;
    return 0;
  }
  if(k%gcd == 0){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    double r;
    cin >> r;

    double area = M_PI * r * r;
    double circumference = 2 * M_PI * r;

    printf("%.6lf %.6lf\n", area, circumference);

    return 0;
}


Measured memory_bytes: 3264
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            List<C.City> col = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                C.City city = new C.City();
                city.x = in.nextInt();
                city.y = in.nextInt();
                col.add(city);
            }

            List<Double> len = new ArrayList<>();
            double sum = 0;
            for (int i = 0; i < N; i++) {
                double temp = 0;
                for (int j = 0; j < N; j++) {
                    C.City c1 = col.get(i);
                    C.City c2 = col.get(j);
                    double pow1 = Math.pow(c1.x - c2.x, 2);
                    double pow2 = Math.pow(c1.y - c2.y, 2);
                    double sqrt = Math.sqrt(pow1 + pow2);
                    temp += sqrt;
                }
                sum += temp * fact(N - 1);
            }
            out.printf("%.10f", sum / fact(N));
        }

        private double fact(double n) {
            if (n <= 1) {
                return 1;
            }
            return n * fact(n - 1);
        }

        static class City {
            int x;
            int y;

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868
n = gets
s = gets.chomp.split("")
count = 0
prev = nil
s.each{|c|
    if !c.nil? && ([c, prev] == ["O", "X"] || [c, prev] == ["X", "O"])
        count += 1
        prev = nil
    else
        prev = c
    end
}
puts count


Measured memory_bytes: 12408
#include "bits/stdc++.h"
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long LL;
#define REP(i,N) for (int i=0; i<N; i++)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a <= c && b >= c ? "Yes" : "No") << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    map<string,ll> mp;
    fr(i,0,n)
    {
        string x;
        cin>>x;
        mp[x]+=1;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    
    cout<<"RE x "<<mp["RE"]<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3664
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        char[] chars = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
        ArrayList<String> wordsList = new ArrayList<>();
        for (char aChar : chars) {
            wordsList.add(Character.toString(aChar));
        }
        Scanner in = new Scanner(System.in);
        final String word = in.nextLine();

        if (word.equals("zyxwvutsrqponmlkjihgfedcba")) {
            System.out.println("-1");
            return;
        }

        for (char c : word.toCharArray()) {
            wordsList.remove(Character.toString(c));
        }

        if (wordsList.size() == 0) {
            for (int i = 25; i >= 0; --i) {
                wordsList.clear();
                for (int j = i + 1; j < 26; j++) {
                    wordsList.add(Character.toString(word.charAt(j)));
                }
                Collections.sort(wordsList);
                if (wordsList.size() == 0) {
                    continue;
                }
                for (String kouho : wordsList) {
                    String newWord = word.substring(0, i) + kouho;
                    if (largeLeft(newWord.substring(i), word.substring(i))) {
                        System.out.println(newWord);
                        return;
                    }
                }

            }
            System.out.println((char) (word.charAt(0) + 1));
        } else {
            System.out.println(word + wordsList.get(0));
        }
    }

    private static boolean largeLeft(String left, String right) {
        return !left.equals(right) && left.charAt(0) - right.charAt(0) > 0;
    }
}


Measured memory_bytes: 22608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
vector<int> G[200000];
bool OX[200000];
void dfs(int N){
	stack<pair<int,int>> sp;
	sp.push({0,-1});
	while(!sp.empty()){
		int v = sp.top().first;
		int f = sp.top().second;
		sp.pop();
		for(int i=0;i<G[v].size();i++){
			int t = G[v][i];
			if(t != f){
				OX[t] = !OX[v];
				sp.push({t,v});
			}
		}
	}
}
int ans[200000];
void Calc(){
	int N = rei();
	for(int i=0;i<N-1;i++){
		int f = rei()-1;
		int t = rei()-1;
		G[f].push_back(t);
		G[t].push_back(f);
	}
	dfs(N);
	int co = 0;
	int cx = 0;
	for(int i=0;i<N;i++){
		if(OX[i]){
			co++;
		}
		else{
			cx++;
		}
	}
	if(co < cx){
		for(int i=0;i<N;i++){
			OX[i] = !OX[i];
		}	
		int temp = co;
		co = cx;
		cx = temp;
	}
	int one = (N+2) / 3;
	int two = (N+1) / 3;
	if(co >= one + two){
		int onep = 1;
		int twop = 2;
		int threep = 3;
		for(int i=0;i<N;i++){
			if(OX[i]){
				if(onep <= N){
					ans[i] = onep;
					onep += 3;
				}
				else if(twop <= N){
					ans[i] = twop;
					twop += 3;
				}
				else{
					ans[i] = threep;
					threep += 3;
				}
			}
		}
		for(int i=0;i<N;i++){
			if(!OX[i]){
				ans[i] = threep;
				threep += 3;
			}
		}
	}
	else{
		int onep = 1;
		int twop = 2;
		int threep = 3;
		for(int i=0;i<N;i++){
			if(OX[i]){
				if(onep <= N){
					ans[i] = onep;
					onep += 3;
				}
				else{
					ans[i] = threep;
					threep += 3;
				}
			}
		}
		for(int i=0;i<N;i++){
			if(!OX[i]){
				if(twop <= N){
					ans[i] = twop;
					twop += 3;
				}
				else{
					ans[i] = threep;
					threep += 3;
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

using ll = long long;

int main() {

    ll n, b, r;

    cin >> n >> b >> r;


    ll br = b + r;

    ll answer = (n / br) * b;
    answer += min(n % br, b);

    cout << answer << endl;

    return 0;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    ll n,sum=0;
    cin>>n;
    sum+=1000*(n/500);
    n%=500;
    sum+=5*(n/5);
    cout<<sum;
}


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

#define fi first
#define se second
#define p_b push_back
#define ull unsigned long long
#define ll  long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(nullptr);cout.tie(nullptr);ios_base::sync_with_stdio(false);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int) x.size()
#define endl '\n'
#define len(x) x.length()

using namespace std;

signed main()
{
    fast_io;
    ll n;
    cin>>n;
    string in;
    vector<pair<ll,string>>a;
    map<string,ll>mp;
    for(ll i=0;i<n;i++){
        cin>>in;
        mp[in]++;
    }
    for(auto &z : mp){
        ll ch=-z.se;
        a.p_b(m_p(ch,z.fi));
    }
    sort(all(a));
    ll ch=a[0].fi;
    for(auto &z: a){
        if(z.fi!=ch){
            break;
        }
        cout<<z.se<<endl;
    }
    return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  int sum = 0;
  int hw[m];
  for(int i = 0; i < m; i++){
    cin >> hw[i];
    sum += hw[i];
  }
  if( n >= sum){
    cout << n - sum << endl;
  }
  else{
    cout << "-1" << endl;
  }
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;

	int ans = 0;
	int A[20][20] = { 0 };
	REP(i, N) {
		int a;
		cin >> a;
		REP(j, a) {
			int x, y;
			cin >> x >> y;
			x--;
			y++;
			A[i][x] = y;
		}
	}
	//1不親切、2正直
	REP(i, 1 << N) {
		int cnt = 0;
		bool F = true;
		REP(j, N) {
			if (i&(1 << j)) {
				cnt++;
				REP(k, N) {
					
					if (A[j][k] == 0)continue;
					//if()
					/*if (i == 6) {
						cout << j << " " << k << " " << A[j][k] << endl;
						cout << i << " " << (i & (1 << k)) << endl;
					}*/
					if (A[j][k] == 1) {
						if ((i&(1 << k)) != 0)F = false;
					}
					if (A[j][k] == 2) {
						if ((i&(1 << k)) == 0)F = false;
					}
				}
				
			}
			
		}
		if (F) {
			//cout << i << " " << cnt << endl;
			chmax(ans, cnt);
		}
	}

	cout << ans << endl;

	return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string str; cin >> str;
    int tree_size = str.size();
    if(str[0] == '0' || str[tree_size - 1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0;i<tree_size;i++){
        if(i >= tree_size - 2 - i) break;
        if(str[i] != str[tree_size - 2 - i]){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> v;
    vector<pair<int, int> > ans;
    for(int i=0;i<tree_size;i++){
        if(str[i] == '1') v.push_back(i+1);
    }
    int v_size = v.size();
    // 部分木の根の頂点番号がその頂点数を示すように構築する
    for(int i=1;i<v_size;i++){
        ans.push_back(make_pair(v[i], v[i-1]));
        int c = v[i] - v[i-1] - 1;
        // v[i]にc個頂点を追加
        for(int j=1;j<=c;j++){
            ans.push_back(make_pair(v[i], v[i-1] + j));
        }
    }
    ans.push_back(make_pair(v[v_size - 1], tree_size));
    for(auto a: ans){
        cout << a.first << " " << a.second << endl;
    }
}

Measured memory_bytes: 2756
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

int gcd(int x, int y) {
  x = std::abs(x); y = std::abs(y);
  int a = std::max(x,y), b = std::min(x,y);
  int r = a % b;
  while(r!=0){ a = b; b = r; r = a % b; }
  return b;
}

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

int main(void) {
  int N, M;
  std::string S, T;
  scanf("%d %d", &N, &M);
  std::cin >> S >> T;
  long long l = lcm(N, M);
  for (int i = 0; i * lcm(l/N, l/M) < l; ++i) {
    if (S[i*(l/M)] != T[i*(l/N)]) {
      puts("-1");
      return 0;
    }
  }
  printf("%lld\n", l);
  return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def count_ordinary_num(n, arr):
    cnt = 0
    for i in range(1, n - 1):
        if (arr[i - 1] < arr[i] < arr[i + 1]) or (arr[i - 1] > arr[i] >
                                                  arr[i + 1]):
            cnt += 1
    return cnt


def main():
    n = int(input())
    p_arr = list(map(int, input().split()))

    ans = count_ordinary_num(n, p_arr)
    print(ans)


main()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// typedef pair<ll,ll> Pair;
// ll mod=1000000007;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,i,j,k,temp,temp2,n,m,x,y,sum=0;
    // string a;
    // cin >> i >> j >> k;
    // swap(i,j);
    // swap(i,k);
    // cout << i << " " << j << " " << k;
    cin >> n >> m;
    temp = m;
    vector <ll> a;
    for(i=0;i<n;i++){
        cin >> temp2;
        a.push_back(temp2);
        sum+=temp2;
    }
    for(i=0;i<n;i++){
        if(4*m*a[i]>=sum){
            temp--;
        }
    }
    if(temp<=0) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
           int N = int.Parse(Console.ReadLine());

            int[] ans = new int[4];

            string AC = "AC x";
            string WA = "WA x";
            string TEL = "TLE x";
            string RE = "RE x";

            for (int i = 0; i < N; i++)
            {
               string Input = Console.ReadLine().Replace("\r\n","");
                switch (Input)
                {
                    case ("AC"):
                        {
                            ans[0]++;break;                       }
                    case ("WA"):
                        {
                            ans[1]++; break;
                        }
                    case ("TLE"):
                        {
                            ans[2]++; break;
                        }
                    case ("RE"):
                        {
                            ans[3]++; break;
                        }
                }
              }

            Console.WriteLine(AC+" " +ans[0]);
            Console.WriteLine(WA + " " + ans[1]);
            Console.WriteLine(TEL + " " + ans[2]);
            Console.WriteLine(RE + " " + ans[3]);
        }
    }
}


Measured memory_bytes: 30536
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[20],B[20],C[20];
  for(int i=1;i<=N;i++){
    cin>>A[i];
  }
  for(int i=1;i<=N;i++){
    cin>>B[i];
  }
  int answer=0;
  for(int i=1;i<=N-1;i++){
   cin>>C[i]; 
  }
  for(int i=1;i<=N;i++){
    answer+=B[A[i]];
    if(i>=2&&A[i]-A[i-1]==1){
      answer+=C[A[i-1]];
    }
  }
  cout<<answer<<endl;
}
/*int main(){
  int N;
  cin>>N;
  cout<<N*N*N<<endl;
}*/

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

int main() {
  int n,k;cin>>n>>k;
  vector<int>p(n);
  rep(i,n)cin>>p[i];
  sort(all(p));
  int cnt=0;
  rep(i,k)cnt+=p[i];
  cout<<cnt<<endl;
}

Measured memory_bytes: 3596
n = gets.to_i
a, b = gets.chomp.split(' ').map(&:to_i)
(n - 1).times do
  a1, b1 = gets.chomp.split(' ').map(&:to_i)
  k = [(a / a1) + (a % a1 == 0 ? 0 : 1), (b / b1) + (b % b1 == 0 ? 0 : 1)].max
  a1 *= k
  b1 *= k
  a = a1
  b = b1
end
puts a + b

Measured memory_bytes: 1788
s = input()
n = len(s)
k = int(input())

dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for a in range(n):
  for b in range(k + 1):
    for c in range(2):
      nd = int(s[a])
      for d in range(10):
        na, nb, nc = a + 1, b, c
        if d != 0:
          nb += 1
        if nb > k:
          break
        if nc == 0:
          if d < nd:
            nc  = 1
          if d > nd:
            break
        dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))

Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vi w(n);
    rep(i, n) cin >> w[i];

    int s=0;
    rep(i, n)  s+= w[i];
    
    int l= w[0], r=s-w[0];
    int ans = abs(l - r);
    for(int i=1; i<n-1; i++){
        r -= w[i]; l += w[i];
        int d = abs(l - r);
        if (ans < d) break;
        else ans = d;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int n,a[3001];
long long f[3001][3001];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(n%2)
			f[i][i]=a[i];
		else
			f[i][i]=-a[i];
	}
	for(int j=1;j<n;j++)
		for(int i=1;i+j<=n;i++)
		{
			if((j+(n%2))%2)
				f[i][i+j]=max(f[i+1][i+j]+a[i],f[i][i+j-1]+a[i+j]);
			else
				f[i][i+j]=min(f[i+1][i+j]-a[i],f[i][i+j-1]-a[i+j]);
		}
	printf("%lld",f[1][n]);
}

Measured memory_bytes: 70016
/****************************************

	LostMartian

****************************************/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	pn(args...); 
}
template <typename Arg1>
void ps(Arg1&& arg1) { 
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) { 
	cout << arg1 << " "; 
	ps(args...); 
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1; 
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { 
	cin >> arg1; 
	read(args...); 
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define LOCAL #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
	clock_t z = clock();
	FAST
	//LOCAL
	ll x;
	cin>>x;
	if(x>=30) {
		cout<<"Yes\n";
	}
	else { cout<<"No\n";}










	debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 3784
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Print(f(a, b))
}

func f(a, b int) int {
	for i := 10 * b; i < 10*(b+1); i++ {
		for j := 25 * a; j < 25*(a+1); j++ {
			if j == 2*i {
				return i
			}
		}
	}
	return -1
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

#define ll long long

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.in","r",stdin);

	int n;
    
    cin>>n;
    std::vector<int> l(n);
    int i,j,k;
    for (i=0;i<n;i++) {
    	cin>>l[i];
    }

    int br = 0;
    for (i=0;i<n-2;i++)
    for (j=i+1;j<n-1;j++)
    for (k=j+1;k<n;k++)
    if (l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k] && l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[j]+l[k]>l[i]) {
    	br++;
    }

    cout<<br<<"\n";

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <queue>
using namespace std;
int main(){
    string a;
    while(cin>>a && a!="#"){
        queue<string> q;
        q.push(a);
        for(int i=122;i>98;i--){
            q.push("END");
            char b=i;
            while(1){
                a=q.front();
                q.pop();
                if(a=="END") break;
                for(int j=0;j<a.size();j++){
                    if(a[j]==b-1){
                        a[j]=b;
                        q.push(a);
                        a[j]=b-1;
                    }
                    if(a[j]==b) break;
                    if(j==a.size()-1) q.push(a);
                }
            }
        }
        q.push("END");
        char b=98;
        int n=0;
        while(1){
            a=q.front();
            q.pop();
            if(a=="END") break;
            for(int j=0;j<a.size();j++){
                if(a[j]==b-1){
                    a[j]=b;
                    q.push(a);
                    n++;
                    a[j]=b-1;
                }
                if(a[j]==b) break;
                if(j==a.size()-1){
                    q.push(a);
                    n++;
                }
            }
        }
        cout<<n<<endl;
        priority_queue<string,vector<string>,greater<string>> pq;
        while(!q.empty()){
            string k=q.front();
            pq.push(k);
            q.pop();
        }
        for(int i=0;i<n;i++){
            string k=pq.top();
            if(i<5 || i>=n-5) cout<<k<<endl;
            pq.pop();
        }
    }
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
 
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  int N;
  cin >> N;

  vector<int> A(N);
  int m2 = 0, m4 = 0;
  REP(i, N) {
    cin >> A[i];
    if ( A[i] % 4 == 0 ) {
      m4++;
    } else if ( A[i] % 2 == 0 ) {
      m2++;
    }
  }

  if ( m2 ) {
    N -= m2;
    if ( m4 >= (N+1)/2 ) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    if ( m4 >= N/2 ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3912
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n, q;
    cin >> n >> q;
    int s[200005], t[200005], x[200005];
    P p[400005];
    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i] >> x[i];
        p[i * 2] = P(s[i] - x[i], x[i]);
        p[i * 2 + 1] = P(t[i] - x[i], -x[i]);
    }
    sort(p, p + n * 2);
    set<int> st;
    int i = 0;
    while(q--){
        int d;
        cin >> d;
        while(i < n * 2 && p[i].first <= d){
            if(p[i].second > 0) st.insert(p[i].second);
            else st.erase(-p[i].second);
            i++;
        }
        if(st.empty()) cout << -1 << endl;
        else cout << *st.begin() << endl;
    }
}


Measured memory_bytes: 18304
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
s=0
for b in B:
    a=bisect.bisect_left(A,b)
    c=N-bisect.bisect_right(C,b)
    s+=a*c
print(s)


Measured memory_bytes: 23200
int main()
{
	/* ?????°??£?¨? */
	int x;				/* ??\??????	*/
	int i;				/* ???????????°	*/
	
	for( i = 1; i <= 10000; i++ ){
		/* ??\????????? */
		scanf( "%d", &x );
		
		if( x == 0 ){
			break;
		}
		else{
			printf("Case %d: %d\n", i, x );
		}
	}
	
	return 0;
}

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

int main() {
	double a,b;
    cin >> a >> b;
    if (a>b)
    cout << "GREATER" << endl;
    else
    if(a<b)
    cout << "LESS"<< endl;
    else
    cout << "EQUAL" << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n,k;
   cin>>n>>k;
   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   sort(a.begin(),a.end());
   int sum=0;
   rep(i,k){
      sum+=a.back();
      a.pop_back();
   }
   cout<<sum;
   return 0;
}

Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>)
{
    val (n, l) = readNInts()

    val aji = mutableListOf<Int>()
    for (i in 1..n) {
        aji.add(l + i - 1)
    }

    var nearest = 100000
    var idx = -1
    for (i in 0..n-1) {
        if (Math.abs(nearest) > Math.abs(aji[i])) {
            nearest = aji[i]
            idx = i
        }
    }

    var ans = 0
    for (i in 0..n-1) {
        if (i == idx) continue
        ans += aji[i]
    }

    println(ans)

}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


Measured memory_bytes: 36028
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	string s;
	while(1){
		int l=0,r=0,ans=0,pre=0;
		cin>>n;
		if(n==0) break;
		rep(i,0,n){
			cin>>s;
			if(s=="lu") l=1;
			if(s=="ru") r=1;
			if(s=="ld") l=0;
			if(s=="rd") r=0;
			if(l==r && l!=pre){
				ans++;
				pre=l;
			}
		}
		o(ans);
	}
}

Measured memory_bytes: 1204
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError : break      
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33764
#include <bits/stdc++.h>
//#define int long long 

using namespace std;
int dp[1000001][3];
int arr[10000001][3];
int solve(int n,int i)
{
    if(n < 0 )
        return 0;
    if(dp[n][i]!=-1)
        return dp[n][i];
    return dp[n][i]=max(arr[n][i%3]+solve(n-1,(i+1)%3),arr[n][i%3]+solve(n-1,(i+2)%3));
}

int main()
{
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
            cin>>arr[i][j];
    }
    int mx = max(solve(n-1,0),max(solve(n-1,1),solve(n-1,2)));
    cout<<mx<<endl;


}

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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  ll n, k, p;
  cin >> n >> k;
  vector<ll> v;
  REP(i, n) {
    cin >> p;
    v.push_back(p);
  }
  SORT(v);

  ll s = 0;
  REP(i, k) s += v[i];

  cout << s << endl;

  return 0;
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
    int N,M;
    cin >> N >> M;
    
    int ma[60][3];
    for(int m=0;m<M;m++){
        for(int j=0;j<2;j++){
            cin >> ma[m][j];
        }
    }
    
    int a[60] = {0};
     
    
    for(int k=0;k<N;k++){
    for(int i=0;i<M;i++){
        for(int j=0;j<2;j++){
            if(ma[i][j] == k+1) a[k]++;
        }
    }
    }
    
    for(int i=0;i<N;i++){
        cout << a[i] <<endl;
    }
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll a;
    cin >> a;
    ll b;
    cin >> b;
    ll c;
    cin >> c;
    ll d;
    cin >> d;
    ll e;
    cin >> e;
    ll k;
    cin >> k;
    if(e-a>k)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, k ] <- readInts
	hs <- readInts
	print $ length $ filter ( k <= ) hs

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N,MOD;
const ll FACN = 3005;
vector<ll> fact(FACN,1),factinv(FACN,1);
ll getPow(ll a,ll p){
  ll ret = 1,cp = a;
  while(p){
    if(p&1) ret = (ret*cp)%MOD;
    p >>= 1;
    cp = (cp*cp)%MOD;
  }
  return ret;
}
ll getInverse(ll a){
  return getPow(a,MOD-2)%MOD;
}
void init(ll l){
  for(ll i = 1; i < l; ++i){
    fact[i] = (fact[i-1]*i)%MOD;
    factinv[i] = (factinv[i-1]*getInverse(i))%MOD;
  }
}
ll C2(ll a,ll b){
  ll ans = fact[a+b];
  ans = (ans*factinv[a])%MOD;
  ans = (ans*factinv[b])%MOD;
  return ans;
}
ll C(ll n,ll a){
  return C2(a,n-a);
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll p;
  cin >> p;
  MOD = p;
  N = MOD;
  init(FACN);
  vector<ll> a(N),b(N);
  for(ll i = 0; i < N; ++i) cin >> a[i], b[0] += a[i];
  // f = sum_0^{N-1} a[i]*(1-(x-i)^(p-1))
  for(ll i = 0; i < N; ++i){
    ll tmp = 0;
    for(ll j = 0; j < N; ++j){
      tmp = (tmp-a[j]*C(N-1,i)*getPow(-j,N-1-i))%MOD;
    }
    b[i] = (b[i]+tmp)%MOD;
    cout << (b[i]+MOD)%MOD << ' ';
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define ll long long

using namespace std;
 
typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
int K;
int a;
vector<int> h;

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

  REP(i, N) {
    scanf("%d", &a);
    h.push_back(a);
  }

  std::sort(h.begin(), h.end(), std::greater<int>());

  int ans;
  ans = 0;

  REP(i, N) {
    if (h[i] < K) {
      break;
    }
    ans += 1;
  }

  printf("%d\n", ans);
}

Measured memory_bytes: 892
H,W=map(int,input().split())
minAns = float('inf')
for h in range(1,H+1):
    hh = -(-(H-h)//2)
    hd = -(-W//2)
    A = h*W
    B = hh*W
    C = (H-h-hh)*W
    D = hd*(H-h)
    E = (W-hd)*(H-h)
    M1 = max(A,B,C)
    m1 = min(A,B,C)
    M2 = max(A,D,E)
    m2 = min(A,D,E)
    minAns = min(minAns,M1-m1,M2-m2)
H,W = W,H
for h in range(1,H+1):
    hh = -(-(H-h)//2)
    hd = -(-W//2)
    A = h*W
    B = hh*W
    C = (H-h-hh)*W
    D = hd*(H-h)
    E = (W-hd)*(H-h)
    M1 = max(A,B,C)
    m1 = min(A,B,C)
    M2 = max(A,D,E)
    m2 = min(A,D,E)
    minAns = min(minAns,M1-m1,M2-m2)
print(minAns)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

vector<int> parent(100010);
vector<int> ran(100010);

void init(int n) {
	for (int i = 0; i < n; i++) {
		parent[i] = i;
		ran[i] = 0;
	}
}

int find(int x) {
	if (parent[x] == x) return x;
	else return parent[x] = find(parent[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (ran[x] < ran[y]) parent[x] = y;
	else {
		parent[y] = x;
		if (ran[x] == ran[y]) ran[x]++;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	init(n);
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> x(m), y(m);
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
		unite(x[i], y[i]);
	}
	int ans = 0;
	vector<set<int>> st(n, set<int>());
	for (int i = 0; i < n; i++) {
		st[find(i)].insert(a[i] - 1);
	}
	for (int i = 0; i < n; i++) {
		if (st[find(i)].count(i)) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11520
#include<stdio.h>
int main(void)
{
  int n,i,a=100000;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      a=a*5/100+a;
      
      if(a%1000!=0)
	{
	  a=a/1000;
	  a=a*1000+1000;
	}
      
    }
  
  printf("%d\n",a);
  
  return 0;
}

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

#define fio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define tc(t) int t; cin >> t; while (t--)
#define for0(i, n)  for(int i = 0; i < n; i++)
#define pb push_back
#define int long long 

void solve()
{
  // int x, y;
  // cin>>x>>y;
  // if((y - 2*x) % 2 != 0) {
  //   cout<<"No";
  //   return;
  // }
  
  // int t = (y - 2*x) / 2;
  // int c = x - t;
  // if(c < 0) {
  //   cout<<"No";
  // }
  // else {
  //   cout<<"Yes";
  // }
  
  int n, x;
  cin>>x>>n;
  if(n == 0) {
    cout<<x;
    return;
  }
  
  int aa[101], xx, l ,r;
  for0(i, 101)  aa[i] = i;
  set<int>s;
  for0(i, n) {
    cin>>xx;
    s.insert(xx);
  }
  
  //cout<<x<<" "<<aa[x];
  l = aa[x], r = aa[x];
  while(1) {
    if(s.find(l) == s.end()) {
      cout<<l;
      return;
    }
    if(s.find(r) == s.end()) {
      cout<<r;
      return;
    }
    --l; ++r;
  }
}

signed main() {

  fio;
  //tc(tt) {
    solve();
    cout<<"\n";
  //}
  
  return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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


int main() {
  ll n;cin >> n;
  if(!n){cout <<0;return 0;}
  string s;
  while(n!=1){
    s.pb(char(abs(n%2)+'0'));
    if(n>0)n=n/(-2);
    else n=(n-1)/(-2);
  }
  s.pb('1');
  reverse(ALL(s));
  cout <<s;
}

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

#define REALLOC_SIZE 256
#define NIL -1

typedef struct _node {
	int friendId;
	int childNum;
	int *childHead;
} node;

typedef struct _queue {
	int head;
	int tail;
	int *ary;
} queue;

void enqueu(queue *q, int value) {
	q->ary[q->tail++] = value;
}

int dequeue(queue *q) {
	return q->ary[q->head++];
}

void allocNode(node *p) {
	p->friendId = NIL;
	p->childNum = 0;
	p->childHead = (int *)malloc(sizeof(int) * REALLOC_SIZE);
}

int *getNewPtr(node *p) {
	int size;
	int *tmp;
	size = p->childNum / REALLOC_SIZE;
	tmp = (int *)realloc(p->childHead, sizeof(int) * REALLOC_SIZE * size);
	if (tmp == NULL) exit(1);
	return tmp;
}

void bfs(node *top, int cur, queue* q, int friendId) {
	int i, u, v;
	q->head = q->tail = 0;
	enqueu(q, cur);
	top[cur].friendId = friendId;
	while (q->head != q->tail) {
		u = dequeue(q);
		for (i = 0; i < top[u].childNum; i++) {
			v = top[u].childHead[i];
			if (top[v].friendId == NIL) {
				enqueu(q, v);
				top[v].friendId = friendId;
			}
		}
	}
}

void setFriendId(node *top,queue *q, int n) {
	int i, friendId;
	friendId = 0;
	for (i = 0; i < n; i++) {
		if (top[i].friendId == NIL) bfs(top, i, q, friendId++);
	}
}

int main() {
	int i, n, m, s, t, q, q1, q2;
	node *top;
	queue queue;

	scanf("%d %d", &n, &m);
	top = (node *)malloc(sizeof(node) * n);
	for (i = 0; i < n; i++) allocNode(&top[i]);
	queue.ary = (int *)malloc(sizeof(int) * n);

	for (i = 0; i < m; i++) {
		scanf("%d %d", &s, &t);
		top[s].childHead[top[s].childNum++] = t;
		top[t].childHead[top[t].childNum++] = s;
		if (top[s].childNum % REALLOC_SIZE == 0) top[s].childHead = getNewPtr(&top[s]);
		if (top[t].childNum % REALLOC_SIZE == 0) top[t].childHead = getNewPtr(&top[t]);
	}

	setFriendId(top, &queue, n);

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d %d", &q1, &q2);
		if (top[q1].friendId == top[q2].friendId) printf("yes\n");
		else printf("no\n");
	}

	for (i = 0; i < n; i++)	free(top[i].childHead);
	free(queue.ary);
	return 0;
}



Measured memory_bytes: 104968
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = (arg[0].split(" ")[0]);
    const last = N.split("")[N.length-1];
    
    if(
        last === "2" ||
        last === "4" ||
        last === "5" ||
        last === "7" ||
        last === "9"
    ) {
        console.log("hon");
    } else if (
        last === "0" ||
        last === "1" ||
        last === "6" ||
        last === "8"
    ) {
        console.log("pon");
    } else {
        console.log("bon");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29620
ans=0
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
for i in range(N):
  A=list(map(int,input().split()))
  s=0
  for j in range(M):
    s+=A[j]*B[j]
  if s+C>0:
    ans+=1
print(ans)

Measured memory_bytes: 8892