akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000000000000
#define MOD 1000000007

ll M;
map<int,map<int,ll>> m;
vector<ll> ans;

ll solve(Graph &G,int v,int p){
  ll ret=1;
  bool flag=false;
  for(auto nv:G.at(v)){
    if(nv==p){
      continue;
    }
    flag=true;
    ret*=(solve(G,nv,v)+1);
    ret%=M;
  }
  if(flag){
    return m[p][v]=ret;
  }else{
    return m[p][v]=1;
  }
}

void dfs(Graph &G,int v,int p){
  int n=G.at(v).size();
  vector<ll> left(n,1),right(n,1);
  for(int i=1;i<n;i++){
    left.at(i)=left.at(i-1)*(m[v][G.at(v).at(i-1)]+1)%M;
  }
  for(int i=n-2;i>=0;i--){
    right.at(i)=right.at(i+1)*(m[v][G.at(v).at(i+1)]+1)%M;
  }
  for(int i=0;i<n;i++){
    if(G.at(v).at(i)==p){
      continue;
    }
    m[G.at(v).at(i)][v]=(left.at(i)*right.at(i))%M;
  }
  for(int i=0;i<n;i++){
    if(G.at(v).at(i)==p){
      continue;
    }
    dfs(G,G.at(v).at(i),v);
  }
}

int main(){
  int N;
  cin>>N>>M;
  Graph G(N);
  for(int i=0;i<N-1;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.at(x).push_back(y);
    G.at(y).push_back(x);
  }

  ans.resize(N);
  ans.at(0)=solve(G,0,-1);
  dfs(G,0,-1);

  cout<<ans.at(0)<<endl;
  for(int i=1;i<N;i++){
    ans.at(i)=1;
    for(auto nv:m[i]){
      ans.at(i)*=nv.second+1;
      ans.at(i)%=M;
    }
    cout<<ans.at(i)<<endl;
  }
}


Measured memory_bytes: 51584
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>

using namespace std;

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

    vector<vector<int32_t>> A(n+1);

    for (int32_t i = 0; i < n; i++) {
        int32_t u, k;
        cin >> u >> k;

        for (int32_t j = 0; j < k; j++) {
            int32_t v;
            cin >> v;

            A[u].push_back(v);
        }
    }

    vector<bool> visited(n+1);
    fill(visited.begin(), visited.end(), false);
    vector<int32_t> d(n+1);
    fill(d.begin(), d.end(), -1);
    queue<int32_t> tovisit;
    visited[1] = true;
    d[1] = 0;
    tovisit.push(1);

    while (!tovisit.empty()) {
        int32_t u = tovisit.front();
        tovisit.pop();

        for (int32_t v : A[u]) {
            if (!visited[v]) {
                visited[v] = true;
                d[v] = d[u] + 1;
                tovisit.push(v);
            }
        }
    }

    for (int32_t i = 1; i <= n; i++) {
        cout << i << " " << d[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3128
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        String[] ss = {A, B, C};

        int ans = 0;
        for(int i = 0; i < N; i++) {
            HashMap<Character, Integer> counts = new HashMap<>();
            for(int k = 0; k < ss.length; k++) {
                char c = ss[k].charAt(i);
                counts.put(c, counts.getOrDefault(c, 0) + 1);
            }
            int maxNum = Collections.max(counts.values());
            ans += (ss.length - maxNum);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
	const int DAT_LIMIT = 200;
	int a,b;
	int cnt = 0;
	while(cin >> a >> b && cnt < DAT_LIMIT) {
		int c = a+b;
		int digit = 1;
		while(c / 10 != 0) {
			digit++;
			c = c / 10;
		}
		cout << digit << endl;
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;  // Be careful not to overflow
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  lint a, b, c, d;
  cin >> a >> b >> c >> d;

  lint ans = b - a + 1;
  ans -= b / c - (a - 1) / c;
  ans -= b / d - (a - 1) / d;

  lint l = lcm(c, d);

  ans += b / l - (a - 1) / l;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 10000
#define true 1
#define false 0

int main()
{
  int i,n,k;
  int j=0;
  int array[N];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&array[i]);
  }

  for(i = 0 ; i < n ; i++){
  k = isprime(array[i]); 
  if(k == 1) j++;
  }

  printf("%d\n",j);

  return 0;
}

  int isprime(int x)
  {
    int i = 3;

    if(x == 2) return true;
    
    if(x < 2 || x % 2 == 0) return false;

    while(i*i <= x){
      if(x % i == 0) return false;
      i+=2;
    }

    return true;
  }

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

int main()
{
  int q;
  cin >> q;
  int i, j;
  vector<int> l(q);
  vector<int> r(q);
  for(i = 0; i < q; i++)
  {
    cin >> l.at(i) >> r.at(i);
  }
  vector<bool> prime(100001, true);
  prime.at(0) = false;
  prime.at(1) = false;
  for(i = 2; i <= sqrt(100000); i++)
  {
    if(prime.at(i))
    {
      for(j = 2; j*i<=100000; j++)
      {
        prime.at(i*j) = false;
      }
    }
  }
  vector<bool> likenum(100001,false);
  for(i = 1; i <= 100000; i += 2)
  {
    if(prime.at(i) && prime.at((i+1)/2))likenum.at(i) = true;
  }
  vector<int> sumprime(100001,0);
  for(i = 2; i <= 100000; i++)
  {
    if(likenum.at(i))sumprime.at(i)=sumprime.at(i-1)+1;
    else sumprime.at(i) = sumprime.at(i-1);
  }
  for(i = 0; i < q; i++)
  {
    cout << sumprime.at(r.at(i))-sumprime.at(l.at(i)-1) << endl;;
  }
}

Measured memory_bytes: 1792
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from itertools import product
def main():
    h, w, k = map(int, input().split())
    gg = []
    for _ in range(h):
        row = [1 if c == '#' else 0 for c in list(input())]
        gg.extend(row)
    row_pro = tuple(product((0, 1), repeat=h))
    col_pro = tuple(product((0, 1), repeat=w))
    pat = tuple(product(row_pro, col_pro))
    r = 0
    for pate in pat:
        t0 = 0
        for i0, p0 in enumerate(pate[0]):
            for i1, p1 in enumerate(pate[1]):
                if p0 and p1:
                    t0 += gg[i0*w + i1]
        if t0 == k:
            r += 1
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9244
from functools import lru_cache


def popcnt(x):
    return bin(x).count("1")


@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    else:
        return rec(n % popcnt(n)) + 1


n = int(input())
arr = input()

ALL_ARR = int(arr, 2)

# ALL_ARR mod popcnt±1を予め計算しておく
cnt = popcnt(int(arr, 2))
init_big = ALL_ARR % (cnt + 1)
if cnt == 1:
    init_small = 0
else:
    init_small = ALL_ARR % (cnt - 1)

# 変更部分だけ調整して剰余を再計算する
# 調整部分だけでも数が大きいためpowの引数modで高速化
li = [0] * n
for i in range(n):
    if arr[i] == "0":
        li[i] = (init_big + pow(2, n - i - 1, cnt + 1)) % (cnt + 1)

    # 0除算回避のためにフラグを立てておく
    elif ALL_ARR - (1 << (n - i - 1)) == 0 or cnt - 1 == 0:
        li[i] = "flg"
    else:
        li[i] = (init_small - pow(2, n - i - 1, cnt - 1)) % (cnt - 1)

ans = []

for x in li:
    if x == "flg":
        ans.append(0)
    else:
        ans.append(rec(x) + 1)

print(*ans, sep="\n")

Measured memory_bytes: 118876
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
int main(){
    int N,K;cin>>N>>K;
    ll ans;
    if(K%2==1){
        int n=N/K;
        ans=pow(n,3);
    }
    else{
        K/=2;
        int n=N/K;
        if(n%2==0)ans=2*pow(n/2,3);
        else ans=pow(n/2,3)+pow(n/2+1,3);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  bool ans = false;
  for (int i = 1; i < 10; i++){
    for (int j = 0; j < 10; j++){
      if(i*j == n)
        ans = true;
    }
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import random
from copy import deepcopy

d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(d)]

ans = []

for i in range(d):
    ans.append(s[i].index(max(s[i]))+1)

def score(l):
    lastd = [0]*26
    point = 0
    for j,k in enumerate(l):
        kk = k-1
        point += s[j][kk]
        lastd[kk] = j+1
        for l in range(26):
            point -= c[l]*(j+1-lastd[l])
    return point

ma = score(ans)

def random_search():
    global ans
    li = deepcopy(ans)
    D = random.randrange(0,d,1)
    Q = random.randrange(0,26,1)
    li[D] = Q+1
    if score(li) > ma:
        ans = deepcopy(li)

for i in range(5000):
    random_search()

for i in ans:
    print(i)

Measured memory_bytes: 84024
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
int r,c,n;
vector<pair<int,int> >a;
stack<int>S;
main()
{
	cin>>r>>c>>n;
	for(int i=0;i<n;i++)
	{
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(x1!=0&&x1!=r&&y1!=0&&y1!=c)continue;
		if(x2!=0&&x2!=r&&y2!=0&&y2!=c)continue;
		int con1,con2;
		if(y1==0)con1=x1;
		else if(y1==c)con1=r+c+r-x1;
		else if(x1==0)con1=2*r+c+c-y1;
		else con1=r+y1;
		if(y2==0)con2=x2;
		else if(y2==c)con2=r+c+r-x2;
		else if(x2==0)con2=2*r+c+c-y2;
		else con2=r+y2;
		a.push_back(make_pair(con1,i));
		a.push_back(make_pair(con2,i));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<a.size();i++)
	{
		if(S.size()>0&&S.top()==a[i].second)S.pop();
		else S.push(a[i].second);
	}
	cout<<(S.size()?"NO":"YES")<<endl;
}


Measured memory_bytes: 2548
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
num = [0] * (N + 1)
ans = 0
for i in range(N):
    if a[i] > N:
        ans += 1
    else:
        num[a[i]] += 1

ans += sum([(0 if (num[i] == 0) else num[i] - i if (num[i] >= i) else num[i]) for i in range(N + 1)])
print(ans)


Measured memory_bytes: 14268
#include <stdio.h>

int main()
{
 int W, H, x, y, r;
 scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
 if(x - r < 0 || y - r < 0 || x + r > W || y + r > H)
 {
     printf("No\n");
 }
 else
 {
     printf("Yes\n");
 }
 return 0;
}

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

int n;
vector<long long> a;
long long b[100010][2];
bool f[100010][2];

long long func(int x, int t){
	if(f[x][t]) return b[x][t];
	if(x == n-1){
		f[x][t] = true;
		return b[x][t] = (1-2*t) * a[x];
	}
	long long res = -1e18;
	res = (1-2*t) * a[x] + func(x+1, 0);
	res = max(res, (2*t-1) * a[x] + func(x+1, 1));
	f[x][t] = true;
	return b[x][t] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	for(auto &i:a) cin >> i;
	cout << func(0, 0) << "\n";
//	for(int i=0; i<n; ++i)
//		cout << b[i][0] << " " << b[i][1] << "\n";
}

Measured memory_bytes: 10624
#!/usr/bin/env ruby

N = gets.chomp.to_i

L = gets.chomp.split.map(&:to_i)

count = 0

0.upto(N-3) do |i|
  (i+1).upto(N-2) do |j|
    (j+1).upto(N-1) do |k|
      a, b, c = [L[i], L[j], L[k]].sort

      next if a == b || b == c || c == a

      count += 1 if a + b > c
    end
  end
end

puts count


Measured memory_bytes: 14384
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>


using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

char alfa[] = { 'A','B' ,'C','D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y','Z' };

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

unsigned GetDigit(unsigned num) {
	return log10(num) + 1;
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	bool debug = false;
	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}


ll calcC(ld lastNum, ld calcNum, ll A, ll B, ll X) {
	if (calcNum < 1) {
		return 0;
	}

	ll ans;

	ans = A * calcNum + B * GetDigit(calcNum);

	if (calcNum == lastNum) {
		return calcNum;
	}

	if (ans > X) {
		return calcC(calcNum, calcNum - (fabs(calcNum - lastNum) / 2), A, B, X);
	}
	else {
		return calcC(calcNum, calcNum + (fabs(calcNum - lastNum) / 2), A, B, X);
	}

}

inline void Main() {
	ll X, Y, N;
	ll A, B;
	ll M1, D1, M2, D2;
	ld ans;
	string S;



	cin >> M1 >> D1 >> M2>>D2;

	if (M1 != M2) {
		cout << 1;
	}
	else {
		cout << 0;
	}

	


}




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


std::vector<int> CountingSort(std::vector<int> A, int k, int n){
    std::vector<int> B(n);
    std::vector<int> C(k, 0);



    for(int i = 0; i < n; i++){
        C[A[i]]++;
    }

    for(int i = 0; i < k; i++){
        C[i] = C[i] + C[i-1];
    }

    for(int i = 0; i < k; i++){
        C[i]--;
    }

    for(int i = n-1; i >= 0; i--){
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }

    

    
    return B;
}

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> A(n);
    int k = 10000;
    std::vector<int> B;
    //std::vector<int> C(k, 0);


    for(int i = 0; i < n; i++){
        std::cin >> A[i];
        //std::cout << A[i] << std::endl;
    }

    B = CountingSort(A, k, n);

    for(int i = 0; i < n; i++){
        if(i != 0) std::cout << " ";
        std::cout << B[i];
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 34216
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


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

    int ans = 0;
    bool check = false;
    rep(i,N){
        int d, e;
        cin >> d >> e;

        if(d == e)ans +=1;
        else ans = 0;

        if(ans == 3){
           check = true;
        
        }
    }
    if(check)cout <<"Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  int ans = 0;
  int n = 1;
  for (int j = 2; j <= N; j++) {
    int i = j;
    int a = 0;
    while (i%2 == 0 && i > 1) {
      a++;
      i /= 2;
    }

    if (ans < a) {
      ans = a;
      n = j;
    }
  }
  cout << n << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<double, double>> xy;
  vector<double> p(n);
  rep(i,n){
    int x, y;
    cin >> x >> y;
    xy.push_back({x, y});
    p[i] = i;
  }
  double sum = 0;
  double cnt = 0;
  do {
    // rep(i,n) cout << p[i] << " ";
    // cout << endl;
    double dist = 0;
    cnt++;
    for(int i=0; i<n-1; ++i){
      double pd = sqrt((xy[p[i]].first - xy[p[i+1]].first)*(xy[p[i]].first - xy[p[i+1]].first) + ((xy[p[i]].second - xy[p[i+1]].second)*(xy[p[i]].second - xy[p[i+1]].second)));
      dist += pd;
      // printf("%.10f,%f ", dist,cnt);
      // cout << dist << " " << cnt << endl;
      // cout << '(' << xy[i].first << ',' << xy[i].second << ')' << " ";
      // cout << i << " ";
    }
    sum += dist;
    // cout << endl;
  }while(next_permutation(p.begin(), p.end()));
  // for(auto x : xy) cout << x.first << " " << x.second << endl;
  double ans = sum / cnt;
  printf("%.12f\n",ans);
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> num;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        num[A[i]]++;
    }
    long long int ans = 0;
    for(auto i = num.begin(); i != num.end(); i++) {
        int key = i->first;
        int value = i->second;
        if(key < value) {
            ans += (value - key);
        }
        if(value < key) {
            ans += value;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
import collections

n = int(input())
s =[]
for i in range(n):
    s.append(input())
ans = collections.Counter(s)
temp = ans.values()
temp2 = max(temp)
# print(ans)
# print(ans[temp2])
temp3 = [k for k ,v in ans.items() if v == temp2]
# print("\n")
temp3 = sorted(temp3)
for i in temp3:
    print(i)
# print(sorted(temp3))

Measured memory_bytes: 104400
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,k; cin >> n >> k;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		if((a[i]|k)==k)ans+=b[i];
	}
	for(ll i=0;i<=30;i++){
		if((k>>i)%2){
			ll mask=((k>>(1LL+i))<<(i+1LL))+(1LL<<i)-1;
			ll sum=0;
			for(int j=0;j<n;j++){
				if((a[j]|mask)==mask){
					sum+=b[j];
				}
			}
			ans=max(ans,sum);
		}
	}
	cout << ans << endl;
}



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

void eratosthenes(int N, int* arr){
  for(int i=0; i < N; i++){
    arr[i] = 1;
  }
  for(int i=2; i < sqrt(N); i++){
    if(arr[i]){
      for(int j=0; i * (j + 2) < N; j++){
        arr[i*(j+2)] = 0;
      }
    }
  }
}

int main(void){
  const int NMAX = 100002;
  const int QMAX = 1000001;
  const int MOD = 1e9+7;
  int dp[NMAX][2]; // dp[idx][自分が素因数(0)か肩(1)か]
  int isprime[QMAX];
  for(int i = 0; i < NMAX; i++) for(int j = 0; j < 2; j++) dp[i][j] = 0;
  eratosthenes(QMAX, isprime);



  int N; cin >> N;
  vector<int> q(N);
  for(int i = 0; i < N; i++) cin >> q[i];
  q.push_back(0);

  if(isprime[q[0]])
    dp[0][0] = 1;

  for(int i = 0; i < N-1; i++){
    for(int j = 0; j < 2; j++){
      if(j == 0){
        dp[i+1][1] = (dp[i+1][1] + dp[i][j]) % MOD;
        if(q[i+1] > q[i] && isprime[q[i+1]]){
          dp[i+1][0] = (dp[i+1][0] + dp[i][j]) % MOD;
        }
      }else{
        if((i == 0 || q[i+1] > q[i-1]) && isprime[q[i+1]]){
          dp[i+1][0] = (dp[i+1][0] + dp[i][j]) % MOD;
        }
      }
    }
  }
  cout << (dp[N-1][0] + dp[N-1][1]) % MOD << endl;
  return 0;
}



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

#define DATA_NUM 10

void swap(int &a, int &b)
{
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
}

int main()
{
        int height[DATA_NUM];
        int max, tmp;

        for(int i=0; scanf("%d\n",&height[i])!=EOF; i++){;}

        for(int i=0; i<DATA_NUM; i++){
                for(int j=i+1; j<DATA_NUM; j++){
                        if(height[i]<height[j]){
                                swap(height[i], height[j]);
                         }
                }
        }
        
        for(int i=0; i<3; i++){
                cout << height[i] << endl;
        }

        return 0;
}

Measured memory_bytes: 1212
A,B,C,D = map(int,input().split())


taka_turn = C//B
taka_para = C%B
if taka_para > 0 :
    taka_turn = taka_turn + 1

ao_turn = A//D
ao_para = A%D
if ao_para > 0 :
    ao_turn = ao_turn + 1

if ao_turn >= taka_turn :
    print('Yes')
if taka_turn > ao_turn :
    print('No')

Measured memory_bytes: 9136
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        if (N == M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int Q; cin >> Q;
    while(Q--){
        ll N; cin >> N;
        map<ll,bool> mp;
        
        bool loop = false;
        ll ans = 0;
        while(true){
            if(mp[N]){
                loop = true;
            }
            if(N < 10) break;
            
            ll nextN = -1;
            
            ll base = 10;
            while(base <= N){
                nextN = max(nextN,(N%base) * (N/base));
                base *= 10;
            }
            N = nextN;
            ans++;
        }
        
        if(loop) ans = -1;
        
        cout << ans << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 3220
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;


int max_n;
const int mn = 100000;

struct edge {
	int to, cap, cost, rev;
};

struct MinCostFlow {
	vector<edge> G[mn];
	int par[mn];
	int dist[mn];
	void add_edge(int from, int to, int cap, int cost) {
		G[from].push_back({ to,cap,cost,(int)G[to].size() });
		G[to].push_back({ from, 0, -cost, (int)G[from].size() - 1 });
		max_n = max({ max_n, from + 1, to + 1 });
	}

	int minimum_road(int s, int t) {
		fill(par, par + max_n, -1);
		fill(dist, dist + max_n, mod);
		dist[s] = 0;
		priority_queue<P, vector<P>, greater<P>> q; q.push({ 0,s });
		while (q.size()) {
			P p = q.top(); q.pop();
			int id = p.second;
			if (id == t)continue;
			if (p.first > dist[id])continue;
			rep(j, G[id].size()) {
				if (G[id][j].cap > 0) {
					int to = G[id][j].to;
					int nd = p.first + G[id][j].cost;
					if (nd < dist[to]) {
						dist[to] = nd;
						par[to] = id;
						q.push({ dist[to],to });
					}
				}
			}
		}
		int cur = t;
		while (cur != s) {
			int p = par[cur];
			if (p < 0)return -1;
			rep(j, G[p].size()) {
				if (G[p][j].cap > 0 && G[p][j].to == cur && dist[p] + G[p][j].cost == dist[cur]) {
					G[p][j].cap--;
					G[cur][G[p][j].rev].cap++;
				}
			}
			cur = p;
		}
		return dist[t];
	}
	int minimum_cost_flow(int s, int t, int k) {
		int ret = 0;
		rep(i, k) {
			int z = minimum_road(s, t);
			if (z < 0)return -1;
			ret += z;
		}
		return ret;
	}
};


 void solve() {
	int n, m;
	cin >> n >> m;
	int d[111][111];
	rep(i, n)rep(j, m)cin >> d[i][j];
	int c1 = m / n, c2 = !!(m%n);
	int ok = 1e9, ng = 0;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		MinCostFlow mc;
		int s = m + n, t = m + n + 1;
		rep(i, n)rep(j, m) {
			if (d[i][j] <= mid) {
				mc.add_edge(i, n + j, 1, 0);
			}
		}
		rep(i, n) {
			mc.add_edge(s, i, c1, 0);
			mc.add_edge(s, i, c2, 1);
		}
		rep(i, m) {
			mc.add_edge(n + i, t, 1, 0);
		}
		int ret = mc.minimum_cost_flow(s, t, m);
		if (ret == m % n)ok = mid;
		else ng = mid;
	}
	cout << c2 << endl;
	cout << ok << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	solve();
	//stop
		return 0;
}


Measured memory_bytes: 5736
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */


template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */
int n;
int arr[100010][3];
int dp[100010][3];


int dfs(int i, int prev){

	if(i == n) return 0;
	
	if(prev != -1 && dp[i][prev] > -1) return dp[i][prev];

	int ans = 0;

	rep(j,0,3){
		if(j == prev) continue;
		chmax(ans, arr[i][j] + dfs(i + 1, j));
	}
	if(prev == -1) return ans;
	return dp[i][prev] = ans;



}





signed main(){


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

	n = input();

	rep(i,0,n){
		rep(j,0,3){
			arr[i][j] = input();
		}
	}

	memset(dp, -1, sizeof(dp));

	print(dfs(0, -1));




	




    



	








    



    





    


    

}



Measured memory_bytes: 12800
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	forn(i, n) {
		cin >> a[i];
	}
	forn(i, m) {
		cin >> b[i];
	}
	vector<int> pa(n);
	pa[0] = a[0];
	int ans = 0;
	for (int i = 1; i < n; i++) {
		pa[i] = pa[i - 1] + a[i];
		if (pa[i] <= k) {
			ans = i + 1;
		}
	}
	int pb = 0;
	forn(i, m) {
		pb += b[i];
		if (pb <= k) {
			ans = max(ans, i + 1);
		} else {
			break;
		}
		int ind = upper_bound(all(pa), k - pb) - pa.begin();
		if (ind > 0 && pb + pa[ind - 1] <= k) {
			ans = max(ans, i + 1 + ind);
		}
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 7948
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num_ = int(num_str)
temp = []
for num in range(3,l+1):
    temp.extend(gen_753(num))
can_l = [int(num) for num in temp if len(set(list(num))) == 3]
count = sum([i <= num_ for i in can_l])
print(count)

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

signed main() {
  int N, C, K;
  cin >> N >> C >> K;
  
  vector<int> T(N);
  for( int i = 0; i < N; i++ ) cin >> T.at(i);
  sort( T.begin(), T.end() );
  
  int bus = 1;
  int count = 0; //乗客数カウント
  int time = 0; //1人目の客の乗車時刻
  for( int i = 0; i < N; i++ ){
    if( count == C ){
      bus++;
      count = 0;
    }
    if( count == 0 ){
      time = T.at(i);
      count++;
    }else{
      if( T.at(i) <= time + K ) count++;
      else{
        bus++;
        count = 1;
        time = T.at(i);
      }
    }
  }
  
  cout << bus << endl;
      
    
}



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

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;
 
struct MComb {
   std::vector<mint> fact;
   std::vector<mint> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = std::vector<mint>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
       inversed = std::vector<mint>(n+1);
       inversed[n] = fact[n] ^ (MOD-2);
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
   }
   mint ncr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[r] * inversed[n-r]);
   }
   mint npr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[n-r]);
   }
   mint nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
   }
   mint fac(int n) {
       if(n < 0)return 0;
       return fact[n];
   }
};
MComb comb(500000);

mint f(int y, int x) {
    return comb.ncr(x + y - 2, x - 1);
}

int main()
{
    int h, w, a, b; cin >> h >> w >> a >> b;
    mint res = f(h, w);
    a = h - a + 1;

    while(a <= h && b >= 0) {
        res -= f(a, b) * f(h - a + 1, w - b + 1);
        a++;b--;
    }
    cout << res << endl;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n;

  cin >> n;

  vector<int> a(n);
  REP(i,n) {
    cin >> a[i];
    a[i]--;
  }
  
  vector<int> b(n,0);

  REP(i,n) b[a[i]]++;

  vector<int> ans(n,0);
  int sum = 0;
  REP(i,n){
    int tmp = b[i];
    ans[i] = tmp * (tmp - 1) / 2;
    sum += ans[i];
  }

  REP(i,n){
    int tmp = b[a[i]] - 1;
    cout << sum - ans[a[i]] + tmp * (tmp - 1) / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#define INF INT_MAX
using namespace std;

int N, K;
int A[100010];

int main(){
	cin >> N >> K;
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	cout << 1+((N - K) / (K - 1))  + (((N - K) % (K - 1) == 0 ? 0 : 1)) << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100
#define A -1
int main(){
  int n,i,j,u,v,k,c,t;
  int a[N][N],b[N],d[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=20000;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      a[u][v]=c;
    }
  }

  for(i=0;i<n;i++){
    b[i]=20000;
    d[i]=0;
  }
  b[0]=0;
  while(1){
    t=20000;
    u=A;
    for(i=0;i<n;i++){
      if(t>b[i] && !d[i]){
        u=i;
        t=b[i];
      }
    }
    if(u==A) break;
    d[u]=1;
    for(v=0;v<n;v++){
      if(!d[v] && a[u][v] != 20000){
        if(b[v]>a[u][v]+b[u]){
          b[v]=a[u][v]+b[u];
        }
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n",i,(b[i]==20000?100008:b[i]));
  }
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstring>

uint32_t MAX_STR_LEN = 3100;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  uint32_t dp[MAX_STR_LEN][MAX_STR_LEN] = {0};

  std::string s;
  std::string t;

  std::cin >> s >> t;

  for (uint32_t i = 0; i < s.size(); i++) {
    for (uint32_t j = 0; j < t.size(); j++) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = std::max(dp[i][j] + 1, dp[i + 1][j + 1]);
      }
      dp[i + 1][j + 1] = std::max(dp[i + 1][j], dp[i + 1][j + 1]);
      dp[i + 1][j + 1] = std::max(dp[i][j + 1], dp[i + 1][j + 1]);
    } 
  }

  uint32_t i = s.size(); uint32_t j = t.size();
  std::string ret;

  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--; 
    } else {
      i--;j--;
      ret = s[i] + ret;
    }
  }

  std::cout << ret << std::endl;

  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int sum = 0;
  
  for (int i = A; i <= B; i++) {
    int a = i / 10000 % 10, e = i % 10;
    int b = i / 1000 % 10, d = i / 10 % 10;
      
    if (a == e && b == d) { 
      sum++;
    }
  }
  cout << sum << endl;
}
    


Measured memory_bytes: 256
#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(__typeof(a) i=a,ENDI=b;i<ENDI;i++)
#define forj(a,b) for(__typeof(a) j=a,ENDJ=b;j<ENDJ;j++)
typedef long long ll;
using namespace std;
char _;

int h,w,k;
bool g[6][6];
int ans=0;
char foo;
int main(){
	
	r(h);r(w);r(k);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> foo;
			if(foo=='.')g[i][j]=true;
			else g[i][j]=false;
		}
	}

	for(int mask=0;mask<(1<<(h+w));mask++){
		bool curGrid[6][6];
		for(int k=0;k<h;k++)
			for(int j=0;j<w;j++)
				curGrid[k][j] = g[k][j];
		for(int i=0;i<(h+w);i++){
			if(mask & (1<<i)){
				if(i<h){
					for(int u=0;u<w;u++)curGrid[i][u]=true;
				}
				else{
					for(int u=0;u<h;u++)curGrid[u][i-h]=true;
				}
			}	
		}
		int count = 0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(!curGrid[i][j])count++;
			}
		}
		if(count==k)ans++;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3564
#include <iostream>

using namespace std;
int main(){
  int n; 
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  for(int i = 0; i < n; i++) {
    int v = a[i];
    int j = i-1;
    while(j >= 0 && a[j] > v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    
    for(int i = 0; i < n; i++) {
      cout << a[i];
      if(i != n-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}



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

int main() {
  string S, T;
  cin >> S >> T;
  int C = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      C++;
    }
  }
  cout << C << endl;
}

Measured memory_bytes: 3904
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(std::string S){
  cout << string(S.size(), 'x') << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int x = M / N;
		while(M % x != 0)
			x -= 1;
		System.out.println(x);
	}

}

Measured memory_bytes: 35732
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
using itn = int;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main(){
  int a,b,c,x,y;
  cin >>a >>b >>c >>x >>y;
  c *= 2;

  int ans=a*x+b*y;
  REP(i,100001){
    ans = min(ans,a*max(0,x-i)+b*max(0,y-i)+c*i);
  }

  cout  <<ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<vector>
#define ll long long
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
struct node{
	int x,y;
};
int dp[maxn];
int deep[maxn];
vector<int>a[maxn];
int n,m;
void dfs(int x,int f){
//	printf("%d %d\n",x,f);
	deep[x]=deep[f]+1;
	int tot=0;
	for(int i=0;i<a[x].size();i++){
		int y=a[x][i],res=m;
		if(y==f)continue;
			tot++;
		if(deep[x]>=2)res-=2;
		else res--;
		res-=tot-1;
		dp[y]=res;
		dfs(y,x);
	}
}

int main() {
	scanf("%d %d",&n,&m);
	for(int i=1,x,y; i<=n-1; i++) {
		scanf("%d %d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	ll ans=1;
	dp[1]=m;
	dfs(1,0);
	for(int i=1;i<=n;i++)ans=(1LL)*ans*dp[i]%mod;
	printf("%lld\n",ans%mod);
	return 0;
}

Measured memory_bytes: 12288
using System;

namespace ABC_C_Grid_Repainting_2
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int h = int.Parse(input[0]);
			int w = int.Parse(input[1]);
			
			string[,] grids = new string[h, w];
			
			//分割してgridsに格納
			for (int i = 0; i < h; i++)
			{
				string GridInputs = Console.ReadLine();
				for (int j = 0; j < w; j++)
				{
					grids[i, j] = GridInputs.Substring(j, 1);
				}
			}

			bool isNotPaintedGrid = false; //塗れない#があるか
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					//現在のマスが#であり
					if (grids[i, j] == "#")
					{
						//上下左右に#が無いか調査、なければisNotPaintedGridをtrueにしてループを抜ける
						if (i >= 1 && grids[i - 1, j] == "#")
						{
						}
						else if(i <= h - 2 && grids[i + 1, j] == "#")
						{
						}else if (j >= 1 && grids[i, j - 1] == "#")
						{	
						}else if (j <= w - 2 && grids[i, j + 1] == "#")
						{
						}
						else
						{
							isNotPaintedGrid = true;
							break;
						}
					}
				}

				if (isNotPaintedGrid)
				{
					break;
				}
			}

			if (isNotPaintedGrid)
			{
				Console.WriteLine("No");
			}
			else
			{
				Console.WriteLine("Yes");
			}
		}
	}
}

Measured memory_bytes: 11192
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int h,w; cin>>h>>w;
  int sh,sw,gh,gw; cin>>sh>>sw>>gh>>gw;
  sh--;sw--;gh--;gw--;
  //cout<<sh<<" "<<sw<<" "<<gh<<" "<<gw<<endl;
  vector<vector<char>> s(1010,vector<char>(1010));
  rep(i,h)rep(j,w) cin>>s[i][j];
  int dist[1010][1010];
  rep(i,h)rep(j,w){
    dist[i][j]=INF;
  }
  stack<pair<int,int>> s1;
  stack<pair<int,int>> s2;
  s1.push({sh,sw});
  int nh,nw;
  int cnt=0;
  while(!(s1.empty()&&s2.empty())){
    //if(s1.empty()) cout<< "empty"<<endl;
    if(s1.empty()){
      cnt++;
      while(!(s2.empty())){
        //cout<<"s2 empty"<<endl;
        int x=s2.top().first, y=s2.top().second;
        s2.pop();
        for(int dx=-2;dx<=2;dx++)for(int dy=-2;dy<=2;dy++){
          if(x+dx>=h||x+dx<0||y+dy>=w||y+dy<0) continue;
          if(dist[x+dx][y+dy]==INF&&s[x+dx][y+dy]=='.'){
            s1.push({x+dx,y+dy});
            //cout<<x+dx<<" "<<y+dy<<endl;
          }
        }
        if(s1.empty()&&s2.empty()) break;
      }
    }
    if(s1.empty()&&s2.empty()) break;
    nh=s1.top().first,nw=s1.top().second;
    s1.pop();
    if(dist[nh][nw]!=INF) continue;
    s2.push({nh,nw});
    dist[nh][nw]=cnt;
    rep(d,4){
      pair<int,int> np={nh+dx[d],nw+dy[d]};
      if(np.first>=h||np.first<0||np.second>=w||np.second<0) continue;
      if(dist[np.first][np.second]!=INF) continue;
      if(s[np.first][np.second]=='#') continue;
      s1.push(np);
      //cout<<np.first<<" "<<np.second<<endl;
    }
    if(dist[gh][gw]!=INF) break;
    if(s1.empty()&&s2.empty()) break;
  }
  if(dist[gh][gw]==INF) cout<<-1<<endl;
  else cout<<dist[gh][gw]<<endl;
}


Measured memory_bytes: 8548