akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    static int n;
    static int mod = 1000000007;
    static int[] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        dp = new int[n+1];
        for (int i = 1; i < n; i++) {
            primeFactorize(i);
        }
        primeFactorize(n);

        long count = 1;
        for (int i = 0; i <= n; i++) {
            if (dp[i] != 0) {
                count = count%mod * (dp[i] + 1)%mod;
            }
        }
        System.out.println(count);
    }
    //素因数分解し、素因数を配列に格納する。
    static void primeFactorize(int num) {
        for (int i = 2; i <= num; i++) {
        if (num % i != 0) continue;
        dp[i]++;
        primeFactorize(num/i);
        break;
        }
    }
}


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

int main() {
 char c;
 cin >> c;
 if(c == 'a'||c=='i'||c=='u'||c=='e'||c=='o'){
     cout << "vowel"<<endl;
 }else{
     cout << "consonant"  << endl;
 }
}


Measured memory_bytes: 764
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	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;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

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

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {

	int n;
	cin >> n;
	bool ta[60000];
	memset(ta, 1, sizeof(ta));
	ta[0] = false;
	ta[1] = false;
	vector<int> re;
	for (size_t i = 2; i <= 55555; i++)
	{
		if (!ta[i]) continue;
		if (i % 10 == 7) {
			re.push_back(i);
		}
		int it = i + i;
		while (it <= 55555)
		{
			ta[it] = false;
			it += i;
		}
	}
	for (size_t i = 0; i < n; i++)
	{
		if (i > 0)cout << " ";
		cout << re[i];
	}
	cout << endl;
}


int main() {
	//COMinit();
	solv();

	return 0;
}


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

#define ll long long

using namespace std;

const int N = 100010;
const int mod = 10007;

inline int read() {
	int jg = 0, jk = getchar() - '0', f = 1;
	while(jk < 0 || jk > 9) {
	    if(jk == '-' - '0')  f = -1;
		jk = getchar() - '0';
	}
	while(jk >= 0 && jk <= 9)
		jg *= 10, jg += jk, jk = getchar() - '0';
	return jg * f;
}

int n, ans, k;
char s[N];

int main() {
	//freopen("a.txt", "r", stdin);
    n = read(), k = read();
	scanf("%s", s);
	for(int i = 1; i < n; ++i)
		if(s[i] == s[i - 1])
			ans++;
	ans += 2 * k;
	ans = min(ans, n - 1);
	printf("%d", ans);
	return 0;
}

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

namespace kyoupuro1
{
    class Program
    {

        static void Main(string[] args)
        {
            int a,t,n;
            var h = new List<int>();
            n = int.Parse(Console.ReadLine());
            var ip1 = Console.ReadLine().Split(' ');
            var ip2 = Console.ReadLine().Split(' ');
            t = int.Parse(ip1[0]);
            a = int.Parse(ip1[1]);
            for(int i = 0;i < n;i++)
                h.Add(int.Parse(ip2[i]));

            float minAbs =Math.Abs( a - (t-h[0]*0.006f));
            int minind = 0;
            for(int i = 1;i < n; i++)
            {
                var d = Math.Abs(a - (t - h[i] * 0.006f));
                if (minAbs > d)
                {
                    minAbs = d;
                    minind = i;
                }
            }
            Console.WriteLine(minind + 1);

        }

        static List<int> GetPNLs(int max)
        {
            List<int> prime = new List<int>();
            if (max <= 1) return new List<int> {2};
            for (int i = 2; i <= max; i++)
            {
                bool isPrime = true;
                foreach (var p in prime)
                {
                    if (i % p == 0 && i != p)
                    {
                        isPrime = false;
                        break;
                    }
                }
                if (isPrime) prime.Add(i);
            }
            return prime;
        }

        static int E(int prime, int n)
        {
            int k = n;
            int c = 0;
            while (k % prime == 0)
            {
                k = k / prime;
                c++;
            }
            return c;
        }

        static int C(int a, int b)
        {
            if (a < b) return 0;
            return F(a) / (F(b) * F(a - b));
        }

        static int F(int n)
        {
            if (n > 1)
                return F(n - 1) * n;
            else
                return 1;
        }
    }
}


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

int main(){
    int K, N;
    cin >> K >> N;
    int init, prev, cur;
    cin >> init;
    prev = init;
    int gap = 0;
    rep(i, N-1){
        cin >> cur;
        gap = max(gap, cur-prev);
        prev = cur;
    }
    gap = max(gap, K+init-prev);
    cout << K-gap << endl;
    return 0;
} 

Measured memory_bytes: 384
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        this.RowCount = inpt[0];
        this.ColCount = inpt[1];
        this.Target = inpt[2];

        string ans = "No";
        for (int i = 0; i <= this.RowCount; i++) {
            if(this.ColCount * i == Target) {
                ans = "Yes";
                break;
            }
            for (int j = 0; j <= this.ColCount; j++) {
                long calc = this.ColCount * i;
                calc -= (i * j * 2);
                calc += this.RowCount * j;
                if(calc == Target) {
                    ans = "Yes";
                    break;
                }
            }
            if(ans.Equals("Yes")) {
                break;
            }
        }
        Console.WriteLine(ans);



    }

    private int RowCount;
    private int ColCount;
    private int Target;


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


7 9 20



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
#define LEN 100005
  
/*プロセスを表す構造体*/
typedef struct pp {
  char name[100];
  int t;
} P;
  
P Q[LEN];
int head, tail, n;
  
void enqueue(P x) {
  Q[tail]=x;
  tail = ( tail+1 ) % LEN;
}
  
P dequeue(){
  P x=Q[head];
  head = (head+1) % LEN;
  return x;
}
  
int min(int a, int b) {return a<b ? a:b ;} /*最小値を返す*/
  
int main() {
  int elaps = 0, c;
  int i,q;
  P u;
  scanf("%d %d", &n, &q);
  
/*すべてのプロセスをキューに順番に追加する*/
  
  for (i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n+1;
  
/*シミュレーション*/
  
  while (head != tail ) {
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) { enqueue(u);}
    else { printf("%s %d\n", u.name,elaps);
    }
      }
  
  
return 0;
  
}


Measured memory_bytes: 11856
#include <iostream>

using namespace std;

int N;
long int A, B;
long int h[100000];
long int h_max = 0;
long int first;
long int endas;
long int temp;

bool enough(long int x);



int main() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
		if (h[i] > h_max) {
			h_max = h[i];
		}
	}

	first = 1;
	endas = h_max;
	temp = (first + endas) / 2;

	while (1) {
		if (enough(temp)) {
			endas = temp;
		}
		else {
			first = temp + 1;
		}
		temp = (first + endas) / 2;
		if (first == endas) break;
	}
	cout << temp << endl;

}

bool enough(long int x) {
	long long int T = 0;
	for (int i = 0; i < N; ++i) {
		long int a = h[i] - x * B;
		if (a > 0) {
			T += a / (A - B);
			if (a % (A - B) != 0) {
				++T;
			}
		}
	}
	if (T > x) {
		return false;
	}
	else {
		return true;
	}
}

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

#define REP(i, a, b) for (int i = a; i < b; ++i)
#define MOD 1000000007
#define nline cout << "\n";
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int lli;
typedef vector<int> vi;
typedef vector<lli> vlli;

typedef pair<int, int> pi;
typedef pair<lli, lli> plli;

typedef vector<pi> vpii;
typedef vector<plli> vplli;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;

    while (t--)
    {

        int n;
        cin >> n;
        int a[4] = {0};
        for (int i = 0; i < n; i++)
        {
            string s;
            cin >> s;
            if (s == "AC")
                a[0]++;
            else if (s == "TLE")
                a[1]++;
            else if (s == "WA")
                a[2]++;
            else
                a[3]++;
        }
        cout << "AC x " << a[0] << endl;
        cout << "WA x " << a[2] << endl;
        cout << "TLE x " << a[1] << endl;
        cout << "RE x " << a[3] << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
N = gets.to_i
S = gets.chomp

max = 0
N.times do |i|
  tmp = 0

  26.times do |x|
    ch = ("a".ord + x).chr
    left = S[0, i+1]
    right = S[i+1, N]
    if left.include? ch and right.include? ch
      tmp += 1
    end
  end

  max = [max, tmp].max
end


puts max


Measured memory_bytes: 1916
//Jai Shree Ram
//#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define loopi(stop) for(int i=0; i<stop; i++)
#define loopj(stop2) for(int j=0; j<stop2; j++)
#define loopk(stop3) for(int k=0; k<stop3; k++)
#define loopi1(stop) for(int i=1; i<=stop; i++)
#define loopj1(stop2) for(int j=1; j<=stop2; j++)
#define loopk1(stop3) for(int k=1; k<=stop3; k++)
#define loopse(kt,sstart, eend) for(int kt = sstart; kt<eend; kt++)
#define faster_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file_io_cf freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define p_b push_back
#define pii pair<int,int>
#define fi first
#define se second
#define prec_10 << fixed << setprecision(10)
#define DEB cout<<"DEBUG"<<'\n';
#define SRAND srand(time(0));

using namespace std;

int mod = 1000000007;

template <typename T>
void O(T x) {
	cout << x << '\n';
}

///////////////////////////////////CODE STARTS HERE///////////////////////////////////////////

int32_t main() {

	faster_io
	// file_io_cf

	int d,t,s;cin>>d>>t>>s;
	if(s*t>=d)O("Yes");
	else{O("No");}

	return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1000000007;

// ref: https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint
{
  ll x;
  mint(ll 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
  {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const
  {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const
  {
    return mint(*this) *= a;
  }
  mint pow(ll 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
  {
    return mint(*this) /= a;
  }
};
istream &operator>>(istream &is, const mint &a)
{
  return is >> a.x;
}
ostream &operator<<(ostream &os, const mint &a)
{
  return os << a.x;
}

struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

mint repeatSquaring(ll n, ll p)
{
  if (p == 0)
    return mint(1);
  if (p % 2 == 0)
  {
    mint t = repeatSquaring(n, p / 2);
    return t * t;
  }
  return mint(n) * repeatSquaring(n, p - 1);
}

int main()
{
  long long K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  mint ans = 0;
  ll ns = S.size();
  combination comb(K + ns);
  for (ll i = ns + K - 1; i >= ns - 1; --i)
  {
    mint sum = comb(i, ns - 1);
    sum *= repeatSquaring(26, max(ns + K - 1 - i, 0LL));
    sum *= repeatSquaring(25, max(i - ns + 1, 0LL));
    ans += sum;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  ll ans=0;
  for(int i=0;i<s.size();i++){
    ans+=(ll)(s[i]-'0');
  }
  cout<<yesno(ans%9==0)<<endl;
  return 0;
}


Measured memory_bytes: 3740
# -*- coding: utf-8 -*-

N, = map(int, input().split())
A = list(map(int, input().split()))
Q, = map(int, input().split())
B = []
C = []
for _ in range(Q):
    Bi, Ci = map(int, input().split())
    B.append(Bi)
    C.append(Ci)

e_dict = {}
for a in A:
    if a in e_dict.keys():
        e_dict[a] += 1
    else:
        e_dict[a] = 1

ans = sum(A)

for b, c in zip(B, C):
    keys = e_dict.keys()
    if b in keys:
        poped = e_dict.pop(b)
        gap = c - b
        ans += (gap * poped)

        if c in keys:
            e_dict[c] += poped
        else:
            e_dict[c] = poped

    print(ans)


Measured memory_bytes: 27040
if __name__=='__main__':
    n=int(input())
    a=list(map(int,input().split()))
    num=1
    count=0
    for i in range(n):
        if a[i]==num:
            num+=1
        else:
            count+=1
    if count==n:
        count=-1
    print(count)


Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N,M;
    cin >> N >> M;
    if(abs(N-M) > 1) { 
        cout << 0 << endl;
        return 0;
    }
    int INF = 1e9+7;
    int ans = 1;
    if(abs(N-M) == 0) {
        for(int i = 1; i <= N; i++) {
            ans*=i;
            ans%=INF;
        }
        for(int i = 1; i <= M; i++) {
            ans*=i;
            ans%=INF;
        }
        cout << ans*2%INF << endl;
    }
    else {
        for(int i = 1; i <= N; i++) {
            ans*=i;
            ans%=INF;
        }
        for(int i = 1; i <= M; i++) {
            ans*=i;
            ans%=INF;
        }
        cout << ans%INF << endl;
    }
}

Measured memory_bytes: 384
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials.append(f)
    f = pow(f, MOD - 2, MOD)
    finvs = [1] * (n + 1)
    finvs[n] = f
    for m in range(n, 1, -1):
        f = f * m % MOD
        finvs[m - 1] = f
    return factorials, finvs


n = int(input())
MOD = 10 ** 9 + 7
facts, finvs = prepare(n, MOD)

ans = 0
for l in range(1, n // 3 + 1):
    m = n - 3 * l
    ans = (ans + facts[l + m - 1] * finvs[m] * finvs[l - 1]) % MOD

print(ans)


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	ll n, k;
	cin >> n >> k;
	ll ans = (n / k) * (n / k) * (n / k);
	if (k % 2 == 0) {
		n += k / 2;
		ans += (n / k) * (n / k) * (n / k);
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

const int maxn=1e5+100;

int a[maxn];


int n,m;

vector<int>G[maxn];
int vis[maxn];
set<int>pos;
set<int>val;

void dfs(int x)
{
    vis[x]=1;
    pos.insert(x);
    for(auto o:G[x]){
        if(vis[o]) continue;
        dfs(o);
    }
}


int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int ans=0;
    memset(vis,0,sizeof(vis));
    set<int>::iterator it1,it2;
    for(int i=1;i<=n;i++){
        if(vis[i]) continue;
        val.clear();
        pos.clear();
        dfs(i);
        for(auto o:pos) val.insert(a[o]);
        for(auto o:pos){
            if(val.find(o)!=val.end()) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 18944
def resolve():
    def get_largest_rectangle(hist: list):
        hist = hist.copy()
        hist.append(0)
        ret = 0
        stack = []
        for i, v in enumerate(hist):
            if len(stack) == 0:
                stack.append((i, v))
            elif stack[-1][1] < v:
                stack.append((i, v))
            elif stack[-1][1] > v:
                while stack and stack[-1][1] > v:
                    i_left, h = stack.pop()
                    ret = max(ret, (i - i_left)*h)
                stack.append((i_left, v))
        return ret


    H, W = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(H)]
    T = [[0]*W for _ in range(H)]

    for j in range(W):
        seq = 0
        for i in range(H):
            if AB[i][j] == 1:
                T[i][j] = 0
                seq = 0
            else:
                T[i][j] = seq + 1
                seq += 1
    ans = 0
    for t in T:
        ans = max(ans, get_largest_rectangle(t))
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 63340
#include <stdio.h>
int main(){
    int mt[10];
    int i ;
    int h1=0,h2=0,h3=0;
    for(i=1;i<=10;i++){
        scanf("%d",&mt[i]);
        
        
        if(h1<=mt[i]){
            h3=h2;
            h2=h1;
            h1=mt[i];
            
        }
        else if(h2<=mt[i]&&mt[i]<=h1){
            h3=h2;
            h2=mt[i];
        }
        else if(h3<=mt[i]&&mt[i]<=h2){
            h3=mt[i];
        }
        
    }


    printf("%d\n%d\n%d\n",h1,h2,h3);



    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>
#include <math.h>

int main()
{
	double x1, y1, x2, y2;
	
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	printf("%.8lf\n", hypot(x1-x2, y1-y2));
	return 0;
}



Measured memory_bytes: 2060
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		String [] a = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
			"k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
			"u", "v", "w", "x", "y", "z"};
		Scanner sc = new Scanner(System.in);
		String ns = sc.nextLine();
		sc.close();
		BigInteger norg = new BigInteger(ns);
		BigInteger n = norg;

		int [] ans = new int[12];

		int i = 1;
		BigInteger max = new BigInteger("26");
		for (i=1; i<12; i++) {
			if (n.compareTo(max)<=0) break;
			n=n.subtract(max);
			max=max.multiply(new BigInteger("26"));
		}
		n=n.subtract(BigInteger.ONE);
		for (int j=1; j<=i; j++) {
			ans[j]=n.mod(new BigInteger("26")).intValue();
			n = n.divide(new BigInteger("26"));
		}

		for (int j=i; j>0;j--) {
			System.out.print(a[ans[j]]);
		}
	}
}


Measured memory_bytes: 27184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	
	string S;
	cin >> S;

	string kotae;

	rep(i, S.size()) {
		if (S[i] == '1') kotae += '1';
		if (S[i] == '0') kotae += '0';
		if (S[i] == 'B' && kotae.size() != 0) kotae.erase(kotae.size() - 1, 1);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();
        int[] lgcd = new int[n];
        int[] rgcd = new int[n];
        lgcd = arraysLGcd(a, n);
        rgcd = arraysRGcd(a, n);
        for (int i = 0; i < n; i++) {
            ans = Math.max(gcd(lgcd[i], rgcd[i]), ans);
        }
        System.out.println(ans);
        sc.close();
    }

    static int gcd(int a1, int a2) {
        if (a1 < a2)
            return gcd(a2, a1);
        if (a2 == 0)
            return a1;
        return gcd(a2, a1 % a2);
    }

    static int[] arraysLGcd(int[] a, int n) {
        int g = 0;
        int[] lgcd = new int[n];
        lgcd[0] = 0;
        for (int j = 0; j < n - 1; j++) {
            g = gcd(g, a[j]);
            lgcd[j + 1] = g;
        }
        return lgcd;
    }

    static int[] arraysRGcd(int[] a, int n) {
        int g = 0;
        int[] rgcd = new int[n];
        rgcd[n - 1] = 0;
        for (int j = n - 1; j > 0; j--) {
            g = gcd(g, a[j]);
            rgcd[j - 1] = g;
        }
        return rgcd;
    }
}

Measured memory_bytes: 50824
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;

const int MAXN = 601;
int N, M;
double dp[MAXN], dp1[MAXN], ans = 1e9;
vector<int> edges[MAXN];

void do_dp(double (&dp)[MAXN], pair<int, int> ignore)
{
    fill(dp + 1, dp + N, 0);
    dp[N] = 0;
    for (int i = N - 1; i >= 1; i--)
    {
        for (int j : edges[i])
        {
            if (i == ignore.first && j == ignore.second)
                continue;
            dp[i] += dp[j];
        }
        dp[i] = dp[i] / (edges[i].size() - (i == ignore.first ? 1 : 0)) + 1;
    }
}

int main()
{
    cin >> N >> M;
    for (int i = 1; i <= M; i++)
    {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
    }

    do_dp(dp, make_pair(0, 0));
    ans = min(ans, dp[1]);
    // cout << "no block: ans = " << ans << endl;

    for (int i = 1; i < N; i++)
    {
        if (edges[i].size() == 1)
            continue;
        int argmax = 0;
        for (int j : edges[i])
        {
            if (dp[argmax] < dp[j])
                argmax = j;
        }
        do_dp(dp1, make_pair(i, argmax));
        // cout << "ignore " << i << " -> " << argmax << ": ans = " << dp1[1] << endl;
        ans = min(ans, dp1[1]);
    }
    cout << setiosflags(ios::fixed) << setprecision(9) << ans << endl;
    // system("pause");
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B;cin>>A>>B;
    int ans=0;

    if(1<=A&&A<=9&&1<=B&&B<=9){
        ans=A*B;
    }
    else{
        ans=-1;
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
n, m = [int(_) for _ in input().split()]
dict = {}
can = True
for i in range(m):
    a, b = [int(_) for _ in input().split()]
    if a in dict.keys():
        dict[a].append(b)
    else:
        dict[a] = [b]
if not 1 in dict.keys():
    can = False
else:
    for i in dict[1]:
        if i in dict.keys() and n in dict[i]:
            can = True
            break
        else:
            can = False
print('POSSIBLE' if can else 'IMPOSSIBLE')


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

int main() {
  int N, M, C;
  int temp;
  vector<int> B(M); 
  cin >> N >> M >> C;
  for (int i=0;i<M;i++){
    cin >> temp;
    B[i] = temp;
  }
  int count = 0;
  for (int i=0;i<N;i++){
    int sum = 0;
    for (int j=0;j<M;j++){
      cin >> temp;
      sum += temp*B[j];
    }
    if (sum + C > 0) count++; 
  }
  cout << count << endl;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	 string s;cin>>s;
	s=="ABC"?cout<<"ARC":cout<<"ABC";
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	
	
	/*
	int q;cin>>q;while(q--){ 
		
	 }
	 //*/
return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,i,j;
    cin>>n>>k;
    vi v(n);
    for(i=0;i<n;i++)cin>>v[i];
    vi dp(n,0);
    dp[0]=0;
    dp[1]=abs(v[0]-v[1]);
    for(i=1;i<k;i++){
        int min=abs(v[0]-v[i]);
        for(j=0;j<i;j++){
            if(dp[j]+abs(v[i]-v[j])<min)min=dp[j]+abs(v[i]-v[j]);
        }
        dp[i]=min;
    }
    for(i=k;i<n;i++){
        int min=dp[i-k]+abs(v[i]-v[i-k]);
        for(j=i-k;j<i;j++){
            if(dp[j]+abs(v[i]-v[j])<min)min=dp[j]+abs(v[i]-v[j]);
        }
        dp[i]=min;
    }
    cout<<dp[n-1];
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  double a=0;
  std::vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    a+=v[i];
  }
  a/=n;
  int b;
  b=a;
  int ans=0;
  if(a-b>=0.5)b++;
  for(int i=0;i<n;i++){
    ans+=(b-v[i])*(b-v[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//aol_itp1_1_d

#include <iostream>
using namespace std;

int main(){
 int S;
 int h,m,s;

 cin>>S;

 h=S/3600;
 m=(S%3600)/60;
 s=S-h*3600-m*60;
 cout<<h<<":"<<m<<":"<<s<<endl;
 return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int p[3][1024][1024], M, N, K;
char str[1024];

int con(char c){
  int ret;
  switch(c){
  case 'J': ret = 0; break;
  case 'O': ret = 1; break;
  case 'I': ret = 2; break;
  }
  return ret;
}

int main(){
  scanf("%d%d%d", &M, &N, &K);
  REP(i, 1, M+1){
    scanf("%s", str);
    rep(j, N)  p[con(str[j])][i][j+1] = 1;
  }

  rep(k, 3){
    rep(i, N+1) rep(j, M) p[k][j+1][i] += p[k][j][i];
    rep(i, M+1) rep(j, N) p[k][i][j+1] += p[k][i][j];
  }

  /*  rep(i, M){
    rep(j, N) printf("%d ", p[0][i][j]); puts("");
    }*/
  int a, b, c, d;
  rep(i, K){
    scanf("%d%d%d%d", &a, &b, &c, &d);
    rep(j, 3) printf(j?" %d":"%d", p[j][c][d]+p[j][a-1][b-1]-p[j][c][b-1]-p[j][a-1][d]); puts("");
  }
  return 0;
}

Measured memory_bytes: 13480
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int d, n;
    cin >> d >> n;
    if (n == 100) n++;
    cout << n << string(2 * d, '0') << endl;

    return 0;
}


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

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

struct mint {
  ll x;
  mint(ll x = 0):x(x%mod){}
  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 c[4005][4005];

void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}

mint comb(int n, int k) {
  return c[n][k];
}

mint f2(int n, int k) {
  return comb(n + k - 1, k -1);
}

mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n - k, k);
}

int main() {
  init();
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    mint blue = f(k, i);
    mint red = 0;
    red += f(n - k, i - 1);
    red += f(n - k, i);
    red += f(n - k, i);
    red += f(n - k, i + 1);

    mint ans = blue * red;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t,u;
	int cnts,cntu;
	cin>>s>>t>>cnts>>cntu>>u;
	if (s==u) cnts--;
	else if (t==u) cntu--;
	cout<<cnts<<" "<<cntu<<endl;
	return 0;
}

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

void start() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int32_t main() {
    start();
    long long a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)cout << "bust";
    else cout << "win";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
  int parent, left, right;
}Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u==NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL) h2=setHeight(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}

int getSibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: parent = %d, sibling = %d, ", u, T[u].parent, getSibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);
  if(T[u].parent==NIL) printf("root\n");
  else if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int i, v, l, r, root=0;

  scanf("%d", &n);

  for(i=0; i<n; i++) T[i].parent=NIL;

  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }

  for(i=0; i<n; i++){
    if(T[i].parent==NIL) root=i;
  }

  setDepth(root, 0);
  setHeight(root);

  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2084
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] anum = new int[n];
		int[][] ans = new int[h][w];
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
			if(i>0){
				anum[i] = anum[i-1] + a[i];
			}else{
				anum[i] = a[i];
			}
		}
		sc.close();
		
		int pos = 0;
		int num = 0;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				num++;
				if(num > anum[pos]){
					pos++;
				}
				if(i%2 == 0){
					ans[i][j] = pos+1;
				}else{
					ans[i][w-j-1] = pos+1;
				}

			}
		}
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				System.out.print(ans[i][j] + " ");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 37228
from collections import deque

K = int(input())
D = [-1]*K
Q = deque()
Q.append([1,0])
while D[0] == -1:
    k,v = Q.popleft()
    D[k] = v
    j = (k*10)%K
    if D[j] == -1:
        Q.appendleft([j,v])
    l = (k+1)%K
    if D[l] == -1:
        Q.append([l,v+1])

print(D[0]+1)

Measured memory_bytes: 13036
S=input()
T=input()

ans=10000

for i in range(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[j]:
      score += 1
  ans = min(ans, score)

print(ans)

Measured memory_bytes: 9128
//In The Name Of GOD
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1000000007;
const ll inf = 200000000000000;
const ll maxn = 5000;
#define pb push_back
#define mp make_pair
#define IO ios_base::sync_with_stdio(false);
int main(){
  IO;
  ll n,x,mini=inf;
  cin>>n>>x;
  ll A[n], B[n], C[n];
  for(ll i=0;i<n;i++){
    cin>>A[i];
    B[i]=C[i]=A[i];
  }
  for(ll i=0;i<n;i++){
    ll sum=0;
    for(ll j=0;j<n;j++){
      B[j]=min(B[j],A[(i+j)%n]);
      sum+=B[j];
    }
    mini=min(sum+x*i,mini);
  }
  for(ll i=0;i<n;i++){
    ll sum=0;
    for(ll j=0;j<n;j++){
      C[j]=min(C[j],A[(j-i+n)%n]);
      sum+=C[j];
    }
    mini=min(sum+x*i,mini);
  }
  cout<<mini;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=25,M=(1<<15)+5;
int to[N],sz[M],lb[M],f[M],bin[M],n,m,lim;
int main(){
	scanf("%d%d",&n,&m),lim=(1<<n);
	for(R int i=1,u,v;i<=m;++i)scanf("%d%d",&u,&v),--u,--v,to[u]|=1<<v;
	bin[0]=1;fp(i,1,m)bin[i]=mul(bin[i-1],2);
	fp(i,1,lim-1)sz[i]=sz[i>>1]+(i&1),lb[i]=i&1?0:lb[i>>1]+1;
	f[0]=1;
	fp(u,1,lim-1)if((u&1)==(u>>1&1))
		for(R int s=u;s;s=(s-1)&u)if((s&1)==(s>>1&1)){
			R int t=u^s,res=f[t];
			for(R int i=s,j=lb[i];i;i-=i&-i,j=lb[i])
				res=mul(res,bin[sz[to[j]&t]]);
			for(R int i=t,j=lb[i];i;i-=i&-i,j=lb[i])
				res=mul(res,bin[sz[to[j]&s]]-1);
			upd(f[u],res);
		}
	printf("%d\n",dec(bin[m],f[lim-1]));
	return 0;
}

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

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

#define MOD 1000000007

int main(void) {
    ll N;
    ll count = 0;
    vector<ll> h;
    ll zero = 0;
    cin >> N;
    h.resize(N);
    for(ll i = 0;i < N;i++) {
        cin >> h[i];
        if(h[i] == 0) zero++;
    }
    while(zero < h.size()) {
        ll current = 0;
        for(ll i = 0;i < h.size();i++) {
            if(h[i] != 0) {
                current = i;
                break;
            }
        }
        for(ll i = current;i < h.size();i++) {
            if(h[i] == 0) break;
            if(--h[i] == 0) zero++;
        }
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    char S[N+1][N+1];
    for(int i = 0;i < N;i++){
        cin >> S[i];
    }
    int M = N*2-1;
    char table[N][M+1];
    for(int i = 0;i < N;i++){
        for(int j = 0;j < M;j++){
            table[i][j] = S[i][j%N];
        }
        table[i][M] = '\0';
    }

    int cnt = 0;
    for(int i = 0;i <= M-N;i++){
        bool flag = 1;
        for(int j = 0;j < N;j++){
            for(int k = 0;k < N;k++){
                if(j >= k)continue;
                if(table[j][k+i] != table[k][j+i])flag = 0;
            }
            if(!flag)break;
        }
        cnt += flag;
    }
    cout << cnt * N << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main(){
    string s, t;
    cin >> s >> t;

    int size = sz(s);
    vi abcS(26,0), abcT(26,0);

    rep(i, size){
        abcS[s[i]-'a']++;
        abcT[t[i]-'a']++;
    }

    sort(abcS.begin(), abcS.end());
    sort(abcT.begin(), abcT.end());
    
    bool ans = true;

    rep(i, 26){
        if(abcS[i] != abcT[i])  ans = false;
    }

    if(ans) yn;

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int S=s.size(),T=t.size();
  vector<char> ss(S),tt(T);
  
  for(int i=0;i<S;i++) ss[i]=s[i];
  for(int i=0;i<T;i++) tt[i]=t[i];
  
  sort(ss.begin(),ss.end());
  sort(tt.begin(),tt.end());
  reverse(tt.begin(),tt.end());
  
  for(int i=0;i<S;i++) s[i]=ss[i];
  for(int i=0;i<T;i++) t[i]=tt[i];

  
  if(s<t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    double t, x;
    cin >> t >> x;

    cout << t / x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
typedef pair<int,int> pi;
unsigned hash[N];
char s[N];
int ls[N], rs[N], n;

int t[N][26];
int g[N][26];
int cnt=1;
int C[26];
long long ans=0;
pi f[N];
inline void ins(int r,int l){
	int u=1;
	for(int i=r;i>=l;i--)C[s[i]-'a']++;
	for(int i=r;i>=l;i--){
		if(i==l){
			ans+=g[u][s[l]-'a'];
		}
		for(int j=0;j<26;j++)if(C[j])g[u][j]++;
		u=t[u][s[i]-'a']==0?(t[u][s[i]-'a']=++cnt):t[u][s[i]-'a'];
		// cout << u << ":";
		C[s[i]-'a']--;
	}
	// puts("");
//	g[u][s[i+1]-'1']++;
}

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++){
		ls[i] = rs[i-1]+1;
		scanf("%s",s+ls[i]);
		rs[i] = ls[i] + strlen(s+ls[i]) - 1;
	//	ins(rs[i], ls[i]);
		f[i] = pi(rs[i]-ls[i]+1,i);
	//	cout << ans << endl;
	}
	sort(f+1,f+n+1);
	for(int i=n;i;i--){
		ins(rs[f[i].second],ls[f[i].second]);
		// cout << f[i].second << ":" << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 207444
#include <iostream>
#include <string>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
using namespace std;


string s;
int main() {
	cin >> s;
	int n = s.length()-1;
	ll ans = 0;

	rep(bit, 0, 1 << n){
		ll sum = 0;
		int old = 0;
		rep(i, 0, n){
			if((bit >> i) & 1) {
				sum += stoll(s.substr(old, i+1-old));
				old = i + 1;
			}
		}
		sum += stoll(s.substr(old));
		ans += sum;
	}

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


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N+10];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      long double a,b,c;
      cin>>a>>b>>c;
      long double x = 2*sqrt(a*b);
          if((c-a-b)>(x))
            cout<<"Yes"<<el;
          else
            cout<<"No"<<el;




    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector < vector<int> > g(N);
	int a, b;
	for (int i = 0; i < N - 1; i++) {
		cin >> a >> b; a--; b--;
		g[b].push_back(a);
		g[a].push_back(b);
	}

	vector<int> C(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	sort(C.begin(), C.end());
	queue<int> q;
	vector<int> D(N);
	vector<int> V(N, 0);

	int cur = 0;

	vector<int> res(N);
	for (int i = 0; i < N; i++) {
		if (g[i].size() == 1) {
			q.push(i);
			V[i] = 1;
			res[i] = C[cur];
			cur++;
		}
		D[i] = g[i].size();
	}

	while (q.size()) {
		int a = q.front();
		q.pop();


		for (int i = 0; i < g[a].size(); i++) {
			if (V[g[a][i]] == 0) {
				D[g[a][i]]--;
				if (D[g[a][i]] == 1) {
					V[g[a][i]] = 1;
					res[g[a][i]] = C[cur];
					cur++;
					q.push(g[a][i]);
				}
			}
		}
	}
	int score = 0;
	for (int i = 0; i < N; i++) {
		for (int j : g[i]) {
			score += min(res[i], res[j]);
		}
	}
	score /= 2;
	cout << score << endl;
	for (int i = 0; i < N; i++) {
		if (i > 0)cout << " ";
		cout << res[i];
	}
	cout << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
    #include<string.h>
    #include<math.h>
    int main(void)
    {
      int a,s,d,f,g,h,i,j;
      scanf("%d %d",&a,&s);
      if(a>9||s>9) printf("-1\n");
      else printf("%d\n",a*s);
      return 0;
    }

Measured memory_bytes: 128