akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		char[][] r = new char[3][3];
		for (int i = 0; i < 3; i++) {
			r[i] = I.next().toCharArray();
		}
		for (int i = 0; i < 3; i++) O.p(r[i][i]);
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25604
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    long a, b, n, ans = 0;
    cin >> n;
    vector<long> as(n);
    vector<long> bs(n);
    vector<long> cs(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> bs[i];
        ans += bs[i];
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> cs[i];
    }
    for (int i = 0; i < n - 1; i++) {
        if (as[i] + 1 == as[i + 1]) {
            ans += cs[as[i] - 1];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

ll number_of_divisor(ll n) {
    ll tao = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (!(n % i)) {
            tao++;
            if (i != (n / i))
                tao++;
        }
    }
    return tao;
}

int main() {
    ll n;
    scanf("%lld", &n);

    // n % k == 1,ie if k | n - 1 besides 1
    ll ans = number_of_divisor(n - 1) - 1;

    for (ll i = 2; i * i <= n; i++) {
        ll num = n;
        if (num % i == 0) {
            while (num % i == 0)
                num /= i;
            if (num % i == 1)
                ans++;
        }
    } // all the divisors with finally n/d^p % d == 1
    printf("%lld\n", ans + 1);
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# 83

while True:
    try:
        a,b,c,d,e,f = map(float,input().split())
        X = (f*b-e*c)/(b*d-e*a)
        Y = (a*f-d*c)/(a*e-b*d)
        if X==-0.0:
            X=0.0
        elif Y==-0.0:
            Y=0.0
        print(f"{X:.3f} {Y:.3f}")
    except:
        break



Measured memory_bytes: 5604
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    buttons = list(map(int, input().split()))
    coin = 0

    max_index = buttons.index(max(buttons))
    coin += max(buttons)
    buttons[max_index] -= 1
    coin += max(buttons)

    print(coin)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
a1=int(input())
a2=int(input())
a3=int(input())
a4=int(input())
a5=int(input())
a6=int(input())
a7=int(input())
a8=int(input())
a9=int(input())
a10=int(input())

print(a1+a2+a3+a4+a5+a6+a7+a8+a9+a10)


Measured memory_bytes: 5588
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  std::vector<int> L;
  long long N;
  std::cin >> N;
  L.resize(2*N);
  for (int i = 0; i < 2*N; i++) 
    std::cin >> L[i];
  std::sort(L.begin(), L.end());
  int sum = 0;
  for (int i = 0; i < N; i++)
    sum += std::min(L[2*i], L[2*i+1]);
  std::cout << sum << std::endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    ll a,b;
    cin>>a>>b;
    ll x = (b+a-1)/a;
    ll y = x*a-b;
    ll v = y/a + y%a;
    if(v <= x-1){
        puts("-1"); return 0;
    }else{
        cout << (b+v) << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100005
#define ll long long
#define ld double
#define mod 998244353
using namespace std;
int a[maxn], b[maxn];
int n;
int c[maxn]; 
int main()
{
	scanf("%d", &n);
	ll ans = 0;
	for(int i = 0; i < n; i++)
		scanf("%d%d", &a[i], &b[i]), 
		c[i] = a[i] + b[i], 
		ans -= b[i];
	sort(c, c + n);
	for(int i = n - 1; i >= 0; i--)
		if((i & 1) == ((n - 1) & 1))
			ans += c[i];
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		scanf("%d",&s);
		g=0;
		for(i=0;i<s;i++){
			scanf("%d %d",&d,&f);
			g+=f-d;
		}
		if(a<=g) printf("OK\n");
		else printf("%d\n",a-g);
	}
	return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int n; cin >> n;
    cout << n*n*n << '\n';

	return 0;
}


Measured memory_bytes: 256
import itertools
import math
from scipy.misc import comb
n = int(input())

dic = {}
for i in range(n):
    string = input()
    sortStr = "".join(sorted(string))
    if sortStr in dic:
        dic[sortStr] += 1
    else:
        dic[sortStr] = 1
sum = 0
for num in dic.values():
    if num == 1:
        sum += 0
    else:
        sum += comb(num, 2,exact=True)
print(math.floor(sum))


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

using namespace std;
typedef long long ll;

const int MAXN = 1e4 + 10;
struct Node {
	ll x, y;
	bool operator < (const Node &a) const {
		return atan2(x, y) < atan2(a.x, a.y);
	}
};

Node node[MAXN];

ll cal(ll x, ll y) {
	return x * x + y * y;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> node[i].x >> node[i].y;
	}
	sort(node, node + n);
	ll maxa = 0;
	for (int i = 0; i < n; i++) {
		ll x = node[i].x, y = node[i].y;
		maxa = max(maxa, x * x + y * y);
		for (int j = (i + 1) % n; j != i; j = (j + 1) % n) {
			x += node[j].x;
			y += node[j].y;
			maxa = max(maxa, x * x + y * y);
		}
	}
	cout << fixed << setprecision(11) << sqrt(maxa) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

int main() {
    int K,n;
    cin >> K >> n;
    int A[n];
	for (int i =0;i<n;i++) cin >> A[i];
	int ans = (K - A[n-1]) + A[0];
	for (int i =1;i<n;i++) {
		ans = max(ans,A[i] - A[i-1]);
	}
	
	cout << K - ans;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N = int(input())
en = [[] for _ in range(N)]
on = [[] for _ in range(N)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    if w % 2:
        on[u - 1].append(v - 1)
        on[v - 1].append(u - 1)
    else:
        en[u - 1].append(v - 1)
        en[v - 1].append(u - 1)

color = [None] * N


def dfs(node, parent, col):
    if color[node] is not None:
        return
    color[node] = col
    for k in en[node]:
        if k != parent:
            dfs(k, node, col)
    for k in on[node]:
        if k != parent:
            dfs(k, node, (col + 1) % 2)


dfs(0, -1, 0)
print(*color, sep="\n")


Measured memory_bytes: 73472
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100005];

int main() {
  ll t;
  cin>>t;
  ll n;
  cin>>n;
  vector<ll> v1;
  vector<ll> v2;
  rep(i,0,n){
    ll a,b;
    cin>>a>>b;
    v1.pb(a);
    v2.pb(b);
  }
  clr(d,0);
  rep(i,0,v1.sz){
    d[i+1] = v2[i]-v1[i];
  }
  rep(i,0,v1.sz){
    d[i+1]+=d[i];
  }
  ll mx = 0;
  rep(i,0,v1.sz){
    vector<ll>::iterator itr = upper_bound(v1.begin(),v1.end(),v1[i]+t-1);
    ll index = itr - v1.begin() - 1;
    ll c = d[index] - d[i];
    ll e = max(0LL,min(v2[index],v1[i]+t)-max(v1[i],v1[index]));
    mx = max(mx,c+e);
  }
  printf("%lld\n",mx);
  return 0;
}

Measured memory_bytes: 3716
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair


int train[509][509];

int main(){
  int n,m,Q;
  cin >> n>> m>> Q;
  rep(i,m){
    int r,l;
    cin >> r>> l;
    train[r][l]++;
  }
  
  rep2(i,n){ 
    rep2(j,n){
      train[i][j]+=train[i][j-1];
    }
  }
  rep2(i,n){ 
    rep2(j,n){      
      train[i][j]+=train[i-1][j];
    }
  }
  
  rep(i,Q){
    int p,q;
    cin>> p>> q;
    p--;
    cout<<train[q][q]-train[p][q]-train[q][p]+train[p][p]<<endl;
  }
  return 0;
}

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

#define LL long long
#define MAXDIV(a, b) ((a)/(b) + (((a)%(b) != 0)? 1 : 0) )

LL digit_sum(LL num) {
    LL sum = 0, divide, digit = 1;
    while((divide = num/digit) != 0) {
        sum += (divide % 10);
        digit *= 10;
    }
    return sum;
}

LL most_digit(LL num) { //何桁あるか求める
    LL digits = 1, cnt = 0;
    while(num / digits != 0) { digits *= 10; ++cnt; }
    return cnt;
}

double digit_div(LL num) {
    return (double)num / digit_sum(num);
}

LL snuke(LL num) {
    LL cnt = 0, m_digits = most_digit(num) + 1;
    LL d = 10, tmp;

    //num以上のsnuke数xがx > numであるときの場合
    LL x = d * ( num/d + 1) - 1;
    for(cnt = 1; cnt <= m_digits; ++cnt) {
        d = d * 10;
        tmp = d * ( num/d + 1) - 1;
        if(digit_div(tmp) < digit_div(x)) { x = tmp; }
    }

    //num以上のsnuke数xがx == numであるときの場合
    if(digit_div(num) <= digit_div(x)) { x = num; }
    return x;
}

void solve(LL num) {
    LL n = 0, i;
    for(i = 0; i < num; ++i) {
        n = snuke(n+1);
        printf("%lld\n", n);
    }
}

int main()
{
    LL k;
    scanf("%lld", &k);
    solve(k);
    return 0;
}

Measured memory_bytes: 128
# https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_1_C
# 螺旋本の説明わかりづらすぎへんか？
# ここでは隣接行列を更新して、i→jに行くときの最短経路としたい(なのでshapeは隣接行列と同じ)

# 操作を理解した後に、螺旋本の証明を読むとわかった気になれる。
# https://qiita.com/okaryo/items/8e6cd73f8a676b7a5d75 このサイトは読んでおくとざっくり操作の概要と仕組みがわかる
# https://triple-four.hatenablog.com/entry/2019/04/02/143939 このサイトでは超丁寧に解説している。お金取れるレベル

from copy import deepcopy

INF = 2**36 - 1


def warchall_floyed(adj_mat: list):
    '''
    隣接行列を受け取る(隣接していないノード間のコストはINFを前提)
    全点間の最短距離を示す行列を返す。
    '''
    n = len(adj_mat)
    ret = deepcopy(adj_mat)
    for k in range(n):  # kは経由を示す。
        for i in range(n):  # iは出発を示す
            if ret[i][k] == INF:
                # ノード同士がつながってなければ更新しない
                continue
            for j in range(n):  # jは終点を示す。
                if ret[k][j] == INF:
                    continue
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
                # 直接行ったほうが近いか、kを経由したほうが近いか
    return ret  # 閉路が存在するかどうかは対角成分を見れば良い(自己に戻ってくるのに距離が負ならば負の閉路があるということ)


n_V, n_E = list(map(int, input().split()))
adj_mat = [[INF] * n_V for _ in range(n_V)]  # INFで初期化
# 対角成分だけは0で初期化
for ij in range(n_V):
    adj_mat[ij][ij] = 0
for _ in range(n_E):
    s, t, d = list(map(int, input().split()))
    adj_mat[s][t] = d

ans = warchall_floyed(adj_mat)

# 負のループの調査
for ij in range(n_V):
    if ans[ij][ij] < 0:
        print('NEGATIVE CYCLE')
        exit()

for i in range(n_V):
    for j in range(n_V):
        print(ans[i][j] if ans[i][j] != INF else "INF", end='')
        if j == n_V - 1:
            print()
        else:
            print(' ', end='')



Measured memory_bytes: 7688
#include <iostream>

using namespace std;

int main(){
	int a[1001];
	int n;
	for(int i=0;i<1001;i++){
		a[i]=i;
	}

	// for(int i=0;i<10;i++){
	// 	cout<<a[i]<<" ";
	// }

	while(cin>>n){
		
		if(n==0)break;
		int ans=0;
		for(int i=1;i<n;i++){
			int	now=0;
			for(int j=i;j<n;j++){
				// cout<<"n:"<<n<<endl;
				now+=a[j];
				// cout<<now<<endl;
				if(now>n)break;
				if(now==n){
					ans++;
					// cout<<"?¢???????"<<endl;
				
				}
				

			}

		}

		cout<<ans<<endl;

	}
	
}

Measured memory_bytes: 3084
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = 1; i <= test_cases; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {
    void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
        String s = in.next();
        if (s.startsWith("YAKI")) out.println("Yes");
        else out.println("No");
    }
}


class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 22996
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    let m = gcd a b
    print . length $ ps m 1

ps m i | i * i <= m && m `mod` i /= 0 = ps m (i + 1)
       | i * i <= m = i : ps (d m i) (i + 1)
       | m == 1 = []
       | otherwise = [m]

d m k | k == 1 = m
      | m `mod` k /= 0 = m
      | otherwise = d (m `div` k) k

Measured memory_bytes: 380
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {

	int n,k;
	cin>>n>>k;
	vector<char>v(n);
	for(int i=0;i<n;i++){
		cin>>v.at(i);
		if(i==k-1){
			v.at(i)=v.at(i)+ 0x20;
		}
		cout<<v.at(i);
	}
	cout<<endl;
	return 0;
}



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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();

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

    c/=a;

    cout<< b*c;
    nl;


    return 0;
}




Measured memory_bytes: 3628
ml = 0
s = str(input())
acgt = ["A","C", "G", "T"]

def count_acgt(s, i):
    v = 0
    for t in range(i, len(s)):
        if s[t] in acgt:
            v += 1
        else:
            break
    return v

for i, _ in enumerate(s):
    n = count_acgt(s, i)
    if n >= ml:
        ml = n

print(ml)

Measured memory_bytes: 3060
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;

int h,w,k;
vector<string>grid;

bool chek(int r, int c){
     int cnt = 0;
     for(int i = 0; i<h; i++){
          for(int j = 0; j<w; j++){
               if((r & (1<<i))>=1 or (c& (1<<j))>=1){
                         continue;
               }
               if(grid[i][j]=='#')cnt++;
          }
     }
     return cnt==k;
}

void task(){
    cin >> h >> w >> k;
    grid.resize(h);

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

    int ans = 0;
    for(int r = 0; r<(1<<h); r++){
     for(int c = 0; c<(1<<w); c++){
          if(chek(r,c))ans++;
     }
    }

    cout << ans << endl;
}

int main(){
        _
        int T = 1; //cin >> T;
        while(T--){
            task();
        }
return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n,k;
  cin >> n >> k;

  if(k >= n) {
    cout << 0 << endl;
    return 0;
  }

  vector<ull> h(n);
  ull total = 0;
  rep(i, n) {
    cin >> h[i];
    total += h[i];
  }

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

  ull minus = 0;
  ull point = n-1;
  rep(i, k) {
    minus += h[point];
    point--;
  }

  ull ans = total - minus;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))

cur_len = 0
ans = 0
for i in range(N - 1):
    if H[i + 1] <= H[i]:
        cur_len += 1
    else:
        if cur_len > ans:
            ans = cur_len
        cur_len = 0
if cur_len > ans:
    ans = cur_len
print(ans)


Measured memory_bytes: 14252
//#define _GLIBCXX_DEBUG
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back 
#define f first
#define s second
#define min3(a, b, c) min(min(a, b), c)
#define max3(a, b, c) max(max(a, b), c)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9;
//const ll INF = 1e18;
const ll mod = 1000000007;
// const ll mod = 998244353;
ll mpow(ll a, ll b){
    ll x = 1;
    while(b > 0){
        if(b&1){
            x = (x*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return x;
}
ll madd(ll a, ll b){
    return (a+b)%mod;
}

ll msub(ll a, ll b){
    return (a - b + mod)%mod;
}
ll mmul(ll a, ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll modinv(ll b){
    ll x = mpow(b, mod-2);
    return x;
}
ll mdiv(ll a, ll b){
    return mmul(a, modinv(b));
}
void solve(int tc){
    ll n;
    cin >> n;

    cout << msub(mpow(10, n), msub(mmul(2, mpow(9, n)), mpow(8, n))) << "\n";
}

int main(){
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    
    int tc = 1;
    //cin >> tc;
    for (int t = 0; t < tc; t++) solve(t);

    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(100000000);
    for(int i = 0; i < n; i++)cin >> a[i];

    int cnt = 0;
    for(int i = 0; i < n; i++){
        bool res = true;
        for(int j = i - 1; j >= 0; j--) {
            if(a[i] < a[j])res = false;
        }
        cnt += res;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 390912
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int, int> p;
int dx[12] = {-1,  0,  1,  2, 2, 2, 1, 0, -1, -2, -2, -2};
int dy[12] = {-2, -2, -2, -1, 0, 1, 2, 2,  2,  1,  0, -1};

void solve()
{
	p pos;
	while(cin >> pos.first >> pos.second, pos.first || pos.second)
	{
		queue<p> states;
		states.push(pos);
		int n;
		cin >> n;
		vector<p> sp(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> sp[i].first >> sp[i].second;
		}
		bool flag = true;
		for(int i = 0; i < n; ++i)
		{
			if(states.size() == 0)
			{
				flag = false;
				break;
			}
			queue<p> next_states;
			while(states.size())
			{
				pos.first = states.front().first;
				pos.second = states.front().second;
				states.pop();
				p np;
				for(int j = 0; j < 12; ++j)
				{
					np.first = pos.first + dx[j];
					np.second = pos.second + dy[j];
					if((0 <= np.first && np.first <= 9 && 0 <= np.second && np.second <= 9) &&
					   (sp[i].first - 1 <= np.first && np.first <= sp[i].first + 1) &&
					   (sp[i].second - 1 <= np.second && np.second <= sp[i].second + 1))
					{
						next_states.push(p(np.first, np.second));
					}
				}
			}
			while(next_states.size())
			{
				states.push(next_states.front());
				next_states.pop();
			}
		}
		if(!flag || states.size() == 0)
		{
			cout << "NA" << endl;
		}
		else
		{
			cout << "OK" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1208
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int data[n];
  for(int i=0;i<n;i++) cin >> data[i];
  for(int i=n-1;i>=0;i--) cout << (i!=n-1?" ":"") << data[i];
  cout << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int N, T; cin >> N >> T;
	vector<int> cost;
	rep(i, 0, N - 1)
	{
		int c, t; cin >> c >> t;
		if (t <= T)cost.push_back(c);
	}
	if (cost.size() == 0)cout << "TLE" << endl;
	else
	{
		sort(all(cost));
		cout << cost[0] << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)


{


int a,b,c;


int count=0;


int i;


scanf("%d %d %d",&a,&b,&c);


for(i=a;i<=b;i++)


{


if(c%i==0) count++;


}


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


return 0; 


}

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

int main()
{
    ll a,b,c,d=0;
    cin>>a>>b;
    while(a--)
    {
        cin>>c;
        if(c>=b)
        {
            d++;
        }
    }
    cout<<d<<endl;
}


Measured memory_bytes: 256
N=int(input())
mod=10**9+7

import math
FACT=dict()

for x in range(1,N+1):
    L=int(math.sqrt(x))



    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1

ANS=1
for j in FACT.values():
    ANS=ANS*(j+1)%mod

print(ANS)

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

int main() {
	// your code goes here
	double rad;
	double deg;
	double k;
	const long double pi = (acos(-1));
	double a,b,x;
	cin>>a>>b>>x;
	if(x<=(a*a*b)/2.0){
	k=(2.0*x)/(a*b*b);
	rad=atan(k);
	deg=(rad)/pi*180.0;
	cout<<fixed<<setprecision(10)<<(double)90-deg<<endl;
	}
	else{
	    k=(2.0*((a*a*b)-x))/(a*a*a);
	    rad =atan(k);
	    deg=(rad)/pi*180.0;
	    cout<<fixed<<setprecision(10)<<deg<<endl;
	    
	}

	return 0;
}


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

int main(void){
    long long int a,b,c,k;
    cin >> a >> b >> c >> k;
    long long int ans = 0;
    if(k <= a){
        ans = k;
    } else{
        ans += a;
        k -= a;
        if(k <= b){

        } else {
            k -= b;
            ans -= k;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;
const int N=350;

int a[N][N],n,m,now[N],cnt[N],del[N];

int main(){
	
	int i,j,k,flag;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	
	for(i=1;i<=n;i++){
		memset(del,0,sizeof(del));
		for(j=1;j<=n;j++)
			now[j]=1;
		while(1){
			memset(cnt,0,sizeof(cnt));
			for(j=1;j<=n;j++)
				cnt[a[j][now[j]]]++;
			int mx=0,mxn=0;
			for(j=1;j<=m;j++){
				if(cnt[j]>mx){
					mx=cnt[j];
					mxn=j;
				}
			}
			if(mx>i){
				flag=0,del[mxn]=1;
				for(j=1;j<=n;j++){
					while(del[a[j][now[j]]])
						now[j]++;
					if(now[j]>m){
						flag=1;
						break;
					}
					
				}
				if(flag)
					break;
			}else{
				for(j=1;j<=n;j++)
					if(now[j]>m)
						break;
				if(j>n)
					flag=2;
				break;
			}
		}
		if(flag==2)
			break;
	}
	
	printf("%d\n",i);

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5&&b==5&&c==7)
	{
		printf("YES\n");
		return 0;
	}
	if(a==5&&b==7&&c==5)
	{
		printf("YES\n");
		return 0;
	}
	if(a==7&&b==5&&c==5)
	{
		printf("YES\n");
		return 0;
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll mod = 1000000007;


// 文字列 s に含まれる 'AB' の数を数える
int count_ab(const string& s) {
  int count = 0;
  string find_word("AB");
  auto pos = s.find(find_word);
  while (pos != string::npos) {
    count++;
    pos = s.find(find_word, pos + find_word.size());
  }
  return count;
}

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  vector<int> black(n, 0);
  vector<int> white(n, 0);

  int ans = INF;
  int n_black = 0;
  int n_white = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '.') {
      n_white++;
      if (i == 0) black[i] = 0;
      else black[i] = black[i-1];
    }
    if (s[i] == '#') {
      n_black++;
      if (i == 0) black[i] = 1;
      else black[i] = black[i-1] + 1;
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '.') {
      if (i == n - 1) white[i] = 1;
      else white[i] = white[i+1] + 1;
    }
    if (s[i] == '#') {
      if (i == n - 1) white[i] = 0;
      else white[i] = white[i+1];
    }
  }

  chmin(ans, n_white);
  chmin(ans, n_black);

  for (int i = 0; i < n - 1; i++) {
    chmin(ans, black[i] + white[i+1]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2196
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long ans = syakutori(a, n);
        System.out.println(ans);
    }
    public static long syakutori(long[] a, int n) {
        int right = 0;
        long res = 0;
        long sum = 0;
        for (int left = 0; left < n; left++) {
            while (right < n && (sum ^ a[right]) == sum + a[right]) {
                sum += a[right];
                right++;
            }
            res += Math.max(0, right - left);
            sum -= a[left];
        }
        return res;
    }
}


Measured memory_bytes: 86860
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1<<31
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> p(m);
  vector<string> s(m);
  for(int i=0;i<m;i++) cin>>p[i]>>s[i];

  vector<long long> cnt(n);
  for(int i=0;i<n;i++) cnt[i]=0;
  long long pena =0;
  long long ac =0;
  for(int i=0;i<m;i++){
    if(cnt[p[i]-1]!=INF){
      if(s[i] == "WA"){
        cnt[p[i]-1]++;
      }else if(s[i] == "AC"){
        pena += cnt[p[i]-1];
        ac++;
        cnt[p[i]-1] = INF;
      }
    }
  }
  cout << ac << " "<< pena << endl;
}


Measured memory_bytes: 6912
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int h, w;
	bool a = true;
	bool b= true;
	while (true) {
		cin >> h>> w;
		if (h == 0 && w == 0) break;
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if(a){
				    cout << "#";
				    a = false;
				}else{
				    cout << ".";
				    a = true;
				}
			
			}
			if(b){
			    a = false;
			    b= false;
			}else{
			    a = true;
			    b=true;
			}
			cout << endl;

		}
		cout << endl;
		a = true;
			    b=true;
	}
}


Measured memory_bytes: 3116
/*
g++ -ggdb -fsanitize=address -std=c++14 E.cpp && ./a.out <<< "5
1 2 3 9 24"
*/

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

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// Source: https://codeforces.com/blog/entry/62393
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const ll MOD = 1000000007LL;

ll modPow(ll x, ll exp, ll mod) {
    ll ret = 1;
    while (exp > 0) {
        if (exp % 2 == 1) ret = ret * x % mod;
        x = x * x % mod;
        exp /= 2;
    }
    return ret;
}

ll modInverse(ll x, ll mod) { return modPow(x, mod - 2LL, mod); }

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n; cin >> n;
    vector<ll> A(n); rep(i, 0, n) cin >> A[i];

    ll lim = *max_element(A.begin(), A.end());

    vector<ll> firstPrimeDiv(lim + 1);
    rep(i, 0, lim + 1) firstPrimeDiv[i] = i;
    for (int a = 2; a <= lim; a++)
        if (firstPrimeDiv[a] == a)
            for (int b = a + a; b <= lim; b += a)
                if (firstPrimeDiv[b] == b)
                    firstPrimeDiv[b] = a;

// rep(i, 0, lim + 1) printf("firstPrimeDiv[%d] = %lld\n", i, firstPrimeDiv[i]);

    unordered_map<ll, int, custom_hash> Q;
    trav(a, A) {

        ll x = a;
        while (x > 1) {
            ll p = firstPrimeDiv[x];
            int pow = 0;
            while (x % p == 0) {
                x /= p;
                pow++;
            }
// printf("a = %lld, p = %lld, pow = %d\n", a, p, pow);
            if (Q.find(p) == Q.end())
                Q[p] = pow;
            else
                Q[p] = max(Q[p], pow);
        }

    }

// printf("NOK:"); trav(kvp, Q) printf(" %lld^%d", kvp.first, kvp.second); cout << endl;

    ll nok = 1;
    trav(kvp, Q) {
        nok = nok * modPow(kvp.first, kvp.second, MOD) % MOD;
    }

// printf("NOK = %lld\n", nok);

    ll ans = 0;
    trav(a, A) {
        ans = (ans + nok * modInverse(a, MOD) % MOD) % MOD;
    }

    cout << ans << endl;
}

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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

ll n;
ll d, a;
ll j;
ll pref_arr[200005];

array<int, 2> monster[200005];


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

    ll ans=0;

    cin >> n >> d >> a;

    for(int i=0; i<n; i++) cin >> monster[i][0] >> monster[i][1];

    sort(monster, monster+n);

    for(int i=0; i<n; i++) {
        j=n;
        for(int x=n; x>0; x>>=1)
            while(j-x>=0 && monster[j-x][0]>monster[i][0]+2*d) j-=x;
        ll need = max((monster[i][1]-pref_arr[i]*a+a-1)/a, 0ll);
        ans+=need;
        pref_arr[i]+=need;
        pref_arr[j]-=need;
        pref_arr[i+1]+=pref_arr[i];
    }

    cout << ans << endl;




    


    return 0;

}



Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 998244353;
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) vi x(n); forn(i,0,n) scanf("%d", &x[i])

#define pb push_back
#define mp make_pair

map<string, ll> full, ans;

ll getfull(string s);

ll get(string s) {
    if(ans[s] != 0) return ans[s];
    int n = s.size();
    if(n==1) {
        if(s=="0") full[s] = 1,ans[s] = 1;
        else full[s] = 2, ans[s] = 2;
        return ans[s];
    }
    ll fs = 0;
    forn(k,2,n+1) {
        if(n%k != 0) continue;
        int len = n/k;
        string add = s.substr(0,len);
        forn(i,len,n) {
            if(s[i] == '0') add[i%len] = '0';
        }
        fs += get(add);
    }
    fs %= mod;
    full[s] = fs;
    forn(i,1,n) fs = (fs + getfull(s.substr(0,i)) * get(s.substr(i))) % mod;
    ans[s] = fs;
    return fs;
}

ll getfull(string s) {
    get(s);
    return full[s];
}

int main()
{
    string s;
    getline(cin, s);
    cout<<get(s);
    
}


Measured memory_bytes: 14720
K,N = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

B = [0]*N
for i in range(N-1):
    B[i] = A[i+1] - A[i]
B[N-1] = A[0]+(K-A[N-1])

print(sum(B) - max(B))


Measured memory_bytes: 100136
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 1 << 15;

    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;

    void _update_input_buffer() {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;

        if (input_len == 0)
            input_buffer[0] = EOF;
    }

    inline char next_char(bool advance = true) {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template<typename T>
    inline void read_int(T &number) {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }
}

template<typename T1, typename T2>
bool maximize(T1 &a, const T2 &b) {
    if (b > a) {
        a = b;
        return true;
    }

    return false;
}

struct prefix_max_fenwick_tree {
    int tree_n;
    vector<long long> tree;

    prefix_max_fenwick_tree(int n = 0) {
        if (n > 0)
            init(n);
    }

    void init(int n) {
        tree_n = n;
        tree.assign(tree_n + 1, 0);
    }

    // index is in [0, tree_n).
    void update(int index, long long value) {
        for (int i = index + 1; i <= tree_n; i += i & -i)
            maximize(tree[i], value);
    }

    // Returns the max of the range [0, count).
    long long query(int count) const {
        long long result = 0;

        for (int i = count; i > 0; i -= i & -i)
            maximize(result, tree[i]);

        return result;
    }
};


int N;
vector<int> H, A;

int main() {
    IO::read_int(N);
    H.resize(N);
    A.resize(N);

    for (int &h : H)
        IO::read_int(h);

    for (int &a : A)
        IO::read_int(a);

    prefix_max_fenwick_tree tree(N);
    long long answer = 0;

    for (int i = 0; i < N; i++) {
        long long value = tree.query(H[i]) + A[i];
        maximize(answer, value);
        tree.update(H[i], value);
    }

    printf("%lld\n", answer);
}


Measured memory_bytes: 3456
using System;

namespace ABC130A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            var X = int.Parse(input[0]);
            var A = int.Parse(input[1]);

            Console.WriteLine(X < A ? 0 : 10);
        }
    }
}

Measured memory_bytes: 11092
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    int x=(n%10);
    if(x==3) cout<<"bon";
    else if(x==0||x==1||x==6||x==8) cout<<"pon";
    else cout<<"hon";
    cout<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <queue>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll          = long long;
using db          = double;
using ld          = long double;
using uint        = unsigned int;
using ull         = unsigned long long;

using pii         = pair<int, int>;
using pll         = pair<ll, ll>;
using tiii        = tuple<int, int, int>;

#define mod7        1000000007
#define mod9        1000000009

#define forall(v)   v.begin(), v.end()
#define prec(x)     setprecision(x) << fixed

/* [💭] [💡] [🎈] */

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

    int l;
    cin >> l;

    string a, b, c;
    cin >> a >> b >> c;

    int s = 0;
    for (int i = 0; i < l; i++) {
        char x = a[i], y = b[i], z = c[i];

        if (x == y && y == z) {
            continue;
        } else if (x == y || y == z || z == x) {
            s++;
        } else {
            s += 2;
        }
    }

    cout << s;

    return 0;
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    string S,T;
    cin >> S >> T;

    int ans=0;
    for(int i=0;i<S.length();i++){
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;
const string RGB = "RGB"; 

int main() {
   int n, q; scanf("%d%d", &n, &q);
   vector<vector<int>> e(n + 1, vector<int>());
   for (int i = 1; i < n; ++i) {
      int a, b; scanf("%d%d", &a, &b);
      e[a].pb(b); e[b].pb(a);
   }
   vector<int> val(n + 1);
   for (int i = 0; i < q; ++i) {
      int p, x; scanf("%d%d", &p, &x);
      val[p] += x;
   }
   vector<bool> visited(n + 1); visited[1] = true;
   queue<int> f; f.push(1);
   while (!f.empty()) {
      int cur = f.front(); f.pop();
      for (int i : e[cur]) {
         if (!visited[i]) {
            val[i] += val[cur];
            visited[i] = true;
            f.push(i);
         }
      }
   }
   for (int i = 1; i <= n; ++i)
      printf("%d ", val[i]);
   return 0;
}

Measured memory_bytes: 15604
def to_infinity(S: str, K: int) -> str:
    """5000兆 = 5e15 であり、文字 n は 5e15 日後には n^(5e15) の長さになっている。
    これは 2^100 = 10^30 より、K の範囲には確実に収まらない。
    """
    if K == 1:
        return S[0]
    # K > 1
    if len(S) == 1:
        return S[0]
    # K > 1 and |S| > 1
    for k in range(K):
        if k >= len(S):
            return '1'
        if S[k] != '1':
            return S[k]
    return '1'


if __name__ == "__main__":
    S = input()
    K = int(input())
    ans = to_infinity(S, K)
    print(ans)


Measured memory_bytes: 3060
# maximum flow
# O(EV^2)

class Dinic():
    def __init__(self, N, INF=10**18):
        self.INF = INF
        self.graph = [{} for _ in range(N)]
        self.N = N
        self.level = [-1]*N
    
    def add_edge(self, u, v, cap, undirected=False):
        # u -> v (maxflow: cap)
        if cap == 0: return
        if undirected:
            self.graph[u][v] = cap
            self.graph[v][u] = cap
        elif v in self.graph[u]:
            self.graph[u][v] = cap
        else:
            self.graph[u][v] = cap
            self.graph[v][u] = 0
    
    def construct(self):
        self.orderedgraph = [[] for _ in range(self.N)]
        for v in range(self.N):
            self.orderedgraph[v] = list(self.graph[v].keys())

    # make level
    def bfs(self, start):
        self.level = [-1]*self.N
        self.que = [start]
        self.level[start] = 0
        while self.que:
            qq = []
            for p in self.que:
                for np, ncap in self.graph[p].items():
                    if ncap > 0 and self.level[np] == -1:
                        self.level[np] = self.level[p] + 1
                        qq.append(np)
            self.que = qq

    def dfs(self, start, finish):
        self.Flow = [self.INF]*self.N
        self.iter = [0]*self.N
        self.Par = [-1]*self.N
        self.stack = [start]
        while self.stack:
            v = self.stack.pop()
            if v == finish:
                d = self.Flow[v]
                while v != start:
                    nv = self.Par[v]
                    self.graph[nv][v] -= d
                    self.graph[v][nv] += d # inverse edge
                    v = nv
                return d
            # for nv, ncap in self.graph[v].items():
            for i in range(self.iter[v], len(self.orderedgraph[v])):
                self.iter[v] = i
                nv = self.orderedgraph[v][i]; ncap = self.graph[v][nv]
                if ncap > 0 and self.level[v] < self.level[nv]:
                    self.stack.append(nv)
                    self.Par[nv] = v
                    self.Flow[nv] = min(self.Flow[v], ncap)
        return 0

    # solve
    def flow(self, start, finish):
        self.construct()
        flow = 0
        while True:
            self.bfs(start)
            if self.level[finish] < 0: return flow
            while True:
                f = self.dfs(start, finish)
                if f == 0: break
                flow += f


if __name__=="__main__":
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    ff = Dinic(N)
    for _ in range(M):
        a, b, c = map(int, input().split())
        ff.add_edge(a, b, c)
    print(ff.flow(0, N-1))



Measured memory_bytes: 5740