akhauriyash/Code-Regression huggingface dataset:
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
v.append(0)

# forward
now = 0
for i in range(n):
    if now + t[i] < v[i]:
        v[i] = now + t[i]

    if v[i] <= v[i+1]:
        now = v[i]
    elif t[i] + v[i+1] + now < 2 * v[i]:
        v[i] = (t[i] + v[i+1] + now) / 2
        now = v[i+1]
    else:
        now = v[i+1]

# back
now = 0
for i in range(n-1, -1, -1):
    if now + t[i] < v[i]:
        v[i] = now + t[i]

    if v[i] <= v[i-1]:
        now = v[i]
    elif t[i] + v[i-1] + now < 2 * v[i]:
        v[i] = (t[i] + v[i-1] + now) / 2
        now = v[i-1]
    else:
        now = v[i-1]

ans = 0
now = 0
for i in range(n):
    t1 = v[i] - now
    t3 = v[i] - v[i+1]
    t2 = t[i] - t1 - t3
    ans += now * t1 + t1 * t1 / 2
    now = v[i] # now += t1
    ans += now * t2
    # now = now
    ans += now * t3 - t3 * t3 / 2
    now -= t3

print(ans)

Measured memory_bytes: 62064
#include <bits/stdc++.h>
#define ll long long

using namespace std;

// input


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

    int a,b,c;
    cin >> a >> b >> c;

    if(a < b && b < c){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    
}


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

int main(){
	
	string s,t; cin>>s>>t; int co  = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]) co++;
	}
	cout<<co<<"\n";
	
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
int main(){

	for(int i=1;;i++){
	int x, y;
	cin>>x>>y;
	if(x > y) swap(x, y);
	if(x == 0 && y== 0) break;
	cout<<x<<" "<<y<<endl;\
	}

	return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int main(){
	string S;
	cin>>S;
	int K;
	cin>>K;
	if(S[0]!='1'){
		cout<<S[0]<<endl;
	}else{
		int now=0;
		while(now<S.size()&&S[now]=='1'){
			now++;
		}
		if(now==S.size()||now>=K){
			cout<<1<<endl;
		}else{
			cout<<S[now]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int n;
struct node{
	int x,y;
}a[10];
int num[10];
double dis(node &a,node &b)
{
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i].x>>a[i].y;
	for(int i=1;i<=n;i++)
	num[i]=i;
	double sum=0;
	do{
		for(int i=1;i<n;i++)
		{
			sum+=dis(a[num[i]],a[num[i+1]]);
		}
	}while(next_permutation(num+1,num+n+1));
	int tot=1;
	for(int i=1;i<=n;i++)
	tot*=i;
	sum=sum*1.0/tot;
	printf("%.7f\n",sum);
}

Measured memory_bytes: 256
K = input()

K_S =K.count("S")
K_N =K.count("N")
K_W =K.count("W")
K_E =K.count("E")

if ((K_S != 0) and (K_N == 0)) or \
((K_E != 0) and (K_W == 0)) or \
((K_N != 0) and (K_S == 0)) or \
((K_W != 0) and (K_E == 0)):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local ret = 1
for x = 1, 100 do
  local r = 0
  for i = 1, n do
    r = r + (t[i] - x) * (t[i] - x)
  end
  if x == 1 then ret = r
  else ret = math.min(ret, r)
  end
end
print(ret)


Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[70],cnt;
ll f[70][10][2];
ll dfs(int pos,int la,bool limit,bool pre) {
    if(pos==0) return pre?1:0;
    if(f[pos][la][pre]!=-1&&!limit) return f[pos][la][pre];
    int up=limit?a[pos]:9;
    ll ans=0;
    for(int i=0;i<=up;i++) {
        if(pre&&abs(i-la)>=2) continue;
        ans+=dfs(pos-1,i,i==up&&limit,pre|i);
    }
    if(!limit) f[pos][la][pre]=ans;
    return ans;
}
ll cal(ll x) {
    cnt=0;
    while(x)
        a[++cnt]=x%10,x/=10;
    ll ans=0;
    if(cnt>1) ans+=dfs(cnt-1,0,false,false);
    for(int i=1;i<=a[cnt];i++)
        ans+=dfs(cnt-1,i,i==a[cnt],true);
    return ans;
}
int main() {
    //freopen("in.txt","r",stdin);
    memset(f,-1,sizeof f);
    int x;
    scanf("%d",&x);
    ll L=1,R=3234566667,ans;
    while(L<=R) {
        ll mid=(L+R)>>1;
        if(cal(mid)>=x) ans=mid,R=mid-1;
        else L=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for(int a = 0; a <= A; a++){
    for(int b = 0; b <= B; b++){
      for(int c = 0; c <= C; c++){
        if(500*a+100*b+50*c == X){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	string s="";
	while(n){
		if(n%-2){
			s="1"+s;
			n--;
		}
		else
			s="0"+s;
		n/=-2;
	}
	if(s=="")
		s+='0';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int h[110];
    rep(i, n) cin >> h[i + 1];
    int ans = 0;
    h[0] = 0;
    rep(i, n) {
        ans += max(0, h[i + 1] - h[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
fn solve(n: i32, k: i32) -> i32 {
    (1..n).fold(k, |m, _| m * (k - 1))
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut iter = s.split_whitespace().map(|w| w.trim().parse().ok().unwrap());
    let n = iter.next().unwrap();
    let k = iter.next().unwrap();
    let ans = solve(n, k);
    println!("{}", ans);
}


Measured memory_bytes: 4352
//edpc_e.cpp
//Sat Jan 12 15:54:30 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll w[n+1];
	ll v[n+1];
	w[0] = 0; v[0] = 0;
	int vtotal = 0;
	for (int i=1;i<n+1;i++){
		cin >> w[i] >> v[i];
		vtotal += v[i];
	}

	ll dp[n+1][vtotal+1];
	fill(dp[0],dp[0]+vtotal+1,1000000000000);
	dp[0][0] = 0;
	for (int i=1;i<n+1;i++){
		for (int j=0;j<vtotal+1;j++){
			if (j>=v[i]){
				dp[i][j] = min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
			}else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}

	for (int i=vtotal;i>0;i--){
//		cout << dp[n][i] << " ";
		if (dp[n][i]<=W){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 79104
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 892
s=list(input())
n=len(s)
ans=[0 for _ in range(n)]
cnt=1
key=index=0
ans=[0 for _ in range(n)]
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    elif s[i]!=s[i+1] and key==0:
        ans[i]=cnt
        index=i+1
        key=1
        cnt=1
    elif s[i]!=s[i+1] and key==1:
        ans[index]=cnt
        cnt=1
        key=0
ans[index]=cnt
index=0
while index<n:
    if ans[index]==0:
        index+=1
    else:
        if (ans[index]+ans[index+1])%2==0:
            a=(ans[index]+ans[index+1])//2
            ans[index]=a
            ans[index+1]=a
        else:
            if max(ans[index],ans[index+1])%2==0:
                a=(ans[index]+ans[index+1]+1)//2
                b=a-1
                if ans[index]%2==0:
                    ans[index]=b
                    ans[index+1]=a
                else:
                    ans[index]=a
                    ans[index+1]=b
            else:
                a=(ans[index]+ans[index+1]+1)//2
                b=a-1
                if ans[index]%2==0:
                    ans[index]=b
                    ans[index+1]=a
                else:
                    ans[index]=a
                    ans[index+1]=b
        index+=2
for i in range(n):
    print(ans[i])

Measured memory_bytes: 55672
n,k=map(int,input().split())
ab=[[] for i in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  ab[a]+=[[b,a]]
  ab[b]+=[[a,b]]
x=k
c=[]+ab[1]
d=[0]*(n+1)
while c:
  y,z=c.pop()
  c+=[i for i in ab[y] if i[0]!=z]
  x=(x*max(0,k-1-d[z]))%(10**9+7)
  d[z]+=1
  d[y]=1
print(x)

Measured memory_bytes: 85280
#!/usr/bin/perl

$line = 0;
while (<>) {
    chomp;
    if($line == 0) {
        ($a, $b, $c, $d) = split /\s+/, $_;
    } else {
        @a = split /\s+/, $_;
    }
    $line++;
}

if($a < $c) {
    if($b < $d) {
        $dup = $b - $c;
    } else {
        $dup = $d - $c;
    }
} else {
    if($b < $d) {
        $dup = $b - $a;
    } else {
        $dup = $d - $a;
    }
}

if($dup > 0) {
    print "$dup\n"
} else {
    print "0\n"
}


Measured memory_bytes: 512
import sys

input = sys.stdin.readline

def main():
    tarou, hanako = 0,0
    n = int(input())
    for i in range(n):
        s = input().split()
        if s[0] == s[1]:
            tarou += 1
            hanako += 1
        elif s[0] < s[1]:
            hanako += 3
        elif s[0] > s[1]:
            tarou += 3
        
    print(tarou,hanako)
if __name__ == "__main__":
    main()


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

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int dp[N+1][N+1];
    memset(dp,0,sizeof(dp));
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(s[i]==s[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            ans=max(ans,min(j-i,dp[i+1][j+1]));
        }
    }
    /*
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << ans << endl;
}

Measured memory_bytes: 97920
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int preT = 0;
        int preX = 0;
        int preY = 0;

        for (int i=0; i < N; i++) {
            int postT = sc.nextInt();
            int postX = sc.nextInt();
            int postY = sc.nextInt();

            int dt = postT - preT;
            int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
            if ((dt < dist) || (dist - dt) % 2 != 0) {
                System.out.print("No");
                return;
            }

            preT = postT;
            preX = postX;
            preY = postY;
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 86720
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const ll INF = 1ll<<50;
 
// セグメント木(RMQ 対応)
// update: k 番目の値を a に変更
// query: [l, r) の区間の最大値を求める
template<typename T>
struct ST {
    vector<T> seg;
    int size;
    ST(int n) {
        size = 1;
        while (size < n) size *= 2;
        seg.resize(2*size-1, INF);
    }
    inline T merge(T x, T y) {
        return min(x, y);
    }
    void update(int k, T a) {
        k += size-1;
        seg[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            seg[k] = merge(seg[k*2+1], seg[k*2+2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return seg[k];
        T vl = query(a, b, k*2+1, l, (l+r)/2);
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return merge(vl, vr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, size);
    }
};
 
const int MAXN = 100100;
int N, E, T;
int X[MAXN];
ll dp[MAXN];
 
int main() {
	cin >> N >> E >> T;
	for (int i = 0; i < N; i++)
		cin >> X[i];
	const ll INF = 1ll<<60;
	ST<ll> seg(N+10);
	for (int i = 0; i <= N; i++) {
		dp[i] = INF;
	}
	X[N] = E;
	dp[N] = 0;
	seg.update(N, dp[N] + X[N] + 2*X[N-1]);
	for (int i = N-1; i >= 0; i--) {
		// まず T が支配的な部分を探索
		int low = i, high = N;
		while (high - low > 1) {
			const int med = (low + high) / 2;
			if (2*(X[med]-X[i]) <= T) {
				low = med;
			} else {
				high = med;
			}
		}
		//cout << i << " " << low << endl;
		dp[i] = dp[low+1] + X[low+1] - X[i] + T;
		dp[i] = min(dp[i], seg.query(low+1, N) - 3ll*X[i]);
		if (i) seg.update(i, dp[i+1] + 2*X[i] + X[i+1]);
		//cout << i << " " << dp[i] << endl;
	}
	cout << X[0] + dp[0] << endl;
	return 0;
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PI;
typedef long long LL;
vector<P> G[100];
int dist[100][1001];
int main() {
	int N, M, C;
	while (cin >> N >> M >> C, N) {
		for (int i = 0; i < N; i++) G[i].clear();
		for (int i = 0; i < M; i++) {
			int f, t, c;
			cin >> f >> t >> c;
			f--; t--;
			G[f].emplace_back(t, c);
		}
		priority_queue<PI, vector<PI>, greater<PI>> Q;
		fill((int*)dist, (int*)(dist + N), 1 << 30);
		dist[0][0] = 0;
		Q.push(PI(0, P(0, 0)));
		while (!Q.empty()) {
			PI p = Q.top(); Q.pop();
			if (dist[p.second.first][p.second.second] < p.first) continue;
			for (P e : G[p.second.first]) {
				int cost = p.first + e.second;
				if (dist[e.first][p.second.second] > cost) {
					dist[e.first][p.second.second] = cost;
					Q.push(PI(cost, P(e.first, p.second.second)));
				}
				if (p.second.second + 1 <= M && dist[e.first][p.second.second + 1] > p.first) {
					dist[e.first][p.second.second + 1] = p.first;
					Q.push(PI(p.first, P(e.first, p.second.second + 1)));
				}
			}
		}
		for (int i = 0; i <= M; i++) {
			if (dist[N - 1][i] <= C) {
				cout << i << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 5816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (10010)
struct data{
	int x,y;
};
int	n,k,cnt,dp[110][64000],sum[64000],sz[64000];
vector<data>q;

int main(){
	scanf("%d%d",&n,&k);
	int x=1;
	while (x<=n){
		int t=n/x;
		int y=n/t;
		q.push_back({x,y});
		sz[++cnt]=y-x+1;
		x=y+1;
	}
	int all=q.size();
	for (int j=1;j<=all;j++) dp[1][j]=sz[j];
	for (int i=2;i<=k;i++){
		for (int j=1;j<=all;j++) sum[j]=(sum[j-1]+dp[i-1][j])%M;
		for (int j=1;j<=all;j++) dp[i][j]=1ll*sum[all-j+1]*sz[j]%M;
	}
	ll ans=0;
	for (int i=1;i<=all;i++) ans=(ans+dp[k][i])%M;
	printf("%lld",ans);
	
}


Measured memory_bytes: 27256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    sort(a.begin(), a.end());
    while(1){
        ll min_div = a[0];
        for(int i=1; i<n; i++){
            if (a[i] % a[0] != 0)   a[i] %= a[0];
        }
        sort(a.begin(), a.end());
        if (a[0] == 1 || min_div <= a[0]) break;
    }
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>

int n, a[100055], b[100055], ans;
vector<int> spares;
long long needSum;

int main() {
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", b + i);
	}
	
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i]) {
			ans++;
			needSum += a[i] - b[i];
		} else {
			spares.push_back(b[i] - a[i]);
		}
	}
	
	sort(spares.begin(), spares.end(), [](const int& u, const int& v) {
		return u > v;
	});
	
	for (int& ele : spares) {
		if (needSum <= 0)
			break;
		
		needSum -= ele;
		ans++;
	}
	
	if (needSum > 0) {
		printf("-1\n");
	} else {
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
bool isPerfectSquare(ll n) 
{ 
    for (ll sum = 0, i = 1; sum < n; i += 2) { 
        sum += i; 
        if (sum == n) 
            return true; 
    } 
    return false; 
} 
using namespace std;
int main()
{
 	speed_up
    ll n,d;cin>>n>>d;
    ll a[n][d],ct=0;
    rep(i,0,n)
    {
    	rep(j,0,d)
    	cin>>a[i][j];
	}
	rep(i,0,n-1)
	{
		rep(j,i+1,n)
		{
			ll ds=0;
			rep(k,0,d)
			{
			  ds+=abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
			}
		//cout<<ds<<endl;
			if(isPerfectSquare(ds)) ct++;
		}
	}
	cout<<ct;
	
	
 return 0;
}

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

int main()
{
	string s, t;
	getline(cin, s);
	getline(cin, t);
	
	int n = s.size();
	
	for (int i = 0; i < n; i++)
	{
		bool check = true;
		for (int k = i; k < n; k++)
		{
			check &= (s[k] == t[k - i]);
		}
		for (int m = 0; m < i; m++)
		{
			int inc = n - i;
			check &= (s[m] == t[m + inc]);
		}
		if(check)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int ok[N],comp,sz,ans[N];
vector<int>g[N];
void dfs(int x,int comp){
    sz++;
    ok[x]=comp;
    for(int u:g[x]) if(!ok[u]) dfs(u,comp);
}
signed main(){
    FastIO;
    int n;
    cin>>n;
    vector<vector<int>>v;
    rep(i,1,n){
        int a,b;
        cin>>a>>b;
        v.pb({a,b,i});
    }
    sort(all(v));
    set<pii>s;
    s.insert({1e9,0});
    rep(i,0,v.size()-1){
        pii p=*s.begin();
        int f=0;
        while(s.begin()->F<v[i][1]){
            f=1;
            g[v[i][2]].pb(s.begin()->S);
            g[s.begin()->S].pb(v[i][2]);
            s.erase(s.begin());
        }
        if(f) s.insert(p);
        else s.insert({v[i][1],v[i][2]});
    }
    rep(i,1,n) if(!ok[i]){
        sz=0;
        comp++;
        dfs(i,comp);
        ans[comp]=sz;
    }
    rep(i,1,n) cout<<ans[ok[i]]<<'\n';
    return 0;
}


Measured memory_bytes: 26904
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	vector<int> a(s.size() + 1);
	vector<int> b(t.size() + 1);
	for (int i = 0; i < s.size(); i++) {
		a[i + 1] = a[i] + (s[i] == 'A');
	}
	for (int i = 0; i < t.size(); i++) {
		b[i + 1] = b[i] + (t[i] == 'A');
	}
	int q;
	cin >> q;
	while (q--) {
		int l, r, ll, rr;
		cin >> l >> r >> ll >> rr;
		l--;
		ll--;
		int x = (a[r] - a[l] - (r - l) + (a[r] - a[l]) + 3 * 1000000) % 3;
		int y = (b[rr] - b[ll] - (rr - ll) + (b[rr] - b[ll]) + 3 * 1000000) % 3;
		if (x == y) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_T 50
#define WIDTH 7125
pair<int, vector<vector<int>>> E[MAX_T][WIDTH], D[WIDTH];
vector<vector<int>>X;
int hantei(vector<vector<int>>a) {
	int sum = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			int Num = (a[i][j] + 15) % 16; if (a[i][j] == 0)continue;
			sum += abs(i - (Num / 4)) + abs(j - (Num % 4));
		}
	}
	return sum;
}
int main() {
	for (int i = 0; i < 4; i++) {
		vector<int>FF; for (int j = 0; j < 4; j++) { int p; cin >> p; FF.push_back(p); }
		X.push_back(FF);
	}
	E[0][0] = make_pair(hantei(X), X);
	for (int i = 0; i < MAX_T; i++) {
		int CNT = 0;
		if (E[i][0].first == 0) { cout << i << endl; break; }
		for (int j = 0; j < WIDTH; j++) {
			if (E[i][j].second.size() == 0)break;
			int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
			vector<vector<int>>H = E[i][j].second; int I = E[i][j].first;
			int C = 0;
			for (int k = 0; k < 16; k++) {
				if (H[k / 4][k % 4] == 0) {
					C = k;
				}
			}
			for (int k = 0; k < 4; k++) {
				vector<vector<int>>J = H;
				int Ex = (C / 4) + dx[k], Ey = (C % 4) + dy[k];
				if (Ex < 0 || Ex > 3 || Ey < 0 || Ey > 3)continue;
				swap(J[C / 4][C % 4], J[Ex][Ey]);
				D[CNT] = make_pair(hantei(J), J); CNT++;
			}
		}
		sort(D, D + CNT); E[i + 1][0] = D[0]; int cnt2 = 1;
		for (int k = 1; k < CNT; k++) {
			if (D[k - 1] == D[k])continue;
			E[i + 1][cnt2] = D[k]; cnt2++;
		}
	}
	return 0;
}

Measured memory_bytes: 80756
#include <stdio.h>
int main(){
    int n,a,b;
    scanf("%d",&n);
    if(n == 1){
        printf("Hello World\n");
    }
    if(n == 2){
        scanf("%d\n%d",&a,&b);
        printf("%d\n",a+b);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
vector<int> v[30];
int main()
{
    string s, t;
    cin >> s >> t;
    rep(i, s.length())
    {
        v[s[i] - 'a'].push_back(i + 1);
        v[s[i] - 'a'].push_back(i + 1 + s.length());
    }
    rep(i, 30)
    {
        sort(v[i].begin(), v[i].end());
    }
    ll ans = 0;
    int id = 0;
    rep(j, t.length())
    {
        if (v[t[j] - 'a'].empty())
        {
            cout << -1 << endl;
            return 0;
        }
        int next = *upper_bound(v[t[j] - 'a'].begin(), v[t[j] - 'a'].end(), id);
        ans += next - id;
        id = next % s.length();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1724
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

ll n,t;

int main(){
	cin>>n>>t;
	ll now=0,res=0;
	for(int i=0;i<n;i++){
		ll A;
		cin>>A;
		if(A<=now){
			res+=A+t-now;
			now=A+t;
		}
		else{
			res+=t;
			now=A+t;
		}
	}
	cout<<res<<endl;
}

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

void main() {
    auto N = readln.chomp.to!int;
    auto A = iota(N).map!(_ => readln.split.map!(to!long).array).array;

    real angle(const long[] a) {
        if (a[0] == 0 && a[1] == 0) return 0;
        return (a[1] < 0 ? -1 : 1) * acos(1.0L * a[0] / sqrt(1.0L * a[0]^^2 + a[1]^^2));
    }

    long ans = 0;
    A.sort!((a,b)=>angle(a)<angle(b));

    foreach (len; 1..N+1) foreach (i; 0..N) {
        long x = 0;
        long y = 0;
        foreach (j; i..i+len) {
            int idx = j % N;
            x += A[idx][0];
            y += A[idx][1];
        }
        ans = max(ans, x*x+y*y);
    }

    writefln("%.15f", sqrt(1.0L*ans));
}



Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<Long, Long> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(sc.next());
            long b = Long.parseLong(sc.next());
            map.merge(b, a, Long::sum);
        }
        long sum = 0;
        for (Map.Entry<Long, Long> e : map.entrySet()) {
            sum += e.getValue();
            if (sum > e.getKey()) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 91356
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N, Q;
	scanf("%d %d", &N, &Q);

	struct rw { 
		int s, t, x; 
		rw(int s = 0, int t = 0, int x = 0) :s(s), t(t), x(x) {}
	};
	vector<rw> RW(N);
	for (int i = 0; i < N; i++) {
		int s, t, x;
		scanf("%d %d %d", &s, &t, &x);
		RW[i] = { s, t, x };
	}
	sort(RW.begin(), RW.end(), [](auto &l, auto &r) { return (l.s - l.x) < (r.s - r.x); });

	int idx = 0;
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
	for (int i = 0; i < Q; i++) {

		int d;
		scanf("%d", &d);

		while (idx < N && RW[idx].s - RW[idx].x <= d) {
			pq.emplace(RW[idx].x, RW[idx].t - RW[idx].x);
			idx++;
		}
		while (!pq.empty() && pq.top().second <= d) pq.pop();

		printf("%d\n", (pq.empty() ? -1 : pq.top().first));

	}

	return 0;
}


Measured memory_bytes: 5360
s = input()
if len(s) == 1:
    print(s)
else:
    t = set(s)
    if len(t) == 1 and "9" in t:
        print(len(s) * 9)
    elif len(t) == 2 and "9" in t and "0" not in t:
        if s[0] != "9":
            k = sorted(list(t))
            print((len(s) - 1) * 9 + int(k[0]))
        else:
            print((len(s) - 1) * 9 + 8)
    else:
        print(int(s[0]) + (len(s) - 1) * 9 - 1)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        ans += i

    print(ans)




if __name__ == '__main__':
    main()



Measured memory_bytes: 9168
#include<cstdio>
#include<queue>
#include<map>
#include<algorithm>

using namespace std;

int N,k;

long long encode(vector<int> a){
	long long res=0;
	long long coe=1;
	for(int i=0;i<N;i++){
		res+=coe*a[i];
		coe*=10;
	}
	return res;
}

vector<int> decode(long long x){
	vector<int> res;
	for(int i=0;i<N;i++){
		res.push_back(x%10);
		x/=10;
	}
	return res;
}

map<long long,int> dis[2];

void bfs(long long s,int id){
	map<long long,int> &res=dis[id];
	queue<long long> que;
	que.push(s);
	res[s]=0;
	while(!que.empty()){
		long long cur=que.front();
		que.pop();
		int d=res[cur];
		if(d>=k) continue;
		vector<int> a=decode(cur);
		for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
			int tmp[10];
			for(int k=i;k<=j;k++) tmp[k]=a[k];
			for(int k=i;k<=j;k++) a[k]=tmp[i+j-k];
			long long nxt=encode(a);
			if(res.count(nxt)>0&&res[nxt]<=d+1){}
			else{
				que.push(nxt);
				res[nxt]=d+1;
			}
			for(int k=i;k<=j;k++) a[k]=tmp[k];
		}
	}
}

int main(){
	scanf("%d",&N);
	k=(N-1)/2;
	vector<int> s,t;
	for(int i=0;i<N;i++){
		s.push_back(i);
		int in;
		scanf("%d",&in);
		t.push_back(in-1);
	}
	long long s_=encode(s);
	long long t_=encode(t);
	bfs(s_,0);
	bfs(t_,1);
	int ans=N-1;
	map<long long,int>::iterator it1=dis[0].begin(),it2=dis[1].begin();
	for(;;){
		if(it1==dis[0].end()||it2==dis[1].end()) break;
		if(it1->first==it2->first){
			ans=min(ans,it1->second+it2->second);
			it1++;it2++;
		}else if(it1->first<it2->first) it1++;
		else it2++;
	}
	printf("%d\n",ans);
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    LL N, K;
    cin >> N >> K;
    vector<vector<LL>> s(N);

    REP0 (i, N)
    {
        LL t, d;
        cin >> t >> d;
        --t;
        s[t].push_back(d);
    }

    for (auto &v : s)
    {
        sort(v.begin(), v.end(), [](LL a, LL b) { return a > b; });
        if (v.empty())  // 番兵により、操作上 N 種類選べるようにしておく
            v.push_back(-INTINF);
    }

    sort(s.begin(), s.end(), [&](vector<LL> a, vector<LL> b) { return a[0] > b[0]; });

    LL cur = 0;
    priority_queue<LL> PQ;  // 選ばれていない集合
    // まず K 種類選ぶ場合
    REP0 (i, K)
    {
        cur += s[i][0];
        for (int j = 1; j < s[i].size(); j++)
        {  // K種類選ぶとき、2つめ以降の要素は選ばれない
            PQ.push(s[i][j]);
        }
    }

    FOR (i, K, N)
        REP0 (j, s[i].size())
            PQ.push(s[i][j]);

    LL res = cur + K * K;
    // K-1種類以上 ~ 1種類以上までみていく
    for (LL x = K - 1; x >= 1; x--)
    {
        LL v = s[x][0];
        LL w = PQ.top();
        if (v < w)
        {
            PQ.pop();
            cur += w;
            PQ.push(v);
            cur -= v;
        }
        res = max(res, cur + x * x);
    }
    cout << res << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<s.size()/2;++i)
    {
        if(s[i]!=s[s.size()-i-1]) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{


string s;
    set<char>st;
    int i, j;
    cin>>s;
for(i=0;i<s.size();i++)
    {
   st.insert(s[i]);
    }
    if(st.size()==2)cout<<"Yes\n";
   else cout<<"No\n";
    }

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

int main(){
    int N,L;
    cin>>N>>L;
    vector<string> S(N);
    for(int i = 0;i<N;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    string Smin = "";
    for(int i=0;i<N;i++){
        Smin = Smin + S[i];
    }
    cout<<Smin<<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define N 1001
char c[N];
int X0, Y0, X1, Y1;
int main() {
    scanf("%s", c);
    int n = strlen(c);
    for (int i = 0; i < n; i++)
        (c[i] == 'N' ? X0 : c[i] == 'W' ? Y0 : c[i] == 'S' ? X1 : Y1) = 1;
    puts(((X0 ^ X1) || (Y0 ^ Y1)) ? "No" : "Yes");
    return 0;
}

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

int main(){
  int score = 0;
  string S1;
  string S2;
  cin >> S1 >> S2;
  
  for (int i = 0; i < S1.length(); i++){
    if (S1[i] != S2[i]) score++;
  }
  
  cout << score;
  return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		sc.close();

		int ok = 0;
		int ng = 0;
		for ( int i = 0 ; i < N - 1 ; i++ ) {
			if ( S.charAt(i) == S.charAt(i + 1) ) {
				ok += 1;
			} else {
				ng += 1;
			}
		}
		if ( ng <= 2 * K ) {
			System.out.println( ok + ng );
		} else {
			System.out.println( ok + 2 * K);
		}
	}
}


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


class Radix {
    private:
    const char* s;
    int a[128];
    public:
    Radix(const char* s = "0123456789ABCDEF") : s(s) {
        int i;
        for(i = 0; s[i]; ++i)
        a[(int)s[i]] = i;
    }
    string to(long long p, int q) {
        int i;
        if(!p)
        return "0";
        char t[64] = { };
        for(i = 62; p; --i) {
        t[i] = s[p % q];
        p /= q;
        }
        return string(t + i + 1);
    }
    string to(const string& t, int p, int q) {
        return to(to(t, p), q);
    }
    long long to(const string& t, int p) {
        int i;
        long long sm = a[(int)t[0]];
        for(i = 1; i < (int)t.length(); ++i)
        sm = sm * p + a[(int)t[i]];
        return sm;
  }
};

int main(){
    Radix r;
    int n, k;
    cin >> n >> k;
    cout << r.to(n, k).size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s[]={"Sunny","Cloudy","Rainy","Sunny"};
    string str;
    cin>>str;
    int i;
    for(i=0;i<4;i++) {
        if(s[i]==str) {
            break;
        }
    }
    cout<<s[i+1]<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include"iostream"
using namespace std;
int main()
{
	int n;
	cin >> n;
	int* num = new int[n];
	int i,j;
	for (i = 0; i < n; ++i)
		cin >> num[i];
	int sub=-2000000000;
	int min = num[0];
	for (i = 1; i < n; ++i)
	{
		sub = num[i] - min > sub ? num[i] - min : sub;
		min = num[i] < min ? num[i] : min;
	}
	delete[]num;
	cout << sub << endl;
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  int x,cnt=0;
  for(int i=1;i<=n;i++){
  	cin>>x;
    if(i%2==1 && x%2==1) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include<map>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    vector<int> B;


    for (int i = 0; i < N - 1; i++) {
        B.push_back(A[i + 1] - A[i]);
    }
    B.push_back(K - A[N - 1] + A[0]);


    int minValue = 100000000;

    for (int i = 0; i < N; i++) {
        if (i == 0) {
            minValue = K - max(B[0], B[N - 1]);
        }else {
            minValue = min(minValue, K - max(B[i], B[i-1]));
        }
       
    }
    cout << minValue << endl;

    return 0;
}



Measured memory_bytes: 2548
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

ll MI = LLONG_MIN / 3, dp[11][1003];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int D, G;
    cin >> D >> G;
    rep(i, D + 1)rep(j, 1003)dp[i][j] = MI;
    dp[0][0] = 0;

    rep(i, D) {
        ll p, c;
        cin >> p >> c;
        for (int j = 0; j < 1003; ++j) if (dp[i][j] >= 0) {
            for (int k = 0; k <= (int)p && j + k < 1003; ++k) {
                ll x = dp[i][j] + (i + 1ll)*100*k;
                if (k == p) {
                    x += c;
                }
                smax(dp[i + 1][j + k], x);
            }
        }
    }

    rep(i, 1003)if (dp[D][i] >= G) {
        cout << i << endl;
        break;
    }
}

Measured memory_bytes: 384
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    ans = {
        'SUN': 7,
        'MON': 6,
        'TUE': 5,
        'WED': 4,
        'THU': 3,
        'FRI': 2,
        'SAT': 1,
    }
    s = input()
    print(ans[s])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

         int n;
         cin>>n;
         string s;
        
         int a=0;
         int b=0;
         int c=0;
         int d=0;
         for(int i=0;i<n;i++)
         {
         	cin>>s;
         	if(s=="AC")
         	a++;
         	if(s=="WA")
         	b++;
         	if(s=="TLE")
         	c++;
         	if(s=="RE")
         	d++;
		 }
		 cout<<"AC"<<" "<<"x"<<" "<<a<<endl;   
		 cout<<"WA"<<" "<<"x"<<" "<<b<<endl; 
		 cout<<"TLE"<<" "<<"x"<<" "<<c<<endl; 
		 cout<<"RE"<<" "<<"x"<<" "<<d<<endl;       
		
		   
}

			
			
   

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

int main() {
  int h,w,k;cin>>h>>w>>k;
  string s[h];rep(i,h)cin>>s[i];
  
  int ans = 0;
  rep(b, pow(2, h+w)) {
    int sum = 0;
    rep(i, h) rep(j, w) {
      if ( (b & (1<<i)) && (b & (1<<h+j)) && (s[i][j]=='#') ) {
        sum++;
      }
    }
    if (sum == k) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 4092
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let A = parseInt(input[0][0], 10);
    let B = parseInt(input[0][1], 10);

    console.log(A * B - A - B + 1);
}



Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29520
n = int(input())
count = 0
lis = []
for i in range(n):
    lis.append(list(map(int, input().split())))

for i in range(n):
    if lis[i][0] == lis[i][1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        break
if count >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9160
'use strict'
function main(inp) {
  inp = inp.trim()

  const MOD = 1000000007
  let dp = [new Array(13).fill(0)]
  dp[0][0] = 1
  
  for (let i = 0; i < inp.length; i++) {
    dp[i + 1] = new Array(13).fill(0)
    const c = inp[i] === '?' ? -1 : inp[i] - 0
    for (let j = 0; j < 10; j++) {
      if (c !== -1 && c !== j) continue
      for (let k = 0; k < 13; k++) {
        dp[i+1][(k * 10 + j) % 13] += dp[i][k]
      }
    }
    for (let j = 0; j < 13; j++) {
      dp[i+1][j] %= MOD
    }
  }
  console.log(dp[inp.length][5])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 55088
#include<cstdio>
using namespace std;
long long gcd(long long x,long long y){
	long long r;
	while(y)
		r=x%y,x=y,y=r;
	return x;
}
long long solve(long long n,long long s,long long t){
	long long fm=n*s*t;
	long long fz1=t*n,fz2=s*n;
	long long fz3=t*s*4;
	if(fz3<=fz1+fz2) return -1;
	fz3-=fz1+fz2;
	long long d=gcd(fm,fz3);
	fz3/=d;
	fm/=d;
	if(fz3==1) return fm;
	return -1;
}
int main(){
	long long n;
	scanf("%lld",&n);
	long long st;
	for(int i=1;i<=3500;i++)
	{
		for(int j=1;j<=3500;j++){
			st=solve(n,i,j);
			if(st!=-1){
				printf("%lld %d %d\n",st,i,j);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
N=int(input())

naiv=0
endsA=0
startsB=0
both=0

for i in range(N):
    s=input()
    naiv+=s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        both += 1
    elif s[0] == 'B':
        startsB += 1
    elif s[-1] == 'A':
        endsA += 1

# print("endsA {}".format(endsA))
# print("startsB {}".format(startsB))
# print("both {}".format(both))
# print("naiv {}".format(naiv))

res=naiv
if both >= startsB and both >= endsA and (endsA > 0 and startsB > 0):
    lower = min(endsA, startsB)
    higher = max(endsA, startsB)
    res += lower*2
    both -= lower
    startsB -= lower
    endsA -= lower
    res += both
    both = 0
elif both <= startsB and both <= endsA:
    res += both*2
    endsA -= both
    startsB -= both
    both = 0
    res += min(endsA, startsB)
# まんなか
elif both > 0 and max(endsA, startsB) > 0:
    lower = min(endsA, startsB)
    res += 2*lower
    both -= lower
    endsA -= lower
    startsB -= lower
    res += both
elif both > 0 and max(endsA, startsB) == 0:
    res += both-1
else:
    res += min(endsA, startsB)

print(res)


Measured memory_bytes: 44008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) {}
#endif

ll bs[51]; // size
ll bp[51]; // num of p

ll f( ll n, ll x ){
	if ( x >= bs[n] )
		return bp[n];
	if ( x <= 0 ) return 0;
	
	ll count = 0;
	x--;
	count += f( n-1, x ); x -= bs[n-1];
	if ( x > 0 ) count++;
	x--;
	count += f( n-1, x ); x -= bs[n-1];
	x--;
	return count;
}



int main(){
	ll n, x;
	cin >> n >> x;
	
	ll s = 1;
	ll p = 1;
	rep(i,51){
		bs[i] = s;
		bp[i] = p;
		s = 3 + s*2;
		p = 1 + p*2;
		eprintf( "%d %lld %lld\n", i, bs[i], bp[i] );
	}
	
	cout << f(n,x) << endl;
	
	return 0;
}




Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)
#define COUT(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<p.first<<" "<<p.second;
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================
// Template End =========================

constexpr int MOD=1e9+7;
locale LOCATE=locale::classic();

int main(void){
  string s; cin>>s;
  map<char,int> mp;
  rep(i,s.size()) ++mp[s[i]];
  bool able=true;
  ran(i,mp) able&=(i.second%2==0);
  Yn(able);
}











Measured memory_bytes: 256
n, seq = [int(x) for x in input().split()]
L = []
for i in range(n):
    L.append([])

for i in range(seq):
    c, t, x = [ int(x) for  x in (input() + " 0").split()][:3]
    if c == 0:
        L[t].append(x)
    elif c == 1:
        print( " ".join(map(str,L[t])) )
    elif c == 2:
        L[t].clear()
    else:
        pass





Measured memory_bytes: 60540
n,m=map(int,input().split(" "))
a = [0]*(m+1)
c = 0
for i in range(n):
  s = list(map(int, input().split(" ")))
  for j in range(1,s[0]+1):
    if j != 0:
      a[s[j]] += 1
      if a[s[j]] == n:
        c+=1
print(c)    

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

using namespace std;


int main(){
  string S;
  cin >> S;
  if(S=="SUN") cout << 7 << endl;
  else if(S=="SAT") cout << 1 << endl;
  else if(S=="FRI") cout << 2 << endl;
  else if(S=="THU") cout << 3 << endl;
  else if(S=="WED") cout << 4 << endl;
  else if(S=="TUE") cout << 5 << endl;
  else if(S=="MON") cout << 6 << endl;


  return 0;
}

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

namespace ConsoleApp111 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            string replacedString = S.Replace("dream", "A").Replace("erase", "B");

            //Console.WriteLine(replacedString);

            string C = "Aer";
            string D = "Br";

            string replacedString_2 = replacedString.Replace(C, "C").Replace(D, "D");

            //Console.WriteLine(replacedString_2);


            if (replacedString_2.ToCharArray().ToList().Except(new List<char> { 'A', 'B', 'C', 'D'}).Count() == 0) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }

        }
    }
}


Measured memory_bytes: 14432