akhauriyash/Code-Regression huggingface dataset:
class Tree
	def initialize(key)
		@key = key
		@left = nil
		@right = nil
	end

	def insert(k)
		if @key > k
			if !@left
				@left = Tree.new(k)
			else
				@left.insert(k)
			end

		else
			if !@right
				@right = Tree.new(k)
			else
				@right.insert(k)
			end
		end
	end

	def inorder(list)
		if @left
			list = @left.inorder(list)
		end
		list << @key
		if @right
			list = @right.inorder(list)
		end
		list
	end

	def preorder(list)
		list << @key
		if @left
			list = @left.preorder(list)
		end
		if @right
			list = @right.preorder(list)
		end
		list
	end
end

n = gets.to_i
head = nil

n.times do
	num = gets.to_s.chomp!
	if num == "print"
		puts " #{head.inorder([]).join(" ")}"
		puts " #{head.preorder([]).join(" ")}"
	else
		num = num.split
		if head
			head.insert(num[1].to_i)
		else
			head = Tree.new(num[1].to_i)
		end


	end

end

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

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

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int sample;
int num[10];
map<string,int> table;

bool good(int a,int b,int c){
	if((a==b&&b==c)||(a+1==b&&b+1==c)){
		return true;
	}
	else {
		return false;
	}
}
bool all_good(int* num){
	return good(num[0],num[1],num[2]) && good(num[3],num[4],num[5]) && good(num[6],num[7],num[8]);
}
int win(int* num){
sort(num,num+9);
	do{
		if(all_good(num)){
			return 1;
		}
	}while(next_permutation(num,num+9));
	return 0;
}

int main(){
	table["R"]=0;
	table["G"]=10;
	table["B"]=20;
	cin>>sample;
	for(int i=0;i<sample;i++){
		for(int j=0;j<9;j++){
			cin>>num[j];
		}
	    string color;
		for(int j=0;j<9;j++){
			cin>>color;
			num[j]+=table[color];
		}
		cout<<win(num)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

struct edge {
	int to;
	int id;
};

vector<vector<edge>> tree;
vector<int> ans;

void dfs(int v, int p = -1, int c = -1) {
	int col = 1;
	rep(i, sz(tree.at(v))) {
		if (col == c) {
			col++;
		}
		if (tree.at(v).at(i).to == p) {
			continue;
		}
		ans.at(tree.at(v).at(i).id) = col;
		dfs(tree.at(v).at(i).to, v, col);
		col++;
	}
}

int main() {
	int N;
	cin >> N;
	tree.resize(N);
	ans.resize(N - 1);
	vector<int> a(N - 1);
	vector<int> b(N - 1);
	rep(i, N - 1) {
		cin >> a.at(i) >> b.at(i);
		a.at(i)--;
		b.at(i)--;
		tree.at(a.at(i)).push_back({ b.at(i), i });
		tree.at(b.at(i)).push_back({ a.at(i), i });
	}
	dfs(0);
	int mx = 0;
	rep(i, N) {
		int s = sz(tree.at(i));
		chmax(mx, s);
	}
	cout << mx << endl;
	rep(i, N - 1) {
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 10880
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int x,a;
  cin >> x >> a;

  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;

  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    if(n%2 == 0){
        cout << n << endl;
    }
    else{
        cout << 2*n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort()
Q.sort()
R.sort()
P = P[::-1]
Q = Q[::-1]
R = R[::-1]
D = P[:X] + Q[:Y] + R
D.sort()
D = D[::-1]
D = D[:X+Y]
ans = sum(D)
print(ans)

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

			string str = Console.ReadLine();
			var ss = new List<string>();

			foreach (var a in str) {
				ss.Add(a.ToString());
			}

			int n = 0;
			int s = 0;
			int e = 0;
			int w = 0;

			foreach (var a in ss) {
				if (a == "N") {
					++n;
				} else if (a == "S") {
					++s;
				} else if (a == "E") {
					++e;
				} else {
					++w;
				}
			}

			string result = "";

			if (n >= 1 && s >= 1 && e >= 1 && w >= 1) {
				result = "Yes";
			} else if (n >= 1 && s >= 1 && e == 0 && w == 0) {
				result = "Yes";
			} else if (n == 0 && s == 0 && e >= 1 && w >= 1) {
				result = "Yes";
			} else if (n == 0 && s == 0 && e == 0 && w == 0) {
				result = "Yes";
			} else {
				result = "No";
			}

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13248
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		if(n == 1) {
			int val = 0;
			if(m > 0) {
				in.nextInt();
				int prev = in.nextInt();
				boolean flag = true;
				for(int i = 0; i < m - 1; i++) {
					in.nextInt();
					if(in.nextInt() != prev) {
						flag = false;
						break;
					}
				}
				if(flag == true) val = prev;
				else val = -1;
			}
			System.out.println(val);
		}else {
			int[] ans = new int[n];
			boolean[] flag = new boolean[n];
			for(int i = 0; i < m; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				x -= 1;
				if(flag[x] == false) {
					if((x == 0) && (y == 0)) {
						ans[x] = -1;
						break;
					}
					ans[x] = y;
					flag[x] = true;
				}else {
					if(ans[x] != y) {
						ans[0] = -1;
						break;
					}
				}
			}
			if(ans[0] == -1) {
				System.out.println("-1");
			}else {
				if(ans[0] == 0) ans[0] = 1;
				for(int i = 0; i < n; i++) {
					System.out.print(ans[i]);
				}
				System.out.print("\n");
			}
		}
	}
} 

Measured memory_bytes: 21844
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		out.println(n%2==0?n:n*2);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    int n,k;
    cin>>n>>k;
    vector<ll> w(n), v(n);
    rep(i,0,n){
        cin>>w[i]>>v[i];
    }
    int tot = accumulate(all(v),0);
    vector<ll>dp(tot+1,INT_MAX);
    dp[0] = 0;
    for (int i = 0 ; i <n ; i++){
        for (ll val = tot - v[i] ; val>=0; val--){
            dp[val + v[i]] = min(dp[val + v[i]],dp[val] + w[i]);
        }
    }
    //cout<<dp[30]<<endl;
    int mxval = 0;
    for (int i=  0 ; i<=tot;i++){
        if (dp[i]<=k)mxval = max(mxval,i);
    }
    cout<<mxval<<endl;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,s=0; cin >> n; int l[n];
	for(int i=0;i<n;i++) cin >> l[i];
	sort(l,l+n);
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			int k=j+1;
			while(l[i]+l[j]>l[k] && k<n)
			{
				s++; k++;
			}
		}
	}
	cout << s;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		// 2020/2/2 No.153
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int h = Integer.parseInt(str[0]);
		int a = Integer.parseInt(str[1]);

		br.close();

		if(h % a == 0) {
			System.out.println(h / a);
		} else {
			System.out.println((h / a) + 1);
		}
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define ull unsigned long long
#define mod 1000000007
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define str string
#define p(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define all(v) v.begin(), v.end()
#define test cout<<"LOL_ABHISHEK"<<endl;
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//kehsihba();
	ll n;cin>>n;
	if(n%10==3){cout<<"bon";}
	else if(n%10==0 or n%10==1 or n%10==6 or n%10==8){
		cout<<"pon";
	}
	else{
		cout<<"hon";}
	
	return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    cin >> t;

    ll ans = 0;
    ll ct = 0;
    REP(i, N) {
        ans += T;
        if (ct > t[i]) {
            ans -= (ct - t[i]);
        }
        ct = t[i] + T;
    }

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

Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

l = [0,*a,0]


s = 0
for i in range(1, n + 2):
    s += abs(l[i] - l[i - 1])

for i in range(1, n + 1):
    delcost = abs(l[i + 1] - l[i]) + abs(l[i] - l[i - 1])
    addcost = abs(l[i + 1] - l[i - 1])
    print(s - delcost + addcost)

Measured memory_bytes: 19008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, 0, 1000) {
        string t;
        int x = i;
        rep(j, 0, 3) {
            t += '0' + x % 10;
            x /= 10;
        }
        int ti = 0;
        rep(j, 0, n) {
            if (s[j] == t[ti]) {
                ti++;
                if (ti == 3) break;
            }
        }
        if (ti == 3) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int n;
  cin >> n;
  map<P, int> nset;
  FOR(i, 1, 9) {
    FOR(j, 1, 9) {
      nset[P(i, j)] = 0;
    }
  }
  FOR(i, 1, n) {
    int num = i;
    int fin = num % 10;
    if (fin == 0) continue;
    int init;
    W1 {
      if (num / 10 == 0) {
        init = num;
        break;
      }
      num /= 10;
    }
    nset[P(init, fin)]++;
  }
  ll ans = 0;
  FOR(i, 1, 9) {
    FOR(j, 1, 9) {
      ans += nset[P(i, j)] * nset[P(j, i)];
    }
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 3480
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;
int dp[1002][1002];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s1,s2;
	while(n--){
		cin>>s1>>s2;
		FOR(i,1,s1.size()+1){
			FOR(j,1,s2.size()+1){
				if(s1[i-1] == s2[j-1])dp[i][j] = dp[i-1][j-1]+1;
				else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
		cout << dp[s1.size()][s2.size()] << endl;
	}
  return 0;
}

Measured memory_bytes: 7024
use std::io;
use std::collections::HashSet;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n = buf.trim().parse::<i32>().ok().unwrap();
	let mut flag = true;
	let mut set = HashSet::new();
	let mut v:Vec<String> = Vec::new();
	for i in 0..n {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let s1 = buf.clone();
		let s2 = buf.clone();
		if !set.insert(s1.trim().to_string()) {
			flag = false;
			break;
		}else{
			v.push(s2.trim().to_string());
		}
	}
	/*for i in &v {
		println!("{}", i);
	}*/
	if flag {
		for i in 1..n {
			let a:Vec<char> = v[i as usize].chars().collect();
			let b:Vec<char> = v[(i-1) as usize].chars().collect();
			if a[0] != b[b.len() - 1] {
				flag = false;
				break;
			}
		}
		if flag {
			println!("Yes");
		}else{
			println!("No");
		}
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n,m,k = map(int,stdin.readline().rstrip().split())
mod = 998244353
wariate = 1
point = 0

def prepare(n, MOD=mod):
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs
facts, invs = prepare(n, mod)
for i in range(n-1,-1,-1):
    now = m
    if i != n-1:
        wariate *= m-1
        wariate %= mod
    now *= wariate%mod

    now *= facts[n-1]*invs[n-1-i]*invs[i]
    if i <= k:
        point += now%mod

print(point%mod)

Measured memory_bytes: 73960
# DP
INF = float('inf')

N, Ma, Mb = map(int, input().split())

cmax = N * 10
t = [[INF] * (cmax + 1) for _ in range(cmax + 1)]
for _ in range(N):
    a, b, c = map(int, input().split())
    for aa in range(cmax, 0, -1):
        for bb in range(cmax, 0, -1):
            if t[aa][bb] == INF:
                continue
            t[aa + a][bb + b] = min(t[aa + a][bb + b], t[aa][bb] + c)
    t[a][b] = min(t[a][b], c)

result = INF
for a in range(1, cmax):
    for b in range(1, cmax):
        if a * Mb == b * Ma:
            result = min(result, t[a][b])
if result == INF:
    result = -1
print(result)


Measured memory_bytes: 4848
import java.util.*;
import java.io.*;

public class Main {
    public static int max = 2000001;
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        long k = Long.parseLong(f.readLine());
        long val = 7;
        boolean found = false;
        for(int i = 1; i <= max; i++){
            if(val % k == 0){
                out.println(i);
                found = true;
                break;
            }
            else{
                val = (10*val+7)%k;
            }
        }
        if(!found) out.println(-1);




        out.close();
    }
}


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

int main(int argc, char const *argv[])
{
	int h, a; cin >> h >> a;
	cout << (h + a - 1) / a << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion
const ll N = 200009;


pls give {
    AC;
    int n;
    cin >> n;
    if (n%2 == 0) cout << n;
    else cout << n*2; 
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll solve(VLL &w, VLL &v, ll W){
  ll n = w.size();
  VVLL dp(n + 1, VLL(W + 1,0));
  rep(i,n){
    rep(j,W+1){
      if(j < w[i]){
        dp[i+1][j] = dp[i][j];
      } else {
        dp[i+1][j] = max<ll>(dp[i][j] , dp[i+1][j-w[i]] + v[i]);
      }
    }
  }
  return dp[n][W];
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  ll r[2][3];
  cin >> n;
  cin >> r[0][0] >> r[0][1] >> r[0][2];
  cin >> r[1][0] >> r[1][1] >> r[1][2];

  // step A->B
  {
    VLL w,v;
    rep(i,3){
      if( r[0][i] < r[1][i] ) {
        w.push_back(r[0][i]);
        v.push_back(r[1][i] - r[0][i]);
      }
    }
    ll add = 0;
    if(w.size() > 0) add = solve(w,v,n);
    if(add > 0) n += add;
  }

  // step B -> A
  {
    VLL w2,v2;
    rep(i,3){
      if( r[1][i] < r[0][i] ) {
        w2.push_back(r[1][i]);
        v2.push_back(r[0][i] - r[1][i]);
      }
    }
    ll add = 0;
    if(w2.size() > 0){
      add = solve(w2,v2,n);
    }
    if(add > 0) n += add;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 773632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

const int MOD = 1000000007;

int main(){
	int N, W;
	static int dp[201][10001];
	while(cin >> N >> W){
		vector<int> w(N);
		for(int i=0;i<N;i++) cin >> w[i];
		sort(w.begin(), w.end());
		memset(dp, 0, sizeof(dp));
		dp[N][0] = 1;
		for(int i=N-1;i>=0;i--){
			for(int j=i+1;j<=N;j++){
				for(int k=W;k>=0;k--){
					dp[i][k] = (dp[i][k]+dp[j][k])%MOD;
					if(k+w[i]<=W) dp[j][k+w[i]] = (dp[j][k+w[i]]+dp[j][k])%MOD;
					dp[j][k] = 0;
				}
			}
		}
		int res = 0;
		for(int i=0;i<=N;i++){
			for(int j=0;j<=W;j++){
				if(i==N || j+w[i] > W) res = (res+dp[i][j])%MOD;
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 9072
#include <stdio.h>

int main(void){
    int n, m;
    char p;
    int tempFlag = 1, flag = 0;
    scanf("%d %d\n", &n, &m);
    char a[n][n+1], b[m][m+1];
    //printf("%d,%d",n,m);
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= n;j++){
            scanf("%c", &a[i][j]);
            //printf("a[i][j] = %c\n",a[i][j]);
        }
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j <= m;j++){
            scanf("%c", &b[i][j]);
            //printf("b[i][j] = %c\n",b[i][j]);
        }
    }

    /*for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            printf("%c\n",a[i][j]);
        }
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j < m;j++){
            printf("%c\n",b[i][j]);
        }
    }*/

    for(int i = 0;i <= n - m;i++){
        for(int l = 0;l <= n - m;l++){
            tempFlag = 1;
            for(int j = 0;j < m;j++){
                for(int k = 0;k < m;k++){
                    if(a[i+j][l+k] == b[j][k]){
                        tempFlag = tempFlag && 1;
                        //printf("match : ");
                        //printf("%c,%c\n",b[j][k],a[i][l]);
                    }else{
                        tempFlag = tempFlag && 0;
                        //printf("NotMatch : %c,%c\n",b[j][k],a[i][l]);
                    }
                }
            }
            if(tempFlag == 1){
                flag = 1;
                break;
            }
            //printf("comp\n");
        }
        if(tempFlag == 1){
                flag = 1;
                break;
        }
        //printf("comp\n");

    }
    printf("%s", (flag == 1) ? "Yes\n" : "No\n");
    //printf("%d", 1 && 0);
    return 0;
}


Measured memory_bytes: 128
# code-festival-2016-qualaB - 仲良しうさぎ / Friendly Rabbits
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    ans, cand = 0, set()
    for i, j in enumerate(A, 1):
        i, j = min(i, j), max(i, j)
        if (i, j) in cand:
            ans += 1
            cand.discard((i, j))
        else:
            cand |= {(i, j)}
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 22500
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main(void){
  int n,k;
  string str;
  cin >> n;
  cin >> str;
  cin >> k;
  char c = str[k - 1];

  for(int i = 0; i != n; i++){
    if(str[i] == c)cout << c;
    else cout << '*';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int k, x;
  scanf("%d%d", &k, &x);
  for (int i = x - (k - 1); i <= x + (k - 1); ++i) {
    if (i > x - (k - 1)) {
      putchar(' ');
    }
    printf("%d", i);
  }
  putchar('\n');
}


Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int n;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9) puts("hon");
	else if(n==3) puts("bon");
	else puts("pon");
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int n, m, a, b;
  int i, ans[100] = {0};

  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    ans[a]++;
    ans[b]++;
  }

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

  return 0;
}


Measured memory_bytes: 128
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    static int n,a[400000];
    static int b[400000]={};
    int flg=0;
    int sum=0;
    int m=0;
    static int ans_list[400000],ans_i=0;


    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]==1)flg=1;
    }

    for(int i=n/2;i<n;i++){
        b[i]=a[i];
        if(b[i]){
            ans_list[ans_i++]=i+1;
        }
    }
    if(!flg){
        printf("0\n");
        return 0;
    }

    
    for(int i=n/2-1;i>=0;i--){
        sum=0;
        for(int j=i;j<n;j+=(i+1)){
            sum+=b[j];
        }
        if(sum%2!=a[i]){
            b[i]++;
        }
        if(b[i]){
            ans_list[ans_i++]=i+1;
        }
    }

    qsort(ans_list,ans_i,sizeof(int),asc);
    printf("%d\n",ans_i);
    for(int i=0;i<ans_i;i++){
        printf("%d ",ans_list[i]);
    }
    printf("\n");
    return 0;


    


}

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

int dp[3002][3002];

int main() {

	string s,t;
	cin>>s>>t;

	int n,m;
	n = s.size(),m = t.size();


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

	for (int i = 0; i <= m; ++i)
	{
		dp[0][i]=0;
	}

	for (int i = 1; i <= n ; ++i)
	{
		for (int j = 1; j <=m ; ++j)
		{
			if(s[i-1]==t[j-1]) {
				dp[i][j] = dp[i-1][j-1]+1;
			}
			else {
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	// cout<<dp[n][m]<<endl;

	int len = dp[n][m];
	stack<char> lcs;

	// for (int i = 0; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= m; ++j)
	// 	{
	// 		cout<<dp[i][j]<<"  ";
	// 	}
	// 	cout<<endl;
	// }

	int row = n,col = m;
	while(row>0 && col>0) {
		if(s[row-1] == t[col-1]) {
			lcs.push(s[row-1]);
			row--;
			col--; 
		}
		else if(dp[row][col-1]>dp[row-1][col]){
			col--;
		}
		else {
			row--;
		}
	}

	if(lcs.empty()) {
		cout<<" ";
	}

	while(!lcs.empty()) {
		cout<<lcs.top();
		lcs.pop();
	}

	return 0;
}

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

typedef long long ll;

ll N;
ll A[200010];
map<ll, ll> mp;

int main()
{
    cin >> N;
    for(ll i = 0; i < N; i++)
    {
        cin >> A[i];
        mp[A[i] - i]++;
    }

    ll ans = 0;
    for(ll i = 0; i < N; i++)
    {
        ll num = -A[i] - i;
        mp[A[i] - i]--;
        ans += mp[num];
    }

    cout << ans << endl;
}


Measured memory_bytes: 27724
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
struct k{
	int x,y,cnt;
};
int i,i2,xx,yy,X,Y,map[1001][1001],b[1001][1001],mi,st[11][3],t,cntsum=0;
int main(){
	k ii;
	queue<k> Q;
	char d,z[1001][1001];
	cin>>Y>>X>>t;
	for(i=0;i<Y;i++){
		for(i2=0;i2<X;i2++){
			map[i2][i]=0;
			cin>>d;
			switch (d){
				case 'S':
					st[0][1]=i2;
					st[0][2]=i;
					break;
				case '.':
					break;
				case 'X':
					map[i2][i]=-1;
					break;
				case '1':
					st[1][1]=i2;
					st[1][2]=i;
					break;
				case '2':
					st[2][1]=i2;
					st[2][2]=i;
					break;
				case '3':
					st[3][1]=i2;
					st[3][2]=i;
					break;
				case '4':
					st[4][1]=i2;
					st[4][2]=i;
					break;
				case '5':
					st[5][1]=i2;
					st[5][2]=i;
					break;
				case '6':
					st[6][1]=i2;
					st[6][2]=i;
					break;
				case '7':
					st[7][1]=i2;
					st[7][2]=i;
					break;
				case '8':
					st[8][1]=i2;
					st[8][2]=i;
					break;
				case '9':
					st[9][1]=i2;
					st[9][2]=i;
					break;
			}
		}
	}
	/*for(i=0;i<Y;i++){
		for(i2=0;i2<X;i2++){
			cout<<map[i2][i]<<' ';
		}
	cout<<endl;
	}
	cout<<endl;*/
	int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
	for(int w=0;w<t;w++){
		for(int ww=0;ww<Y;ww++)for(int www=0;www<X;www++)b[www][ww]=0;
		mi=999999999;
		ii.x=st[w][1];
		ii.y=st[w][2];
		ii.cnt=0;
		Q.push(ii);
		b[st[w][1]][st[w][2]]=1;
		map[st[w+1][1]][st[w+1][2]]=2;

		while(!Q.empty()){
			for(int I=0;I<4;I++){
				ii=Q.front();
				xx=ii.x+dx[I];
				yy=ii.y+dy[I];
				if(xx>=0&&yy>=0&&xx<X&&yy<Y&&map[xx][yy]!=-1&&b[xx][yy]!=1){
					ii.x=xx;
					ii.y=yy;
					ii.cnt++;
					Q.push(ii);
					b[xx][yy]=1;
		
					/*for(i=0;i<Y;i++){
						for(i2=0;i2<X;i2++){cout<<b[i2][i]<<' ';
						}
						cout<<endl;
					}
					cout<<"x="<<ii.x<<' '<<"y="<<ii.y<<' '<<"cnt="<<ii.cnt<<endl;*/
		
				}
				if(map[ii.x][ii.y]==2){
					mi=min(mi,ii.cnt);
					//cout<<"x="<<ii.x<<' '<<"y="<<ii.y<<' '<<"cnt="<<ii.cnt<<endl;
				}
			}
			Q.pop();
		}

		map[st[w+1][1]][st[w+1][2]]=0;
		cntsum+=mi;
	}
	cout<<cntsum<<endl;
}

Measured memory_bytes: 10928
#include<stdio.h>
int main(void)
{
	int a, b, c, x;
	scanf("%d %d %d", &a, &b, &c);
	if(a < b){
	if(a < c){
	if(b < c){printf("%d %d %d\n", a, b, c);}
	else{printf("%d %d %d\n", a, c, b);}}
	else{printf("%d %d %d\n", c, a, b);}}
	else{
	if(a < c){printf("%d %d %d\n", b, a, c);}
	else{
	if(b < c){printf("%d %d %d\n", b, c, a);}
	else{printf("%d %d %d\n", c, b, a);}}}
	return 0;
}

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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,m,c;
	cin>>n>>m>>c;
	vector<int> v;
	REP(i,m){
		int b;
		cin>>b;
		v.push_back(b);
	}
	int ans=0;
	REP(i,n){
		int sum=c;
		REP(i,m){
			int a;
			cin>>a;
			sum+=a*v[i];
		}
		if(sum>0) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val hVector = Vector.fill(n)(sc.nextInt)

    val count = (2 to n).count(i => hVector.take(i - 1).forall(h => h <= hVector(i - 1)))
    println(count + 1)
  }
}


Measured memory_bytes: 25552
#include <bits/stdc++.h>
using namespace std;
string s;
int mod = 1e9+7,n;
vector<vector<int> > dp(1e5,vector<int>(13,-1));
 
int digit_dp(int idx,int sum){
	if(idx==n)
		return sum==5?1:0;
	if(s[idx]!='?')
		return dp[idx][sum] = digit_dp(idx+1,(sum*10+s[idx]-48)%13);
	if(dp[idx][sum]==-1){
		dp[idx][sum]++;
		for(int i=0;i<10;i++)
			dp[idx][sum] = (dp[idx][sum]+digit_dp(idx+1,(sum*10+i)%13))%mod;
	}
	return dp[idx][sum];
}
 
int main()
{
    cin >> s;
    n = s.size();
    cout << digit_dp(0,0);
    return 0;
}

Measured memory_bytes: 19836
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int a, b, c;
  cin >> a >> b >> c;
  int d = a/(b+c);
  int ans = b*d + min(a-(b+c)*d, b);
  cout << ans << endl;

}

Measured memory_bytes: 256
char m[14][14];

solve(i,j){
  m[i][j]='0';
  if(m[i][j-1]-'0')solve(i,j-1);
  if(m[i-1][j]-'0')solve(i-1,j);
  if(m[i+1][j]-'0')solve(i+1,j);
  if(m[i][j+1]-'0')solve(i,j+1);
}

main(){
  int w=12,h=12,i,j,r;
  for(;;printf("%d\n",r)){
    memset(m,'0',sizeof(m));
    r=0;
    for(i=1;i<=h;m[i][13]='0',i++)
      if(scanf("%s",m[i]+1)==-1)return 0;
    for(i=1;i<=h;i++)
      for(j=1;j<=w;j++)
        if(m[i][j]-'0')solve(i,j),r++;
  }
}

Measured memory_bytes: 544
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int mornint_start,morning_end,lunch_start,lunch_end,dinner_start,dinner_end;
};

int calc(int hour,int minute){
	return 60*hour+minute;
}

int main(){

	int N;
	scanf("%d",&N);

	Info info[N];

	vector<int> MORNING,LUNCH,DINNER;

	int m_st_h,m_st_m,m_ed_h,m_ed_m,l_st_h,l_st_m,l_ed_h,l_ed_m,d_st_h,d_st_m,d_ed_h,d_ed_m;
	for(int i = 0; i < N; i++){
		scanf("%d %d %d %d %d %d %d %d %d %d %d %d",&m_st_h,&m_st_m,&m_ed_h,&m_ed_m,&l_st_h,&l_st_m,&l_ed_h,&l_ed_m,&d_st_h,&d_st_m,&d_ed_h,&d_ed_m);

		info[i].mornint_start = calc(m_st_h,m_st_m);
		info[i].morning_end = calc(m_ed_h,m_ed_m);
		MORNING.push_back(info[i].mornint_start);
		MORNING.push_back(info[i].morning_end);

		info[i].lunch_start = calc(l_st_h,l_st_m);
		info[i].lunch_end = calc(l_ed_h,l_ed_m);
		LUNCH.push_back(info[i].lunch_start);
		LUNCH.push_back(info[i].lunch_end);

		info[i].dinner_start = calc(d_st_h,d_st_m);
		info[i].dinner_end = calc(d_ed_h,d_ed_m);
		DINNER.push_back(info[i].dinner_start);
		DINNER.push_back(info[i].dinner_end);
	}

	sort(MORNING.begin(),MORNING.end());
	sort(LUNCH.begin(),LUNCH.end());
	sort(DINNER.begin(),DINNER.end());

	MORNING.erase(unique(MORNING.begin(),MORNING.end()),MORNING.end());
	LUNCH.erase(unique(LUNCH.begin(),LUNCH.end()),LUNCH.end());
	DINNER.erase(unique(DINNER.begin(),DINNER.end()),DINNER.end());

	int ans = 0,tmp;

	for(int a = 0; a < MORNING.size(); a++){
		for(int b = 0; b < LUNCH.size(); b++){
			for(int c = 0; c < DINNER.size(); c++){
				tmp = 0;
				for(int i = 0; i < N; i++){
					if(info[i].mornint_start <= MORNING[a] && info[i].morning_end >= MORNING[a] &&
					   info[i].lunch_start <= LUNCH[b] && info[i].lunch_end >= LUNCH[b] &&
					   info[i].dinner_start <= DINNER[c] && info[i].dinner_end >= DINNER[c]){
						tmp++;
					}
				}
				if(tmp > ans){
					ans = tmp;
				}
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 3268
x, n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    i = 0
    flag = False
    ans = 0
    while True:
        x_minus = x-i
        x_plus = x+i
        if x_plus not in p:
            ans = x_plus
            flag = True
        if x_minus not in p:
            ans = x_minus
            flag = True
        if flag:
            break
        else:
            i += 1
    print(ans)
    
else:
    print(x)


Measured memory_bytes: 61648
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
  string s;
  cin >> s;
  int length = s.length();
  int sum = 0;
  for (int i = 0; i < length; ++i) {
    char c = s[i];
    sum += int(c-'0');
  }
  if(sum%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3360
n,k = map(int, input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans = Base_10_to_n(n,k)
print(len(ans))

Measured memory_bytes: 3060
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
/*int gcd(int n,int m)
{
	if(m==0)
		return n;

	return gcd(m, n % m);
}*/
int a,b,c,d;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin>>a>>b>>c>>d;
	if((abs(a-c)<=d)||(abs(a-b)<=d&&abs(b-c)<=d))
		cout<<"Yes\n";
	else
		cout<<"No\n";

	return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::sort;
using std::abs;

using std::fixed;
using std::setprecision;
using std::setw;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 314;

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool ans = true;
    for (int i = 0; i < a; i++) {
        if (!('0' <= s[i] && s[i] <= '9')) {
            ans = false;
        }
    }

    if (!(s[a] == '-')) {
        ans = false;
    }

    for (int i = a + 1; i < a + b + 1; i++) {
        if (!('0' <= s[i] && s[i] <= '9')) {
            ans = false;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int main(){
  int a,b;
  cin>>a>>b;

  if(a+b==15)
    cout<<'+'<<endl;
  else if(a*b==15)
    cout<<'*'<<endl;
  else
    cout<<'x'<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std ;
int main()
{
    int n ;
    cin >> n ;
    string a,b;
    cin >> a >> b ;
    for(int i=0;i<n;i++)
    {
        cout << a[i] << b[i] ;
    }
    cout << endl;
    return 0;
}


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

int main(){
  int n; cin >> n;
  vector<int> t(n); rep(i,n) cin >> t[i];
  int m; cin >> m;
  
  rep(i,m){
    vector<int> tmp(n); copy(t.begin(),t.end(),tmp.begin());
    int p,x; cin >> p >> x;
    tmp[p-1] = x;
    int sum = accumulate(tmp.begin(),tmp.end(),0);
    cout << sum << endl;
  }
}

Measured memory_bytes: 3580
S=list(input())
n=len(S)
ans=0
for i in range(2**(n-1)):
  A=[0]
  s=format(i,"12b")
  for j in range(1,n):
    if s[-j]=="1":
      A.append(j)
  A.append(n)
  for j in range(len(A)-1):
    a=""
    for k in range(A[j+1]-A[j]):
      a=a+S[A[j]+k]
    ans=ans+int(a)
print(ans)

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

int main(){
   int n;
   int a[1000];
   cin >> n;
   for(int i=0;i < n;i++){
       cin >> a[i];
   }
   cout << a[n-1];
   for(int i=1;i < n;i++){
       cout << " " << a[n-i-1];
   }
   cout << endl;
}


Measured memory_bytes: 3084
import java.util.*;class Main{public static void main(String[]z){int a,b=0,t,i;for(Scanner s=new Scanner(System.in);;System.out.printf("%c %d\n",a+64,b),b=0)for(i=a=0;i++<5;)if((t=s.nextInt()+s.nextInt())<1)return;else if(b<t){b=t;a=i;}}}

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

int n, m;
vector<int> p(100010,0);

vector<bool>memo(100010,false);
multimap<int,int>mp;

int dfs(int i)
{
    if (memo[i]|| p[i] == 0)
        return p[i];
    for(auto j=mp.lower_bound(i);j!=mp.upper_bound(i);j++)
    p[i] = max(p[i], 1 + dfs(j->second));
    
    memo[i] = true;
    return p[i];
}

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

    cin >> n >> m;
    
    rep(i, m)
    {
        int s,t;
        cin>>s>>t;
        mp.insert(make_pair(s,t));
        p[s] = 1;
    }
    

    int ans = 0;
    forx(i, 1, n + 1) ans = max(ans, dfs(i) );

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8832
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
//		StringBuilder out = new StringBuilder();
		int k = sc.nextInt();
		int n = sc.nextInt();
		if(k*500 >= n) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
	static int calc(int[] arr, int n) {
		int res = 0;
		boolean[] seen = new boolean[n];
		for(int i = 0; i < n-1; i++) {
			int k = 0;
			for(int j = 0; j < n; j++) {
				if(!seen[j] && j < arr[i]) k++;
			}
			seen[arr[i]] = true;
			res += k;
			res *= (n-i-1);
		}
		return res;
	}

	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


Measured memory_bytes: 22484
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;

class Program
{

    static void Main(string[] args)
	{
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');

        int N = int.Parse(input[0]);
        int X = int.Parse(input[1]);
        int T = int.Parse(input[2]);

        var i = N / X;
        if (N % X != 0) i++;



        Console.WriteLine(i * T);
    }
}

Measured memory_bytes: 17900