akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	string A, B, C;
	int turn = 1, winner = 0;//1=A,2=B,3=C

	cin >> A >> B >> C;

	while (winner == 0) {

		switch (turn) {

		case 1:

			if (A.size() == 0) {

				winner = 1;

			}
			else {

				if (A[0] == 'a')turn = 1;
				else if (A[0] == 'b')turn = 2;
				else turn = 3;
				A.erase(A.begin());

			}
			break;

		case 2:

			if (B.size() == 0) {

				winner = 2;

			}
			else {

				if (B[0] == 'a')turn = 1;
				else if (B[0] == 'b')turn = 2;
				else turn = 3;
				B.erase(B.begin());

			}
			break;

		case 3:

			if (C.size() == 0) {

				winner = 3;

			}
			else {

				if (C[0] == 'a')turn = 1;
				else if (C[0] == 'b')turn = 2;
				else turn = 3;
				C.erase(C.begin());

			}
			break;

		}

	}

	switch (winner) {

	case 1:

		cout << "A" << endl;
		break;

	case 2:

		cout << "B" << endl;
		break;

	case 3:

		cout << "C" << endl;
		break;

	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define READ() freopen("in.txt","r",stdin)
#define pb(x) push_back(x)
#define mem(arr,val) memset(arr,val,sizeof(arr));
typedef long long ll;
struct data{
    bool ev;
    int val;
};
bool cmp(data a,data b)
{
    if(a.val<b.val)
        return true;
    if(a.val==b.val)
        return a.ev;
    return false;
}

int main()
{
//    READ();
    int a,b;
    cin>>a>>b;
    if((a+b)%3==0)
        cout<<"Possible"<<endl;
    else if(a%3==0)
        cout<<"Possible"<<endl;
    else if(b%3==0)
        cout<<"Possible"<<endl;
    else
        cout<<"Impossible"<<endl;
    return 0;
}


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

int main()
{
    int a,s,m;
    while(~scanf("%d",&a))
    {
        if(a%3==0)
            printf("%d\n",a/3);
        else
        {
            if(a<3)
                printf("0\n");
            else
                printf("%d\n",a/3);
        }
    }


    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int H,N;
    cin >> H >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int cnt = 0;
    for(int i = 0;i < N;i++) {
        cnt += vec.at(i);
    }
    if(cnt >= H) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int main() {
  char s[5], t[5];
  scanf("%s %s", s, t);
  int ans = 0;
  for (int i = 0; i < 3; i++)
    if (s[i] == t[i])
      ans++;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6540
import java.util.Scanner;

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

            int W,H,x,y,r;

            W=scanner.nextInt();
            H=scanner.nextInt();
            x=scanner.nextInt();
            y=scanner.nextInt();
            r=scanner.nextInt();

            if((x-r>=0&&x+r<=W)&&(y-r>=0&&y+r<=H)){
                System.out.println("Yes"); 
            }else if((x-r<0||x+r>W)||(y-r<0||y+r>H)){
                System.out.println("No");
            }

        }finally{
            scanner.close();
        }

    }
    
}


Measured memory_bytes: 26332
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, m, R; cin >> n >> m >> R;
  vector<ll> r(R); cin >> r;
  each(v, r) --v;
  vector<vector<ll>> dist(n, vector<ll>(n, linf));
  rep(i, n) dist[i][i] = 0;
  rep(i, m) {
    ll a, b, c; cin >> a >> b >> c; --a, --b;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k, n) rep(i, n) rep(j, n) {
    chmin(dist[i][j], dist[i][k] + dist[k][j]);
  }
  vector<vector<ll>> ndist(R, vector<ll>(R));
  rep(i, R) rep(j, R) ndist[i][j] = dist[r[i]][r[j]];
  dist = ndist;
  vector<vector<ll>> dp(R, vector<ll>(1LL<<R, linf));
  rep(i, R) dp[i][1LL<<i] = 0;
  rep(j, 1LL<<R) rep(i, R) {
    if (dp[i][j] == linf) continue;
    rep(to, R) {
      ll nj = j | (1LL<<to);
      chmin(dp[to][nj], dp[i][j] + dist[i][to]);
    }
  }
  ll ans = linf;
  rep(i, R) chmin(ans, dp[i][(1LL<<R)-1]);
  cout << ans << endl;
}


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

int N;

pair<int, int> red[100];
pair<int, int> blue[100];
bool red_checked[100];


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> red[i].second >> red[i].first;
    }
    for(int i = 0; i < N; i++){
        cin >> blue[i].first >> blue[i].second;
    }
    sort(red, red+N, greater<pair<int, int> >());
    sort(blue, blue+N);

    long long ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if((!red_checked[j]) && red[j].second < blue[i].first && red[j].first < blue[i].second){
                red_checked[j] = true;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
char s[N];
int f[N][26];

int main() {
	scanf("%s", s+1);
	int n = strlen(s+1);
	PER(i,1,n) {
		memcpy(f[i],f[i+1],sizeof f[0]);
		++f[i][s[i]-'a'];
	}
	ll ans = 0;
	REP(i,1,n) {
		ans += n-i-f[i+1][s[i]-'a'];
	}
	printf("%lld\n", ans+1);
}








Measured memory_bytes: 22784
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let s = next()
    let ans = 0
    let l = 0
    let r = s.length-1
    while(r-l>=0){
        if(s[l] !== s[r]) ans++
        l++
        r--
    }
    console.log(ans)
}
Main()


Measured memory_bytes: 29356
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);
    
	int H, W;
	cin >> H >> W;
    vector<string> S(H+1,"#");
    for(int i=1; i<=H; ++i){
        string tmp;
        cin >> tmp;
        S[i] += tmp;
    } 

    vector<vector<vector<int>>> dp(4,vector<vector<int>>(H+2,vector<int>(W+2,0)));
    for(int i=1; i<=H; ++i){
        for(int j=1; j<=W; ++j){
            if(S[i][j]=='#') continue;
            dp[0][i][j] = dp[0][i][j-1]+1;
            dp[2][i][j] = dp[2][i-1][j]+1;
        }
    }
    for(int i=H; i>=1; --i){
        for(int j=W; j>=1; --j){
            if(S[i][j]=='#') continue;
            dp[1][i][j] = dp[1][i][j+1]+1;
            dp[3][i][j] = dp[3][i+1][j]+1;
        }
    }

    int ans=0;
    for(int i=1; i<=H; ++i){
        for(int j=1; j<=W; ++j){
            ans = max(ans, dp[0][i][j]+dp[1][i][j]+dp[2][i][j]+dp[3][i][j]);
        }
    } 
	cout << ans-3 << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

int n;
int p[1005], x[1005];
vector<vector<int>> ch(1005);

pair<pair<int, int>, pair<int, int>> dfs(int now) {
    vector<pair<pair<int, int>, pair<int, int>>> bw;
    int m = ch[now].size();
    if (m == 0) return {{x[now], 0}, {0, x[now]}};
    for (auto nx : ch[now]) {
        bw.push_back(dfs(nx));
    }
    bool okb = true, okw = true;
    int ret_b_w = INF, ret_w_b = INF;
    rep(k, 2) {
        vector<vector<int>> dp(m + 1, vector<int> (x[now] + 1, INF));
        dp[0][0] = 0;
        if (k % 2 == 0) {
            rep(i, m)rep(j, x[now] + 1) {
                if (j - bw[i].fi.fi >= 0) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - bw[i].fi.fi] + bw[i].fi.se);
                if (j - bw[i].se.fi >= 0) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - bw[i].se.fi] + bw[i].se.se);
            }
            rep(j, x[now] + 1) ret_b_w = min(ret_b_w, dp[m][j]);
            if (ret_b_w == INF) okb = false;
        }
        else {
            rep(i, m)rep(j, x[now] + 1) {
                if (j - bw[i].fi.se >= 0) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - bw[i].fi.se] + bw[i].fi.fi);
                if (j - bw[i].se.se >= 0) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - bw[i].se.se] + bw[i].se.fi);
            }
            rep(j, x[now] + 1) ret_w_b = min(ret_w_b, dp[m][j]);
            if (ret_w_b == INF) okw = false;
        }
    }
    if (!okb && !okw) {
        cout << "IMPOSSIBLE" << endl;
        exit(0);
    }
    else if (!okb) {
        return {{INF, INF}, {ret_w_b, x[now]}};
    }
    else if (!okw) {
        return {{x[now], ret_b_w}, {INF, INF}};
    }
    else return {{x[now], ret_b_w}, {ret_w_b, x[now]}};
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n - 1) {
        cin >> p[i];
        p[i]--;
        ch[p[i]].push_back(i + 1);
    }
    rep(i, n) cin >> x[i];
    dfs(0);
    cout << "POSSIBLE" << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, m;
	cin >> n >> m;
	vector< vector< pair<int, int> > > a(n);
	vector<int> ans(m, 0);

	queue< vector< pair<int, int> > > que;

	for(int i = 0; i < m; ++i)
	{
		int in_a, in_b;

		cin >> in_a >> in_b;
		in_a--;
		in_b--;

		a[in_a].push_back(make_pair(in_a, in_b));
		a[in_b].push_back(make_pair(in_b, in_a));
	}

	que.push(a[0]);
	while(!que.empty())
	{
		vector< pair<int, int> > vec = que.front();
		que.pop();
		for(const auto& v : vec)
		{
			if (ans[v.second] == 0)
			{
				ans[v.second] = v.first + 1;
				que.push(a[v.second]);
			}
		}
	}

	// No の判定もする
	bool isOk = true;
	for (int i = 1; i < n; ++i)
	{
		isOk = (isOk & (ans[i] != 0));
	}

	if (isOk)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
		return;
	}
	
	for(int i = 1 ;i < n; ++i)
	{
		cout << ans[i] << endl;
	}

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 19240
import sys
input=sys.stdin.readline

N,M=map(int,input().split())

R=[1 for i in range(N+1)]
A,B=map(int,input().split())
R[A]=0
R[B]=0

L=[[]for i in range(N+1)]
L[A].append(B)
L[B].append(A)

for i in range(M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)

l=[A]
P=A
#print(L)

for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            l.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(l)
r=[B]
P=B
for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            r.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(r)
l=l[::-1]
ans=l+r


print(len(ans))
print(*ans)


Measured memory_bytes: 62384
#include<stdio.h>
#include<stdlib.h>
typedef long long int lli;
long long int gcd(lli,lli);
int lli_compare(const void*a,const void*b){return *(lli*)a-*(lli*)b;}
int main(void)
{
    lli n;
    lli a[100000];

    scanf("%lld",&n);
    for(lli i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(lli i=0;i<n-1;i++){
        a[i+1]=gcd(a[i],a[i+1]);
    }
    printf("%lld\n",a[n-1]);
    return 0;
}
long long int gcd(lli x,lli y)
{
    if(x<y){
        lli tmp=x;
        x=y;
        y=tmp;
    }
    if(x%y==0)return y;
    else return gcd(y,x%y);
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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 int mod = 1e9+7;

long long Modpow(long long a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    long long res = Modpow(a, n/2);
    return res * res % mod;
  }
  return a * Modpow(a, n-1) % mod;
}

int inv(int n) { // 逆元
  return Modpow(n, mod-2);
}

struct Combination { 
  vector<long long> fact, ifact;
  Combination(int n):fact(n+1), ifact(n+1) {
    fact[0] = 1;
    for(long long i = 1; i <= n; i++) fact[i] = fact[i-1]*i % mod;
    ifact[n] = inv(fact[n]);
    for(long long i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i % mod;
  }
  long long operator()(int n, int k) { // modcom (nCk % mod)
    if(k < 0 || k > n) return 0;
    return ((fact[n] * ifact[k]) % mod * ifact[n-k]) % mod;
  }
};



int main(){
    
    int x, y;
    cin >> x >> y;

    int n = (2*y-x) / 3;
    int m = (2*x-y) / 3;
    if(n < 0 || m < 0 || (x+y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    Combination c(n+m);

    int ans = c(n+m, n);
    cout << ans << endl;
}

Measured memory_bytes: 13796
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import Counter
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    H, W, K = map(int, readline().split())
    C = read().split()
    black = 0
    low = [0]*H
    column = [0]*W
    for h in range(H):
        c = C[h]
        b = c.count('#')
        black += b
        low[h] = b
        for w in range(W):
            if c[w]=='#':
                column[w]+=1
    ans = 0
    for i in range(2**H):
        for j in range(2**W):
            loss = 0
            for h in range(H):
                if ((i>>h)&1)==1:
                    loss += low[h]
                    for w in range(W):
                        if ((j>>w)&1) == 1:
                            if C[h][w]=='#':
                                loss -= 1
            for w in range(W):
                if ((j >> w)&1) == 1:
                    loss += column[w]
            if black-loss == K:
                ans += 1
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9404
import java.io.*;

public class Main {
    public static void main(String[] args) {
        String S;
        try (InputScanner is = new InputScanner(System.in)) {
            S = is.next();
        }
        char[] carr = S.toCharArray();
        if(carr[2] == carr[3] && carr[4] == carr[5]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

    //-------------------------------------------------------------------
    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }

        //next int
        public int ni() {
            return Integer.parseInt(this.nextElement());
        }

        //next long
        public long li() {
            return Long.parseLong(this.nextElement());
        }

        //next int array
        public int[] nia(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if (!hasElement()) {
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null) {
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
//-------------------------------------------------------------------
}


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

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>H>>W>>N;
    M = max(H, W);
    cout<<(M + N - 1) / M<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static long[] memo = new long[87];
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long ans = 0;
		int n = sc.nextInt();
		Arrays.fill(memo, -1);
		System.out.println(luca(n));
	}
	
	static long luca(int n) {
		if(memo[n]!=-1) return memo[n];
		if(n==0) return memo[n] = 2;
		if(n==1) return memo[n] = 1;
		return memo[n] = luca(n-1)+luca(n-2);
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 23764
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> S = new HashMap<>();
		long r = 0L;
		for(int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = String.valueOf(s);
			int cnt = 0;
			if(S.containsKey(ss)) {
				cnt = S.get(ss);
				r += cnt;
			}
			S.put(ss, ++cnt);
		}
		sc.close();
		System.out.println(r);
	}
}

Measured memory_bytes: 54028
#include<iostream>

using namespace std;

int main() {

	int A[9];
	int N;
	
	for (int i = 0; i < 9; ++i)
	{
		cin >> A[i];
	}
	cin >> N;

	int* b = new int[N];

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

	for (int i = 0; i < 9; ++i)
	{
		for (int j = 0; j < N; ++j)
		{
			if (A[i] == b[j]) A[i] = 0;
		}
	}


	if ((A[0] == 0 && A[1] == 0 && A[2] == 0) ||
		(A[3] == 0 && A[4] == 0 && A[5] == 0) ||
		(A[6] == 0 && A[7] == 0 && A[8] == 0) ||
		(A[0] == 0 && A[3] == 0 && A[6] == 0) ||
		(A[1] == 0 && A[4] == 0 && A[7] == 0) ||
		(A[2] == 0 && A[5] == 0 && A[8] == 0) ||
		(A[0] == 0 && A[4] == 0 && A[8] == 0) ||
		(A[2] == 0 && A[4] == 0 && A[6] == 0)) {
		cout << "Yes";
	}
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val M = scanner.nextInt()
	val D = scanner.nextInt()

	var cnt = 0

	for (m in 4..M) {
		for (d in 22..D){
			val d1 = d%10
			val d10 = d/10
			if (d1>=2 && d1*d10==m) cnt++
		}
	}

	println(cnt)
}

Measured memory_bytes: 29596
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INFTY 1<<21

int main() {
  int N;
  int T[105];
  int M;
  int P;
  int X;

  int sum=0;
  int ans=0;

  cin >> N;
  for (int i = 0; i < N; i++) {
	cin >> T[i];
	sum += T[i];
  }


  cin >> M;

  for (int i = 0; i < M; i++) {
	cin >> P >> X;
	ans = sum - T[P - 1] + X;
	cout << ans << endl;
  }

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n;
  cin >> n;
  vector<int>v(n);
  map<int,int>a,b;
  rep(i,n)cin >> v[i];
  rep(i,n){
    if(i%2)a[v[i]]++;
    else b[v[i]]++;
  }
  int a_cnt = -1,b_cnt = -1,a_num = -1,b_num = -1;
  for(auto i : a){
    if(i.second > a_cnt){
      a_cnt = i.second;
      a_num = i.first;
    }
  }
  for(auto i : b){
    if(i.second > b_cnt){
      b_cnt = i.second;
      b_num = i.first;
    }
  }
  if(a_num != b_num){
    cout << (n / 2) - a_cnt + (n / 2) - b_cnt;
    return 0;
  }
  ll ans = 0;
  int tmp_cnt = -1,tmp_num = - 1;
  for(auto i : a){
    if(i.second > tmp_cnt && i.first != a_num){
      tmp_cnt = i.second;
      tmp_num = i.first;
    }
  }
  if(tmp_num == -1)tmp_cnt = 0;
  ans = (n / 2) - tmp_cnt + (n / 2) - b_cnt;
  tmp_cnt = -1,tmp_num = - 1;
  for(auto i : b){
    if(i.second > tmp_cnt && i.first != b_num){
      tmp_cnt = i.second;
      tmp_num = i.first;
    }
  }
  if(tmp_num == -1)tmp_cnt = 0;
  ans = min(ans,(ll)(n / 2) - a_cnt + (n / 2) - tmp_cnt);
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

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

int main(){
    //入力
    int N;
    cin >> N;

    vector<int> l(N),r(N);

    for(int i=0;i<N;i++){
        cin >> l.at(i) >> r.at(i);
    }

    //出力
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=r.at(i)-l.at(i)+1;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <sstream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iterator>
#include <stdio.h>
#include <memory.h>

using namespace std;

//#define DEBUG_MODE

#ifdef DEBUG_MODE
#include <fstream>
//#include "prettyprint.hpp"
#endif // DEBUG_MODE

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<PII> VII;

#define A1D(T)              vector<T>
#define A2D(T)              vector<vector<T> >
#define sz(x)               ((int)(x).size())
#define maxof(x)            numeric_limits<x>::max()
#define minof(x)            numeric_limits<x>::min()
#define lowbit(x)           ((x)&-(x))
#define log2(x)             (log((double)x)/log(2.0))
#define _FORu(T,i,l,h,k)    for(T i=(l);i<=(h);i+=(k))
#define _FORd(T,i,h,l,k)    for(T i=(h);i>=(l);i-=(k))
#define FOR(i,n)            _FORu(int,i,0,n,1)
#define FORu1(i,l,h)        _FORu(int,i,l,h,1)
#define FORuk(i,l,h,k)      _FORu(int,i,l,h,k)
#define FORd1(i,h,l)        _FORd(int,i,h,l,1)
#define FORdk(i,l,h,k)      _FORd(int,i,h,l,k)
#define FOREACH(e,s)        for(__typeof__((s).begin()) e=(s).begin();e!=(s).end();++e)
#define IO_OPT              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef DEBUG_MODE
#define debug(...)          fprintf(stderr, __VA_ARGS__)
#define DEBUG(x)            cerr << '>' << #x << ':' << x << endl << flush;
#else
#define debug(...)
#define DEBUG(x)
#endif // DEBUG_MODE

const double PI      = acos(-1.0);
const double E       = exp(1.0);
const double EPS     = 1e-8;
const int HALF_INF   = 0x3f3f3f3f;

#define MOD 1000000007

class Solver
{
public:
    void Solve()
    {
        LL a, b;
        scanf("%lld%lld", &a, &b);
        if(2 * a >= b) {
            printf("%lld\n", b / 2);
        } else {
            LL c = b - 2 * a;
            printf("%lld\n", c / 4 + a);
        }
    }
};

int main()
{
#ifdef DEBUG_MODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w+", stdout);
#endif // DEBUG_MODE

    Solver * solver = new Solver();
    solver->Solve();

    return 0;
}


Measured memory_bytes: 256
input_lines = gets.to_i
input_lines.times{
  s = gets.chomp.split(" ")
  s.map! {|x| x.to_i}
  if (s[0]**2+s[1]**2==s[2]**2)||(s[1]**2+s[2]**2==s[0]**2)||(s[2]**2+s[0]**2==s[1]**2) then
    puts "YES"
  else
    puts "NO"
  end
}

Measured memory_bytes: 6116
def dfs(splitted: "the list of integer", a: int, b: int, depth: int) -> int:
  if len(splitted) == depth:
    return a + b
  else:
    # 左のdfs() 呼び出し -> +を挿入しなかったとき
    # 右のdfs() 呼び出し -> +を挿入したとき
    return dfs(splitted, a, b * 10, depth + 1) + dfs(splitted, a + b, splitted[depth], depth + 1)

s = [int(x) for x in input()]
print(dfs(s, 0, 0, 0))

Measured memory_bytes: 3060
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		ll i, j, n;
		for (i = 0; i < 5; ++i){
            cin >> j;
            if (j == 0) n = i + 1;
        }
        cout << n << '\n';
	}

	return 0;
}




Measured memory_bytes: 3652
#include<iostream>
#include<deque>
using namespace std;
deque<int>P;
int d[1<<17],k;
main()
{
	cin>>k;
	for(int i=0;i<k;i++)d[i]=1e9;
	P.push_back(1);d[1]=1;
	while(!P.empty())
	{
		int u=P.front();P.pop_front();
		if(d[10*u%k]>d[u])
		{
			P.push_front(10*u%k);
			d[10*u%k]=d[u];
		}
		if(d[(u+1)%k]>d[u]+1)
		{
			P.push_back((u+1)%k);
			d[(u+1)%k]=d[u]+1;
		}
	}
	cout<<d[0]<<endl;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, M; cin >> N >> M;
    string s; cin >> s;

    vector<int> res;
    int nowidx = N;
    while (true) {
        bool found = false;
        for (int i = M; i >= 1; --i) {
            if (nowidx - i >= 0 && s[nowidx - i] == '0') {
                found = true;
                res.emplace_back(i);
                nowidx -= i;
                break;
            }
        }
        if (!found) {
            return cout << -1 << "\n", 0;
        }
        if (nowidx <= 0) {
            break;
        }
    }

    reverse(res.begin(), res.end());

    for (auto &ri: res) {
        cout << ri << (&ri == &res.back())[" \n"];
    }

    return 0;
}


Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

using P = pair<ll,ll>;
const ll inf = 1e14;

class min_cost_flow{
private:
    int N;
    struct edge{int to; ll cap,cost; int rev; bool is_rev;};
    vector<vector<edge>> G;
    vector<ll> h,dist,prevv,preve;
public:
    min_cost_flow(int n){
        N = n;
        G = vector<vector<edge>>(N);
        h = dist = prevv = preve = vector<ll>(N,0);
    }
    void add_edge(int from,int to,ll cap,ll cost){
        G[from].push_back((edge){to,cap,cost,(int) G[to].size(),false});
        G[to].push_back((edge){from,0,-cost,(int) G[from].size()-1,true});
    }
    ll answer(int s,int t,ll f){
        ll res = 0;
        fill(h.begin(),h.end(),0);
        while(f>0){
            priority_queue<P,vector<P>,greater<P>> Q;
            fill(dist.begin(),dist.end(),inf);
            dist[s] = 0;
            Q.push(P(0,s));
            while(!Q.empty()){
                P p = Q.top(); Q.pop();
                int v = p.second;
                if(dist[v]<p.first) continue;
                for(int i=0;i<G[v].size();i++){
                    edge &e = G[v][i];
                    if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                        dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        Q.push(P(dist[e.to],e.to));
                    }
                }
            }
            if(dist[t]==inf) return -1;
            for(int v=0;v<N;v++) h[v] += dist[v];
            ll d = f;
            for(int v=t;v!=s; v=prevv[v]){
                d = min(d,G[prevv[v]][preve[v]].cap);
            }
            f -= d;
            res += d*h[t];
            for(int v=t;v!=s;v=prevv[v]){
                edge &e = G[prevv[v]][preve[v]];
                e.cap -= d;
                G[v][e.rev].cap += d;
            }
        }
        return res;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vvec<char> S(N,vec<char>(M));
    for(auto& v:S) for(auto& c:v) cin >> c;
    min_cost_flow flow(N*M+2);
    
    auto id = [&](int x,int y){
        return x*M+y;  
    };
    int s = N*M,t = N*M+1;
    int c = 0;
    for(int i=0;i<N;i++) for(int j=0;j<M;j++){
        if(S[i][j]=='#') continue;
        if(S[i][j]=='o'){
            flow.add_edge(s,id(i,j),1,0);
            c++;
        }
        flow.add_edge(id(i,j),t,1,0);
        if(i+1<N && S[i+1][j]!='#') flow.add_edge(id(i,j),id(i+1,j),100,-1);
        if(j+1<M && S[i][j+1]!='#') flow.add_edge(id(i,j),id(i,j+1),100,-1);
    }
    cout << -flow.answer(s,t,c) << "\n";
}

Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 998244353;
const ll INF = 100000000000000000LL;
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; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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 OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// Binary Indexed Tree 1-index
// 一点加算、区間和 O(logN)
// http://hos.ac/slides/20140319_bit.pdf
ll n;
ll bit[400040];

void bitadd(ll a, ll w){
    for(ll x = a; x <= n; x += x & -x) bit[x] += w;
}
ll sum(ll a){
    ll ret = 0;
    for(ll x = a; x > 0; x -= x & -x) ret += bit[x];
    return ret;
}
ll sum(ll a, ll b){
    return sum(b)-sum(a-1);
}

// 座標圧縮
// {10, 3, 1, -5, 1} -> {3, 2, 1, 0, 1}
template<typename T>
vector<T> CoordinateCompression(vector<T> &x){
    vector<T> y = x, ret(SZ(x));
    sort(ALL(y));
    y.erase(unique(ALL(y)), y.end());
    rep(i, SZ(x)){
        ret[i] = lower_bound(ALL(y), x[i]) - y.begin();
    }
    return ret;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> n;
    vll x(n), y(n);
    vp sp(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    vll cx(CoordinateCompression(x));
    vll cy(CoordinateCompression(y));
    rep(i, n){
        sp[i].first = cx[i];
        sp[i].second = cy[i];
    }
    sort(ALL(sp));
    
    ll ans = 0;
    auto addans = [&](ll r){
        ans += powmod(2, r);
        ans %= MOD;
    };
    auto subans = [&](ll r){
        ans -= powmod(2, r);
        ans = (ans+MOD) % MOD;
    };
    rep(i, n){
        addans(n);
        subans(n-sp[i].second-1);
        subans(sp[i].second);
        subans(i);
        subans(n-i-1);
        addans(sum(sp[i].second+2, n));
        addans(sum(sp[i].second));
        addans(n-sp[i].second-1-sum(sp[i].second+2, n));
        addans(sp[i].second-sum(sp[i].second));
        subans(0);
        bitadd(sp[i].second+1, 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  cout << (A+B >= C ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector> 

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a*b - ((a + b) - 1) << endl;
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (n); ++i)

int main() {
    int A, B;
    cin >> A >> B;
    int c = A+B;
    int d = A-B;
    int e = A*B;
    cout << max({c, d, e}) << endl;

    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll INF = 1e9+5;

int cnt[65][31];

int main() {
	int n;
	scanf("%d", &n);
	ll sol = 0;
	for (int i=0 ; i<n ; i++) {
		string s;
		cin >>s;
		ll x = 0, y = 0;
		ll MOD = 1;
		bool t = false;
		for (int i=0 ; i<s.size() ; i++) {
			if (s[i] == '.') {
				t = true;
				continue;
			}
			if (t) {
				y = y*10+s[i]-'0';
				MOD*=10;
			} else {
				x = x*10+s[i]-'0';
			}
		}
		//cout <<x<<" "<<y<<endl;
		int b2 = 0;
		int b5 = 0;
		ll d = 1;
		while (y) {
		//	cout <<"y = "<<y<<endl;
			while ((y/d)%10 == 0) d*=10;
			/*if (y%10 == 0) y/=10;
			else */if ((y/d)%10 == 5) {
		//	cout <<"ddd"<<endl;
				b2--;
				y*=2;
				x*=2;
				x+=y/MOD;
				y%=MOD;
			} else {
				b5--;
				y*=5;
				x*=5;
				x+=y/MOD;
				y%=MOD;
			}
		}
	//	cout <<"x = "<<x<<endl;
		while (x%5 == 0) {
			b5++;
			x/=5;
		}
		while (x%2 == 0) {
			b2++;
			x/=2;
		}
	//	cout <<b2<<", "<<b5<<endl;
		sol += cnt[-b2+31][-b5+15];
		for (int j=b2 ; j>=-31 ; j--) {
			for (int k=b5 ; k>=-15 ; k--) {
				cnt[j+31][k+15]++;
			}
		}
	//	cout <<"sol = "<<sol<<endl;
	}
	printf("%lld\n", sol);
	return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

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

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

int main(int argc, const char * argv[]) {
    int a,b,c;
    
    cin >> a;
    cin >> b;
    cin >> c;
    
    if(a < b && b < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;

void main ()
{
	string l;
	while((l = readln()).length >= 2)
	{
		int a, b, c, d, f, G, L;
		a = to!int(l.split()[0]), b = to!int(l.split()[1]);
		if(a < b)
		{
			c = a;
			a = b;
			b = c;
		}
		d = a, f = b;
		while(true)
		{
			c = d % f;
			if(c == 0) 
			{
				G = f;
				break;
			}else{
				d = f % c;
				if(d == 0)
				{
					G = c;
					break;
				}else{
					f = c % d;
					if(f == 0)
					{
						G = d;
						break;
					}
				}
			}
		}
		L = a / G * b;
		writefln("%d %d",G,L);
	}
}

Measured memory_bytes: 1176
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,k,c=0,ans=0;
	map<int,int> mp;
	priority_queue<int,vector<int>,greater<int>> qq;
	cin>>n>>k;
	FOR(i,0,n){
		int in;
		cin>>in;
		auto itr = mp.find(in);        // "xyz" が設定されているか？
    if( itr != mp.end() ) {
        mp[in]++;
    } else {
        c++;
				mp[in]=1;
    }
	}
	for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        //std::cout << "key = " << itr->first           // キーを表示
        qq.push(itr->second);   // 値
    }
		FOR(i,0,c-k){
			ans+=qq.top();
			qq.pop();
		}
		cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10748
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    num = (N-1)*(N-2)//2
    if K > num:
        print(-1)
        return
    ans = []
    for i in range(2, N+1):
        ans.append((1, i))
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
    print(len(ans))
    for u, v in ans:
        print(u, v)

if __name__ == '__main__':
    main()

Measured memory_bytes: 43248
#include<bits/stdc++.h>
#define nl "\n"
using namespace std;
typedef unsigned long long ull;

void solve() {
	string s;
	string t;
	cin >> s >> t;
	for (unsigned int i = 0; i < s.length(); i ++) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
	return;
}

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


Measured memory_bytes: 3660