akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION
void solve(void)
{
  int N;
  cin>>N;
  string str;
  cin>>str;
  vector<int> R,G,B;
  for (int i = 0; i < N; i++)
  {
    if(str[i] =='R')
    {
      R.push_back(i);
    }
    else if(str[i] =='G')
    {
      G.push_back(i);
    }
    else
    {
      B.push_back(i);
    }
  }
  int ANS = R.size()*G.size()*B.size();
  for (int i = 0; i < R.size(); i++)
  {
    for (int j = 0; j < G.size(); j++)
    {
       int P = R[i]; int Q = G[j];
       if(P > Q) swap(P,Q);
       if(find(ALL(B),P - abs(Q - P)) != B.end())
       {
         ANS--;
       }
       if(find(ALL(B),Q + abs(Q - P)) != B.end())
       {
         ANS--;
       }
       if(find(ALL(B),(P+Q)/2) != B.end() && (P+Q)%2 == 0)
       {
         ANS--;
       }
      //  DEBUG(P,Q, P + abs(Q - P));
    }
    
  }
  // DEBUG(R);DEBUG(G);DEBUG(B);
  cout<<ANS<<endl;
  
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  solve();

  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)

int D, G;
vector<int> p;
vector<int> c;
int mincnt = 10000;

int dfs(int i, int sum, int cnt, vector<int> &flg){
    //cout << i << endl;
    if(i==D){
        //cout << i << " ";
        //REP(j, D) cout << flg[j] <<" ";
        //cout << "sum=" << sum << " cnt=" << cnt<< endl;
        //cout << "cnt1= "<< cnt << endl;

        int ret=1<<15;
        if (sum >= G){
            ret = cnt;
        }
        else{
            for (int j = D-1; j >= 0; j--){
                if (flg[j] == 1) continue;
                REP(k, p[j]){
                    if (sum >= G){
                        ret = cnt;
                        break;
                    }
                    sum += (1+j) * 100;
                    cnt++;
                }
            }
        }
        //cout << ">> " << sum << " " << cnt << endl;
        return ret;
    }

    int mincnt = 10000;
    
    int tmp_cnt;
    flg[i] = 1;
    tmp_cnt = dfs(i+1, sum+100*(i+1)*p[i] + c[i], cnt+p[i], flg);
    mincnt = min(mincnt, tmp_cnt);
    flg[i] = 0;
    tmp_cnt = dfs(i+1, sum, cnt, flg);
    mincnt = min(mincnt, tmp_cnt);
    

    return mincnt;
}

int main()
{
    cin >> D>>G;

    p.resize(D);
    c.resize(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    vector<int> flg(D, -1);
    int rtn = dfs(0, 0, 0, flg);
    cout << rtn << endl; 

   return 0;
}

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

int main(){
    long a, b, c, k;
    cin >> a >> b >> c >> k;
    long sum = 0;
    if(k <= a){
        sum = k * 1;
    }else if(k <= (a + b)){
        sum = (a*1) + (k - a) * 0;
    }else if(k <= (a + b + c)){
        sum = (a*1) + (b * 0) + (k - (a + b)) * (-1); 
    }
    cout << sum << endl;   
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
vector<int> data(100001,-1);

int root(int x){
  if(data[x] == -1)return x;
  else return data[x] = root(data[x]);
}

bool same(int x,int y){
  if(root(x) == root(y))return 1;
  else return 0;
}

int unite(int x,int y){
  if(!same(x,y))data[root(x)] = y;
  return 0;
}

int main(){
  int N,M,x,y,q,ans=0;
  cin >> N >> M;
  int p[N+1];
  for(int i = 0;i < N+1;i++)p[i]=0;
  for(int i = 1;i <= N;i++){
    cin >> q;
    p[q] = i;
  }
  for(int i = 0;i < M;i++){
    cin >> x >> y;
    unite(x,y);
  }
  for(int i = 1;i <= N;i++)if(same(p[i],i))ans++;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;
 
int main(){
  int n;
  while(~scanf("%d",&n)){
    int res = 0;
    for(int a=0;a<=9;a++)
      for(int b=0;b<=9;b++)
	for(int c=0;c<=9;c++)
	  for(int d=0;d<=9;d++)
	    if(a+b+c+d == n) res++;
    printf("%d\n",res);
  }
}

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

#define ll long long

ll my_pow(ll x, ll n) {
	if (x == 1) return 1;
	ll res = 1;
	while (n > 0) {
		if (n & 1) {
			if (res <= LLONG_MAX / x)
				res *= x;
			else
				return -1;
		}
		if (x <= LLONG_MAX / x)
			x *= x;
		else
			return -1;
		n >>= 1;
	}
	return res;
}

int main() {
	string s;
	ll k, n = 5000000000000000;
	cin >> s >> k;
	vector<ll> sn(s.size());
	for (int i = 0; i < sn.size(); i++) {
		sn.at(i) = my_pow((ll)(s.at(i) - '0'), n);
		if (sn.at(i) != -1) {
			k -= sn.at(i);
			if (k <= 0) {
				cout << s.at(i) << endl;
				return 0;
			}
		}
		else {
			cout << s.at(i) << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)

N = int(input())
M = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    M[u].append([v, w])
    M[v].append([u, w])

V = [0] * N
D = [0] * N
C = [0] * N


def dfs(n, c):
    if V[n] == 1:
        return
    C[n] = c
    V[n] = 1
    for w in M[n]:
        if w[1] % 2 == 0:
            dfs(w[0], c)
        else:
            dfs(w[0], (c + 1) % 2)

dfs(0, 0)
for c in C:
    print(c)


Measured memory_bytes: 86624
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 1e9+7;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e5+5;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 1e6;
int binsearch(int lo, int hi){
    while(lo<hi){
        int mid=(lo+hi)/2;
        if((mid))   // check(mid)
            hi=mid;
        else
            lo=mid+1;
    }
    return lo;
}
int power(int x,int y){
    int res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}

int main(){
    FAST
    ll n,d,ans=0;
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        ll x,y;
        cin>>x>>y;
        if(x*x + y*y <= d*d){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

int main(void){
  while(1){
    int stone[50];
    for(int k = 0 ; k < 50 ; k++){stone[k] = 0;}

    int bowl;
    int n, p;  // n：候補者人数，p：小石の総数
    cin >> n;
    cin >> p;

    if(n == 0 && p == 0){return 0;}

    bowl = p;

    bool flg = true;
    int ans;

    for(int i = 0 ; flg ; i = (i+1) % n){

      if(bowl == 0){
        bowl = bowl + stone[i];
        stone[i] = 0;
      }else{
        stone[i]++;
        bowl--;
        if(bowl == 0 && stone[i] == p){ans = i; flg = false;}
      }
    }

    for(int i = 0 ; i < 10000000 ; i++){
        for(int j = 0 ; j < 10000000 ; j++){
            for(int k = 0 ; k < 10000000 ; k++){
                for(int l = 0 ; l < 10000000 ; l++){
                    int K = l + i + j + k;
                }
            }
        }    
    }


    cout << ans << endl;
  }
}



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

int main() {
	int n[5];
	for(int i = 0; i < 5; i++) cin >> n[i];
	sort(n, n+5, greater<int>());
	for(int i = 0; i < 4; i++) cout << n[i] << ' ';
	cout << n[4] << endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

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

    cin >> S;
    cin >> Q;
    vector<int> R, F;
    vector<char> C;
    int q1 = 0;
    int q2 = 0;
    REP(i, Q) {
        int t;
        cin >> t;
        if (t == 1) {  //反転
            q1++;
        } else if (t == 2) {
            q2++;
            int f;
            char c;
            cin >> f >> c;
            R.push_back(q1);
            F.push_back(f - 1);
            C.push_back(c);
        }
    }

    string force, back;
    REP(i, q2) {
        if ((R[i] % 2 + F[i]) % 2 == 0) {
            force.push_back(C[i]);
        } else {
            back.push_back(C[i]);
        }
    }
    if (q1 % 2 == 1) {
        reverse(ALL(S));
        reverse(ALL(back));
        cout << back << S << force << endl;
    } else {
        reverse(ALL(force));
        cout << force << S << back << endl;
    }

    return 0;
}


Measured memory_bytes: 2924
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    h = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n):
        cnt += 1 if h[i] >= k else 0
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 51440
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    class union_find{
        public:
        vector<ll> parent, tree_size;
            union_find(unsigned long _n) : parent(_n), tree_size(_n, 1){
                for(unsigned long i = 0; i < _n; ++i)parent[i] = i;
            }
            ll find(ll x){
                while(parent[x] != x)x = parent[x] = parent[parent[x]];
                return x;
            }
            void merge(ll a, ll b){
                a = find(a);
                b = find(b);
    	    if(a==b) return;
                if(tree_size[a] < tree_size[b])swap(a, b);
                tree_size[a] += tree_size[b];
                parent[b] = a;
                return;
            }
    	bool same(ll a, ll b){
    	    a = find(a);
    	    b = find(b);
    	    return a == b;
    	}
        };
    //uf.mergeのように使う
    //ufはMAX_N+1でとるか、代入時に0-indexedにする
    cin>>N>>M;
    union_find uf(N + 10);
    rep(i,M){
        cin>>A>>B;
        uf.merge(A, B);
    }
    ll res = 1;
    rep(i,N) res = max(res, uf.tree_size[i + 1]);
    cout<<res<<endl;
}

Measured memory_bytes: 6420
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A = int(readline())
S,T=readline().decode('utf-8').split()

ans=""

for a,b in zip(S,T):
    ans+=a+b

print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
void swap(long long *x, long long *y)
{
	long long temp=*x;
	*x=*y;
	*y=temp;
}
long long GCD(long long m, long long n)
{
	long long temp;

	if(m<n) swap(&m, &n);

	while(n!=0){
		temp=m%n; m=n; n=temp;
	}
	return m;
}
int main(void)
{
	int n, x;

	cin>>n>>x;

	vll p(n+1);
	
	rep(i, n) cin>>p[i];

	p[n]=x;

	sort(all(p));

	ll ans;
	rep(i, n){
		if(i==0){
			ans=p[i+1]-p[i];
		}else{
			ans=GCD(p[i+1]-p[i], ans);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

struct xyh{
    int x;
    int y;
    long long h;
    xyh(int x, int y, long long h){
        this->x = x;
        this->y = y;
        this->h = h;
    }
};

bool operator>(const xyh& lhs, const xyh& rhs){
    return lhs.h > rhs.h;
}

long long max(long long a, long long b){
    if(a>b)
        return a;
    else
        return b;
}

int main() {
    int n; cin >> n;
    vector<int> xs(n),ys(n);
    vector<long long> hs(n);
    vector<xyh> pos;
    for(int i = 0; i<n;i++){
        cin >> xs[i] >> ys[i] >> hs[i];
        pos.push_back(xyh(xs[i],ys[i],hs[i]));
    }
    sort(pos.begin(),pos.end(), greater<xyh>());
    for(int x = 0; x <= 100; x++){
        for(int y = 0; y <= 100; y++){
            bool isOK = true;
            long long htmp = pos[0].h + abs(x-pos[0].x) + abs(y-pos[0].y);
            for(int i = 0; i< n; i++){
                long long height = max(htmp - abs(x-pos[i].x) - abs(y-pos[i].y),0);
                if(pos[i].h != height){
                    isOK = false;
                    break;
                }
            }
            if(isOK){
                cout << x << " " << y << " " << htmp << endl;
                return 0;
            }
        }
    }
}


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

const int MAXN = 100005;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int vis[MAXN];
int n, m, u, v;
list<int> lst;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> u >> v;
		push(u, v), push(v, u);
	}
	int l = 1, r = 1;
	vis[1] = 1;
	lst.push_back(l);
	while (1) {
		int flag = 1;
		for (int i = head[l]; i; i = edge[i].next) {
			int to = edge[i].to;
			if (!vis[to]) {
				lst.push_front(to);
				vis[to] = 1, l = to, flag = 0;
				break;
			}
		}
		if (flag) break;
	}
	while (1) {
		int flag = 1;
		for (int i = head[r]; i; i = edge[i].next) {
			int to = edge[i].to;
			if (!vis[to]) {
				lst.push_back(to);
				vis[to] = 1, r = to, flag = 0;
				break;
			}
		}
		if (flag) break;
	}
	cout << lst.size() << endl;
	for (auto i : lst)
		cout << i << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 6016
import queue
s = input()

l = len(s)

def P(n,i):
    product = 1
    for x in range(i):
        product *= (n-x)
    return product

def f(n):
    product = 1
    for x in range(n):
        prodcut *= (n-x)
    return product

if(l<3):
    print("0")
    exit(0)

res = 0
'''
for i in range(3,l):
    res += P(i,3)*(3**(i-3))

#for l digit

digit = list(range(1,l+1))

numlist = [0]*l
'''
q = queue.Queue()

q.put('')

while not q.empty():
    x = q.get()
    if(x !='' and int(x)>int(s)):
        continue
    else:
        q.put(x+'3')
        q.put(x+'5')
        q.put(x+'7')
    if('3' in x and '5' in x and '7' in x):
        res += 1
print(res)


Measured memory_bytes: 8048
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

vector<int> connects[100005];
int group[100005];
int currentGroup = 0;

void dfs(int parent) {
	group[parent] = currentGroup;
	for (int c : connects[parent]) {
		if (group[c] != 100005) continue;
		dfs(c);
	}
}

int main() {
	int N, M;
	cin >> N >> M;

	vector<int>p(N);
	for (int i = 0; i < N; ++i)cin >> p[i];
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		connects[a - 1].push_back(b - 1);
		connects[b - 1].push_back(a - 1);
	}
	
	for (int i = 0; i < N; ++i)group[i] = 100005;
	for (int i = 0; i < N;++i) {
		if (group[i] != 100005)continue;
		dfs(i);
		currentGroup++;
	}
	
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (group[p[i]-1] == group[i])ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 9856
//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=1007,mod=1e9+7;
typedef long long LL; 
typedef double db;
using namespace std;
LL n,m,k,f[4]={0,0,1,0},g[4],a[N][N],b[N][N],ev,ud,lr,v;
char s[N];

template<typename T> void read(T &x) {
    char ch=getchar(); x=0; T f=1;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}

LL ksm(LL a,LL b) {
	LL rs=1,bs=a;
	while(b) {
		if(b&1) rs=rs*bs%mod;
		bs=bs*bs%mod;
		b>>=1;
	}
	return rs;
}

struct jz {
	LL a[4][4];
	friend jz operator *(const jz&A,const jz&B) {
		jz rs;
		For(i,0,3) For(j,0,3) {
			rs.a[i][j]=0;
			For(k,0,3) (rs.a[i][j]+=A.a[i][k]*B.a[k][j]%mod)%=mod;
		}
		return rs;
	}
}bs,rs;

LL jzksm(LL b) {
	while(b) {
		if(b&1) rs=rs*bs;
		bs=bs*bs;
		b>>=1;
	}
}

//#define DEBUG
int main() {
#ifdef DEBUG
	freopen("1.in","r",stdin);
	//freopen(".out","w",stdout);
#endif
	read(n); read(m); read(k);
	For(i,1,n) {
		scanf("%s",s+1);
		For(j,1,m) {
			a[i][j]=(s[j]=='#');
			v+=a[i][j];
		}
	}
	For(i,1,n) lr+=(a[i][1]&a[i][m]);
	For(i,1,m) ud+=(a[1][i]&a[n][i]);
	if(lr&&ud) puts("1");
	else if(!lr&&!ud) printf("%lld\n",ksm(v,k-1));
	else {
		if(lr) {
			For(i,1,n) For(j,1,m) b[j][i]=a[i][j];
			swap(n,m); swap(lr,ud);
		}
		else For(i,1,n) For(j,1,m) b[i][j]=a[i][j];
		For(i,1,n-1) For(j,1,m) if(b[i][j]&&b[i+1][j]) ev++;
		For(i,0,3) rs.a[i][i]=1;
		bs.a[2][0]=1; bs.a[3][1]=1; bs.a[2][2]=v;
		bs.a[2][3]=ev; bs.a[3][3]=ud;
		jzksm(k-1);
		For(i,0,3) For(j,0,3) (g[i]+=f[j]*rs.a[j][i]%mod)%=mod;
		LL ans=(g[2]-g[3]+mod)%mod;
		printf("%lld\n",ans);
	}
    return 0;
}

Measured memory_bytes: 16000
from functools import singledispatch
import math

EPS = 1e-10

COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0

class Segment():
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, point):
        # + 演算子での挙動を指定
        return Point(self.x+point.x, self.y+point.y)

    def __sub__(self, point):
        # - 演算子での挙動を指定
        return Point(self.x-point.x, self.y-point.y)

    def __mul__(self, a):
        # * 演算子での挙動を指定
        return Point(a*self.x, a*self.y)

    def __truediv__(self, a):
        # / 演算子での挙動を指定
        return Point(self.x/a, self.y/a)

    def __abs__(self):
        # abs関数での挙動を指定
        return math.sqrt(self.norm())

    def norm(self):
        return self.x**2+self.y**2

    def __eq__(self, point):
        # == 演算子での挙動を指定
        return abs(self.x-point.x) < EPS and abs(self.y-point.y) <EPS

def dot(a, b):
    return a.x*b.x+a.y*b.y

def cross(a, b):
    return a.x*b.y - a.y*b.x

def isOrthogonal(a, b):
    return dot(a, b) == 0

def isParallel(a, b):
    return cross(a, b) == 0

def project(s, p):
    #s: Segment(), p: Point()
    base = s.p2 - s.p1
    r = dot(p-s.p1, base)/base.norm()
    return s.p1+base*r

def reflect(s, p):
    return p+(project(s, p)-p)*2

@singledispatch
def get_distance(a, b):
    return abs(a-b)

def get_distance_lp(l, p):
    return abs(cross(l.p2-l.p1, p-l.p1)/abs(l.p2-l.p1))

def get_distance_sp(s, p):
    if dot(s.p2-s.p1, p-s.p1) < 0:
        return abs(p-s.p1)
    if dot(s.p1-s.p2, p-s.p2) < 0:
        return abs(p-s.p2)
    return get_distance_lp(s, p)
    
@get_distance.register(Segment)
def _(s1, s2):
    if intersect(s1, s2):
        return 0
    return min([get_distance_sp(s1, s2.p1), get_distance_sp(s1, s2.p2),
                get_distance_sp(s2, s1.p1), get_distance_sp(s2, s1.p2)])

def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if cross(a, b) > EPS:
        return COUNTER_CLOCKWISE
    if cross(a, b) < -EPS:
        return CLOCKWISE
    if dot(a, b) < -EPS:
        return ONLINE_BACK
    if a.norm() < b.norm():
        return ONLINE_FRONT
    return ON_SEGMENT

@singledispatch
def intersect(p1, p2, p3, p4):
    return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0
            and ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0)

@intersect.register(Segment)
def _(s1, s2):
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2)


if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    q = int(input())
    for _ in range(q):
        x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
        p0 = Point(x0, y0)
        p1 = Point(x1, y1)
        p2 = Point(x2, y2)
        p3 = Point(x3, y3)
        s1 = Segment(p0, p1)
        s2 = Segment(p2, p3)
        print(get_distance(s1, s2))


Measured memory_bytes: 6452
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
int n, w[201000], p[201000];
set<int>Set;
long long res;
int main(){
    int i, a ,b;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
        p[w[i]] = i;
    }
    Set.insert(0);
    Set.insert(n+1);
    for(i=1;i<=n;i++){
        set<int>::iterator it;
        it = Set.lower_bound(p[i]);
        b = *it;
        it--;
        a = *it;
        res += 1ll * (p[i]-a)*(b-p[i])*i;
        Set.insert(p[i]);
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 11136
#include <stdio.h>
int main(void){

    int N, a[100], MIN, i;
    double sum = 0, ave, min = 100;
    
    scanf("%d", &N);
    
    for(i = 0 ; i < N ; i++){
        scanf("%d", &a[i]);
        sum += a[i];
    }
    
    ave = sum / (double)N;
    
    for(i = N-1; i >= 0; i--){

    if(a[i] >= ave){
        if(min >= a[i] - ave){
            min = a[i] - ave;
            MIN = i;
        }
    }else{
        if(min >= ave - a[i]){
            min = ave - a[i];
            MIN = i;
        }
    }
    }
    
    printf("%d", MIN);
    
    return 0;
}


Measured memory_bytes: 128
# !/usr/local/bin/python3

MOD = int(1e9+7)

def nCk(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n]*(finv[n-k]*finv[k]%MOD)%MOD

def solve():
    a.sort()

    for i in range(2, MAX_N):
        fac[i] = fac[i-1]*i%MOD
        inv[i] = MOD-(inv[MOD%i])*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD

    max_x = 0
    for i in range(k-1, n):
        max_x = (max_x+a[i]*nCk(i, k-1))%MOD

    min_x = 0
    for i in range(n-k+1):
        min_x = (min_x+a[i]*nCk(n-i-1, k-1))%MOD

    return((max_x-min_x)%MOD)

if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    a = [(lambda x: int(x))(x) for x in input().split()]
    MAX_N = n+5
    fac = [1, 1]+[0 for _ in range(MAX_N)]
    finv = [1, 1]+[0 for _ in range(MAX_N)]
    inv = [0, 1]+[0 for _ in range(MAX_N)]
    print(solve())


Measured memory_bytes: 25824
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int max(int a, int b){
	return a >= b ? a : b;
}

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int euclid(int a, int b){
  if(a < b){
    int tmp = a;a = b;b = tmp;
  }
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,check1=0,check2=0,check3=0,count=0;
  scanf("%d",&N);
	char a[N],b[N],c[N];
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  //printf("%c",a[0]);  printf("%c",b[1]);  printf("%c",c[2]);
	for(int i=0;i<N;i++){
		check1=0;check2=0;check3=0;
		if(a[i]==b[i])check1=1;
		if(b[i]==c[i])check2=1;
		if(c[i]==a[i])check3=1;
		if(check1+check2+check3 >= 2)count = count;
    if(check1+check2+check3 == 1) count++;
		if(check1+check2+check3 == 0) count+=2;
	}
	printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	std::vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << (a[2] - a[1]) + (a[1] - a[0]) << endl;

 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll A, B, C, K, S;

int main() {
	cin >> A >> B >> C >> K;
	
	if(K&1) {
		cout << (B-A) << endl;
	} else {
		cout << (A-B) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#ABC060C
N, T=map(int,input().split())
t=list(map(int,input().split()))
ans=0
for i in range(N):
    if i==0:
        ans+=T
    else:
        if t[i]-t[i-1]>=T:
            ans+=T
        else:
            ans+=t[i]-t[i-1]
print(ans)

Measured memory_bytes: 25200
#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i: a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sum(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

struct LIS {
private:
  vector<int> temp;

public:
  vector<int> dp;
  LIS(vector<int> &a) {
    temp = a;
    dp.assign(temp.size(), INF);
  }
  int lis() { //return length of LIS
    int ret = 0;
    rep(i, temp.size()) {
      int ind = distance(begin(dp), lower_bound(ALL(dp), temp[i]));
      dp[ind] = temp[i];
      ret     = max(ret, ind + 1);
    }
    return ret;
  }
  void restoration() { //make dp LIS
    while (dp[dp.size() - 1] == INF) dp.pop_back();
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  LIS lis(a);
  cout << lis.lis() << endl;
}


Measured memory_bytes: 5248
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    
    map<int, int> M;
    rep(i, N) {
        M[P[i] - 1] = i;
    }
    
    int cur = 0;
    int tmp = 1;
    rep(i, 1, N) {
        if(M[i] > M[i - 1]) tmp++;
        else {
            cur = max(cur, tmp);
            tmp = 1;
        }
    }
    cur = max(cur, tmp);
    output(N - cur);
    
    
    
    return 0;
}


Measured memory_bytes: 10368
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)
 
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound
 
#define ALL(V)  V.begin(),V.end()
 
#define MX1     100000LL
#define MX2     1000000LL
#define Inf     5000000000000000000LL
#define mod		1000000007LL
using namespace std;
 
lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
 
    lli N,K,i;
    cin>>N>>K;
 
    vlli V(N),V1(N);
 
    rep(i,0,N)
    {
        cin>>V[i]>>V1[i];
    }
 
    ulli Store=0,low=0,high=Inf;
 
    while(low <= high)
    {
        lli mid=(low+high)/2;
        lli Sum=0;
 
        //cout<<mid<<' ';
 
        rep(i,0,N)
        {
            lli x;
 
            if(mid<V[i])
            {
                x=0;
            }
            else
            {
                x=(mid-V[i])/(V1[i]);
 
                x++;
            }
 
            Sum+=x;
            if(Sum>=K) break;
        }
 
        if(Sum >= K)
        {
            high=mid-1;
            Store=mid;
        }
        else
        {
            low=mid+1;
        }
    }
 
    cout<<Store;
 
 
 
 
 return 0;
}

Measured memory_bytes: 1792
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n;
    
    cin >> n;
    
    for(int i=1; i<=9; i++)
    {
        if (n % i == 0 && n / i <= 9)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


int main(){
    int n,l;
    cin >> n >> l;
    int wa = 0;
    Reps(i,n){
        wa += l + i - 1;
    }
    int mi = Inf;
    int ans;
    Reps(i,n){
        if(mi > abs(wa-(wa-(l+i-1)))){
            mi = abs(wa-(wa-(l+i-1)));
            ans = wa-(l+i-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import bisect
#from math import factorial
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort()
max_a = max(a_ls)
a_ind = bisect.bisect_left(a_ls, max_a / 2)
print(max_a, a_ls[a_ind] if a_ls[a_ind] - max_a / 2 < max_a / 2 - a_ls[a_ind - 1] else a_ls[a_ind - 1])

Measured memory_bytes: 58864
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(c-a-b<=0){
        cout << "No" << endl;
        return 0;
    }
    if(4*a*b<(c-a-b)*(c-a-b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

signed main()
{
    string s[3];

    rep(i, 3) cin >> s[i];

    rep(i, 3) {
        cout << s[i][i];
    }

    cout << endl;
}


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

int main() {

	//入力
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	//処理
	int ans = 0;

	//今見ている山
	for (int i = 0; i < N; i++) {

		//自分より高い山があるかどうかのフラグ
		bool flag = true;

		//自分より西の山について調べる
		for (int j = 0; j < i; j++) {
			if (H[j] > H[i]) flag = false;
		}

		if (flag) ans++;


	}

	//出力
	cout << ans << endl;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
using tii = tuple<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
//#define INF (ll)1E9
#define INF INT_MAX
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

//constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	double n, m, k;
	cin >> n >> m >> k;
	double ans = ((n - k) * 2 / (n*n)*(m - 1));
	if (k == 0)ans /= 2;
	printf("%lf\n", ans);
}

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


main(){
	int j,m,n,k,i,u;
	int g[101][101];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	    for(j=1;j<=n;j++)
		   g[i][j]=0;
	}
	for(i=1;i<=n;i++){
		scanf("%d%d",&k,&u);
		for(j=0;j<u;j++){
			scanf("%d",&m);
			g[k][m]=1;
		}
	}
	for(i=1;i<=n;i++){
	    for(j=1;j<=n;j++){
		printf("%d",g[i][j]);
		if(j<n)
		printf(" ");}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 3240
def main():
  def cal(k):
    for a,b in AB:
      tmp = k-a
      if tmp<0:
        tmp = 0
      new = dp[tmp]+b
      if new<dp[k]:
        dp[k]=new
  H,N = map(int,input().split())
  AB = [list(map(int,input().split())) for _ in range(N)]
  mi_a,mi_b = min(AB,key = lambda x:x[1])
  INF = float('inf')
  dp = [0]+[mi_b]*mi_a+[INF]*H
  for i in range(mi_a+1,H+1):
    cal(i)

  print(dp[H])
main()

Measured memory_bytes: 3720
#include<stdio.h>
 
int main()
{
  int X, day;
 
  scanf( "%d", &X );
 
  if( 7 <= X ) day = X % 7;
  else day = X;
 
  switch( day ){
  case 1:
    printf( "fri" );
    break;
 
  case 2:
    printf( "sat" );
    break;
 
  case 3:
    printf( "sun" );
    break;
 
  case 4:
    printf( "mon" );
    break;
 
  case 5:
    printf( "tue" );
    break;
     
  case 6:
    printf( "wed" );
    break;
     
  case 0:
    printf( "thu" );
    break;
 
  }
 
  printf( "\n" );
 
  return 0;
 
}

Measured memory_bytes: 1852
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for3(n) for (int k = 0 ; k < n ; k++)
#define for4(n) for (int l = 0 ; l < n ; l++)

int main() {
    ios::sync_with_stdio(false);
    ll n, k, a, b;
    cin >> n >> k;
    a = n / k;
    b = (n + k / 2) / k; 
    if (k % 2) cout << a * a * a;
	else cout << a * a * a + b * b * b;                                                     
}
/*
*/

Measured memory_bytes: 3648
n,k=map(int,input().split())
win=0

for i in range(1,n+1):
    if i<=k-1:
        n1=i
        for j in range(1,k+1):
            n1=n1*2
            if n1<=k-1:
                continue
            else:
                win+=(1/n)*(1/2**j)
                break
    else:
        win+=1/n
        
print(win)

Measured memory_bytes: 3060
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def intread():
    return int(sysread())
def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())


def run():
    H, W = mapline()
    dic = [0] * 27
    for i in range(H):
        S = input()
        for s in S:
            dic[ord(s) - 96] += 1
    permited2 = 0
    permited1 = 0
    if H % 2 and W % 2:
        permited2 += H // 2 + W // 2
        permited1 += 1
    else:
        if H % 2:
            permited2 += W // 2
        elif W % 2:
            permited2 += H // 2
    permited4 = (H * W - permited2 * 2 - permited1) // 4
    for val in dic:
        done = True
        while val and done:
            done = False
            if val >= 4 and permited4:
                val -= 4
                permited4 -= 1
                done= True
            elif val >= 2 and permited2:
                val -= 2
                permited2 -= 1
                done = True
            elif val == 1 and permited1:
                val -= 1
                permited1 -= 1
                done = True
            if not done:
                print('No')
                return
    print('Yes')


if __name__ == "__main__":
    run()


Measured memory_bytes: 9332
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prl puts("\n------------------\n")
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prl 
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    string a, b;
    sf(a, b);
    int len = a.size();
    int cnt = 0;
    for (int i = 0; i < len; ++i) {
        if (a[i] == b[i]) ++cnt;
    }
    cout << cnt << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];
    vector<ll> B(n);
    rep(i, n) cin >> B[i];
    vector<ll> C(n);
    rep(i, n) cin >> C[i];
        
    sort(all(A));
    sort(all(B));
    sort(all(C));

    vector<int> Ia(n);
    vector<int> Ic(n);

    ll sum = 0;
    rep(i, B.size()) {
        ll b = B[i];
        // b以上Aのインデックスの最後
        Ia[i] = lower_bound(all(A), b) - A.begin();
        // bより大きいBのインデックスの最初
        Ic[i] = upper_bound(all(C), b) - C.begin();

        sum += Ia[i] * (n - Ic[i]);
    }

    put(sum);
    return 0;
}

Measured memory_bytes: 6428
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<usize>();
  let m = read::<usize>();
  let mut map: Vec<Vec<i64>> = vec![vec![0; n]; n];

  for _ in 0..m {
    let a = read::<usize>();
    let b = read::<usize>();
    map[a - 1][b - 1] += 1 as i64;
    map[b - 1][a - 1] += 1 as i64;
  }

  for i in map {
    println!("{}", i.iter().sum::<i64>());
    // println!();
  }
}



Measured memory_bytes: 4352