akhauriyash/Code-Regression huggingface dataset:
var debug = false;

function Main(input) {
    let sp = input.split("\n");
    let n = sp[0].split(" ")[0];
    let k = sp[0].split(" ")[1];

    let ans = {};

    for (let i = 0; i < k; i++) {
        let d = sp[2 * i + 1];
        let alist = sp[2 * i + 2].split(" ");

        for (let j = 0; j < d; j++) {
            ans[Number(alist[j]) -1] = true;
        }
    }

    let res = 0;
    for (let i = 0; i < n; i++) {
        if (!ans[i]) {
            res++;
        }
    }
    console.log(res);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
if (debug) {
    Main(require("fs").readFileSync("./input", "utf8"));
} else {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}

Measured memory_bytes: 29728
//#include <cmath>
//#include <cstdio>
//#include <vector>
//#include <map>
//#include <iostream>
//#include <algorithm>
//#include <set>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vb = vector<bool>;
using pli = pair<ll,int>; 		
#define fi first
#define v vector
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
int INF = 1e9+7;
ll inf = 1e18+7;

const int N = 3010;

int dp[N][N];


void add_self(int &a, int b){
	a += b;
}

void max_self(int &a, int b){
	if(b > a)	a = b;
}
void solve(){
	string s,t;
	cin >> s;
	cin >> t;
	int n1 = s.size();
	int n2 = t.size();
	
	for(int i = 1; i <= n1; ++i){
		for(int j = 1; j <= n2; ++j){
			if(s[i-1] == t[j-1]){
				add_self(dp[i][j], dp[i-1][j-1]+ 1);
			}
			max_self(dp[i][j], dp[i-1][j]);
			max_self(dp[i][j], dp[i][j-1]);
		}
	}
	int i = n1, j=  n2;
	string ns;
	while (i-1 >= 0 && j-1 >= 0){
		
		if(dp[i][j] == dp[i-1][j-1] + 1 && s[i-1] == t[j-1]){
			ns += s[i-1];
			i-= 1;
			j -= 1;
		}
		else if(dp[i][j] == dp[i-1][j]){
			i -= 1;
		}
		else{
			j -= 1;
		}
	}
	reverse(ns.begin(), ns.end());
	cout << ns << endl;
	
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	//scanf("%d",&t);
	while(t--){
		solve();
	}
		
			
}


Measured memory_bytes: 38832
#include <cstdio>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <array>

#include <boost/format.hpp>
#include <boost/range/irange.hpp>

enum Type {
   Shoujiki, Fuseijitu, Unknown
};

int main() {
   int n;
   std::scanf("%d", &n);
   std::vector<std::vector<Type> > map;
   map.resize(n);
   for (unsigned int i = 0; i < n; i++) {
      map[i].resize(n, Type::Unknown);
      int a;
      std::scanf("%d", &a);
      for (unsigned int j = 0; j < a; j++) {
         int x, y;
         std::scanf("%d %d", &x, &y);
         map[i][x-1] = y == 1 ? Type::Shoujiki : Type::Fuseijitu;
      }
   }

   const unsigned int max = 1 << map.size();
   std::vector<Type> status;
   unsigned int shoujiki = 0;
   for (unsigned int i = 1; i < max; i++) {
      status.assign(map.size(), Type::Fuseijitu);
      for (unsigned int j = 0, l = i; l > 0; l >>= 1, j++) {
         if ((l & 1) != 1) {
            continue;
         }
         status[j] = Type::Shoujiki;
      }
      bool result = true;
      for (unsigned int j = 0; j < status.size(); j++) {
         if (status[j] != Type::Shoujiki) {
            continue;
         }
         for (unsigned int l = 0; l < map.size(); l++) {
            if (map[j][l] == Type::Unknown) {
               continue;
            }
            if (map[j][l] != status[l]) {
               result = false;
               break;
            }
         }
         if (!result) {
            break;
         }
      }
      if (!result) {
         continue;
      }
      const unsigned int count = std::count(status.begin(), status.end(), Type::Shoujiki);
      shoujiki = std::max(shoujiki, count);
   }
   std::cout << shoujiki << std::endl;
   return 0;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

s = input()

if s == "SRR" or s == "RRS":
    print(2)
elif s == "RRR":
    print(3)
elif s == "SSS":
    print(0)
else:
    print(1)





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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int people[n];
	for (int i = 0; i < n; ++i) {
		int a; cin >> a; people[i] = a;
	}
	int result = numeric_limits<int>::max();
	for (int i = 1; i <= 100; ++i) {
		int r = 0;
		for (int j = 0; j < n; ++j) {
			r += pow(people[j] - i, 2);
		}
		result = min(r, result);
	}
	cout << result;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	int N,A,B,sum;
	cin>>N>>A>>B;
	sum=A+B;
	if(A==N&&B==N)
		sum=N;
	else if(sum>=N)
		sum-=N;
	else
		sum=0;
	cout<<min(A,B)<<" "<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int n, sum;
int a[510], b[510];

int cnt(int m){
    int c = 0;
    for(int i=0;i<n;++i){
        b[i] = a[i]%m;
        c += b[i];
    }
    c/=m;
    std::sort(b,b+n);
    int s = 0;
    for(int i=0;i<n-c;++i)
        s+=b[i];

    return s;
}

std::vector<int> divi;

void init(){
    for(int i=1;i*i<=sum;++i) if(sum%i==0){
        divi.emplace_back(i);
        divi.emplace_back(sum/i);
    }
    std::sort(std::begin(divi),std::end(divi),std::greater<int>());
}

int main() {

    int k;

    std::cin >> n >> k;

    for(int i=0;i<n;++i){
        std::cin >> a[i];
        sum+=a[i];
    }

    init();

    int ans;

    for(int m : divi){
        if(cnt(m)<=k){
            ans=m;
            break;
        }
    }

    std::cout << ans << std::endl;
}


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

using namespace std;

#define MAX_K 10005
#define MAX_T 105

int K, T;
int A[MAX_T];

void input()
{
  cin >> K >> T;
  for (size_t i = 0; i < T; i++) {
    cin >> A[i];
  }
}

int main()
{
  input();

  sort(A, A+T);
  int sum = 0;
  for (size_t i = 0; i < T-1; i++) {
    sum += A[i];
  }

  int diff = A[T-1] - sum;
  if(diff <= 1){
    cout << 0 << endl;
  }
  else{
    cout << diff - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N){
  int ketasu = calcDigits(N);
  int ans = 0;
  if (ketasu == 1) {
    ans = N;
  } else 
  if (ketasu == 2) {
    ans = 9;
  }
  if (ketasu == 3) {
    ans += N - 99;
    ans += 9;
  } else
  if (ketasu == 4) {
    ans += 900;
    ans += 9;
  } else if (ketasu == 5) {
    ans += N - 9999;
    ans += 900;
    ans += 9;
  } else if (ketasu == 6) {
    ans += 90000;
    ans += 900;
    ans += 9;
  }
  
  cout << ans << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    d =  INT()

    if d==25: print('Christmas')
    elif d==24: print('Christmas Eve')
    elif d==23: print('Christmas Eve Eve')
    elif d==22: print('Christmas Eve Eve Eve')




if  __name__=='__main__':
    main()

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool ok(int64 x) {
	string s = to_string(x);
	REP(i, s.size()-1) {
		if (s[i] != s[i+1]-1) return 0;
	}
	return 1;
}

int main(void) {
	int N;
	cin >> N;
	vector<int64> a(N);
	REP(i, N) cin >> a[i];
	int64 res = -1;
	REP(i, N) {
		FOR(j, i+1, N) {
			if (ok(a[i]*a[j])) {
				res = max(res, a[i]*a[j]);
			}
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 3268
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int k = sc.nextInt();
	//	int c = sc.nextInt();
		// 文字列の入力
	//	String s = sc.next();

		// 出力
		if(n%k==0)System.out.println("0");
		else System.out.println("1");
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;
int main() {
	string s;
	int ptn = 753, num, min = 753;
	istringstream check;
	cin >> s;
	for (int i = 0; i < s.size() - 2; i++) {
		check = istringstream(s.substr(i, 3));
		check >> num;
		if (abs(ptn - num) < min) min = abs(ptn - num);
	}
	cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

// (i-1)回目での評点P_(i-1) = Π_{n = i-1 - K + 1}^{i-1}A_n
// (i)回目での評点P_i = Π_{n = i - K + 1}^{i}A_n
// P_i = P_(i-1) * A_i / A_{i-K}
// P_i > P_(i-1)となるためには、
// P_ (i-1) * A_i / A_{i-K} > P_{i-1}
// A_i > A_{i-K} である必要がある

int main() {
    int N, K;
    cin >> N >> K;
    V<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = K; i < N; ++i) {
        if (A[i - K] < A[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

typedef struct {
	long number;
	long x;
  long y;
} S_TOWN;
typedef struct {
	long a;
  long b;
  long cost;
} S_NODE;

int cmpAscX(const void * n1, const void * n2)
{
	if (((S_TOWN *)n1)->x > ((S_TOWN *)n2)->x)
	{
		return 1;
	}
	else if (((S_TOWN *)n1)->x < ((S_TOWN *)n2)->x)
	{
		return -1;
	}
	else
	{
    if (((S_TOWN *)n1)->number > ((S_TOWN *)n2)->number)
  	{
  		return 1;
  	}
  	else if (((S_TOWN *)n1)->number < ((S_TOWN *)n2)->number)
  	{
  		return -1;
  	}
    else
    {
      return 0;
    }
	}
}
int cmpAscY(const void * n1, const void * n2)
{
	if (((S_TOWN *)n1)->y > ((S_TOWN *)n2)->y)
	{
		return 1;
	}
	else if (((S_TOWN *)n1)->y < ((S_TOWN *)n2)->y)
	{
		return -1;
	}
	else
	{
    if (((S_TOWN *)n1)->number > ((S_TOWN *)n2)->number)
  	{
  		return 1;
  	}
  	else if (((S_TOWN *)n1)->number < ((S_TOWN *)n2)->number)
  	{
  		return -1;
  	}
    else
    {
      return 0;
    }
	}
}
int cmpNode(const void * n1, const void * n2)
{
	if (((S_NODE *)n1)->cost > ((S_NODE *)n2)->cost)
	{
		return 1;
	}
	else if (((S_NODE *)n1)->cost < ((S_NODE *)n2)->cost)
	{
		return -1;
	}
	else
	{
    return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  S_TOWN towns[n];
  for (long i = 0; i < n; i++) {
    towns[i].number = i;
    scanf("%ld %ld", &towns[i].x, &towns[i].y);
  }
  S_NODE nodes[n*2-2];
  qsort(towns, n, sizeof(S_TOWN), cmpAscX);
  for (long i = 0; i < n-1; i++) {
    nodes[i].a = towns[i].number;
    nodes[i].b = towns[i+1].number;
    nodes[i].cost = towns[i+1].x-towns[i].x;
  }
  qsort(towns, n, sizeof(S_TOWN), cmpAscY);
  for (long i = 0; i < n-1; i++) {
    nodes[n-1+i].a = towns[i].number;
    nodes[n-1+i].b = towns[i+1].number;
    nodes[n-1+i].cost = towns[i+1].y-towns[i].y;
  }
  qsort(nodes, n*2-2, sizeof(S_NODE), cmpNode);
  long parent[n];
  for (long i = 0; i < n; i++) {
    parent[i] = i;
  }
  long par_a,par_b;
  long list[n];
  long list_size;
  long sum = 0;
  for (long i = 0; i < n*2-2; i++) {
    par_a = nodes[i].a;
    list_size = 0;
    while (parent[par_a] != par_a) {
      list[list_size] = par_a;
      list_size++;
      par_a = parent[par_a];
    }
    for (long j = 0; j < list_size; j++) {
      parent[list[j]] = par_a;
    }
    par_b = nodes[i].b;
    list_size = 0;
    while (parent[par_b] != par_b) {
      list[list_size] = par_b;
      list_size++;
      par_b = parent[par_b];
    }
    for (long j = 0; j < list_size; j++) {
      parent[list[j]] = par_b;
    }
    if (par_a != par_b) {
      parent[par_b] = par_a;
      sum += nodes[i].cost;
    }
  }
  printf("%ld\n", sum);

  return 0;
}

Measured memory_bytes: 14292
n, m = map(int, input().split())
a = []
s = 0
stock = {}
for i in range(n):
    yen, s = map(int, input().split())
    if yen in stock:
        stock[yen] += s
    else:
        stock[yen] = s
        a.append(yen)
a.sort()
ans = 0
for i in range(n):
    s = stock[a[i]]
    if s < m:
        m -= s
        ans += s * a[i]
    else:
        ans += m * a[i]
        break
print(ans)

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

using namespace std;

int N, A, B, C;
vector<int> L;

int dfs(int count, int a, int b, int c)
{
	if (count == N)
	{
		if (a == 0 || b == 0 || c == 0)
		{
			return 1000000;
		}

		return abs(A - a) + abs(B - b) + abs(C - c) - 30;
	}

	int noUse = dfs(count + 1, a, b, c);
	int useA = dfs(count + 1, a + L[count], b, c) + 10;
	int useB = dfs(count + 1, a, b + L[count], c) + 10;
	int useC = dfs(count + 1, a, b, c + L[count]) + 10;

	return min(noUse, min(useA, min(useB, useC)));
}

int main()
{
	cin >> N >> A >> B >> C;

	L.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}

	cout << dfs(0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Long num = Long.valueOf(info[1]);
		List<Integer> child = Arrays.asList(sc.nextLine().split(" "))
				.stream()
				.map(Integer::valueOf)
				.sorted()
				.collect(Collectors.toList());
		Integer result = 0;
		for (Integer i : child) {
			num -= i;
			if (num >= 0)
				result++;
			else
				break;
		}
		System.out.println(num>0?result-1:result);
	}
}

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

int diff(int la, int sa)
{
    int da = abs(la - sa);
    if (da < 1800) return da;
    return 3600 - da;
}

void solve(int h, int m)
{
    int la = h * 300 + m * 5;
    int sa = m * 60;
    int da = diff(la, sa);

    //printf(" %02d:%02d %d %d %d\n", h, m, la, sa, da);
    if (da < 300) puts("alert");
    else if (da < 900) puts("warning");
    else puts("safe");
}

int main(void)
{
    int n;

    scanf("%d", &n);
    while (n-- > 0){
        int h, m;

        scanf("%d:%d", &h, &m);
        solve(h, m);
    }

    return 0;
}

Measured memory_bytes: 580
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void calc() {

	Int N; std::cin >> N;
	std::vector<Int> a(N);
	Int max = -1;
	rep(i, N) {
		std::cin >> a[i];
		max = std::max(max, a[i]);
	}
	Int another = -1;
	Int dist = INF;
	rep(i, N) {
		Int tmp_dist = 0;
		if (a[i] == max)continue;
		if (max % 2 == 0)tmp_dist = std::abs(max / 2 - a[i]);
		else {
			tmp_dist = std::min(std::abs(max / 2 + 1 - a[i]), std::abs(max / 2 - 1 - a[i]));
		}
		if (tmp_dist < dist) {
			dist = tmp_dist;
			another = a[i];
		}
	}

	std::cout << max << " " << another;

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

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


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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};



int main(){
	int a = 0;
	int in;
	for(int i = 0; i < 2; i++){
		cin >> in;
		a += in;
	}

	if(a % 2 == 0) cout << a/ 2 << endl;
	else cout << a/ 2 + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main() {
	int n;
	cin >> n;
	cout << 10 - n / 200 << endl;
	return 0;
}

Measured memory_bytes: 3620
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
    string s ;
    cin >> s ;
    int cur = 0 , ans = 0, n = s.length(); 
    rep(i,n){
        if(s[i] == 'A') cur++ ;
        else if(i < n-1 && s[i] == 'B' && s[i+1] == 'C') ans += cur , i++ ;
        else cur = 0 ;
    }
    cout << ans ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 720
n = gets.to_i
s = gets.chomp.split('')
ans = 0

(0..999).each do |i|
  str = sprintf("%03d", i)
  tmp = 0
  flag = true
  str.split('').each do |j|
    index = s[tmp..-1].index(j)
    if index
      tmp = index + 1 + tmp
    else
      flag = false
      break
    end
  end
  ans += 1 if flag
end

puts ans

Measured memory_bytes: 6780
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define breps(i,x,n) for(int i=x;i>=n;i--)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

/**
* ------------- ここからコード -------------
*/

int main(void) {

	int N; cin >> N;
	vector<int> col(N);
	int R = 0, last = 0;
	rep(i, N) {
		char c;
		cin >> c;
		if (c == 'R') {
			col[i] = 1;
			R++;
			last = i;
		}
		else col[i] = 0;
	}

	ll A,B;
	// 交換
	int a = 0;
	rep(i, R) {
		if (col[i] == 1) a++;
	}
	A = R - a;

	// 色変え
	int b = 0;
	rep(i, last) {
		if (col[i] == 0) b++;
	}
	B = b;

	cout << min(A, B) << endl;
	return 0;
}


Measured memory_bytes: 4044
#!/usr/bin/env python3
#ABC61 B

n,m = map(int,input().split())

c = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    c[a-1] += 1
    c[b-1] += 1
for i in range(n):
    print(c[i])


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
string str;
int N,K;
char nt(char a)
{
  if (a=='R')
  {return 'L';
  }
  if (a=='L')
  {return 'R';
  }  
}
int findInd(int a)
{
  int i=a;
  char c=str[a];
  while (str[i]==c)
  {
    i++;    
  } 
  return i;
  
}

int rep(int l,int r)
{
  string a(str);
  
  for (int i=0;i<=r-l;i++)
  {
    a[i+l]=nt(str[r-i]);
  }
  
  str = a;
  return 0;
}
int countS()
{
  int count =0;
  for (int i=0;i<N;i++)
  {    if (str[i+1]==str[i])
    {count ++;
    }
  }
  return count;
}

int main()
{
  cin >> N >> K;
  cin >> str;
  int i=0;
  int p=0;
  while (findInd(p)!=N && i<K)
  {
    p=findInd(p);
    rep(p,findInd(p)-1);
  i++;
  }
  cout << countS();
  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <string.h>
using namespace std;
typedef long long ll;

ll min(ll a, ll b) {
  return a < b ? a : b;
}

int main(void) {
  ll i, j, k, n, max = 0, a = 0, b = 0, c, d, ans = 0;
  char s[100010];
  scanf("%s", s);
  n = strlen(s);
  for(i = 0; i < n; ++i) {
    if(s[i] == '1') {
      if(i & 1) a++;
      else b++;
    }
  }
  printf("%lld", min(a + (n + 1) / 2 - b, b + n / 2 - a));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  
  if (M == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  
  ll sum = 0;
  vector<int> kukan(M - 1, 0);
  for (int i = 0; i < M - 1; i++) {
    kukan[i] = p[i + 1] - p[i];
    sum += kukan[i];
  }
  sort(kukan.begin(), kukan.end());
  
  for(int i = 0; i < N - 1; i++) {
    if (sum >= 0) {
      sum -= kukan[kukan.size() - 1 - i];
    }
  }
  cout << max(0LL, sum) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

int64_t solve(int64_t n) {
  std::array<int64_t, 9> scores{111, 222, 333, 444, 555, 666, 777, 888, 999};
  for (auto const score : scores) {
    if (n <= score) {
      return score;
    }
  }
  return 0;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  auto const res = solve(n);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int range = sc.nextInt();
		Set<String> set = new HashSet<String>();
		for (int i = 0; i < range; i++){
			set.add(sc.next()); 
		}
		if ( set.size() < range){
        	System.out.println("NO");
        }else{
         	System.out.println("YES"); 
        }
	}
}	

Measured memory_bytes: 76448
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define INF 2000000007LL
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;

int n;
string s;

int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cin >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  FOR(i, n/2) {
    if (s[i] != s[n/2+i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
table={
  1:2,
  2:5,
  3:5,
  4:4,
  5:5,
  6:6,
  7:3,
  8:7,
  9:6,
}
dp=[-1]*(n+1)
dp[0]=0
for i in range(1,n+1):
  mx=-1
  for j in a:
    if not 0 <= i-table[j] < n+1:
      continue
    #print(i,i-table[j],dp[i-table[j]],j)
    if dp[i-table[j]]<0:
      continue
    if mx < dp[i-table[j]]*10+j:
      mx =dp[i-table[j]]*10+j
  dp[i]=mx
print(dp[n])

Measured memory_bytes: 20240
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class TaskB {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] x = new int[n];
			int[] y = new int[n];
			for (int i = 0; i < n; i++) {
				x[i] = in.nextInt();
				y[i] = in.nextInt();
			}

			for (int i = 0; i < n; i++) {
				double[] a = new double[n];
				int p = 0;
				for (int j = 0; j < n; j++) {
					if (j != i) {
						a[p++] = Math.atan2(y[j] - y[i], x[j] - x[i]);
					}
				}
				Arrays.sort(a, 0, p);
				a[p++] = a[0] + 2 * Math.PI;
				double max = 0;
				for (int j = 0; j + 1 < a.length; j++) {
					max = Math.max(max, a[j + 1] - a[j]);
				}
				max = Math.max(max - Math.PI, 0.0);
				out.printf("%.15f\n", max / (2 * Math.PI));
			}
		}

	}

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

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

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

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

	}
}



Measured memory_bytes: 22876
#include <iostream>

#include <string>
using namespace std ;



int main (){
    int n, k ;
    cin >> n >> k ;
    int marr[n] ;
    for(int i=0 ; i<n ; i++){
        marr[i] = i+1 ;
    }
    for (int i=0 ; i<k ;i++ ){
        int n1 = 0 ;
        cin >> n1 ;
        int arr[n1] ;
        for (int j=0 ; j<n1 ; j++){
            cin >> arr[j] ;
            marr[arr[j]-1] = 0 ;
        }
        
    }
    int ans = 0 ;
    for (int i=0 ; i<n ; i++){
        if(marr[i]!=0) ans++ ;
    }
    cout << ans ;
    
    return 0 ;
}



Measured memory_bytes: 3636
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-K),i))
print(dp[N-1])

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

int main() {
 int n; cin >> n;
 vector<int> a(n-1);
 vector<int> ans(n,0);
 for(int i=0;i<n-1;i++){
   cin >> a[i];
   ans[a[i]-1]++;
 }

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


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int cost = 1000000;
        for(int n=0;n<N;n++){
        	int c = sc.nextInt();
        	int t = sc.nextInt();
        	if(t<=T) cost = Math.min(cost,c);
        }
        if(cost>10000) System.out.println("TLE");
        else System.out.println(cost);
    }
}

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

int main() {
	string str[1001], tmp;
	int max_num = 0, max_length = 0, i, max = 1, max_str = 0, a[1001] = {};
	
	while (cin >> tmp) {
		for (i = 0; i < tmp.size(); i++) {
			if ('A' <= tmp[i] && tmp[i] <= 'Z')
				tmp[i] = tmp[i] + 'a' - 'A';
		}

		for (i = 0; i < max; i++) {
			if (str[i] == tmp) {
				a[i]++;
				if (max_str < a[i]) {
					max_str = a[i];
					max_num = i;
				}
				if (tmp.size() > max_length)
					max_length = (int)tmp.size();
				break;
			}
		}
		if (i >= max) {
			str[i-1] = tmp;
			max++;
			a[i - 1]++;
			if (max_str < a[i-1]) {
				max_str = a[i - 1];
				max_num = i - 1;
			}
			if (tmp.size() > max_length)
				max_length = (int)tmp.size();
		}
	}
	cout << str[max_num];

	for (i = 0; i < max; i++) {
		if ((int)str[i].size() == max_length)
			cout <<" "<< str[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
def grouping():
	x, y = map(int, input().split())

	l = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]

	if l[x] == l[y]:
		print('Yes')
	else:
		print('No')

if __name__ == '__main__':
	grouping()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
// vector<int>adj[100005];
// int dp[100005];
// bool vis[100005];
// int in_degree[100005];
// void dfs(int src){
//     vis[src]=true;    
//     for(auto it:adj[src]){
//         dp[it]=max(dp[it],dp[src]+1);
//         --in_degree[it];
//         if(in_degree[it]==0)dfs(it);
//         }
//
//
//
// }
//

int solve(int i,int n,int a[]){
    if(i>n)return 0;
    if(n-i>2);
    return max(solve(i+2,n,a)+a[i],solve(i,n-2,a)+a[n-1]);

}
ll int dp[3000][3000];   
int main(){
ios_base::sync_with_stdio(0);
ll int t,n,i,j,k,m;
t=1;
// cin>>t;
int T;
Fo(T,1,t+1){
//  cout<<"Case #"<<T<<": ";
  cin>>n;

ll  int a[n];
  fo(i,n)cin>>a[i];
    for(int L=n-1;L>=0;L--){
        for(int R=L;R<n;R++){
            if(L==R)dp[L][R]=a[L];

        
        else{
            dp[L][R]=max(a[L]-dp[L+1][R],a[R]-dp[L][R-1]);
        }
        }
    }
    cout<<dp[0][n-1];

}
}


Measured memory_bytes: 49800
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];

	std::sort(all(a));
	// check if a[i] is needed
	int l = -1, r = n;
	while(r-l>1) {
		int mid = (r+l)/2;
		int needed = false;
		// knapsack without a[i]
		std::vector<int> dp(k,0);
		dp[0] = 1;
		rep(i,n) {
			if(i==mid) continue;
			for(int v=k-1;v>0;v--) {
				if(v-a[i]>=0) dp[v] = std::max(dp[v],dp[v-a[i]]);
			}
		}
		int max = 0;
		for(int v=k-1;v>0;v--) {
			if(dp[v]>0) {
				max = v;
				break;
			}
		}
		if(max+a[mid]>=k) needed = true;
		if(needed) r=mid;
		else l=mid;
	}
	print(r);
	return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  init();

  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> ss(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      ss[i].emplace_back(s);
    }
  }
  vector<int> ps;
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p;
    ps.emplace_back(p);
  }

  const int mp = 1 << n;
  int res = 0;
  for (int i = 0; i < mp; i++) {
    int lits = 0;
    for (int j = 0; j < ss.size(); j++) {
      int sp = 0;
      for (auto s : ss[j]) {
        if (i & (1 << (s - 1))) {
          sp++;
	}
      }
      if (sp % 2 == ps[j]) {
	lits++;
      }
    }
    if (lits == m) {
      res++;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val sc = java.util.Scanner(System.`in`)
  val A = sc.nextInt()
  val B = sc.nextInt()
  val r = Array(50) { Array(100) { '.' } } + Array(50) { Array(100) { '#' } }

  for (i in 0..(B - 2)) {
    r[i / 50 * 2][i % 50 * 2] = '#'
  }
  for (i in 0..(A - 2)) {
    r[i / 50 * 2 + 51][i % 50 * 2] = '.'
  }
  println("100 100")
  r.forEach { println(it.joinToString("")) }
}


Measured memory_bytes: 35956
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] a = new int[n];

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

        int mod = (int)1e9+7;

        long ans = 1;

        int[] xyz = new int[3];

        for (int i=0; i<n; i++){
            int tmp = a[i];
            int cnt = 0;
            for (int j=0; j<3; j++){
                if (xyz[j] == tmp) {
                    cnt++;
                }
            }
            for (int j=0; j<3; j++){
                if (xyz[j]==tmp){
                    xyz[j]++;
                    break;
                }
            }
            ans *= cnt;
            ans %= mod;
        }
        System.out.println(ans);


    }
}

Measured memory_bytes: 51880
n,a = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
y = [i - a for i in x]
X = max(a,max(x))

dp = []
for i in range(n+1):
    dp.append([0]*(2*n*X+1))
for j in range(n,-1,-1):
    for t in range(2*n*X+1):
        if j == n and t ==n*X:
            dp[j][t] = 1
        elif j == n:
            dp[j][t] = 0
        elif 0 <= t-y[j] <= 2*n*X:
            dp[j][t] = dp[j+1][t] + dp[j+1][t-y[j]]
        else:
            dp[j][t] = dp[j+1][t]
def main():
    print(dp[0][n*X]-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 5484
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))

cnta=0
cntm=0
cntb=0

for i in range(n):
  if p[i]<=a:
    cnta+=1
  elif (p[i]>=a+1) and (p[i]<=b):
    cntm+=1
  else:
    cntb+=1

print(min(cnta,cntm,cntb))

Measured memory_bytes: 3064
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
string s[10101];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> s[i];

    int a = 0, b = 0, ba = 0, acc = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < s[i].size() - 1; ++j) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') acc++;
        }
        if (s[i][s[i].size()-1] == 'A' && s[i][0] == 'B') ba++;
        if (s[i][s[i].size()-1] == 'A') a++;
        if (s[i][0] == 'B') b++;
    }
    if (ba == a && ba == b) {
        cout << acc + max(0, ba - 1) << endl;
    } else {
        cout << acc + min(a, b) << endl;
    }
    return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
 
signed main()
{   
    gearup;
    ll n; cin >> n;
    ll ma = 200010;
    vl c(n);
    vector<mint> dp(n+1);
    vvl p(ma);
    rep(i,n){
        cin >> c[i];
        p[c[i]].push_back(i);
    }
    dp[0] = 1;
    rep(i,n){
        dp[i+1] += dp[i];
        int num = c[i];
        int idx = lower_bound(all(p[num]),i) - p[num].begin();
        if(idx > 0){
            int pre_pos = p[num][idx-1]; //前の位置
            if(pre_pos + 1 < i)dp[i+1] += dp[pre_pos+1]; //隣あっていなかったら
        }
    }
    out(dp[n].x);
}


Measured memory_bytes: 17028
import copy
import numpy as np
n=int(input())
xl=[]
for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l,l+x])
#print(xl)
xl = sorted(xl, key=lambda x: x[0],reverse=True)
#print(xl)

ans=0
r=2*(10**9+1)
for i in range(n):
  if xl[i][1]>r:
    continue
  if xl[i][0]<=r:
    r=xl[i][0]
    #print("r",r)
    ans+=1
print(ans)

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

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

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

  int x, y;
  cin >> x >> y;
  vector<int> a = {1, 3, 5, 7, 8, 10, 12};
  vector<int> b = {4, 6, 9, 11};
  vector<int> c = {2};

  if (find(a.begin(), a.end(), x) != a.end() &&
      find(a.begin(), a.end(), y) != a.end()) {
    cout << "Yes" << endl;
  } else if (find(b.begin(), b.end(), x) != b.end() &&
             find(b.begin(), b.end(), y) != b.end()) {
    cout << "Yes" << endl;
  } else if (find(c.begin(), c.end(), x) != c.end() &&
             find(c.begin(), c.end(), y) != c.end()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256