akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define maxn 200100
#define ll long long
#define INF 0x3f3f3f3f
#define P pair<int,int>
int x[maxn],y[maxn];
int n;
int mx,id1,mn,id2;
set<P>ss;
int main()
{
    while(~scanf("%d",&n))
    {
        mx=0,mn=INF;
        for(int i=1;i<=n;++i)
        {
            scanf("%d%d",&x[i],&y[i]);
            if(x[i]>y[i]) swap(x[i],y[i]);
            if(mx<y[i]) mx=y[i],id1=i;
            if(mn>x[i]) mn=x[i],id2=i;
        }
        ll ans;
        ll tmp1=y[id2],tmp2=x[id1];
        for(int i=1;i<=n;++i)
        {
            tmp1=min(tmp1,(ll)y[i]);
            tmp2=max(tmp2,(ll)x[i]);
        }
        ans=(mx-tmp1)*(tmp2-mn);
        if(id1==id2){cout<<ans<<"\n"; continue;}
        ss.clear();
        ss.insert(P(x[id1],-1)); ss.insert(P(y[id2],-1));
        tmp1=INF;
        for(int i=1;i<=n;++i)
        {
            if(i==id1||i==id2) continue;
            ss.insert(P(x[i],i));
        }
        set<P>::iterator it;
        P tx1,tx2;
        while(true)
        {
            it=ss.begin();
            tx1=*(it);
            it=ss.end();
            it--;
            tx2=*(it);
            tmp1=min(tmp1,(ll)(tx2.first-tx1.first));
            if(tx1.second==-1) break;
            ss.erase(tx1);
            ss.insert(P(y[tx1.second],-1));
        }
        ans=min(ans,tmp1*(mx-mn));
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int L = sc.nextInt();
        long[][] graph = new long[N][N];
        int[] A = new int[M];int[] B = new int[M];int[] C = new int[M];
        for(int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
            graph[A[i] - 1][B[i] - 1] = C[i];
            graph[B[i] - 1][A[i] - 1] = C[i];
        }

        for(int i = 0; i < N; i++) {
            graph[i][i] = 0;
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = 0; j < N; j++) {
                    if(graph[i][j] == 0) {
                        graph[i][j] = (long)10e10;
                    }
                    if(graph[i][j] > graph[i][k] + graph[k][j]) {
                        graph[i][j] = graph[i][k] + graph[k][j];
                    }
                }
            }
        }

        long[][] floyd = new long[N][N];
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                floyd[i][j] = graph[i][j] <= L ? 1 : (long)10e10;
            }
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = 0; j < N; j++) {
                    if(floyd[i][j] > floyd[i][k] + floyd[k][j]) {
                        floyd[i][j] = floyd[i][k] + floyd[k][j];
                    }
                }
            }
        }

        int Q = sc.nextInt();
        for(int i = 0; i < Q; i++) {
            int s = sc.nextInt(); int t = sc.nextInt();
            long ans = -1;
            if(s > t) {
                ans = floyd[t-1][s-1] - 1;
            } else {
                ans = floyd[s-1][t-1] - 1;
            }
            if(ans >= (long)10e10 - 1) {
                System.out.println("-1");
            } else {
                System.out.println(ans);
            }
        }
    }
}

Measured memory_bytes: 93404
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define all(i) i.begin(),i.end()
#define fix(i) fixed<<setprecision((i))
#define Max( i , j ) (i)=max((i),(j))
#define Min( i , j ) (i)=min((i),(j))
#define pii pair<int,int>
using namespace std;

const long long maxn = 1e5+100;
const long long INF = 3e18+1191;
const long long mod = 1e9+7;

int c[5][5];
int A[3],B[3];

int32_t main()
{
  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

  for(int i = 0;i<=2;i++)
    for(int j = 0;j<=2;j++)
      cin>>c[i][j];
  
  for(int a1 = 0;a1<=100;a1++)
    for(int a2 = 0;a2<=100;a2++)
      for(int a3 = 0;a3<=100;a3++)
	{
	  int b1 = c[0][0] - a1;
	  int b2 = c[0][1] - a1;
	  int b3 = c[0][2] - a1;
	  A[0] = a1;
	  A[1] = a2;
	  A[2] = a3;
	  B[0] = b1;
	  B[1] = b2;
	  B[2] = b3;
	  bool ok = 1;
	  for(int i = 0;i<=2;i++)
	    for(int j = 0;j<=2;j++)
	      if(A[i] + B[j] != c[i][j]) ok = 0;
	  if(ok)
	    return cout<<"Yes"<<endl,0;
	}
  cout<<"No"<<endl;
  
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    double a, b, x;
    cin >> a >> b >> x;
    double S = x / a;
    double rad;
    if (S >= a * b / 2) {
        double h = (a * b - S) * 2 / a;
        rad = atan2(h, a);
    } else {
        double w = S * 2 / b;
        rad = atan2(b, w);
    }
    cout << rad / M_PI * 180 << '\n';
}

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


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

int main() {
	int a, b;
	cin >> a >> b;
	string answer;
	if (a == b) {
		answer = "Draw";
	}
	else if(a == 1 || (a > b && b != 1)){
		answer = "Alice";
	}
	else {
		answer = "Bob";
	}

	cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    int mn = INF;
    for (int i = 0; i < n; i++) {
        int t, cnt = 0;
        cin >> t;
        while (t % 2 == 0) {
            t = t >> 1;
            cnt++;
        }
        mn = min(cnt, mn);
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, AC, WA, TLE, RE;
  AC = WA = TLE = RE = 0;
  string S[100000];
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> S[i];
    if (S[i] == "AC")
      AC++;
    if (S[i] == "WA")
      WA++;
    if (S[i] == "TLE")
      TLE++;
    if (S[i] == "RE")
      RE++;
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  return 0;
}

Measured memory_bytes: 6752
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int GCD(int x, int y)
{
	if (x < y)swap(x, y);
	int r = x % y;
	while (r > 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}

int main(void)
{
	int A, B; cin >> A >> B;
	lli ans = (lli)A / GCD(A, B) * B;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    while (a > 0 && c > 0)
    {
        c -= b;

        if (c <= 0)
            break;

        a -= d;
    }

    if (c <= 0)
        cout << "Yes";
    else if (a <= 0)
        cout << "No";

    cout << "\n";

    return 0;
}

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

bool solve(int A[], int n, int i, int m) {
  if (!m) return true;
  if (i >= n) return false;
  int res = solve(A, n, i + 1, m) || solve(A, n, i + 1, m - A[i]);
  return res;
}

int main() {
  int n; cin >> n;
  int A[20]; for (int i = 0; i < n; i++) cin >> A[i];
  int q; cin >> q;
  int m[200]; for (int i = 0; i < q; i++) cin >> m[i];

  for (int i = 0; i < q; i++) {
    if (solve(A, n, 0, m[i])) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()

int main(){
    int n,r;
    cin >> n >> r;
    if(n<10) r += 100*(10-n);
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: String = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };

    let ans = match S.as_str() {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        _ => 1,
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
length = []
for i in range(N):
    for j in range(i+1, N):
        l = (XY[j][0] - XY[i][0]) ** 2 + (XY[j][1] - XY[i][1]) ** 2
        length.append(l ** (1/2))
#print(len(length))
if N == 2:
    answer = sum(length)
else:
    answer = sum(length) * (N-1) / ((N-1) * N // 2)
print(answer)

Measured memory_bytes: 3188
#include <stdio.h>

int swap(int *, int *);

int main(void) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a > b && swap(&a, &b);
    b > c && swap(&b, &c);
    a > b && swap(&a, &b);
    printf("%d %d %d\n", a, b, c);
    return 0;
}

int swap(int *a, int *b) {
    *a ^= *b;
    *b ^= *a;
    *a ^= *b;
    return 0;
}

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

int main(void){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll c=0;
    
    rep(i,n){
        char c;
        cin>>c;
        if(c=='R')a[i]=0;
        else a[i]=1;
    }
    int f=0;
    ll x=n-1;
    //if(a[0]==1)f=1;
    rep(i,n){
        if(f==1)break;
        if(a[i]==1){
            for(int j=x;j>i;j--){
                if(a[j]==0){
                    a[i]=0;
                    a[j]=1;
                    x=j;
                    c++;
                    break;
                }if(j==i+1){
                    f=1;
                }
            }
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s, t, u;
    ll a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
int x[MAX_N], y[MAX_N];

vector<int> graph[MAX * 2 + 20];

int node2conn[MAX * 2 + 20];

void dfs(int node, int conn) {
  if (node2conn[node] >= 0) return;  // visited

  node2conn[node] = conn;

  for (auto &child : graph[node]) {
    dfs(child, conn);
  }
}

int main(void) {
  // Here your code !

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &(x[i]), &(y[i]));

    int node_x = x[i];
    int node_y = y[i] + MAX;

    graph[node_x].push_back(node_y);
    graph[node_y].push_back(node_x);
  }

  for (int i = 0; i < MAX * 2 + 20; ++i) {
    node2conn[i] = -1;
  }

  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    dfs(node_x, i);
  }

  unordered_set<int> xs;
  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    xs.insert(node_x);
  }

  unordered_map<int, ll> conn2xnodenum;
  for (auto &e : xs) {
    conn2xnodenum[node2conn[e]] += 1LL;
  }

  unordered_set<int> ys;
  for (int i = 0; i < n; ++i) {
    int node_y = y[i] + MAX;
    ys.insert(node_y);
  }

  unordered_map<int, ll> conn2ynodenum;
  for (auto &e : ys) {
    conn2ynodenum[node2conn[e]] += 1LL;
  }

  unordered_set<int> conns;
  for (int i = 0; i < MAX * 2 + 20; ++i) {
    int conn = node2conn[i];
    if (conn < 0) continue;
    conns.insert(conn);
  }

  ll ans = 0LL;

  for (auto &key : conns) {
    ans += conn2xnodenum[key] * conn2ynodenum[key];
  }

  ans -= (ll)(n);

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

  return 0;
}


Measured memory_bytes: 19692
K, N = map(int,input().split())
A = list(map(int,input().split()))
x = []

for i in range(N - 1):
    x.append(A[i + 1] - A[i])
x.append(A[0] + K - A[N - 1])
x = sorted(x)
del x[N - 1]
print(sum(x))

Measured memory_bytes: 32372
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 6 * 100 * 1000LL;
int nbContraintes[MAXN];
int valeur[MAXN];
int32_t main()
{
	string demandes;
	cin >> demandes;
	int nbNombres = demandes.size() + 1;
	deque <int> peut;
	for (int i = 0 ; i < nbNombres ; i++)
	{
		if (i > 0)
		{
			if (demandes[i - 1] == '<')
			{
				nbContraintes[i]++;
			}	
		}
		if (i < nbNombres - 1)
		{
			if (demandes[i] == '>')
			{
				nbContraintes[i]++;
			}
		}
	}
	for (int i = 0 ; i < nbNombres ; i++)
	{
		if (nbContraintes[i] == 0)
		{
			peut.push_back(i);
		}
	}
	int total = 0;
	while (!peut.empty())
	{
		int actu = peut.front();
		peut.pop_front();
		int v = 0;
		if (actu > 0 && demandes[actu - 1] == '<')
		{
			v = max(v , valeur[actu - 1] + 1);
		}
		else if (actu > 0)
		{
			nbContraintes[actu - 1]--;
			if (nbContraintes[actu - 1] == 0) peut.push_back(actu - 1);
		}
		if (actu < nbNombres - 1 && demandes[actu] == '>')
		{
			v = max(v , valeur[actu + 1] + 1);
		}
		else if (actu < nbNombres - 1)
		{
			nbContraintes[actu + 1]--;
			if (nbContraintes[actu + 1] == 0) peut.push_back(actu + 1);
		}
		total += v;
		valeur[actu] = v;
	}
	cout << total << endl;
}

Measured memory_bytes: 10628
#include <iostream>

using namespace std;

int main() {
  int M, D, ans{};
  cin >> M >> D;
  for (int i = 1; i <= M; ++i) {
    for (int j = 2; j <= D; ++j) {
      if (j / 10 < 2 || j % 10 < 2) continue;
      if (i == j % 10 * (j / 10)) ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long mod=1e9+7;
long long mod2=1e9+5;

long long expo(long long x,long long y){
    long long z=1;
    while(y>0){
        if (y&1){
            z=z*x%mod;
        }
        x=x*x%mod;
        y >>=1;
    }
    return z;
}

long long conb(long long x, long long y,long long fact[], long long revfact[]){    
    return ((fact[x]*revfact[y])%mod*revfact[x-y])%mod;
}
int main(){
    long long h,w,a,b;
    cin >> h >> w >> a >> b;
    long long ans=0;
    long long fact[1000000];
    fact[0]=1;
    for (int i=1; i<1000000; i++){
        fact[i]=(fact[i-1]*i)%mod;
    }
    long long revfact[1000000];
    for (int i=0; i<1000000; i++){
        revfact[i]=expo(fact[i],mod2)%mod;
    }   
    for (long long i=b; i<w; i++){
        ans+=conb(h-a+i-1,h-a-1,fact,revfact)*conb(w-i+a-2,a-1,fact,revfact)%mod;
        ans%=mod;
    }
    cout << ans;   
}

Measured memory_bytes: 16000
x, k, d = map(int, input().split())
if abs(x) >= k * d:
    if x >= 0:
        print(x - k * d)
    else :
        print(-(x + k * d))
    exit()
if x < 0:
    x = -x
a = x // d
if a % 2 == k % 2:
    ans = x % d
else:
    ans = d - x % d
print(ans)


Measured memory_bytes: 9180
x,y=map(int,input().split())

ans=abs(abs(x)-abs(y))

if x<=y:
  if x*y<0:
    ans+=1
  elif x*y>=0:
    ans+=0
else:
  if x*y<0:
    ans+=1
  elif x*y==0:
    ans+=1
  else:
    ans+=2
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

ll func(ll n, ll a){
  int res = 0;
  while(n){
    res += n % a;
    n /= a;
  }
  return res;
}

int main(){
  ll n;
  cin >> n;

  ll res = n;
  for(ll i = 0; i <= n; i++){
    ll mi = func(i, 6) + func(n - i, 9);
    res = min(res, mi);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    int A[100000];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int ans=1;
    n-=k;
    if(n%(k-1)!=0) ans+=n/(k-1)+1;
    else ans+=n/(k-1);
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


int second_number(int a, int b, int c){
    vector<int> s;
    s.push_back(a);
    s.push_back(b);
    s.push_back(c);
    sort(s.begin(), s.end());
    
    return s[1];
}


int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    rep(i, n-2){
        if(p[i+1] == second_number(p[i], p[i+1], p[i+2])){
            ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();

		if (A * C <= B) {
			System.out.println(C);
		} else {
			System.out.println(Math.floorDiv(B, A));
		}
		in.close();
	}

}

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

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> g[n];
    vector<bool> used(n,false);
    vector<ll> ans(n,0); 
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,q){
        int p, x;
        cin >> p >> x;
        ans[p-1] += x;
    }
    queue<int> que;
    que.push(0);
    while(que.size()){
        int y = que.front();
        que.pop();
        used[y] = true;
        rep(i,g[y].size()){
            if(!used[g[y][i]]) {
                ans[g[y][i]] += ans[y];
                que.push(g[y][i]);
            }
        }
    }
    rep(i,n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
 
int main() {
	FASTIO
	
	int n;
	cin >> n;
	vector<int> h(n);
	for(int& x : h) cin >> x;
	ll total = 0;
	for(int i=1; i<n; i++) {
		if(h[i] < h[i-1]) {
			total += (ll) h[i-1]-h[i];
			h[i] = h[i-1];
		}
	}
	cout << total << "\n";
	
	return 0;
}

Measured memory_bytes: 3940
import math
from collections import deque

n = int(input())

log_six = math.floor(math.log(n, 6))
log_nine = math.floor(math.log(n, 6))

count = [-1]*(n*100)
count[0] = 0
todo = deque([0])

while todo:
    i = todo.popleft()

    for j in range(1, log_six+1):
        money = i + 6 ** j

        if money <= n and count[money] is -1:
            count[money] = count[i] + 1
            todo.append(money)

    for k in range(1, log_nine+1):
        money = i + 9 ** k

        if money <= n and count[money] is -1:
            count[money] = count[i] + 1
            todo.append(money)

    if count[i+1] is -1:
        count[i+1] = count[i] + 1
        todo.append(i+1)

    if count[n] != -1:
        break

print(count[n])

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


int main(){
  long long n,p,i;

  cin >> n >> p;
  long long num=p;
  long long ma=1;
  map<long long ,long long> ans;

  for(i=2;i*i<=p;++i){
    while(num%i==0){
      ans[i]++;
      num/=i;
    }
  }
  for(auto z : ans){
    if(z.second>=n){
      while(z.second>=n){
        ma*=z.first;
        z.second=z.second-n;
      }
    }
  }
  if(n==1){
    ma=p;
  }
  cout << ma << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 200000000000000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

int dp[60][60][10010];

int main(){
  ll N;cin >> N;
  ll a = 0,b = 0;
  vector<ll> A(N),B(N);
  rep(i,N){
      cin >> A[i];
      a+=A[i];
  }
  rep(i,N){
      cin >> B[i];
      b+=B[i];
  }
  rep(i,N){
      if(A[i] < B[i]){
          a += ((B[i]-A[i]+1)/2) * 2;
          b += (B[i]-A[i]+1)/2;
      }
  }
  if(a > b){
      cout << "No" << endl;
  }else{
      cout << "Yes" << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll h,w;
v2 a;

void no(){
    cout << "Impossible" << endl;
    exit(0);
}

void yes(){
    cout << "Possible" << endl;
    exit(0);
}

int main(){
    cin >> h >> w;
    a = v2(h+2, v1(w+2, 0));
    for(ll i = 1;i <= h;i++){
        for(ll j = 1;j <= w;j++){
            char c;
            cin >> c;
            if(c == '#') a[i][j] = 1;
        }
    }
    ll x,y;
    x = 1;
    y = 1;
    while(true){
        a[x][y] = 0;
        if(a[x+1][y] == 1) x += 1;
        else if(a[x][y+1] == 1) y += 1;
        else break;
    }
    for(ll i = 1;i <= h;i++){
        for(ll j = 1;j <= w;j++){
            if(a[i][j] == 1) no();
        }
    }
    yes();

}


Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
#include<string>
#include<list>
#include<vector>
#include<algorithm>
#include <numeric>
#include<queue>
#include <climits>

using namespace std;

int main(int argc, char const *argv[])
{
	/*
	cin>>x;
	cout<<x<<endl;
	*/
	int a,b,i,j,n,ans;
	cin>>a>>b;
	if(a<=5){
		cout<<"0"<<endl;
	}else if(a<=12){
		cout<<b/2<<endl;
	}else{
		cout<<b<<endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll fast(ll x,ll n) {ll ans=1;for(;n;n>>=1,x=x*x%mod) if(n&1) ans=ans*x%mod; return ans;}
const int N=1e6+100;

ll c(ll x) {
    return x*(x+1)/2;
}
ll ans[N],siz[N],temp[N],a[N],n;
vector<int>edge[N];

void dfs(int x,int f) {
    ll t=temp[a[x]];
    siz[x]=1;
    for(auto &v:edge[x]) if(v!=f) {
        ll pre=temp[a[x]];
        dfs(v,x);siz[x]+=siz[v];
        ans[a[x]]-=c(siz[v]-(temp[a[x]]-pre));
    }
    temp[a[x]]=t+siz[x];
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<n;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) {
        ans[i]+=c(n)-c(n-temp[i]);
        printf("%lld\n",ans[i]);
    }
}


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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
        int n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 最初の文字の固まりを整数値と想定して読み込む
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            // 二重ループ(forの中にfor)を書いて、H x W個の # を表示しよう！
            for (int i = 0; i < H; i++) {

                if (i == 0 || i == H - 1) {
                    for (int j = 0; j < W; j++) {

                        System.out.print("#");
                    }
                } else {
                    for (int j = 0; j < W; j++) {
                        if (j == 0 || j == W - 1) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 37508
<?php

while ($n = trim(fgets(STDIN))) {
	$a = explode(' ', trim(fgets(STDIN)));
	$rest = 32;
	$i = 0;
	$d = count($a);
	while(true) {
		$rest -= ($rest - 1) % 5;
		echo $rest . "\n";
		if ($rest == 0) {
			break;
		}
		$rest -= min($rest, $a[$i++ % $d]);
		echo $rest . "\n";
		if ($rest == 0) {
			break;
		}
	}
}

Measured memory_bytes: 6596
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        tmp = a // 2
        a -= tmp
        b += tmp
    else:
        if b % 2 == 1:
            b -= 1
        tmp = b // 2
        a += tmp
        b -= tmp

print(a, b)

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

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long a = vs[0];
			long b = vs[1];
			long k = vs[2];
			if (a < k) {
				k -= a;
				a = 0;
				b -= k;
				if (b < 0) {
					b = 0;
				}
			} else {
				a -= k;
			}
			Console.WriteLine($"{a} {b}");


			Console.Out.Flush();
		}
	}
}


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

using namespace std;
using ll = long long;

int main()
{
    ll n,maxi=0,x,cnt=0;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x;
        cnt+=max(0ll,maxi-x);
        maxi=max(maxi,x);
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main() {
  int r, D, x, i;
  r = D = x = i = 0;
  
  scanf("%d%d%d", &r, &D, &x);
  
  for(i = 0; i < 10; ++i){
    x = r * x - D;
    printf("%d\n", x);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    
    
        int n,c;
        cin>>n>>c;
        
        
       if(n>c){
            for(int i=0;i<n;i++){
                cout<<c;
            }
            }else{
                for(int i=0;i<c;i++){
                cout<<n ;
            }
            }
        
     return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int search(int A[],int N,int key){
  int left,right,mid;
  left =0;
  right =N;
  while(left <right){
    mid=(left+right)/2;
    if(key==A[mid])
      return mid;
    else if(key < A[mid])
      right = mid;
    else
      left=mid+1;
  }
  return 0;
}

int main(){
  int i,M,N,key,k=0;
  int A[100000];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&key);
    if(search(A,N,key))
      k++;
      }
  printf("%d\n",k);

  return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
#include<list>
#include<iomanip>


#define prDouble(x) cout<<fixed<<setprecision(10)<<x //to print decimal numbers

using namespace std;
typedef long long ll;
int modulo = 1e9 + 7;

double dp[3001][3001];

double heads_prob(double prob[], int n, int x){
    if(x == 0){
        return 1;
    }
    if(n == 0){
        return 0;
    }
    if(dp[n][x]> -0.9){
        return dp[n][x];
    }
    dp[n][x] = (prob[n]*heads_prob(prob,n-1,x-1) + (1-prob[n])*heads_prob(prob,n-1,x));
    return dp[n][x];
}

int main(){
    int n;
    cin>>n;
    double prob[n+1];
    for(int i = 1; i<=n; i++){
        cin>>prob[i];
    }
    int x = (n+1)/2;
    for(int i = 0; i<=n; i++){
        for(int j = 0; j<=x; j++){
            dp[i][j] = -1;
        }
    }
    prDouble(heads_prob(prob,n,x));

    // double dp[n+1][x+1];
    // dp[0][0] = 1.0;
    // for(int i = 1; i<=x; i++){
    //     dp[0][x] = 0;
    // }
    // for(int i = 1; i<=n; i++){
    //     dp[i][0] = 1;
    // }
    // for(int i = 1; i<=x; i++){
    //     dp[i][i] = prob[i]*dp[i-1][i-1];
    // }
    // for(int i = 1; i<=n; i++){
    //     for(int j = 1; j<=x; j++){
    //         dp[i][j] = dp[i-1][j-1]*prob[i] + (1-prob[i])*dp[i-1][i];
    //     }
    // }
    // cout<<dp[n][x]<<endl;
}

Measured memory_bytes: 51080
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            long k=Long.parseLong(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[n];
            for(int j=0;j<n;j++){
                arr[j]=Integer.parseInt(ss[j]);
            }
            int i=0;
            int[] vis=new int[n];
            int p=1;
            vis[i]=1;
            while(k>0){
                i=arr[i]-1;
                k--;
                p++;
                if(vis[i]!=0){
                    int u=p-vis[i];
                    k=k%u;
                    while(k>0){
                        i=arr[i]-1;
                        k--;
                    }
                }else{
                    vis[i]=p;
                }

            }
            System.out.println(i+1);

        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static void dfs(ArrayList<HashSet<Integer>> list,boolean[] vis,int i){
        vis[i]=true;
        Iterator<Integer> it=list.get(i).iterator();
        while(it.hasNext()){
            int u=it.next();
            if(!vis[u]){
                dfs(list,vis,u);
            }
        }
    }
    static int modInverse(int x,int m){
        return power(x,m-2,m);
    }
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        long p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        return (int)((y%2==0)? p : (x*p)%m);
    }
    static void shuffle(String[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            String temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static class quad{
        int a,b,c,d;
        public quad(int a,int b,int c,int d){
            this.a=a;
            this.b=b;
            this.c=c;
            this.d=d;
        }
    }
}

Measured memory_bytes: 61252
#include<bits/stdc++.h>
using namespace std;
#define llu unsigned long long int
int main()
{
    llu n,m,res=0,cnt=0,x,b,a,i;
    cin>>n>>m;
    vector<pair<long long int,long long int> > p(n);
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        p[i]=make_pair(a,b);
    }
    sort(p.begin(),p.end());
    for(i=0;i<n;i++)
    {
        x=m-cnt;
        if(p[i].second<=x)
            res+=(p[i].first*p[i].second),cnt+=p[i].second;
        else
            res+=(p[i].first*x),cnt+=x;
    }

    cout<<res<<endl;
    return 0;
}


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

int INF=100000;

int main()
{
    int N;
    int X,Y;
    cin >> N >> X >> Y ;
    int m_dist;
    int dist[N+1][N+1];
    int ans[N+1];
    for(int i=1;i<=N;i++){
        ans[i]=0;
    }
    //初期値の設定
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(i==j){
                dist[i][j]=0;
            }else{
                dist[i][j]=INF;
            }
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(dist[i][j]==INF){
                m_dist=min(abs(j-i),abs(X-i)+1+abs(Y-j));
                m_dist=min(m_dist,abs(X-j)+1+abs(Y-i));
                dist[i][j]=dist[j][i]=m_dist;
                ans[m_dist]++;
            }
                
        }
    }
    for(int i=1;i<N;i++){
        cout << ans[i] << endl;
    }
}


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

int main(){
  int n,u,k;
  int ad;
  int arisutoteresu[200][200] = {0};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      arisutoteresu[u][ad] = 1;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout << arisutoteresu[i][j];
      if(j != n)cout << " ";
    }
    cout << endl;
  }



  return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"

using namespace std;

int main(){
	string S;
	cin >> S;
	int ans = 0;

	for (int i = 1; i < S.size(); i++) {
		if (S[i - 1] != S[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
const int maxn=2e5+10;
int n,x[maxn];
ll ans;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>x[i];
	for(int i=1,j=1,now=0;i<=n;++i){
		while(now&x[i])
			now^=x[j],++j;
		now|=x[i];
		ans+=i-j+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<ll, ll>;

ll dfs(const vector<P>& B, vector<vector<ll>>& dp, int x, int y, int idx) {
    if (idx == (int)B.size()) {
        return 0;
    }
    if (dp[x][y] >= 0) {
        return dp[x][y];
    }
    ll cost = B[idx].first;
    ll pos = B[idx].second;
    // x番目におく場合
    chmax(dp[x][y], dfs(B, dp, x + 1, y, idx + 1) + cost * abs(pos - x));
    // N-y-1番目におく場合
    chmax(dp[x][y], dfs(B, dp, x, y + 1, idx + 1) + cost * abs((ll)B.size() - y - 1 - pos));
    return dp[x][y];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    vector<P> B;
    rep(i, 0, N) {
        B.emplace_back(A[i], i);
    }
    sort(all(B));
    reverse(all(B));
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -1));
    cout << dfs(B, dp, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 34880
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,k,fa[N],dep[N],ans;
vector<int> e[N];
void dfs(int x){
	for (int i=0;i<e[x].size();i++){
		int v=e[x][i];
		dfs(v);
		dep[x]=max(dep[x],dep[v]+1);
	}
	if (dep[x]==k-1&&fa[x]!=1) ans++,dep[x]=-1e9;
}
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&fa[i]);
	if (fa[1]!=1) fa[1]=1,ans++;
	for (int i=2;i<=n;i++) e[fa[i]].push_back(i);
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  cout << ( (100*r+10*g+b) % 4 == 0 ? "YES" : "NO" ) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
  int i,j,k;
  int input;
  int d[2048];
  int N;
  int sum=0;
  
  scanf("%d",&N);
  
  for(i=1;i<=N;i++){
    scanf("%d",&input);
    d[i] = input;
  }
  
  for(i=1;i<=N;i++){
    for(j=i+1;j<=N;j++){
      sum += d[i]*d[j];
    }
  }
 
  printf("%d\n",sum);
  
  return 0; 
}

Measured memory_bytes: 128
#!/usr/bin/env python3
n, *p = map(int, open(0).read().split())
b = [p[i] == i + 1 for i in range(n)]
c = 0
for i in range(1, n):
    if b[i - 1] and b[i]:
        c += 1
        b[i] = False
        b[i - 1] = False
print(c + sum(b))


Measured memory_bytes: 20104
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)((v).size())
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 


#define M 100010


ll mx=-1,n,m,q;
ll a[51],b[51],c[51],d[51];
void f(ll i,ll cnt,vll v){
	if(cnt<0 or i>m+1)return;
	if(cnt==0){
		ll sum=0;
		rep(j,0,q)if(v[b[j]]-v[a[j]]==c[j])sum+=d[j];
		mx=max(mx,sum);
		// teln(v,n);
	}
	rep(j,0,cnt+1){
		if(j)v.pb(i);
		f(i+1,cnt-j,v);
	}
}
int main(){
    IOS;
    tihs;
    
    cin>>n>>m>>q;
    rep(i,0,q)cin>>a[i]>>b[i]>>c[i]>>d[i],a[i]--,b[i]--;
    vll v;
    f(1,n,v);
    cout<<mx;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define     sorta(v)         sort(all(a))
#define     sortd(v)        sort(all(a), greater<ll >())
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

bool compare_float(double x, double y){
    return fabs(x - y) < DBL_EPSILON;
}

double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
// vll pwx(61);
// void cal(ll x){ pwx[0] = 1; rep(i, 1, 61)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve(){
	ll n,m,k;
    cin >> n >> m >> k;
	char c;
	ll mat[n][m];
	ll tot = 0;
    rep(i, 0, n){
		rep(j, 0, m){
			cin>>c;
			if(c=='#'){
				mat[i][j] = 1;
				tot++;
			}
			else
				mat[i][j] = 0;
		}
	}
	ll ans = 0;
	rep(i, 0, pow(2,n)){
		rep(j, 0, pow(2,m)){
			ll cnt = 0;
			vector<vector<ll>> vis(n,vector<ll>(m));
			rep(i0, 0, 32){
				if((i>>i0)&1){
					rep(j0, 0, m){
						if(mat[i0][j0]==1){
							cnt++;
							vis[i0][j0] = 1;
						}
					}
				}
			}
			rep(i0, 0, 32){
				if((j>>i0)&1){
					rep(j0, 0, n){
						if(mat[j0][i0]==1 && vis[j0][i0]==0){
							cnt++;
						}
					}
				}
			}
			if(tot-cnt==k){
				ans++;
			}
		}
	}
	cout << ans  << nl;
}

 
int main(){
    boost;
    // cal(1);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 4060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            long[] H = new long[N];
            for (int i = 0; i < N; i++)
            {
                H[i] = cin.nextLong();
            }

            var max = H[0];
            var ans = "Yes";
            for (int i = 1; i < N; i++)
            {
                var now = H[i];

                if(Math.Abs(max - now) >= 2 && max >= now)
                {
                    ans = "No";
                    break;
                }

                if (max <= now)
                {
                    max = now;
                }
            }
            
            Console.WriteLine(ans);
        }

        
    }





    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 nextInt()
        {
            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] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            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] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            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] = nextDouble() + add;
            }
            return Array;
        }
    }
}


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

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  while (A > 0 && B > 0) {
    C -= B;
    if (C <= 0) { cout << "Yes" << endl; return 0; }
    A -= D;
    if (A <= 0) { cout << "No" << endl; return 0; }
  }
}

Measured memory_bytes: 3596
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Task
{
    int cost;
    int limit;
};

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

    vector<Task> tasks(n);

    for (auto& task : tasks)
    {
        cin >> task.cost >> task.limit;
    }

    sort(tasks.begin(), tasks.end(), [](const auto& lhs, const auto& rhs){
        return lhs.limit < rhs.limit;
    });

    int s = 0;

    for (const auto& task : tasks)
    {
        s += task.cost;

        if (s > task.limit)
        {
            cout << "No";

            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    string S,T;
    cin >> S >> T;
    T[T.size()-1] = ' ';
    S += ' ';

    if(S==T) cout << "Yes" << endl;
    else cout <<"No" << endl;

    return 0;

}

Measured memory_bytes: 3616
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] m = new int[sc.nextInt()];

		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int a = sc.nextInt();
				m[a - 1]++;
			}
		}
		System.out.println(Arrays.stream(m).filter(x -> x == n).count());
		sc.close();
	}
}


Measured memory_bytes: 28560
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, K; cin >> N >> K;
	vector<pair<int, int>> v;
	for (int i = 2; i <= N; ++i) {
		v.push_back(make_pair(1, i));
	}
	K = (N-1)*(N-2)/2-K;
	for (int i = 2; i <= N; ++i) {
		for (int j = i+1; j <= N; ++j) {
			if (K) {
				v.push_back(make_pair(i, j));
				--K;
			}
		}
	}
	if (K) {
		cout << -1 << endl;
	} else {
		cout << v.size() << endl;
		for (auto x : v) {
			cout << x.first << ' ' << x.second << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 384