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

using namespace std;

int main() {
    int H,W; cin>>H>>W;
    
    string S[H+1];
    
    for (int i=0;i<H;i++) {
        cin>>S[i];
    }

    // cout << endl;
    // for (int i=0;i<H+2;i++)
    //     cout << S[i] << endl;
    // cout << endl;

    int dpL[H+1][W+1],dpR[H+1][W+1],dpD[H+1][W+1],dpU[H+1][W+1];
    memset(dpL,0,sizeof(dpL));
    memset(dpR,0,sizeof(dpR));
    memset(dpD,0,sizeof(dpD));
    memset(dpU,0,sizeof(dpU));

    for (int i=0;i<H;i++) {
        for (int j=1;j<W;j++) {
            if (S[i][j-1]=='#') dpL[i][j]=0;
            else dpL[i][j]=dpL[i][j-1]+1;
        }
    }

    for (int i=0;i<H;i++) {
        for (int j=W-2;j>=0;j--) {
            if (S[i][j+1]=='#') dpR[i][j]=0;
            else dpR[i][j]=dpR[i][j+1]+1;
        }
    }

    for (int i=H-2;i>=0;i--) {
        for (int j=1;j<W;j++) {
            if (S[i+1][j]=='#') dpD[i][j]=0;
            else dpD[i][j]=dpD[i+1][j]+1;
        }
    }

    for (int i=1;i<H;i++) {
        for (int j=0;j<W;j++) {
            if (S[i-1][j]=='#') dpU[i][j]=0;
            else dpU[i][j]=dpU[i-1][j]+1;
        }
    }


    long long ans=0;
    for (int i=0;i<H;i++) {
        for (int j=0;j<W;j++) {
            if (S[i][j]!='#') {
                long long a = dpL[i][j]+dpR[i][j]+dpD[i][j]+dpU[i][j]+1;
                ans = max(ans, a);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 66944
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

h, a = Is()
print(ceil(h/a))

Measured memory_bytes: 63980
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<vector<int>> edge;
vector<int> c;
vector<int> result;
vector<bool> isVisited;

int dfs(int node, int offset)
{
    isVisited[node] = true;

    rep(i, edge[node].size())
    {
        int child = edge[node][i];
        if (!isVisited[child]) {
            offset = dfs(child, offset);
        }
    }
    result[node] = c[offset];
    return offset + 1;
}

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

    edge.resize(n);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    c.resize(n);
    rep(i, n)
    {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    int score = 0;
    rep(i, n - 1)
    {
        score += c[i];
    }

    result.resize(n);
    isVisited.resize(n);
    fill(isVisited.begin(), isVisited.end(), false);
    dfs(0, 0);

    cout << score << endl;
    rep(i, n)
    {
        cout << result[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main()
{
   int a,b,c,k;cin>>a>>b>>c>>k;
   int ans=0;
   while(k>0)
   {
       bool ok=false;
       while(a)
       {
           ans++;
           k--;
           a--;
           if(k<=0) 
           {
               ok=true;
               break;
           }
       }
       if(ok) break;
       while(b)
       {
           k--;
           b--;
           if(k<=0) 
           {
               ok=true;
               break;
           }
       }
       if(ok) break;
       while(c)
       {
         ans--;
         k--;
         c--;
         if(k<=0) 
         {
             ok=true;
             break;
         }
       }
       if(ok) break;
   }
   cout<<ans<<"\n";
}

Measured memory_bytes: 3636
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

int binarySearch(alias pred, T)(in T[] arr, bool isLower = true)
{ 
	int ok, ng;
	if (isLower) { ok = cast(int)arr.length; ng = -1; }
	else		 { ok = -1; ng = cast(int)arr.length; }
	while (abs(ok-ng) > 1)
	{
		auto mid = (ok+ng) / 2;
		if (unaryFun!pred(arr[mid]))
			ok = mid;
		else ng = mid;
	}
	return ok;
}

void main()
{
	auto s = RD!string;
	auto t = RD!string;
	auto len = s.length;

	auto next = new long[][](26);
	foreach (i, c; s)
	{
		next[c-'a'] ~= i;
	}
	long i;
	long ans;

	bool f(long pos)
	{
		return pos >= i%len;
	}
	
	while (!t.empty)
	{
		auto n = next[t[0]-'a'];
		auto l = binarySearch!(f)(n);
		debug writeln(t[0], " ", i%len, " l:", l);
		if (l == n.length)
		{
			i += len - i%len;
			auto l2 = binarySearch!(f)(n);
			debug writeln(t[0], " ", i%len, " l2:", l2);
			if (l2 == n.length)
			{
				ans = -1;
				break;
			}
			else
			{
				i = (i / len) * len + n[l2] + 1;
				ans = i;
			}
		}
		else
		{
			i = (i / len) * len + n[l] + 1;
			ans = i;
		}
		t.popFront;
		debug writeln(ans);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 4504
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
bool visit[100100];
int prime[100005];

void init_prim()
{
    memset(visit, true, sizeof(visit));
    int num = 0;
    for (int i = 2; i <= 100000; ++i)
    {
        if (visit[i] == true)
        {
            num++;
            prime[num] = i;
        }
        for (int j = 1; ((j <= num) && (i * prime[j] <= 100000));  ++j)
        {
            visit[i * prime[j]] = false;
            if (i % prime[j] == 0) break; //点睛之笔
        }
    }
}
int main()
{
    init_prim();
    int a[100005],b[100005];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    visit[0]=visit[1]=false;
    for(int i=3;i<=100000;i+=2)
    {
        if(visit[i]&&visit[(i+1)/2]) a[i]=1;
    }
    for(int i=1;i<=100000;i++)
    {
        b[i]=b[i-1]+a[i];
    }
    int q,l,r;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d %d",&l,&r);
        printf("%d\n",b[r]-b[l]+a[l]);
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int ans=0;
    
    if(n < 105) ans=0;
    else if(n < 135) ans=1;
    else if(n < 165) ans=2;
    else if(n < 189) ans=3;
    else if(n < 195) ans=4;
    else ans=5;

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

Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/05.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int X[5];

    for (int i = 0; i < 5; ++i) {
        cin>>X[i];
    }

    int amari = 100;
    int min_index = -1;
    for (int i = 0; i < 5; ++i) {
        int a = X[i] % 10;
        if(a != 0){
            if(amari > a){
                amari = a;
                min_index = i;
            }

        }
    }

    int ans = 0;
    for (int i = 0; i < 5; ++i) {
        if(min_index != -1 && i == min_index){
            ans += X[i];
        }else{
            int a = X[i] % 10;
            if(a!=0){
                ans += X[i] + 10 - a;
            }else{
                ans += X[i];
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
set<int> a, b;
int main()
{
	int n, m;
	scanf("%d",&n);
	int i;
	for(i=0; i<n; i++)
	{
		int x;
		scanf("%d",&x);
		a.insert(x);
	}
	scanf("%d",&m);
	for(i=0; i<m; i++) 
	{
		int x;
		scanf("%d",&x);
		b.insert(x);
	}
	vector<int> v;
	set_symmetric_difference(a.begin(), a.end(), b.begin(), b.end(), back_inserter(v));
	for(i=0; i<v.size(); i++) printf("%d\n",v[i]);
	return 0;
}


Measured memory_bytes: 23684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

ll d[13][100001]={};
int r[100000]={};
int l[100000]={};
int t[100000]={};
int main() {
	int a,b;
	cin>>a>>b;
	cout<<max(max(a+b,a-b),a*b)<<endl;
	return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 575;
const int MAX_C = 77;

int N, C;
int D[MAX_C][MAX_C];
int c[MAX_N][MAX_N];

// mod3の数字列をMAX_Nに変更する時にかかるコスト
int memo[3][MAX_C];

// mod3の数字列のデータ
vector< int > data[3];

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

  cin >> N >> C;
  REP(hi, C) {
    REP(wi, C) {
      cin >> D[hi][wi];
    }
  }

 
  REP(hi, N) {
    REP(wi, N) {
      CIN(a);
      data[(hi + wi) % 3].emplace_back(a - 1);
      // cin >> c[hi][wi];
    }
  }

  REP(h, 3) {
    REP(i, C) {
      int tmp = 0;
      EACH(di, data[h]) {
	tmp += D[di][i];
      }
      memo[h][i] = tmp;
    }
  }


  int ans = INF;
  REP(h, C) {
    REP(i, C) {
      if (h == i) continue;
      REP(j, C) {
	if (h == j or i == j) continue;
	ans = min(ans, memo[0][h] + memo[1][i] + memo[2][j]);
	/*
	if (ans == memo[0][h] + memo[1][i] + memo[2][j]) {
	  debug(h);
	  debug(i);
	  debug(j);
	  cout << ans << endl;
	}
	*/
      }
    }
  }

  cout << ans << endl;

  /*
  REP(i, 3) {
    debug(i);
    EACH(di, data[i]) {
      debug(di);
    }
    cout << endl;
    REP(ci, C) {
      debug(ci);
      debug(memo[i][ci]);
    }
    cout << endl;
  }
  */

  return 0;
}



Measured memory_bytes: 1520
// A - Table Tennis Training
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n, a, b, ans = 0;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		ans = (b - a) / 2;
	} else {
		ans = min(b - 1, n - a);
		ans = min(ans, a + (b - a - 1) / 2);
		ans = min(ans, n - b + 1 + (b - a - 1) / 2);
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	int b[m], a[n][m];
	for (int i = 0; i < m; i++) cin >> b[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x = c;
		for (int j = 0; j < m; j++) {
			x += b[j] * a[i][j];
		}
		if (x > 0) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

int ok[1 << 20];
int used[5][50];
int dp[2][1 << 20];



int main(){
	int n;
	while (cin >> n, n){
		array<string, 5> ar;
		rep(i, 5) cin >> ar[i];

		int len = 0;
		rep(i, 5) rep(j, n) if (ar[i][j] == 'X') len = max(len, j+1);

		rep(i, 1 << n){
			ok[i] = 1;
			MEMSET(used, 0);
			rep(j, n){
				if (i&(1 << j)){
					rep(k, 5) rep(l, n){
						if (ar[k][l] != 'X') continue;
						if (used[k][l+j]) ok[i] = 0;
						used[k][l+j] = 1;
					}
				}
			}

			//if (ok[i]){
			//	rep(j, n) cout << !!(i&(1 << j));
			//	cout << endl;
			//}
		}
		int mask = (1 << n) - 1;

		MEMSET(dp, 0);
		rep(i, n * 15){
			rep(j, 1 << n){
				int nxt = (i + 1) & 1, bits = (j << 1)&mask;
				dp[nxt][bits] = max(dp[nxt][bits], dp[i & 1][j]);
				if (ok[bits | 1]) dp[nxt][bits | 1] = max(dp[nxt][bits | 1], dp[i & 1][j] + 1);
				if (dp[nxt][bits | 1] == 10){
					cout << i + len << endl;
					goto end;
				}
			}
			//rep(j, 1 << n){
			//		rep(k, n) cout << !!(j&(1 << n-k-1));
			//		cout << endl;
			//		cout << dp[i + 1 & 1][j] << endl;
			//}
		}
	end:;
	}

	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

#define D  double
typedef pair<D,int>T;
int N;
int X[1111],Y[1111],R[1111];
D dist[1111];
D INF=1e15;
D EPS=1e-12;

int table2[1111][1111];
D table[1111][1111];

signed main(){

    cin>>X[0]>>Y[0]>>X[1]>>Y[1];
    cin>>N;
    rep(i,N)cin>>X[i+2]>>Y[i+2]>>R[i+2];
    N+=2;

    rep(i,N)rep(j,N){
        table2[i][j]=(X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]);
        table[i][j]=sqrt(1.0*table2[i][j]);
    }

    fill_n(dist,1111,INF);
    dist[0]=0;
    priority_queue<T,vector<T>,greater<T>>que;
    que.push(make_pair(0,0));
    while(que.size()){
        D d;
        int idx;
        tie(d,idx)=que.top();
        que.pop();
        if(dist[idx]+EPS<d)continue;
        rep(i,N){
            int foo=table2[i][idx];
            int bar=R[i]+R[idx];
            D cost;
            if(foo<=bar*bar)cost=0.0;
            else cost=table[i][idx]-bar;
            if(dist[i]<=dist[idx]+cost)continue;
            dist[i]=cost+dist[idx];
            que.push(T(dist[i],i));

        }
    }
    printf("%.20f\n",dist[1]);
    return 0;
}


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

AtCoder Regular Contest 069

*/

int main()
{
    LL n,m;
    scanf("%lld%lld",&n,&m);
    if(n*2>m)
        printf("%lld\n",m/2LL);
    else
        printf("%lld\n",n+(m-2LL*n)/4LL);
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, pp, min = 200001, ans = 0;
	cin >> nn;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> pp;
		if(min >= pp)
		{
			ans++;
			min = pp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer>p = new ArrayList<>();
    for(int i=0;i<n;i++){
      p.add(sc.nextInt()-1);
    }
    int a = 0;
    for(int i=0;i<n;i++){
      if(p.get(i)!=i)a++;
    }
    if(a<=2)System.out.println("YES");
    else System.out.println("NO");

  }
}


Measured memory_bytes: 22612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

Int calc(vector<Int>& a, Int b, Int N) {
	Int sum = 0;
	for (Int i = 0; i < N; i++) {
		sum += abs(a[i] - b);
	}
	return sum;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> Man(N);

	Int temp = 0;
	for (Int i = 0; i < N; i++) {
		cin >> temp;
		Man[i] = temp - (i + 1);
	}

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

	Int ans = 0;
	//if (N % 2) {
		ans = calc(Man, Man[N / 2], N);
		cout << ans << endl;
		return 0;
	//}

	/*ans = min(calc(Man, Man[N / 2], N), calc(Man, Man[N / 2 - 1], N));
	cout << ans << endl;
	return 0;
*/
}

Measured memory_bytes: 1792
#pragma warning(disable : 26451)
#pragma warning(disable : 26495)

#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<fstream>
#include<stdio.h>
#include<map>
#include<unordered_set>
#include<limits.h>
#include<list>
#include <cassert>
#include<sstream>
#include<bitset>
#include<list>
#include<unordered_map>
#include<unordered_set>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using uint = unsigned int;

int main() {
	int rows, cols, k, all=0, need, cur;
	ll anscnt = 0;
	cin >> rows >> cols >> k;
	vector<vector<int>> g(rows, vector<int>(cols));
	vector<int> rrec(rows, 0), crec(cols, 0);
	for(int r=0;r<rows;++r)
		for (int c = 0; c < cols; ++c)
		{
			g[r][c] = (cin >> ws).get() == '#';
			rrec[r] += g[r][c];
			crec[c] += g[r][c];
			all += g[r][c];
		}
	need = all - k;
	//dfs
	vector<int> rsta(rows), csta(cols);
	auto parse = [&](const ull &dfs)->bool {//rows first
		cur = 0;
		for (int r = 0; r < rows; ++r) {
			rsta[r] = (dfs & (1ULL << r));
			cur += rsta[r] ? rrec[r] : 0;
		}
		for (int c = 0; c < cols; ++c) {
			csta[c] = (dfs & (1ULL << (rows + c)));
			cur += csta[c] ? crec[c] : 0;
		}
		for (int r = 0; r < rows; ++r)
			for (int c = 0; c < cols; ++c)
				if (rsta[r] && csta[c] && g[r][c])
					--cur;
		return cur == need;
	};
	for (ull bits = 0; bits < (1ULL << (cols + rows)); ++bits)
	{
		anscnt += parse(bits);
	}
	cout << anscnt << endl;
}




Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 2010;

int n, m, ans;
char Map[N][N];
bool G[N][N];
int up[N][N], stk[N], pos[N], top;

int main(){
	scanf("%d%d", &n, &m);
	ans = max(n, m);
	For(i, 1, n) scanf("%s", Map[i] + 1);
	For(i, 1, n - 1) For(j, 1, m - 1)
		G[i][j] = ((Map[i][j] == '#') + (Map[i][j + 1] == '#') + (Map[i + 1][j] == '#') + (Map[i + 1][j + 1] == '#')) % 2 == 0;
	--n, --m;
	For(i, 1, n) For(j, 1, m) up[i][j] = G[i][j] ? up[i - 1][j] + 1 : 0;
	For(i, 1, n){
		stk[top = 1] = 1, pos[1] = 1;
		int *f = up[i];
		For(j, 2, m + 1){
			bool flag = true;
			while(top && f[j] < f[stk[top]]){
				flag = false;
				ans = max(ans, (j - pos[top] + 1) * (f[stk[top]] + 1)), --top;
			}
			stk[++top] = j;
			if(flag) pos[top] = j;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	int n;
	cin >> n;
	string s;
	cin >> s;
	//まずEを向いている人の数を数える
	ll count = 0;
	For(i,1,n){
		if(s[i]=='E'){
			count ++;
		}
	}
	ll ans = count;
	For(i,1,n){
		if(s[i-1]=='W') count++;
		if(s[i]=='E')count--;
		chmin(ans,count);
	}
	cout << ans << endl;
		

}


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

int main(){
	long ans=0;
	char s[200001]={};
	cin>>s;
	long j=0,old=0;
	for(long i=0;s[i]!=0;i++){
		for(j=0;s[i+j]=='A';j++);
		if(j>0 || old>0){
			if(s[i+j]=='B' && s[i+j+1]=='C'){
				ans+=j+old;
				old+=j;
				i+=j+1;
			}else{
				old=0;
				i+=j-1;
			}
		}else{
			old=0;
		}
	}
	printf("%ld",ans);
	return 0;
}


Measured memory_bytes: 384
N=int(input())
q=[]  
for i in range(N):
    q+=[list(input())]
    q[i].sort()
q.sort() 
i=0
s=0
z=0 #総得点
while i<N-1:
    if q[i]!=q[i+1]:
        z+=((s*(s+1))//2)
        s=0
    else:
        s+=1
    i+=1
z+=((s*(s+1))//2)
print(z)


Measured memory_bytes: 98904
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n;cin>>n;n%=1000;cout<<((n%1000)?(1000-n):0)<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  string s(b,'0'+a);
  string t(a,'0'+b);
  if(a>b){
    cout<<t<<endl;
  }
  else{
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import heapq


class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        """
        :param rote_map:
        :param start_point:
        :param distance:
        :return:
        """
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) != 0:
            prov_cost, src = heapq.heappop(heap_q)

            if dist[src] < prov_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        if self.goal_point is not None:
            return self.get_path(self.goal_point, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))


n, m, s, t = map(int, input().split())
yen_route_map = [dict() for _ in range(n)]
snuuk_route_map = [dict() for _ in range(n)]

for i in range(m):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    yen_route_map[u][v] = yen_route_map[v][u] = a
    snuuk_route_map[u][v] = snuuk_route_map[v][u] = b
yen_dijkstra = Dijkstra(yen_route_map, s-1).execute()
snuuk_dijkstra = Dijkstra(snuuk_route_map, t-1).execute()

from itertools import accumulate
ans = list(accumulate([y+s for y, s in zip(yen_dijkstra, snuuk_dijkstra)][::-1],min))
[print(10**15-ans[i]) for i in range(n-1,-1,-1)]

# answer1 = [yen + snuuk for yen, snuuk in zip(yen_dijkstra, snuuk_dijkstra)]
# answer2
#
# for i in range(n):
#     print(10**15 - answer1[i])




Measured memory_bytes: 96272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;

ll kaizyou(ll k) { 
    ll sum = 1;
    for (ll i = 1; i <= k; i++){
      sum *= i%MOD;
      sum %= MOD;
    }
    return sum%MOD;
}

int main(){
    ll N, M;
    cin >> N >> M;
    ll out = (kaizyou(N) % MOD) * (kaizyou(M) % MOD);
    if (N == M) {
      out *= 2;
      out %= MOD;
    } else if (abs(N - M) > 1) {
      out = 0;
    }
    cout << out%MOD << endl;
    return 0;
}

Measured memory_bytes: 3572
n = int(input())
List = list(map(int, input().split()))
min = 10000000000
sum = 0
# Pを決める
for P in range(1,101):
 # L[i]のループこのループ終わったらsumを初期化しておきたい

    sum = 0
    for L in List:
        sum += pow((P - L), 2)
    if min >= sum:
        min = sum
# 　値の更新がうまくできていない
print(min)


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, (int)(n) - 1)
#define REPD(i, n) FORD(i, (int)(n) - 1, 0)
#define VAL(x) cout << #x << " = " << (x) << endl
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * 1ll * (x))
#define y0 yy0
#define y1 yy1

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

int main() {
    int n, l;
    cin >> n >> l;
    int pos = -1, prev = 0;
    REP(i, n) {
        int now;
        cin >> now;
        if (i > 0 && prev + now >= l)
            pos = i - 1;
        prev = now;
    }
    if (pos == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    FOR(i, 0, pos - 1)
        cout << i + 1 << endl;
    FORD(i, n - 2, pos + 1)
        cout << i + 1 << endl;
    cout << pos + 1 << endl;
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(void){
    int p[1000000]={0};
    int avarage[100000]={0};
    int n=0,count=0;
    int s=0,max=0,min=0;
    while(1){
        max=0;
        min=0;
        scanf("%d",&n);
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            scanf("%d",&s);
            if(i==0){
                max=s;
                min=s;
            }
            if(s>max){
                max=s;
            }
            if(s<min){
                min=s;
            }
            p[count]+=s;
        }
        p[count]-=max+min;
        avarage[count]=p[count]/(n-2);
        count++;
    }
    for(int i=0;i<count;i++){
        printf("%d\n",avarage[i]);
    }
    return 0;
}


Measured memory_bytes: 5992
from heapq import heappop, heappush

n,m=map(int,input().split())
a=[]
for i in range(n):
    heappush(a,list(map(int,input().split())))
heap=[]
s=0
for i in range(m):
    while 1:
        if len(a)==0:break
        else:
            if a[0][0]==i+1:heappush(heap,-heappop(a)[1])
            else:break
    if len(heap)>0:s+=-heappop(heap)
print(s)

Measured memory_bytes: 27884
#include<iostream>
#include<vector>
using namespace std;
struct Point { long double px, py; };
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
Point Minus(Point a, Point b) { a.px -= b.px; a.py -= b.py; return a; }
int ccw(const Point& p0, const Point& p1, const Point& p2) {
	Point a = Minus(p1, p0), b = Minus(p2, p0);
	if (crs(a, b) > 1e-10) return 1;
	if (crs(a, b) < -1e-10) return -1;
	if (dot(a, b) < -1e-10) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
bool is_convex(vector<Point> v) {
	if (v.size() < 3) return false;
	int s = -3;
	for (int i = 0; i < v.size(); i++) {
		int r = ccw(v[i], v[(i + v.size() - 1) % v.size()], v[(i + 1) % v.size()]);
		if (abs(r) == 1 && s == -3) s = r;
		if (s * r == -1) return false;
	}
	return true;
}
int n; Point p[1000]; vector<Point>G;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i].px >> p[i].py; G.push_back(p[i]);
	}
	cout << is_convex(G) << endl;
	return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Raag4924 ios_base::sync_with_stdio(0);
#define fastio cin.tie(0);cout.tie(0);
#define mod 1000000007
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/
int h,w;
string s[1009];
int dp[1001][1001];
int solve(int i,int j)
{
    if(i>=h or j>=w) return 0;
    if(s[i][j]=='#') return 0;
    if(i==h-1 and j==w-1) return 1;
    if(dp[i][j]!=-1) return dp[i][j];

    return dp[i][j] = (solve(i+1,j)%mod+solve(i,j+1)%mod)%mod;
}
int32_t main()
{
    Raag4924
    fastio
 
  
  
    
    cin>>h>>w;

  

    for(int i=0;i<h;i++)
        cin>>s[i];

    memset(dp,-1,sizeof dp);

    cout<<solve(0,0)<<"\n";
    
   


 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 12752
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, k = list(map(int,ipti().split()))
    h = list(map(int,ipti().split()))
    ans = 0

    for hi in h:
        if hi >= k:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;

  vll p(n);
  REP(i, n){
    cin >> p[i];
    p[i]--;
  }

  vll index(n);
  REP(i, n)
    index[p[i]] = i;

  set<ll> s;
  ll ans = 0;
  for(ll i = n-1; i >= 0; i--){
    s.insert(index[i]);
    vll l(2, -1), r(2, n);
    {
      auto it = s.find(index[i]);
      REP(j, 2){
        if(it == s.begin())
          break;
        it--;
        l[j] = *it;
      }
    }
    {
      auto it = s.find(index[i]);
      REP(j, 2){
        it++;
        if(it == s.end())
          break;
        r[j] = *it;
      }
    }

    auto it = s.find(index[i]);
    vll ls(2), rs(2);
    ls[0] = *it - l[0];
    ls[1] = l[0] - l[1];
    rs[0] = r[0] - *it;
    rs[1] = r[1] - r[0];



    ans += (i+1)*(rs[0]*ls[1]+rs[1]*ls[0]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  double ans=0;
  rep(i,n){
    double a;
    string s;
    cin >> a >> s;
    if(s[0]=='J')ans+=a;
    else ans+=a*380000;
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b){
        if(a != c){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else if(a == c){
        if(a != b){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else{
        if(b == c){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
using namespace std;

const int M=1005;
char ti[M][M];
int isu[M][M];
int n,m,nn;

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

queue<int> qu;
void init_bfs()
{
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(ti[i][j]=='S')
            {
                qu.push(i*M+j);
                isu[i][j]=0;
                return;
            }
}
int bfs()
{
    int ans=0;
    int edx,edy;
    for(int ii=1;ii<=nn;ii++)
    {
        while(!qu.empty())
            qu.pop();
        memset(isu,-1,sizeof(isu));
        if(ii==1)
            init_bfs();
        else
        {
            qu.push(edx*M+edy);
            isu[edx][edy]=0;
        }
        int f=0;
        while(!qu.empty())
        {
            int t=qu.front();
            qu.pop();
            int tx=t/M,ty=t%M;
            for(int i=0;i<4;i++)
            {
                int x=tx+dx[i],y=ty+dy[i];
                if(x<1||x>n||y<1||y>m||ti[x][y]=='X'||isu[x][y]!=-1)
                    continue;
                if(ti[x][y]=='0'+ii)
                {
                    ans+=isu[tx][ty]+1;
//                    cout<<ans<<endl;
//                    for(int i=0;i<=n+1;i++)
//                    {
//                        for(int j=0;j<=m+1;j++)
//                            cout<<'\t'<<isu[i][j];
//                        cout<<endl;
//                    }
                    edx=x;edy=y;
                    f=1;
                    break;
                }
                qu.push(x*M+y);
                isu[x][y]=isu[tx][ty]+1;
            }
            if(f==1)
                break;
        }
        if(!f)
            return -1;
    }
    return ans;
}

int main()
{
    //freopen("1.out","w",stdout);
    scanf("%d%d%d",&n,&m,&nn);
    for(int i=1;i<=n;i++)
        scanf("%s",ti[i]+1);
    printf("%d\n",bfs());
    return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n, k; cin >> n >> k;
    int d = 1;
    int num = 1;
    while (true) {
        if (num <= n && n < num * k) {
            cout << d << endl;
            return 0;
        }
        num *= k; d++;
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            // int num = 5;
            // int[] arr = {5, 3, 2, 4, 1};
            int num = Integer.parseInt(br.readLine());
            String[] s = br.readLine().split("\\s");
            int[] arr = new int[num];
            
            for(int i=0; i<num; i++){
                arr[i] = Integer.parseInt(s[i]);
            }
            
            
            // Sort sort = bubbleSort(num, arr);
            Sort sort = selectSort(num, arr);
            
            String[] output = new String[num];
            
            for(int i=0; i<num; i++){
                output[i] = String.valueOf(sort.array[i]);
            }
            System.out.println(String.valueOf(String.join(" ", output)));
            System.out.println(String.valueOf(sort.count));
            
            
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
    
    static Sort bubbleSort(int num, int[] arr) {
        int count = 0;
        for(int i=0; i<num; i++) {
            for(int j=num-1; i<j; j--){
                if(arr[j] < arr[j-1]) {
                    int tmp = arr[j];
                    arr[j]  = arr[j-1];
                    arr[j-1] =  tmp;
                    count += 1;
                }
            }
        }
        return new Sort(count, arr);
    }
    
    static Sort selectSort(int num, int[] arr) {
        int count = 0;
        
        for(int i=0; i<num; i++){
            
            int min = i;
            for(int j=i; j<num; j++){
                
                if(arr[min] > arr[j]){
                    min = j;
                }
            }
            int tmp = arr[min];
            arr[min] = arr[i];
            arr[i] = tmp;
            if (min != i) {
                count++;
            }
        }
        return new Sort(count, arr);
    }
}

class Sort{
    public int count;
    public int[] array;
    
    public Sort(int count, int[] array){
        this.count = count;
        this.array = array;
    }
}



Measured memory_bytes: 24512
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

const int MAX = 100010;
ll fac[MAX];
ll FACinit(ll a) { // a! mod
  fac[0]=fac[1] = 1;
  reps(i, 2, MAX){
    fac[i] = fac[i - 1] * i % MOD;
  }
  return fac[a];
}

void Main(){

  int N;
  cin>>N;

  cout << FACinit(N) <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 10, mod = 1e9 + 7;
ll a[maxn], n, dp[maxn], c[maxn];

int main()
{
    ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> a[i];
    dp[0] = dp[1] = 1;
    c[a[1]] += dp[0];
    for (int i = 2; i <= n; i ++)
    {
        if (a[i] != a[i - 1])
            c[a[i]] += dp[i - 1];
        dp[i] = (c[a[i]] % mod);
    }
    cout << dp[n] % mod << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
int n,A,B,C,ans,a[10],b[5];
bool vis[10];

void dfs(int k,int nl) {
	if (k>n) {
		if (b[1]==0 || b[2]==0 || b[3]==0) return;
		int tmp=abs(b[1]-A)+abs(b[2]-B)+abs(b[3]-C);
		ans=min(ans,tmp+nl-30);
		return;
	}
	
	dfs(k+1,nl);
	b[1]+=a[k]; dfs(k+1,nl+10); b[1]-=a[k];
	b[2]+=a[k]; dfs(k+1,nl+10); b[2]-=a[k];
	b[3]+=a[k]; dfs(k+1,nl+10); b[3]-=a[k];
}

int main()
{
	scanf("%d%d%d%d",&n,&A,&B,&C);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	
	ans=INF;
	dfs(1,0);
	cout<<ans;
	return 0;
}

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

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

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::vector<long long>> D) {
    for(int i = 0 ; i + 3 <= N ; i++){
        int c = 0;
        for(int j = 0 ; j < 3 ; j++){
            if( D[i+j][0] == D[i+j][1]) c++;
        }
        if( c == 3 ){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::vector<long long>> D(N, std::vector<long long>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      scanf("%lld", &D[i][j]);
    }
  }
  solve(N, std::move(D));
  return 0;
}


Measured memory_bytes: 3700
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

struct Data {
  int p, v, l;
  Data(int p, int v, int l) : p(p), v(v), l(l) {}
  bool operator<(const Data& d) const { return l > d.l; }
};

int main() {
  ll N, M;
  cin >> N >> M;
  vector<vector<ll>> to(N);
  ll a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  priority_queue<Data> q;
  vector<pair<ll, ll>> prev_list(N, {INF, -1});
  vector<ll> MEMO(N, INF);
  q.emplace(-1, 0, 0);
  while (!q.empty()) {
    int prev = q.top().p;
    int pos = q.top().v;
    int len = q.top().l;
    q.pop();
    if (prev != -1 && MEMO[pos] <= len) continue;
    for (int next_pos : to[pos]) {
      if (MEMO[next_pos] > len + 1) {
        q.emplace(pos, next_pos, len + 1);
      }
    }
    MEMO[pos] = min(MEMO[pos], (ll)len);
    if (prev_list[pos].first > len) prev_list[pos] = {len, prev + 1};
  }
  bool flag = true;
  for (int i = 1; i < N; i++) {
    if (prev_list[i].second == -1) flag = false;
  }
  if (flag) {
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
      cout << prev_list[i].second << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 16044
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
1 ~ N-1 の約数の合計
*/



int main()
{
    int n;
    cin >> n;
    // int ans = 0; 
    // rep1(i, n-1){
    //     set<int> a;
    //     divisor(i, a);
    //     ans += a.size();
    // }
    int ans = 0;
    for (int a = 1; a < n; a++)
    {
        for (int b = 1; a*b < n ; b++)
        {
            ans++;        
        }
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
    int monsterHP, attacksDone, specialAttack;
    int attackPower = 0;
    scanf("%d %d", &monsterHP, &attacksDone);

    // Reads from input specialAttack
    for (int i = 0; i < attacksDone; i++)
    {
        scanf("%d", &specialAttack);
        // Adds 'power' of specialAttacks to basic attackPower of the monster
        attackPower += specialAttack;
    }

    if (attackPower >= monsterHP)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


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

typedef long long ll;
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

int n , a;

int main()
{
    _FastIO;
    cin >> n >> a;
    int l = a;
    int r = a + n - 1;
    int eat;
    if(r <= 0)  eat = r;
    else    if(l >= 0) eat = l;
    else eat = 0;
    int ans = (r + l) * (r - l + 1) / 2 - eat;
    cout << ans << endl;
    return 0;
}


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 INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll K;
    cin >> K;
    cout << 50 << endl;
    int num = K%50;
    int N=50;
    vector<ll> A(N);
    rep(i,N){
        A[i]=i;
    }
    rep(i,num){
        rep(j,N){
            if(i==j){
                A[j]+=N;
            }else{
                A[j]-=1;
            }
        }
    }
    rep(i,N){
        A[i]+=K/N;
    }
    rep(i,N){
        cout << A[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cstring>
#include <iomanip>
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d=b/a;
    if(d>=c){
        cout<<c;
    }else{
        cout<<d;
    }
}

Measured memory_bytes: 256