akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;

struct tree{
  int t[N * 4], pos[N * 4];
  void build(int *a, int v, int tl, int tr){
    if(tl == tr){
      t[v] = a[tl];
      pos[v] = tl;
      return;
    }
    int tm = (tl + tr) >> 1;
    build(a, v * 2, tl, tm);
    build(a, v * 2 + 1, tm + 1, tr);
    t[v] = min(t[v * 2], t[v * 2 + 1]);
    pos[v] = (t[v * 2] < t[v * 2 + 1] ? pos[v * 2] : pos[v * 2 + 1]);
  }

  pii get(int v, int tl, int tr, int l, int r){
    if(l > r){
      return {inf, inf};
    }
    if(l == tl && r == tr){
      return make_pair(t[v], pos[v]);
    }
    int tm = (tl + tr) >> 1;
    pii a = get(v * 2, tl, tm, l, min(r, tm));
    pii b = get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
    return min(a, b);
  }
}t1, t2;

int n;
int p[N], p1[N], p2[N];
vector < int > ans;
set < pair < int, pii > > s;

int get(int l, int r){
  if(l % 2){
    return t1.get(1, 1, n, l, r).first;
  } else{
    return t2.get(1, 1, n, l, r).first;
  }
}

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%d", p + i);
    if(i % 2){
      p1[i] = p[i];
      p2[i] = inf;
    } else{
      p2[i] = p[i];
      p1[i] = inf;
    }
  }
  t1.build(p1, 1, 1, n);
  t2.build(p2, 1, 1, n);
  s.insert(make_pair(get(1, n), make_pair(1, n)));
  while(!s.empty()){
    int l = (*s.begin()).second.first;
    int r = (*s.begin()).second.second;
    s.erase(s.begin());
    int id1, id2;
    if(l % 2){
      id1 = t1.get(1, 1, n, l, r).second;
      id2 = t2.get(1, 1, n, id1, r).second;
    } else{
      id1 = t2.get(1, 1, n, l, r).second;
      id2 = t1.get(1, 1, n, id1, r).second;
    }
    assert(id1 != id2 && id1 < id2);
    assert(((id1 % 2) == (l % 2)) && ((id2 % 2) != (l % 2)));
    ans.push_back(p[id1]);
    ans.push_back(p[id2]);
    if(id1 > l){
      s.insert({get(l, id1 - 1), {l, id1 - 1}});
    }
    if(id1 + 1 <= id2 - 1){
      s.insert({get(id1 + 1, id2 - 1), {id1 + 1, id2 - 1}});
    }
    if(id2 < r){
      s.insert({get(id2 + 1, r), {id2 + 1, r}});
    }
  }
  for(int i : ans){
    printf("%d ", i);
  }
  return 0;
}


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


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& a : A){
    cin >> a;
    a--;
  }
  set<int> used;
  int ii = 0;
  int count = 0;
  while(true){
    if(ii==1){
      cout << count << endl;
      return 0;
    }
    if(used.find(ii)!=used.end()){
      cout << -1 << endl;
      return 0;
    }
    used.insert(ii);
    ii = A[ii];
    count++;
  }
}

Measured memory_bytes: 5376
<?php
$ans = -PHP_INT_MAX;
fscanf(STDIN, "%d", $N);
for ($i = 0; $i < $N; $i++) {
    $tmp = explode(" ", trim(fgets(STDIN)));
    $F[$i] = bindec(implode("", $tmp));
    // echo $F[$i] . PHP_EOL;
}
for ($i = 0; $i < $N; $i++) {
    $P[$i] = explode(" ", trim(fgets(STDIN)));
}
for ($p = 1; $p < 1024; $p++) {
    $score = 0;
    for ($i = 0; $i < $N; $i++) {
        $b = $F[$i] & $p;
        // echo "\$b: " . $b . PHP_EOL;
        $cnt = 0;
        for ($t = 0; $t < 10; $t++) {
            $c = pow(2, 9 - $t) & $b;
            // printf("%d %d = %d\n", pow(2, 9 - $t), $b, $c);
            if ($c == pow(2, 9 - $t)) {
                // echo "o ";
                $cnt++;
            } else {
                // echo "x ";
            }
        }
        // echo "cnt: " . $cnt;
        // echo PHP_EOL;
        $score += $P[$i][$cnt];
    }
    $ans = max($ans, $score);
}
// echo "answer: ";
echo $ans . PHP_EOL;


Measured memory_bytes: 4728
#include <stdio.h>

int main()
{
    int grid[4][4];
    int i,j;
    for(i=1;i<=3;i++){
        for(j=1;j<=3;j++) scanf("%d", &grid[i][j]);
    }
    
    int a, b, c, d;
    int judge = 1;
    a = grid[1][2] - grid[1][1];
    b = grid[1][3] - grid[1][2];
    c = grid[2][1] - grid[1][1];
    d = grid[3][1] - grid[2][1];
    for(i=2;i<=3;i++){
        if (a != grid[i][2] - grid[i][1]) judge = 0;
        if (b != grid[i][3] - grid[i][2]) judge = 0;
        if (c != grid[2][i] - grid[1][i]) judge = 0;
        if (d != grid[3][i] - grid[2][i]) judge = 0;
    }
    if(judge == 1) printf("Yes");
    else printf("No");
    
    return 0;
}

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


int main() {
	ll a; cin >> a;
	long double b; cin >> b;
	cout << (long long)floor(a * b) << endl;
	return 0;
}

Measured memory_bytes: 3724
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=INT_MAX/5;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
	bool operator<(const Edge& e)const{return weight<e.weight;}
	bool operator>(const Edge& e)const{return weight>e.weight;}
};
typedef vector<vector<Edge>> Graph;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vvi gl(n,vi(n,INFTY)),gs(n,vi(n,INFTY)); // 陸路，海路
		rep(i,n) gl[i][i]=gs[i][i]=0;
		rep(i,m){
			int s,d,w; char sl; cin>>s>>d>>w>>sl; s--,d--;
			if(sl=='L' && gl[s][d]>w) gl[s][d]=gl[d][s]=w;
			if(sl=='S' && gs[s][d]>w) gs[s][d]=gs[d][s]=w;
		}
		int r; cin>>r;
		vi route(r);
		rep(i,r) cin>>route[i],route[i]--;
		
		// warshall-floyd
		rep(k,n) rep(i,n) rep(j,n){
			gl[i][j]=min(gl[i][j],gl[i][k]+gl[k][j]);
			gs[i][j]=min(gs[i][j],gs[i][k]+gs[k][j]);
		}
		
		vvi dp(r,vi(n,INFTY)); // [集配先][船の位置]
		dp[0][route[0]]=0;
		repi(i,1,r){
			rep(j,n)
				dp[i][j]=min(dp[i][j],dp[i-1][j]+gl[route[i-1]][route[i]]);
			rep(j,n) rep(k,n)
				dp[i][k]=min(dp[i][k],dp[i-1][j]+gl[route[i-1]][j]+gs[j][k]+gl[k][route[i]]);
		}
		cout<<*min_element(all(dp[r-1]))<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace abc81_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int[] nums = ReadLine().Split().Select(int.Parse).ToArray();

            var dic = new Dictionary<int, int> ();

            foreach (var item in nums){
               if(dic.ContainsKey(item)) dic[item]++;
               else dic[item] = 1;
            }

            int cnt=0;
            if(dic.Count<=input[1]){
                WriteLine(0);
            }else{
                var array = dic.OrderBy((x) => x.Value).ToArray();
                for(int i=0; i<dic.Count-input[1]; i++){
                    cnt += array[i].Value;
                }
                WriteLine(cnt);
            }
        }
    }
}

Measured memory_bytes: 44868
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

//func fib(n int) int {
//	fmt.Println(n)
//	if n == 0 {
//		return 0
//	}
//	if n == 1 {
//		return 1
//	}
//	if done[n] {
//		fmt.Println("done" + fmt.Sprint(n))
//		return memo[n]
//	}
//	done[n] = true
//	memo[n] = fib(n-1) + fib(n-2)
//	return memo[n]
//}

var dp []int = make([]int, 10)
var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

func fib(n int) int {
	dp[0] = 0
	dp[1] = 1
	for i := 2; i <= n; i++ {
		dp[i] = dp[i-1] + dp[i-2]
	}
	return dp[n]
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	hey := false
	sad := false
	for i := 0; i < 3; i++ {
		a := nextInt()
		d := mInt[a]
		if d == 1 {
			if hey {
				sad = false
				continue
			}
			hey = true
			sad = true
			continue
		}
		mInt[a] = 1
	}
	if sad {
		fmt.Fprint(out, string("Yes"))
	} else {
		fmt.Fprint(out, string("No"))
	}
}


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

#define ll long long

void solve(){
    int in,l[100];
    for(int i=0;i<5;++i){
        cin >> in; 
        l[i] = in;
    }
    if(l[0]==0)
        cout << 1;
    else if(l[1]==0)
        cout << 2;
    else if(l[2]==0)
        cout << 3;
    else if(l[3]==0)
        cout << 4;
    else if(l[4]==0)
        cout << 5;
}

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans = 1;
  for(int i=1; i<s.size(); i++){
    if(s[i]!=s[i-1])ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
/**
  @date Time-stamp: <2019-05-19 21:30:39 tagashira>
  @file b.cpp
  @title B - YYMM or MMYY
  @brief https://atcoder.jp/contests/abc126/tasks/abc126_b
**/

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool is_month(int num) {
  return (1 <= num && num <= 12);
}

bool is_year(int num) {
  return (0 <= num && num <= 99);
}

int main(int argc, char* argv[]) {
  string S;
  cin >> S;

  int mae, ato;

  mae = stoi(S.substr(0, 2));
  ato = stoi(S.substr(2, 2));

  // cout << mae << endl;
  // cout << ato << endl;

  if ((is_year(mae) && is_month(ato)) && (is_month(mae) && is_year(ato))) {
    cout << "AMBIGUOUS" << endl;
  } else if (is_year(mae) && is_month(ato)) {
    cout << "YYMM" << endl;
  } else if (is_month(mae) && is_year(ato)) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}


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

int main() {
  	long long int N;
  	cin >> N;
  	long long int A[N];
  	for (int i = 0; i < N; i++) cin >> A[i];
  
  	sort(A, A + N);
  	long long int count = 0;
  	long long int count2 = 0;
    for (int i = N - 1; i >= 0; i--){
      	count += A[i];
      	count2++;
        if (i != N - 1 && count2 < N - 1){
          	count += A[i];
          	count2++;
        }
      	if (count2 == N - 1) break;
    }
  
  	cout << count << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll a,b;

int main(){
    cin >> a >> b;
    if(a+b == 15)cout << "+" << endl;
    else if(a*b == 15)cout << "*" << endl;
    else cout << "x" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>

using namespace std; 

namespace fastinput
{
	/** Interface */

	inline int readChar();
	template <class T = int> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(int x);
	inline void writeWord(const char *s);

	/** Read */

	static const int buf_size = 16384;
	char buf[buf_size];
	int len = 0, pos = 0;

	inline int getChar() {
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline int readChar() {
		int c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		int s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static int write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(int x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	inline string readWord()
	{
		string tmp;
		tmp.push_back(readChar());
		char c;
		while ((c = getChar()) > 32)
			tmp.push_back(c);
		--pos;
		return tmp;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		int n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;

int n;
vector <long long> v;

int main() 
{
	n = readInt();
	v.resize(n);
	for (int i = 0; i < n; ++i)
		v[i] = readInt();

	long long res = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		long long here = v[i] / 2;
		res += here;
		v[i] -= here * 2;
		here = min(v[i], v[i + 1]);
		res += here;
		v[i] -= here;
		v[i + 1] -= here;
	}
	cout << res + v[n - 1] / 2 << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long n, a[200003]; vector<pair<long long, long long> >vec;
int main() {
	cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; }
	vec.push_back(make_pair(0, 0));
	long long cnt = 0;
	for (int i = 1; i <= n; i++) {
		cnt += a[i]; vec.push_back(make_pair(cnt, i));
	}
	vec.push_back(make_pair(100000000000000000LL, n + 1));
	sort(vec.begin(), vec.end());
	long long maxn = 0; long long L = 0;
	for (int i = 1; i < vec.size(); i++) {
		if (vec[i].first != vec[i - 1].first) {
			maxn = max(maxn, vec[i - 1].second - vec[L].second);
			L = i;
		}
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 8544
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,x[100010],p[100010],y[100010],a,cnt,res,t,siz[100010],ring[100010],ans;
bool f[100010];
int main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&x[i]),y[i]=x[i]-x[i-1],p[i]=i;
	scanf("%lld%lld",&m,&k);
	for (int i=1;i<=m;i++) {
		scanf("%lld",&a);
		swap(p[a],p[a+1]);
	}
	for (int i=1;i<=n;i++) if (!f[i]) {
		cnt++;
		res=i;
		while (!f[res]) {
			f[res]=true;
			siz[cnt]++;
			ring[res]=cnt;
			res=p[res];
		}
	}
	for (int i=1;i<=n;i++) {
		t=k%siz[ring[i]];
		res=i;
		while (t--) res=p[res];
		ans+=y[res];
		printf("%lld.0\n",ans);
	}	
}

Measured memory_bytes: 5504
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int trans(char c){
  if(c=='a')return 0;
  if(c=='b')return 1;
  if(c=='c')return 2;
  if(c=='d')return 3;
  if(c=='e')return 4;
  if(c=='f')return 5;
  if(c=='g')return 6;
  if(c=='h')return 7;
  if(c=='i')return 8;
  if(c=='j')return 9;
  if(c=='k')return 10;
  if(c=='l')return 11;
  if(c=='m')return 12;
  if(c=='n')return 13;
  if(c=='o')return 14;
  if(c=='p')return 15;
  if(c=='q')return 16;
  if(c=='r')return 17;
  if(c=='s')return 18;
  if(c=='t')return 19;
  if(c=='u')return 20;
  if(c=='v')return 21;
  if(c=='w')return 22;
  if(c=='x')return 23;
  if(c=='y')return 24;
  if(c=='z')return 25;

  return -1;
}

int main(){
  string s;
  std::cin >> s;

  int cout[26]={};
  for (int i = 0; i < 26; i++)cout[i]=-4;

  int i=0;
  bool succes=false;
  do {
    if(i-cout[trans(s[i])]<3){succes=true;break;}
    else {cout[trans(s[i])]=i;i++;}
  } while(i!=(s.length()));

  if(succes==false)std::cout << "-1 -1" << '\n';
  else{std::cout <<cout[trans(s[i])]+1<<" "<<i+1<< '\n';}

return 0;
}


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

int main(){
  int x,y,s,m[14][14]={0},max=0,none=0;
  while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
    if(s>=1){
      m[x+2][y+2]++;
      m[x+2][y+1]++;
      m[x+2][y+3]++;
      m[x+1][y+2]++;
      m[x+3][y+2]++;
    }
    if(s>=2){
      m[x+1][y+1]++;
      m[x+1][y+3]++;
      m[x+3][y+1]++;
      m[x+3][y+3]++;
    }
    if(s==3){
      m[x+2][y]++;
      m[x+2][y+4]++;
      m[x][y+2]++;
      m[x+4][y+2]++;
    }
  }
  for(y=0;y<10;y++){
    for(x=0;x<10;x++){
      if(m[x+2][y+2]>max)max=m[x+2][y+2];
      if(!m[x+2][y+2])none++;
    }
  }
  cout<<none<<endl<<max<<endl;
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    ll n;
    cin >> n;
    if(n%2==0)cout << n << endl;
    else cout << n*2 << endl;
}

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

open_Shop=[]
for i in range(N):
    open_shop=list(map(int,input().split()))
    open_Shop.append(open_shop)
    
profit_List=[]
for i in range(N):
    profit_list=list(map(int,input().split()))
    profit_List.append(profit_list)
    

max_profit=(-1000000000)

sub_Array=[]
for i in range(1,1024):
    Num=i
    for j in range(10):
        sub_Array.append(Num//(2**(9-j)))
        Num%=2**(9-j)
    score=0
    profit=0
    for k in range(N):
        for l in range(10):
            score+=(open_Shop[k][l]*sub_Array[l])
        profit+=profit_List[k][score] 
        score=0
    if max_profit<profit:
        max_profit=profit
    sub_Array=[]
    #print(profit)
#print(sub_Array)
print(max_profit)

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

int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    string str;
    for(int i=0;i<n;i++){
        cin>>str;
        mp[str]++;
    }
    cout<<mp.size()<<endl;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#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=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n+1);
  REP(i, n+1) {
    cin >> a[i];
  }
  if(n == 0) {
    if(a[0] == 1) {
      cout << 1 << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  vector<P> v;
  int l = a[n], r = a[n];
  v.push_back({l, r});
  bool ok = true;
  RREP(i, n-1) {
    l = l/2 + l%2;
    l += a[i];
    r += a[i];

    if(i <= 17) {
      ll tmp = 1ll<<i;
      chmin(r, tmp);
      if(tmp < l) {
        ok = false;
        break;
      }
    }

    v.push_back({l, r});
  }

  if(!ok) {
    cout << -1 << endl;
    return 0;
  }

  reverse(ALL(v));

  ll now = 1;
  ll cnt = 1;
  FOR(i, 1, n+1) {
    now = min(v[i].second, 2 * (now - a[i-1]));
    cnt += now;
  }
  cout << cnt << endl;

}
























Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    string s,t;
    cin >> s >> t;
    REP(i,s.size()){
        if(s[i]!=t[i]) {
            cout <<"No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
 

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[]S = new int[13];
		int[]H = new int[13];
		int[]C = new int[13];
		int[]D = new int[13];
		for(int i = 0; i < n; i++) {
			String s = scan.next();
			int k = scan.nextInt();
			if(s.equals("S")) {
				S[k - 1] = 1;
			}else if(s.equals("H")) {
				H[k - 1] = 1;
			}else if(s.equals("C")) {
				C[k - 1] = 1;
			}else {
				D[k - 1] = 1;
			}
		}
		scan.close();
		for(int i = 0; i < 13; i++) {
			if(S[i] == 0) {
				int m = i + 1;
				System.out.println("S " + m);
			}
		}
		for(int i = 0; i < 13; i++) {
			if(H[i] == 0) {
				int m = i + 1;
				System.out.println("H " + m);
			}
		}
		for(int i = 0; i < 13; i++) {
			if(C[i] == 0) {
				int m = i + 1;
				System.out.println("C " + m);
			}
		}
		for(int i = 0; i < 13; i++) {
			if(D[i] == 0) {
				int m = i + 1;
				System.out.println("D " + m);
			}
		}
	}
}


Measured memory_bytes: 26260
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  long tmp;
  long mini = 1e7;
  long count;
  rep(i,n){
    cin >> tmp;
    count = 0;
    while(tmp % 2 == 0 && tmp > 0){
      count++;
      tmp /= 2;
    }
    mini = min(mini,count);
  }
  cout << mini << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
const int MaxN = 1e5;
using namespace std;
int a[MaxN + 5];
int n ;
int main()
{
	while(~scanf("%d" , &n)){
		int Max = 0;
		for(int i = 1;i <= n;i++){
			scanf("%d" , &a[i]);
			Max = max(Max , a[i]);
		}
		int cnt = 0;
		for(int i = 1;i <= n;i++) cnt += (a[i] == Max);
		if(cnt == n && Max == n - 1){
			printf("Yes\n");
			return 0;
		}
		else if(cnt == 1){
			printf("No\n");
			return 0;
		}
		for(int i = 1;i <= n;i++){
			if(Max - a[i] > 1) {
				printf("No\n");
				return 0;
			}
		}
		int Min_c = n - cnt + 1;
		int Max_c = n - cnt + cnt / 2;
		if(Max >= Min_c && Max <= Max_c){
			printf("Yes\n");
		}
		else printf("No\n");
	}
}

Measured memory_bytes: 512
using System;
class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
        int[] d = new int[n];

        input = Console.ReadLine().Split(' ');

        for(int i = 0; i < n; i++)
        {
            d[i] = int.Parse(input[i]);
        }

        int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (d[i] >= k)
            {
                cnt++;
            }
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 15968
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;
 
 int main()
 {
   string s;
   while(cin>>s)
   {
     if(s.length()>=4&&s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I')
     {
        cout<<"Yes"<<endl;                                                          
     }             
     else cout<<"No"<<endl;
   }
   return 0;
 }
 

Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x, sum;
vi g[N];
main() {
  file("threesum");
  ios;
  int n;
  cin >> n;
  fo(i, 2, n, 1) {
    int x;
    cin >> x;
    g[x].eb(i);
  }
  fo(i, 1, n, 1) cout << g[i].size() << "\n";
  return 0;
}
/**

*/


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

vector<vector<int>> Graph;
vector<int> label;

void dfs(int v, int c){
  label[v] = c;
  for(int nv : Graph[v]){
    if(label[nv] != -1) continue;
    dfs(nv, c);
  }
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(m), b(m), c(k), d(k);
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  for(int i = 0; i < k; i++){
    cin >> c[i] >> d[i];
    c[i]--; d[i]--;
  }
  
  Graph.resize(n);
  for(int i = 0; i < m; i++){
    Graph[a[i]].push_back(b[i]);
    Graph[b[i]].push_back(a[i]);
  }
  
  vector<vector<int>> Block(n);
  for(int i = 0; i < k; i++){
    Block[c[i]].push_back(d[i]);
    Block[d[i]].push_back(c[i]);
  }
  
  int count = 0;
  label.assign(n,-1);
  for(int i = 0; i < n; i++){
    if(label[i] != -1) continue;
    dfs(i, count);
    count++;
  }
  
  vector<int> labelSize(100005,0);
  for(int i = 0; i < label.size(); i++) labelSize[label[i]]++;
  vector<int> ans(n,0);
  
  for(int i = 0; i < n; i++) ans[i] += labelSize[label[i]] - Graph[i].size() -1;
  for(int i = 0; i < k; i++){
    if(label[c[i]] == label[d[i]]){
      ans[c[i]]--; ans[d[i]]--;
    }
  }
  for(int i = 0; i < n; i++){
    if(i == 0) cout << ans[i];
    else cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 16924
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N = int(input())
    A = read_list()
    dp = [[-10 ** 20 for _ in range(2)] for _ in range(N // 2 + 5)] 

    dp[0][0] = 0
    dp[1][1] = A[0]
    for i in range(1, N):
        for k in range(i // 2 + 2, max(0, i // 2 - 2), -1):
            dp[k][0] = max(dp[k][1], dp[k][0])
            dp[k][1] = dp[k - 1][0] + A[i]

    print(max(dp[N // 2]))


if __name__ == "__main__":
    main()


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

int v[21], c[21];

signed main() {

    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> v[i];
    }
    for (int i = 1; i <= N; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 1; i <= N; i+=1){
        if (v[i] - c[i] > 0) {
            ans = ans + v[i] - c[i];
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl '\n'
// using namespace std;


int main() {
    int M,N;
    std::cin >> N >> M;
    std::vector<int> A;
    int totalVotes = 0;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        std::cin >> tmp;
        totalVotes += tmp;
        A.push_back(tmp);
    }
    float cst = totalVotes/(4.0*M) ;
    int count = 0;
    for (int i:A) {
        if (i >= cst) {
            count++;
        }
        if (count >= M) break;
    }

    std::string ans =  count >= M ? "Yes" : "No"; 
    std::cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N, K = map(int, input().split())
H = list(map(int, input().split()))

DP = np.zeros(N, dtype=int)
H = np.array(H)

for i in range(1, N):
    start = max(0, i-K)
    DP[i] = min(DP[start:i] + np.abs(H[i] - H[start:i]))

print(DP[-1])

Measured memory_bytes: 22836
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

const ll MAX_N = 1e9 + 21;
ll q, A, B;

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

	while (q--) {
		cin >> A >> B;
		if (A == B) {
			cout << (A - 1) * 2 << "\n";
			continue;
		}

		if (B < A)
			swap(A, B);

		ll s = 0, e = B;
		while (e - s > 1) {
			ll mid = e + s >> 1;
			ll mx = 0;
			if (mid <= A + 1)
				mx = (A + 1) * mid;
			else {
				if ((mid - (A + 1)) % 2 == 0)
					mx = (mid + A + 1) / 2 * (mid + A + 1) / 2;
				else
					mx = (mid + A + 1) / 2 * (mid + A + 2) / 2;
			}

			if (mx < A * B)
				s = mid;
			else
				e = mid;
		}

		ll mid = s, mx = 0;
		if (mid <= A + 1)
			mx = (A + 1) * mid;
		else {
			if ((mid - (A + 1)) % 2 == 0)
				mx = (mid + A + 1) / 2 * (mid + A + 1) / 2;
			else
				mx = (mid + A + 1) / 2 * (mid + A + 2) / 2;
		}

		cout << A - 1 + s << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define REP(i,n) for (int i = 0 ; i < (int)n ; i++)
typedef long long ll;

int main(){
    char a[3];
    scanf("%c%c%c",&a[0],&a[1],&a[2]);

    if(a[1] == 'R'){
        printf("ABC\n");
    }else
    {
        printf("ARC\n");
    }
    
}

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

using namespace std;

int C[10][10];
int h, w;

int main() {
    scanf("%d%d", &h, &w);
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++) scanf("%d", &C[i][j]);
    for (int k = 0; k < 10; k++)
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++) C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
    int ans = 0;
    for (int i = 0, x; i < h; i++)
        for (int j = 0; j < w; j++) scanf("%d", &x), ans += (x==-1)?0:C[x][1];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define SWAP(a,b) a += b;b = a - b;a -= b

int main()
{
	int a[3];
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	if (a[0] > a[1]){
		SWAP(a[0], a[1]);
	}
	if (a[1] > a[2]){
		SWAP(a[1], a[2]);
	}
	if (a[0] > a[1]){
		SWAP(a[0], a[1]);
	}
	if (a[1] > a[2]){
		SWAP(a[1], a[2]);
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
    os<<'[';
    for(auto& p: c) os << p << " ";
    return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
    print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
    os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
    print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
    print_tuple<0,Args...>(os<<'(',t);
    return os<<')';
}


constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=1001;

int n;
vi numx;
vi children[maxn];
bool dfs(int p, vi& nx, vi& anx) {
	for(int c: children[p]) if(!dfs(c, nx, anx)) return false;

	int cum=0, mcum=0;
	vi dif;
	for(int c: children[p]) {
		cum+=nx[c]+anx[c];
		mcum+= min(nx[c],anx[c]);
		dif.push_back(abs(nx[c]-anx[c]));
	}

	if(mcum > nx[p]) return false;

	vi dp(nx[p] + 1 - mcum, 0);
	dp[0] = 1;
	for(int d: dif) for(int i = nx[p] - mcum; i >= d; i--) 
		dp[i] |= dp[i-d];

	for(int i = nx[p] - mcum; i>=0;i--) if(dp[i]) {
		anx[p] = cum - i - mcum;
		return true;
	}
	return true;
}

	


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

	while(cin>>n) {
		rep(i, maxn) children[i].clear();
		numx.clear();
	FOR(i, n-1) {
		int head;
		cin>>head;
		children[--head].push_back(i);
	}
	copy_n(istream_iterator<int> (cin), n, back_inserter(numx));
	vi anumx = vi(n, 0);

	cout << (dfs(0, numx, anumx)? "POSSIBLE":"IMPOSSIBLE") <<
		endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < k; ++i)
	{
		ans += a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
  ll A,B,C,X[107];
  ll N,M;
  string S;
  cin >> A >> B;
  cout << (A<10 && B<10 ? A*B : -1LL) << endl;
}

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

class Union_Find{
private:
  vector<int64_t> par;
  vector<int64_t> rank;
  vector<int64_t> num;

  int64_t find(int64_t x){
    if(par.at(x)==x){
      return x;
    }else{
      return par.at(x)=find(par.at(x));
    }
  }

public:
  Union_Find(int64_t n){
    par.resize(n);
    rank.resize(n,0);
    num.resize(n,1);
    for(int64_t i=0;i<n;i++){
      par.at(i)=i;
    }
  }

  void unite(int64_t x,int64_t y){
    x=find(x);
    y=find(y);
    if(x==y){
      return;
    }
    if(rank.at(x)<rank.at(y)){
      par.at(x)=y;
      num.at(y)+=num.at(x);
    }else if(rank.at(x)>rank.at(y)){
      par.at(y)=x;
      num.at(x)+=num.at(y);
    }else{
      par.at(x)=y;
      rank.at(y)++;
      num.at(y)+=num.at(x);
    }
  }

  bool same(int64_t x,int64_t y){
    return find(x)==find(y);
  }

  int64_t size(int64_t x){
    return num.at(find(x));
  }

};

int main(){
  int N,M;
  cin >> N >> M;
  int A,B;
  Union_Find uf(N+1);
  for(int i=0;i<M;i++){
    cin >> A >> B;
    uf.unite(A,B);
  }
  int64_t ans=0;
  for(int i=1;i<=N;i++){
    ans=max(ans,uf.size(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7956
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] hps = new int[n];
        int maxHp = 0;
      	long res = 0;
      	
      	for (int i = 0; i < n; i++) {
      		int hp = sc.nextInt();
      		hps[i] = hp;
      		maxHp = Math.max(maxHp, hp);
      	}
      	
      	long left = 0;
      	long right = (maxHp / b);
      	while (left <= right) {
      		long middle = (left + right ) / 2;
      		if (isEnough(middle, hps, a, b)) {
      			// 在middle回以內的爆炸可以消掉怪獸，因此找更小的
      			// middle回以内の爆発で　全ての怪獣を消すことができる。
      			// もっと　小さいmiddleを求める。
      			left = middle + 1;
      		} else {
      			right = middle - 1;
      		}
      	}
      	System.out.println(left);
	}
	
	// 可以在t回內打死所有怪獸嗎？
	// t回以内の爆発で　全ての怪獣を消すことができるか?
	private static boolean isEnough(long t, int[] hps, int a, int b) {
		long times = 0;
		for (int hp: hps) {
			if (hp > b*t) {
				times += (int)Math.ceil((hp*1.0 - b*t) / (double)(a - b));
			}
		}
		return times > t;
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 36812
while 1:
	N, M = map(int,raw_input().split(" "))
	if (N, M) == (0,0):
		break
	computer = [0 for i in range(N+1)]
	computer[1] = 1
	packets =[map(int,raw_input().split(" ")) for i in range(M)]
	packets.sort()
	for t,s,d in packets:
		if computer[s] == 1:
			computer[d] = 1
	print sum(computer) 

Measured memory_bytes: 12648
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const int N = 2e5 + 10;

int n, v, m, ans[N];
int a[N], b[N], L[N][22], R[N][22], f[N << 3], g[N << 3];

bool ask(int u)
{
    return ans[L[u][0] - 1] <= R[u][0] + 1;
}

int main()
{
    n = read(), v = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (m = 0; v; v >>= 1, m++)
    {
        L[0][m] = L[1][m] = 1;
        for (int j = 2; j <= n; j++)
            L[j][m] = a[j] - a[j - 1] <= v ? L[j - 1][m] : j;
        R[n + 1][m] = R[n][m] = n;
        for (int j = n - 1; j >= 1; j--)
            R[j][m] = a[j + 1] - a[j] <= v ? R[j + 1][m] : j;
    }
    for (int i = 1; i <= n; i++) L[i][m] = R[i][m] = i;
    for (int i = 0; i < (1 << m); i++) g[i] = n + 1;
    for (int i = 0; i < (1 << m); i++)
        for (int j = 0; j < m; j++)
            if (!(i >> j & 1))
            {
                f[i | (1 << j)] = max(f[i | (1 << j)], R[f[i] + 1][j + 1]);
                g[i | (1 << j)] = min(g[i | (1 << j)], L[g[i] - 1][j + 1]);
            }
    for (int i = 0; i <= n; i++) ans[i] = 2e9;
    for (int i = 0; i < (1 << m); i++)
        ans[f[i]] = min(ans[f[i]], g[((1 << m) - 1) ^ i]);
    for (int i = n - 1; i >= 1; i--)
        ans[i] = min(ans[i], ans[i + 1]);
    for (int i = 1; i <= n; i++) puts(ask(i) ? "Possible" : "Impossible");
}


Measured memory_bytes: 42368
from operator import itemgetter

N, M = list(map(int, input().split()))
ab = sorted([list(map(int, input().split())) for i in range(M)], key=itemgetter(1))
ans = B = 0

for a, b in ab:
    if a >= B:
        ans += 1
        B = b
print(ans)


Measured memory_bytes: 29920
import sys
from string import digits

def main():
    n, s = sys.stdin.read().split()

    res = []
    for i in digits:
        x = s.find(i)
        if x == -1:
            continue
        for j in digits:
            y = s.find(j, x+1)
            if y == -1:
                continue
            for k in digits:
                if k in s[y+1:]:
                    res.append((i, j, k))
                    
    print(len(res))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll x,a;  cin>>x>>a;
    if(x<a) cout<<0;
    else cout<<10;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(int i=p;i<n;i++)
#define fr1(i,p,n) for(int i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (int)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int a[n];
        fr(i,0,n) cin>>a[i];
        sort(a,a+n);
        int ans=0;
        fr(i,0,k) ans+=a[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3656