akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  int x, n;
  cin >> x >> n;

  if (n == 0)
  {
    cout << x << endl;
    return 0;
  }

  vector<int> p;
  rep(i, n)
  {
    int x;
    cin >> x;
    p.push_back(x);
  }

  sort(p.begin(), p.end());

  int min = p[0] - 1;
  int max = p[p.size() - 1] + 1;
  int min_abs = iINF;
  int ans = 0;

  repi(i, min, max + 1)
  {
    if (!binary_search(p.begin(), p.end(), i))
    {
      int tmp_abs = abs(x - i);
      if (tmp_abs < min_abs)
      {
        ans = i;
        min_abs = tmp_abs;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100008
ll maxn,type,sum;
struct str{
	int x,y;
}st[N];
map<int,int> mp;
stack<int> s;
bool cmp(str a,str b){
	return a.y>b.y;
}
int  main(){
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>st[i].x>>st[i].y;
  sort(st+1,st+n+1,cmp);
  for(int i=1;i<=k;i++){
  	if(!mp[st[i].x]){
  		mp[st[i].x]=1;type++;
  	}
  	else s.push(st[i].y);
  	sum+=st[i].y;
  	if(maxn<type*type+sum)maxn=type*type+sum;
  }
  for(int i=k+1;i<=n;i++){
  	if(s.empty())break;
  	if(mp[st[i].x])continue;
  	mp[st[i].x]=1;
	type++;
	sum=sum-s.top();
  	s.pop();
	sum+=st[i].y;
  	if(maxn<type*type+sum)maxn=type*type+sum;
  }
  cout<<maxn;
	return 0;
}

Measured memory_bytes: 4096
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val array = Array.ofDim[Int](10001)
  for {
    x <- 1 to 100
    y <- 1 to 100
    z <- 1 to 100
    result = x * x + y * y + z * z + x * y + y * z + z * x
    if result <= 10000
  } array(result) += 1
  1.to(N).foreach(i => println(array(i)))
}


Measured memory_bytes: 58776
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

class UnionFind{
    public:
        vector<ll> uni;
        UnionFind(ll s) : uni(s, -1) { }

       //頂点aが所属するグループを調べる
        ll root(ll a)
        {
            if (uni[a] < 0) return a;
            return uni[a] = root(uni[a]);
        }

        //頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
        bool connect(ll a, ll b)
        {
            a = root(a);
            b = root(b);
            if (a == b) return false;

            if (uni[a] > uni[b])
            {
                a ^= b;
                b ^= a;
                a ^= b;
            }

            uni[a] = uni[a] + uni[b];
            uni[b] = a;
            return true;
        }

        //頂点a,bが同じグループであるかを調べる
        bool isConnect(ll a, ll b)
        {
            return root(a) == root(b);
        }

        //頂点aを含むグループの頂点数を調べる
        ll size(ll a)
        {
            return -uni[root(a)];
        }
};

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;

    UnionFind u(n);

    for (ll i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        u.connect(a, b);
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ans = max(ans, u.size(i));
    }

    cout << ans << endl;
}


Measured memory_bytes: 4836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,k;
	cin >> n >> k;
	if(k==1){
		cout << 0 << endl;
		return 0;
	}
	cout << (n-k) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
#define Rep(i,s,n) for(int i=(s);i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    ll n;
    cin >>n;
    ll ans=0;

    Rep(i,1,n+1){
        ll j=n/i;
        ans+=i*(1+j)*j/2;
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;
 
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pi;

//#define int ll
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007
#define loop(n) for(int i = 0; i < n; i++)
#define rloop(n) for(int i = n-1; i >= 0; i--)

void io() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
bool checkValidity(int a, int b, int c) 
{
    // check condition 
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
}
void solve() {

    int cnt=0;
    int n; cin>>n;
    vi l(n);
    map <int,int> freq;
    loop(n) {
        cin>>l[i];
        freq[l[i]]++;
    }
    vi a = l;
    srt(a);
    auto it = unique(a.begin(), a.end());
    a.resize(distance(a.begin(), it));
    n = a.size();
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            for(int k=j+1; k<n; k++) {
                int x = a[i];
                int y = a[j];
                int z = a[k];
                if(checkValidity(x,y,z)) cnt += freq[x]*freq[y]*freq[z];
            }
        }
    }
    cout<<cnt<<"\n";
    return;
}
int32_t main() {
    io();
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3668
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toArray).tail
  val N = ls.size
  val bin = (0 to 100).map(_ => 0).toArray
  ls.map(_.tail).flatten.foreach{e => bin(e) += 1}
  //println(bin.toSeq)
  //println(N)
  val ret = bin.count(_ == N)
  println(ret)
}


Measured memory_bytes: 25400
import java.util.*
fun main(args: Array<String>) {

    val D = readLine()!!.split(" ").map{it.toInt()}[0]
    println(
    when (D) {
        22-> "Christmas Eve Eve Eve"
        23-> "Christmas Eve Eve"
        24-> "Christmas Eve"
        25-> "Christmas"
        else-> "err"
    }
    )
}


Measured memory_bytes: 36092
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {

	var n int;
    n = nextInt();
    p := make([]int,n);
    for i := 0 ; i < int(n) ; i++ {
        p[i] = nextInt();
    }
	solve(n, p);

}

func solve(n int, p []int){
	count := 0
	for i := 1; i < int(n)-1; i++ {
		if (p[i-1] > p[i] &&  p[i] > p[i+1] )|| ( p[i-1] < p[i] && p[i] < p[i+1] ){
			count++
		}
	}
	Println(count)
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}



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

int n;
string ans;

void gen(char c)
{
	if(ans.size() == n)
		printf("%s\n", ans.c_str());
	else
	{
		for(char a = 'a'; a <= c; a++)
		{
			ans.push_back(a);
			gen(a == c ? c + 1 : c);
			ans.pop_back();
		}		
	}	
}

int main ()
{
	cin >> n;
	gen('a');
	return 0;
}	

Measured memory_bytes: 1536
#include<cstdlib>
#include<map>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define For(i,a,b)for(int i=(int)a;i<=(int)b;++i)
#define Fordownd for(int i=(int)a;i>=(int)b;--i)
#define inf 2100000000
#define maxn 200000+10
#define ll long long
int n,tt,flag,sum1,sum2;
int head[maxn],b[maxn];
int l[maxn],top;
struct node
{
	int u,v,next;
}e[maxn<<1];
inline void read(int &x)
{
	int ans=0,fl=1;
	char c=getchar();
	while(!isdigit(c)&&c!='-')c=getchar();
	if(c=='-'){fl=-1;c=getchar();}
	while(isdigit(c)){ans=(ans<<3)+(ans<<1)+(c-'0');c=getchar();}
	x=ans*fl;
}
void add(int x,int y)
{
	++tt;
	e[tt].u=x;e[tt].v=y;
	e[tt].next=head[x];head[x]=tt;
}
void init()
{
	int x,y;
	read(n);
	For(i,1,n-1)
	{
		read(x);read(y);
		add(x,y);add(y,x);
	}
}
void dfs(int u)
{
	int i,v;
	b[u]=1;
	l[++top]=u;
	if(u==n){flag=1;return;}
	for(i=head[u];i;i=e[i].next)
	{
		v=e[i].v;
		if(!b[v])
		{
			dfs(v);
			if(flag)return;
			if(!flag)--top;
		}
	}
}
void dfss(int u)
{
	int i,v;
	sum2++;b[u]=1;
	for(i=head[u];i;i=e[i].next)
	{
		v=e[i].v;
		if(!b[v])
		{
			dfss(v);
		}
	}
}
void work()
{
	dfs(1);
	//For(i,1,top)printf("%d ",l[i]);
	memset(b,0,sizeof(b));
	int mid=(top+1)/2;
	b[l[mid+1]]=1;
	sum2=0;	dfss(1);
	sum1=sum2;sum2=0;
	dfss(l[mid+1]);
	if(sum1>sum2)printf("Fennec\n");
	else printf("Snuke\n");
}
int main()
{
	init();
	work();
	return 0;
}


Measured memory_bytes: 8448
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

ans = 0
for _ in range(n):
    a = list(map(int, input().split()))
    ans += 1 if sum([aa*bb for aa, bb in zip(a, b)])+c > 0 else 0
print(ans)


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

int main(int argc, char const *argv[])
{
	int n, k; cin >> n >> k;
	vector<int> t(n), d(n); rep(i, n) cin >> t[i] >> d[i];

	vector<pair<int, int>> v(n);
	rep(i, n) {
		v[i] = make_pair(t[i], -d[i]);
	}
	sort(v.begin(), v.end());

	vector<ll> vmax;
	vector<ll> vother;
	int prev = -1;
	for (auto tmp : v) {
		int t = tmp.first, d = -tmp.second;
		if (prev == t) {
			vother.push_back(d);
		} else {
			vmax.push_back(d);
			prev = t;
		}
	}

	sort(vmax.begin(), vmax.end()); reverse(vmax.begin(), vmax.end());
	sort(vother.begin(), vother.end()); reverse(vother.begin(), vother.end());

	ll ans = 0;
	rep(i, k + 1) {
		if (vmax.size() < i or vother.size() < k - i) continue;
		ll sum = accumulate(vmax.begin(), vmax.begin() + i, 0ll);
		sum += accumulate(vother.begin(), vother.begin() + k - i, 0ll);
		sum += (ll)i * i;
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int i,j,N,M;
  int result = 0;
  
  cin >> N;
  vector<string> Blue(N);
  for(i=0; i<N ; i++){
    cin >> Blue.at(i);
    //cout << Blue.at(i);
  }
  
  cin >> M;
  vector<string> Red(M);
  for(i=0; i<M ; i++){
    cin >> Red.at(i);
    //cout << Red.at(i);
  }
  
  for(i=0; i< N ; i++){
    int result_tmp = 0;
    string Blue_tmp = Blue.at(i);
    for(j=0; j<N ; j++){
      if(Blue_tmp == Blue.at(j)){
        result_tmp++;
        //cout << Blue.at(j);
      }
    }
    for(j=0; j<M ; j++){
      if(Blue_tmp == Red.at(j)){
        result_tmp--;
        //cout << Red.at(j);
      }
    }
    if(result < result_tmp){
      result =  result_tmp;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        var dp = new int[n + 1, n / 2 + 1, 2];
        for (int i = 0; i < n - 1; i++)
            a[i] = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n + 1; i++)
            for (int j = 0; j < n / 2 + 1; j++)
                for (int k = 0; k < 2; k++) dp[i, j, k] = int.MaxValue;
        goDP(dp, a, n);
        var ans = Min(dp[n, n / 2, 0], dp[n, n / 2, 1]);
        Console.WriteLine(ans);
    }
    static void goDP(int[,,] dp, int[] a, int n)
    {
        dp[0, 0, 0] = 0;
        dp[0, 0, 1] = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n / 2; j++)
                {
                    if (dp[i, j, 0] == int.MaxValue | dp[i, j, 1] == int.MaxValue) continue;
                    dp[i + 1, j + 1, 0] = Min(dp[i + 1, j + 1, 0], dp[i, j, 0]);
                    dp[i + 1, j, 1] = Min(dp[i + 1, j, 1], dp[i, j, 1]);
                    dp[i + 1, j + 1, 1] = Min(dp[i + 1, j + 1, 1], dp[i, j, 0] + a[i]);
                    dp[i + 1, j, 0] = Min(dp[i + 1, j, 0], dp[i, j, 1] + a[i]);
                }
    }
}


Measured memory_bytes: 408224
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

struct State {
  int pos;
  string str_result;
  int int_result;
  State(int pos,string str_result) 
    : pos(pos), str_result(str_result) {}
  State(int pos,int int_result) 
    : pos(pos), int_result(int_result) {}
};

// EXPR ::= NUMBERS ( EXPR ) | NUMBERS ALPHA | ALPHAS

State alphas(const string& str,int pos){
  string tmp = "";
  while(pos < str.size() && isalpha(str[pos])){
    tmp.push_back(str[pos]);
    pos++;
  }
  return State(pos,tmp);
}

State numbers(const string& str,int pos){
  int tmp = 0;
  while(pos < str.size() && isdigit(str[pos])){
    tmp += (str[pos] - '0');
    tmp *= 10;
    pos++;
  }
  tmp /= 10;
  return State(pos,tmp);
}

State expr(const string& str,int pos){
  string result = "";
  while(pos < str.size() && (isdigit(str[pos]) || isalpha(str[pos]))){
    if(isdigit(str[pos])){
      State s1 = numbers(str,pos);
      pos = s1.pos;
      if(str[pos] == '('){
        pos++;
        State s2 = expr(str,pos);
        string tmp = "";
        for(int i = 0; i < s1.int_result; i++){
          tmp += s2.str_result;
          if(tmp.size() > 1000000) break;
        }
        result += tmp;
        pos = s2.pos + 1;
      }
      else{
        State s2 = alphas(str,pos);
        string tmp = "";
        for(int i = 0; i < s1.int_result; i++){
          tmp += s2.str_result;
          if(tmp.size() > 1000000) break;
        }
        result += tmp;
        pos = s2.pos;
      }
    }
    else if(isalpha(str[pos])){
      State s1 = alphas(str,pos);
      result += s1.str_result;
      pos = s1.pos;
    }
  }
  return State(pos,result);
}


int main(){
  string genome;
  int pos;
  while(cin >> genome >> pos){
    if(genome == "0" && pos == 0) break;
    string result = expr(genome,0).str_result;
    if(pos < result.size()){
      cout << result[pos] << endl;      
    }
    else{
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 12096
import copy
n,m=map(int,input().split())
l=[]
for i in range(n):
    s=list(input())
    l.append(s)
flag=0
s=copy.deepcopy(l)
#print(l)
if(l[0][0]=="#"):
    l[0][0]=1 
else:
    l[0][0]=0;
for i in range(1,n):
    if(l[i][0]=="#"):
        if s[i-1][0]=="#":
            l[i][0]=l[i-1][0]
        else:
            l[i][0]=l[i-1][0]+1
            
    else:
        l[i][0]=l[i-1][0]
for i in range(1,m):
    if( l[0][i]=="#"):
        if s[0][i-1]=="#":
            l[0][i]=l[0][i-1]
        else:
            l[0][i]=l[0][i-1]+1
    else:
        l[0][i]=l[0][i-1]

for i in range(1,n):
    for j in range(1,m):
        if(l[i][j]=="#"):
            a1=l[i][j-1]
            a2=l[i-1][j]
            if s[i][j-1]==".":
                a1+=1
            if s[i-1][j]==".":
                a2+=1
            l[i][j]=min(a1,a2)
        else:
            l[i][j]=min(l[i-1][j],l[i][j-1])
#print(l)
print(l[n-1][m-1])
            
    
            
            
            

Measured memory_bytes: 44528
#include <climits>
#include <cstring>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <fstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define f first
#define s second

#define MM INT_MAX/5
#define MIM INT_MIN/2

int di[] = { 1,-1,0,0 };
int dj[] = { 0,0,1,-1 };

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define v vector
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

#define MAX (int)1e5+1

ll vals[101];
int weights[101];
ll dp[MAX];

int main()
{
	for (int i = 0; i < 101; i++)
		dp[i] = -1;
	int N, W;
	cin >> N >> W;
	for (int i = 1; i <= N; i++)
	{
		cin >> weights[i];
		cin >> vals[i];
	}
	dp[0] = 0;
	for (int i = 1; i <= N; i++)
		for (int j = W; j >= 0; j--)
		{
			if (dp[j] >= 0 && j + weights[i] <= W)
				dp[j + weights[i]] = max(dp[j] + vals[i], dp[j + weights[i]]);
		}
	ll ans = -1;
	for (int i = W; i > 0; i--)
		ans = max(ans, dp[i]);
	cout << ans;
}



Measured memory_bytes: 1024
import math
dic = {}
N = int(input())
for i in range(2, N+1):
    fact = []
    while i % 2 == 0:
        fact.append(2)
        i //= 2
    f = 3
    while f*f <= i:
        if i%f == 0:
            fact.append(f)
            i //= f
        else:
            f += 2
    if i != 1:
        fact.append(i)
    for j in fact:
        if j in dic:
            dic[j] += 1
        else:
            dic[j] = 1
cnt = 0
s1 = len([k for k, v in dic.items() if v >= 2])
s2 = len([k for k, v in dic.items() if v >= 4])
s3 = len([k for k, v in dic.items() if v >= 14])
s4 = len([k for k, v in dic.items() if v >= 24])
s5 = len([k for k, v in dic.items() if v >= 74])

#3*5*5
if s2 >= 2 and s1 >= 3:
    cnt += s2*(s2-1)/2*(s1-2)
#15*5
if s3 >= 1:
    cnt += s3*(s2-1)
#25*3
if s4 >= 1:
    cnt += s4*(s1-1)
#75
if s5 >= 1:
    cnt += s5
print(int(cnt))

Measured memory_bytes: 3188
#import<cstdio>
#include<bitset>

int n, s, a,i;
std::bitset<4000000> b;
int main()
{
	scanf("%d",&n);
	b[0]= 1;
	while (n--) {
		scanf ("%d", &a);
		b |= b << a;
		s += a;
	}
	for (i = (s+1) / 2;!b[i];i++);
	printf("%d",i);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

const int MAX_V = 10010;

int V, E;
vector<vector<int>> G(MAX_V);
vector<vector<int>> rG(MAX_V);
vector<int> vs;
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);

void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v){
    used[v] = true;
    
    for(int i=0; i<G[v].size(); i++){
        if(!used[G[v][i]]) dfs(G[v][i]);
    }

    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;

    for(int i=0; i<rG[v].size(); i++){
        if(!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
}

int scc(){
    for(int i=0; i<MAX_V; i++) used[i] = false;
    vs.clear();
    
    for(int v=0; v<V; v++){
        if(!used[v]) dfs(v);
    }

    for(int i=0; i<MAX_V; i++) used[i] = false;
    int k = 0;

    for(int i=vs.size()-1; i>=0; i--){
        if(!used[vs[i]]) rdfs(vs[i], k++);
    }

    return k;
}

int main(){
    cin>>V>>E;
    for(int i=0; i<E; i++){
        int s, t; cin>>s>>t;
        add_edge(s, t);
    }

    scc();

    int q; cin>>q;
    while(q--){
        int s, t; cin>>s>>t;
        cout << (cmp[s] == cmp[t]) << endl;
    }
}


Measured memory_bytes: 4716
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A-B>=0){
			System.out.println("delicious");
		} else if(B-A<=X){
			System.out.println("safe");
		} else{
			System.out.println("dangerous");
		}
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n),dic(100010,0);
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        a[i] = tmp+1;
        dic[tmp+1]++;
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans = max(ans, dic[a[i]-1]+dic[a[i]]+dic[a[i]+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
     let ps = line.split_whitespace()
                .map(|t| t.parse::<usize>().unwrap())
                .collect::<Vec<_>>();
     
    let mut cnt = 0;
    for i in 1..(n-1) {
        if ps[i] > ps[i-1] && ps[i] > ps[i+1] {
            continue;
        }
        if ps[i] < ps[i-1] && ps[i] < ps[i+1] {
            continue;
        }
        cnt += 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin>>N>>K;
    rep(i,0,N){
        cin>>a[i];
    }
    ans = 0;
    rep(i,0,N){
        rep(j,0,N){
            if(a[i]>a[j]){
                if(i<j){
                    ans+=((1+K)*K)/2;
                }else{
                    ans+=((1+K-1)*(K-1))/2;
                }
                ans%=mod;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
bl = [0]*n
blli = [0]*n
al = [0]*n
alli = [0]*n
import bisect

for i in range(n):
    bl[i]=n-bisect.bisect(c,b[i])

blli[0] = sum(bl)
for i in range(n-1):
    blli[i+1] = blli[i]-bl[i]
   
for i in range(n):
    al[i]=n-bisect.bisect(b,a[i])

for i in range(n):
    if al[i]!=0:
        alli[i] = blli[-al[i]]

print(sum(alli))

Measured memory_bytes: 34000
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int x;
        for(int i = 1;;i++){
            x = scan.nextInt();
            if(x==0){
                break;
            }
            System.out.println("Case " + i + ": " + x);
        }
    }
}


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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::vec_deque::VecDeque;

fn main() {
    input! {
        k: usize
    }
    let mut q: VecDeque<i64> = VecDeque::new();
    for i in 1..10 {
        q.push_back(i);
    }
    if k <= 9 {
        println!("{}", q[k-1]);
        return;
    }
    let mut cnt = q.len();
    loop {
        let x = *q.front().unwrap();
        q.pop_front();
        for i in &[-1,0,1] {
            let d = x % 10 + i;
            if d < 0 || 9 < d { continue; }
            let nx = x * 10 + d;
            q.push_back(nx);
            cnt += 1;
            if cnt == k {
                println!("{}", q.back().unwrap());
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    int K,A,B;
    cin >> K >> A >> B;
    string ans = "NG";
    rep1(i,A,B+1) {
        if(i%K==0) {
            ans ="OK";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+5;
const long long mod = 1e9+7;
long long Sort[maxn];
long long ans[maxn];
int dir[9][2]={-2,-2,-2,-1,-2,0,-1,-2,-1,-1,-1,0,0,-2,0,-1,0,0};
int tot;
int main()
{
	long long H,W,N;
	scanf("%lld%lld%lld",&H,&W,&N);
	long long Ans=(long long)(H-2)*(long long)(W-2);
	for(int i=0;i<N;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		for(int j=0;j<9;j++)
		{
			int xx=x+dir[j][0];
			int yy=y+dir[j][1];
			if(xx>=1 && xx<=H-2 &&yy>=1 && yy<=W-2)
			{
				Sort[tot++] = xx * mod + yy;
			}
		}
	}
	sort(Sort,Sort+tot);
	int cnt=1;
	for(int i=0;i<tot;i++)
	{
		if(Sort[i]==Sort[i+1])
			cnt++;
		else
		{
			ans[cnt]++;
			cnt=1;
			Ans--;
		}
	}
	printf("%lld",Ans);
	for(int i=1;i<10;i++)
		printf(" %lld",ans[i]);
	printf("\n");
	
	
	return 0;
}

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

arr = list(map(int,input().split()))
d = [0 for i in range(n)]

for i in range(n-1):
    d[i] = arr[i+1]-arr[i]

d[-1] = k-arr[-1]+arr[0]
# print(d)

print(k-max(d))

Measured memory_bytes: 87372
# C - Snuke Festival

N = int(input())
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())

A.sort()
C.sort()

def binarySearchLeft(a, b):
    l = -1
    r = N
    while l+1<r:
        m = (l+r)//2
        if a[m]<b:
            l = m
        else:
            r = m
    return r

def binarySearchRight(a, b):
    l = -1
    r = N
    while l+1<r:
        m = (l+r)//2
        if a[m]<=b:
            l = m
        else:
            r = m
    return r

ans = 0
for j in range(N):
    ans += binarySearchLeft(A, B[j]) * (N - binarySearchRight(C, B[j]))

print(ans)

Measured memory_bytes: 23328
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

A,B,C,D = map(int,input().split())
count = 0

QC = 0 #Cで割り切れる
QD = 0 #Dで割り切れる
QCD = 0 #CとDで割り切れる

CD = lcm(C,D) #最大公約数

#約数の個数を求める
QC = (B // C) - (A // C)
if A % C == 0:
        QC += 1

QD = (B // D) - (A // D)
if A % D == 0:
        QD += 1

QCD = (B // CD) - (A // CD)
if A % CD == 0:
        QCD += 1

N = B-A+1
CorD = QC+QD-QCD

print(N-CorD)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 10000000
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 998244353
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

bool prime[MAX];
vector <int> p;

void sieve()
{
    memset(prime,0,sizeof(prime));
    prime[0]=prime[1]=1;

    for(int i = 4; i < MAX; i += 2)
    {
        prime[i] = 1;
    }
    for(int i = 3; i*i < MAX; i += 2)
    {
        if(!prime[i])
        {
            for(int j = i*i; j < MAX; j += i)
                prime[j] = 1; /// not prime
        }
    }

    for(int i = 2; i < MAX; i++)
        if(!prime[i])
            p.push_back(i);
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    sieve();
    int x;
    cin>>x;
    vector<int>::iterator it = lower_bound(p.begin(), p.end(), x);
    cout<<*it<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 16240
/*input
10 10
*/

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

int main() {
    int s, w;
    cin >> s >> w;
    if (s > w) puts("safe");
    else puts("unsafe");
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
	int n,k;
	cin>>n>>k;
	map<int,int> kasi;
	rep(i,0,k){
		int d;cin>>d;
		rep(j,0,d){
			int a; cin>>a;
			kasi[a-1]+=1;
		}
	}

	int ans=0;
	rep(i,0,n){
		if(kasi[i]==0) ans++;
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 3632
def grinp(h):
  ret=[]
  for i in range(h):
    ret.append(list(input()))
  return ret
h,w,k=map(int,input().split())
gr=grinp(h)
ans=0
for i in range(2**h):
  chx=[]
  for j in range(h):
    if((i>>j)&1):
      chx.append(j)
  for j in range(2**w):
    chy=[]
    for kk in range(w):
      if ((j>>kk)&1):
        chy.append(kk)
    com=0
    for kk in range(h):
      for l in range(w):
        if kk in chx or l in chy:
          continue
        if gr[kk][l]=="#":
          com+=1
    if com==k:
      ans+=1
print(ans)

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

using namespace std;

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

int main(){

	int n,k;
	cin>>n>>k;
	int d[k];
	rep(i,k)cin>>d[i];

	int a=n;
	int ans=n;
	int flag=0;
	while(true){
		flag=0;
		a=ans;
		while(a!=0){
			rep(i,k){
				if(d[i]==a%10){
					flag=1;
					break;
				}
			}
			if(flag==1)break;
			a/=10;
		}
		if(flag==0)break;
		ans++;
	}


	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n;

void sort(int a[]){

    int key,j;
    for(int i=1;i<=n;i++){

	for(int l=0;l<n;l++){
	    cout << a[l];
	    if(l < n-1) cout << " ";
	}
	cout << endl;

	if(i == n) break;

	key = a[i];
	j = i - 1;
	while(j >= 0 && key < a[j]){
	    a[j+1] = a[j];
	    a[j] = key;
	    j--;
	}

    }

}
	


int main(){

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

    sort(a);

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<vector<int>> d(10, vector<int>(10, 1000000));

void warshall_floyd(int n) {
    rep(k,n) rep(i,n) {
        rep(j,n) {
            d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        }
    }
}
int main()
{
    int n; cin >> n;
    vector<int> a(n,0);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            if (i % j == 0)
                a[i-1]++;
        }
    }
    int ans = 0;
    rep(i,n) if (a[i] == 8 && i % 2 == 0) ans++;
    cout <<ans << endl;
    
    return 0;
}


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

class Program {
    static Scanner cin = new Scanner();
    static int N = cin.Int();
    static int K = cin.Int();
    static int[] D = cin.ArrayInt(K);
    static List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    static List<int> ANS = new List<int>();
    static void Main() {
        foreach (var x in D) {
            list.Remove(x);
        }
        foreach (var x in list) {
            if(x != 0) hoge(x);
        }

        ANS = ANS.Where(x => x >= N).ToList();
        Console.WriteLine(ANS.Min());
        Console.ReadLine();
    }

    static void hoge(int n) {
        ANS.Add(n);
        if (n >= 100 * N) return;
        foreach (var x in list) {
            hoge(10 * n + x);
        }
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 72660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string C;
  cin >> C;
  if(C == "a"){
    cout << "b" << endl;
  }
  
   if(C == "b"){
    cout << "c" << endl;
  }

   if(C == "c"){
    cout << "d" << endl;
  }
  
  if(C == "d"){
    cout << "e" << endl;
  }
  
  if(C == "e"){
    cout << "f" << endl;
  }
  
  if(C == "f"){
    cout << "g" << endl;
  }
  
  if(C == "g"){
    cout << "h" << endl;
  }
  
  if(C == "h"){
    cout << "i" << endl;
  }
  
  if(C == "i"){
    cout << "j" << endl;
  }
  
  if(C == "j"){
    cout << "k" << endl;
  }
  
  if(C == "k"){
    cout << "l" << endl;
  }
  
  if(C == "l"){
    cout << "m" << endl;
  }
  
  if(C == "m"){
    cout << "n" << endl;
  }
  
  if(C == "n"){
    cout << "o" << endl;
  }
  
  if(C == "o"){
    cout << "p" << endl;
  }
  
  if(C == "p"){
    cout << "q" << endl;
  }
  
  if(C == "q"){
    cout << "r" << endl;
  }
  
  if(C == "r"){
    cout << "s" << endl;
  }
  
  if(C == "s"){
    cout << "t" << endl;
  }
  
  if(C == "t"){
    cout << "u" << endl;
  }
  
  if(C == "u"){
    cout << "v" << endl;
  }
  
  if(C == "v"){
    cout << "w" << endl;
  }
  
  if(C == "w"){
    cout << "x" << endl;
  }
  
  if(C == "x"){
    cout << "y" << endl;
  }
  
  if(C == "y"){
    cout << "z" << endl;
  }
}


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

using namespace std;

typedef long long ll;

bool cmp(pair<int, int>a, pair<int, int>b) {
    if(a.second == b.second) return a.first<b.first;
    return a.second > b.second;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int> > g(n);
    vector<pair<int, int> > ed(n-1);
    vector<int> deg(n, 0);
    int k=0;
    for(int i=0, u, v; i<n-1; i++) {
        cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
        deg[u]++; deg[v]++;
        k = max(k, max(deg[u], deg[v]));
        ed[i] = {u, v};
    }
    cout << k << endl;
    vector<pair<int, int> > p(n);
    for(int i=0; i<n; i++) {
        p[i] = {i, deg[i]};
    }
    sort(p.begin(), p.end(), cmp);
    vector<set<int> > s(n);
    map<int, map<int, int> > mp;
    for(int i=0; i<n; i++) {
        int c = 1;
        for(auto x : g[i]) if(!mp[i][x]){
            if(s[i].find(c)!=s[i].end()||s[x].find(c)!=s[x].end())
                c++;
            s[i].insert(c);
            s[x].insert(c);
            mp[i][x] = mp[x][i] = c;
            c++;
        }
    }
    for(auto x: ed) {
        cout << mp[x.first][x.second] << endl;
    }
    return 0;
}


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

using namespace std;

int ret[100000];

bool is_male(int seat) {
  cout << seat << endl;
  string v;
  cin >> v;
  if (v == "Vacant") {
    exit(0);
  }
  if (ret[seat] != -1) {
    return ret[seat];
  }
  if (v == "Male") {
    ret[seat] = true;
    return true;
  } else {
    ret[seat] = false;
    return false;
  }
}

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

  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    ret[i] = -1;
  }

  int l = 0, r = n;
  is_male(l);
  while (l < r) {
    int m = (l + r) / 2;
    is_male(m);
    if ((m - l) % 2) {
      if (ret[m] == ret[l]) {
        r = m;
      } else {
        l = m;
      }
    } else {
      if (ret[m] == ret[l]) {
        l = m;
      } else {
        r = m;
      }
    }
  }
}


Measured memory_bytes: 1236
import math
import collections


f = math.factorial


def comb(n, r, memo):
    if (n, r) in memo:
        return memo[n, r]
    elif n < r:
        memo[n, r] = 0
        return 0
    else:
        res = memo[n, r] = f(n) // f(r) // f(n - r)
        return res


N = int(input())
A = list(map(int, input().split()))
memo = {}
counts = collections.Counter(A)
total = sum(comb(count, 2, memo) for count in counts.values())
for a in A:
    count = counts[a] - 1
    diff = count * (counts[a] - count + 1) // 2
    print(total - diff)

Measured memory_bytes: 26780
import numpy  as np

N = int(input())

# log_6 10^5 < 7
# log_9 10^5 < 6
# 15 = 1 + 6 + 5
memo = np.zeros((15, N + 1),int)
memo[:, :] = N * 2
memo = memo.tolist()
memo[0][0] = 0

values = []

i = 1
while i <= N:
    values.append(i)
    i *= 6
i = 9
while i <= N:
    values.append(i)
    i *= 9

for i in range(len(values)):
    v = values[i]
    for w in range(N+1):
        if v > w:
            memo[i + 1][w] = memo[i][w]
        else:
            memo[i + 1][w] = min(memo[i][w], memo[i+1][w - v] + 1)
print(int(memo[len(values)][N]))

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    if (n < 1000)
        puts("ABC");
    else
        puts("ABD");
}

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


Measured memory_bytes: 256
#include "stdio.h"

int main(void)
{
	int W,H,x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if(x-r<0 || x+r>W || y-r<0 || y+r>H)
		puts("No");
	else
		puts("Yes");
	return 0;
}

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

using i64 = int64_t;

std::vector<i64> divisor(i64 n) {
    std::vector<i64> res;
    for (i64 i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i)
                res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }

    vector<int> rem(n+1), ans(n+1);
    int m = 0;
    for(int i=n;i>0;--i){
        auto d = divisor(i);
        if(rem[i]^v[i-1]){
            m++;
            ans[i] = 1;
            for(auto e: d){
                rem[e] ^= 1;
            }
        }
    }

    cout << m << endl;
    if(m > 0){
        vector<int> b;
        for(int i=0;i<n;++i){
            if(ans[i+1] > 0)b.push_back(i+1);
        }
        for(int i=0;i<m;++i){
            if(i)cout << " ";
            cout << b[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 4212