akhauriyash/Code-Regression huggingface dataset:
import sys
sa = list(input())
sb = list(input())
sc = list(input())

def turn(s,n):
  if len(s)==0:
    print(n)
    sys.exit()
  tmp = s.pop(0)
  if tmp == "a":
    turn(sa,"A")
  elif tmp == "b":
    turn(sb,"B")
  elif tmp == "c":
    turn(sc,"C")
    
turn(sa,"A")

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

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

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int x = input(), y = input() / 2;
    cout << x + y << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>


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

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for(ll i=2; i*i<=n; i++){
    if(n%i) continue;
    res.emplace_back(i, 0);

    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1);
  return res;
}

int main(){
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll a,b,c;cin>>a>>b>>c;
    cout<<min({a*b*(c-c/2-c/2),b*c*(a-a/2-a/2),c*a*(b-b/2-b/2)});   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
using namespace std;
int main(){
int a,b;
cin >> a >> b;
cout << "100 100\n";
REP(i,100){
REP(j,100) i<50 ? cout << (i%2&&j%2&&--a>0 ? "." : "#") : cout << (i%2&&j%2&&--b>0 ? "#" : ".");
cout << "\n";
}
}


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

using namespace std;
int main() {
    string s, s1;
    cin >> s >> s1;

    vector<vector<int>> dp(s.length() + 1, vector<int>(s1.length() + 1, 0));

    for (int i = 1; i <= s.length(); i++) {
        for (int j = 1; j <= s1.length(); j++) {
            // if character matches
            if (s.at(i - 1) == s1.at(j - 1)) {
                // let matching character = c
                // pick: dp[i - 1][j - 1] + c, dp[i - 1][j], dp[i][j - 1]
                if (dp[i - 1][j] < dp[i - 1][j - 1] + 1) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else dp[i][j] = dp[i - 1][j];

                if (dp[i][j - 1] > dp[i][j]) {
                    dp[i][j] = dp[i][j - 1];
                }
            } else {
                // otherwise pick dp[i - 1][j], dp[i][j - 1]
                if (dp[i - 1][j] >= dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                } else dp[i][j] = dp[i][j - 1];
            }
        }
    }

    string res;
    int i = s.length(), j = s1.length();
    while (i > 0 && j > 0) {
        if (s.at(i - 1) == s1.at(j - 1)) {
            res += s.at(i - 1);
            i--;
            j--;
            continue;
        }
        if (dp[i - 1][j] >= dp[i][j - 1]) {
            i--;
        } else {
            j--;
        }
    }

    reverse(res.begin(), res.end());
    cout << res;
}

Measured memory_bytes: 35584
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define VI(v,n) vector<int> v(n)



int main() {
	long long n, a, b;
	cin >> n >> a >> b;

	if (a > b) {
		cout << 0 << endl;
	}
	else if ( n == 1) {
		if (a != b) {
			cout << 0 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
	
	else {
		cout << (b - a)*(n - 2) + 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b
import bisect

n = getN()
pres = getlist()
needs = getlist()

mores = []
for i in range(len(pres)):
    mores.append(pres[i] - needs[i])

ans = 0
mores.sort(reverse=False)

div = bisect.bisect_left(mores, 0)

ans += div
husoku = -(sum(mores[:div]))

amari = mores[div:]#.sort(reverse=True)
if type(amari) == int:
    amari = [amari]
amari.sort(reverse=True)

if sum(amari) < husoku:
    ans = -1
else:
    if husoku > 0:
        for a in amari:
            ans += 1
            if a >= husoku:
                break
            else:
                husoku -= a

print(ans)



Measured memory_bytes: 18652
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    ll n, k;
    
    cin >> n >> k;
    ll ara[n];
    for(ll K=0; K<n; K++) cin >> ara[K];
    
    for(ll K=k; K<n; K++){
		if(ara[K]>ara[K-k]){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
	}
}


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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}


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

void insertionSort(int a[], int N){
  for(int i=1;i<N;i++){
    int v =a[i];
    int j = i-1;
    while(j>=0 && a[j]>v){
      a[j+1] =a[j];
      j--;
    }
    a[j+1]=v;
    for(int k=0;k<N;k++){
      if(k==N-1) cout<<a[k]<<endl;
      else cout <<a[k]<<" ";
    }
  }
}

int main() {
  int N;
  cin>>N;
  int a[N];
  for (int j = 0; j < N; j++) cin>>a[j];

  for(int k=0;k<N;k++){
      if(k==N-1) cout<<a[k]<<endl;
      else cout <<a[k]<<" ";
    }
  insertionSort(a,N);

  }



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll x;
	ll ans=0LL;
	cin >>x;
	ll sum=0LL;
	int i;
	for( i=1;sum<x;i++){
		sum+=i;
	}
	cout<<i-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<queue>
//int[1e7] ll[5*1e6]
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

int ans,a[111],n,tmp;

inline bool cmp(int x,int y){return x < y;}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> n;
    for(register int i = 1;i <= n;++i){
        cin >> a[i];
    }
    ans = 1e9 + 9;
    std::sort(a+1,a+n+1,cmp);
    for(register int i = 1;i <= a[n];++i){
        tmp = 0;
        for(register int j = 1;j <= n;++j){
            tmp += std::abs(a[j] - i) * std::abs(a[j] - i);
        }
        ans = tmp < ans ? tmp : ans;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*16
#define mod 1000000007
#define int long long 
int h,n,p[nn],ans=0;
int m;int tag[nn];
void move(int x,int road){
	road=road*x%mod;
	tag[x]=(tag[x]+road)%mod;
	if(x/2) move(x/2,road);
}
void clsmove(int x,int road){
	road=road*x%mod;
	tag[x]=0;
	if(x/2) clsmove(x/2,road);
}
void goleft(int x,int l,int road){
	road=road*x%mod;
	if(l==h-1){
	//	cout<<x<<"="<<m<<":"<<p[x-m]+m<<"\n";
		move(p[x-m]+m,road);
	}
	else{
		goleft(x<<1,l+1,road);
		goleft(x<<1|1,l+1,road);
	}
}
void clsleft(int x,int l,int road){
	road=road*x%mod;
	if(l==h-1){
		clsmove(p[x-m]+m,road);
	}
	else{
		clsleft(x<<1,l+1,1);
		clsleft(x<<1|1,l+1,1);
	}
}
void ask(int x,int road){
	if(x==1) return ;
	int y=x^1;
	road=road*x%mod;
	ans=(ans+tag[y]%mod*road%mod*(x/2))%mod;
	if(x/2) ask(x/2,road);
}
void goright(int x,int l,int road){
	road=road*x%mod;
	if(l==h-1){
		ask(p[x-m]+m,road);
	}
	else{
		goright(x<<1,l+1,road);
		goright(x<<1|1,l+1,road);
	}
}
void dfs(int x,int l){
	if(l!=h-1){
		goleft(x<<1,l+1,1);
		goright(x<<1|1,l+1,x);
		clsleft(x<<1,l+1,1);
	//	memset(tag,0,sizeof tag);
		dfs(x<<1,l+1);
		dfs(x<<1|1,l+1);
	}
}
signed main(){
	scanf("%lld",&h);n=(1<<h-1);m=n-1;
	for(int i=1;i<=n;i++) scanf("%lld",&p[i]);
	dfs(1,0);
	printf("%lld\n",(ans%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 6880
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = ns()
    uf = UnionFind(n)

    for _ in range(m):
        x, y, z = ns()
        uf.union(x - 1, y - 1)

    ans = uf.group_count()
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15876
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(c) c.begin(),c.end()

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<int> a(N);
  REP(i, N) {
    cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  REP(i, N) {
    if (a[a[i]] == i) ans++;
  }
  cout << ans/2 << endl;
  return 0;
}

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

int main(){
 string S; cin >> S;
  int count[20] ={0};
  int j = 0;
  
  for(int i=0;i<S.length();i++){
    if(S[i] == 'A'||S[i] == 'C'||S[i] == 'G'||S[i] =='T'){
      count[j]++;
    }
    else{
      j++;
    }
  }
  
  int max =0;
  for(int i=0;i<20;i++){
    if(max < count[i]){
      max = count[i];
    }
  }
  cout  << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<map>

using namespace std;

int dp[1000][7]; 
char charge[1001], att[7][4] = { "J", "O", "I", "JO", "JI", "OI", "JOI" };
int a;

int ny(char c[4], char ch){
	int i = 0;
	while (c[i]!='\0'){
		if (c[i] == ch)return 1;
		i++;
	}
	return 0;
}

int ans(int n, int m){
	int ret = 0;
	if (dp[n][m] > 0)return dp[n][m];
	if (ny(att[m], charge[n])){
		if (n == a - 1)return 1;
	}
	else return 0;
	for (int j = 0; j < 7; j++){
		int k = 0,flag=0;
		while (att[m][k] != '\0'){
			if (ny(att[j], att[m][k])){
				flag = 1;
				break;
			}
			k++;
		}
		if (flag){
			ret += ans(n + 1, j);
			ret %= 10007;
		}
	}
	return dp[n][m]=ret;
}

int main(){
	scanf("%d",&a);
	cin >> charge;
	printf("%d\n", (ans(0, 0) + ans(0, 3) + ans(0, 4) + ans(0, 6))%10007);
	return 0;
}

Measured memory_bytes: 1308
c='753'
def dfs(s,L):
    global c
    li.append(s)
    if(len(s)==L):
        return
    for i in range(3):
        dfs(s+c[i],L)

N=int(input())
L=len(str(N))
li=[]
dfs('',L)
ans=0
for x in li:
    if(x==''):
        continue
    if(int(x)<=N and '7' in x and '5' in x and '3' in x):
        ans+=1
print(ans)

Measured memory_bytes: 5144
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>

using namespace std;
typedef long long ll;

const ll mod = 1000000007;

int cycle(int k, int P){
	if(k > P){
		return k-P;
	}else if(k <= 0){
		return k+P;
	}else{
		return k;
	}
}

int main()
{
	int N, x;
	cin >> N >> x;
	
	list<int> v;
	
	if(x <= 1 || x >= 2*N-1){
		cout << "No" << endl;
	}else{
		v.push_back(x);
		for(int i = 1; i <= N-1; i++){
			v.push_back(cycle(x + i, N*2-1));
			v.push_front(cycle(x-i, N*2-1));
		}
		
		cout << "Yes" << endl;
		for(auto itr = v.begin(); itr != v.end(); itr++){
			cout << *itr << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7808
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

x = INT()
ans = 0
ans += x // 11 * 2
x %= 11
if 0 < x <= 6:
    ans += 1
elif 7 <= x:
    ans += 2
print(ans)


Measured memory_bytes: 3892
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s;
  cin >> s;
  string t = "KIHBR$$$$";
  int cnt = 0, tmp = 0;
  if(s.size() >= 10) {
    cout << "NO" << endl;
    return 0;
  }
  REP(i, s.size()) {
    // cout << i << " " << s[i] << " " << cnt << " " << tmp << endl;
    if(s[i] == 'A') i++, tmp++;
    else tmp = 0;
    if(tmp > 1 || (cnt == 1 && tmp > 0) || (cnt == 2 && tmp > 0)) {
      // cout << tmp << ":" << cnt << endl;
      cout << "NO" << endl;
      return 0;
    }
    if(s[i] != 'A') tmp = 0;
    if(i<s.size() && s[i] != t[cnt++]) {
      // cout << i << "," << cnt << 10endl;
      cout << "NO" << endl;
      return 0;
    }
  }
  if(cnt != 5) cout << "NO" << endl;
  else cout << "YES" << endl;

  return 0;
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m,0));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

#ifdef _TEST
void test();
#endif

void Main()
{
	int H,W,K;
	cin>>H>>W>>K;
	vecvec(c,H,W);
	char t;
	rep(i,H){
		rep(j,W){
			cin>>t;
			if(t=='#')c[i][j]=false;//黒
			else c[i][j]=true;
		}
	}

	ll ans=0;
	//dout<<bitset<8>((1<<7)-1)<<_n;

	rep(i, (1<<H)){
		rep(j,(1<<W)){
			int cnt=0;
			rep(k,H){
				rep(l,W){
					if((c[k][l]==false) && !(i&(1<<k)) && !(j&(1<<l)))cnt++;
				}
			}
			if(cnt==K){
				ans++;
				dout<<"i:"<<bitset<8>(i)<<"  j:"<<bitset<8>(j)<<_n;
			}
			
		}
	}
	cout<<ans<<endl;
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
#ifndef _TEST
	Main();
#else
#endif
	return 0;
}

#ifdef _TEST
int test(){

}
#endif

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



int main() {

	int n;
	cin >> n;

	vector<int64_t> lucas(87);

	lucas.at(0) = 2;
	lucas.at(1) = 1;

	for(int i=2; i<87; i++){
		lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
	}

	cout << lucas.at(n);
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var b int
		fmt.Scan(&b)

		for i, array := range a {
			for j, val := range array {
				if val == b {
					a[i][j] = -1
				}
			}
		}
	}
	ans := false
	for i := 0; i < 3; i++ {
		cnt := 0
		for j := 0; j < 3; j++ {
			if a[i][j] == -1 {
				cnt++
			}
		}
		if cnt == 3 {
			ans = true
		}
	}

	for i := 0; i < 3; i++ {
		cnt := 0
		for j := 0; j < 3; j++ {
			if a[j][i] == -1 {
				cnt++
			}
		}
		if cnt == 3 {
			ans = true
		}
	}
	cnt := 0
	for i := 0; i < 3; i++ {
		if a[i][i] == -1 {
			cnt++
		}
	}
	if cnt == 3 {
		ans = true
	}

	cnt = 0

	for i := 0; i < 3; i++ {
		if a[i][2-i] == -1 {
			cnt++
		}
	}
	if cnt == 3 {
		ans = true
	}

	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
# coding: utf-8
N, K = map(int, input().split())
mod = 10**9 + 7
A = list(map(int, input().split()))
l = []
for i in range(N):
    tmp = [0, 0]
    for j in range(N):
        if j < i:
            if A[i] < A[j]:
                tmp[0] += 1
        else:
            if A[i] < A[j]:
                tmp[1] += 1
    l.append(tmp[:])
ans = 0
for i in range(N):
    ans += l[i][0]*K*(K+1) // 2
    ans %= mod
    ans += l[i][1] * K * (K - 1) // 2
    ans %= mod
print(ans % mod)

Measured memory_bytes: 3320
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007

typedef long long ll;
ll mod;
vector<vector<ll>> matmul(vector<vector<ll>> a, vector<vector<ll>> b){
    vector<vector<ll>> r(3, vector<ll>(4,0));
    rep(i,3) rep(j,3){
        rep(k,3) r[i][j] = (r[i][j] + (a[i][k]*b[k][j])) % mod;
    }
    return r;
}

vector<vector<ll>> matpow(vector<vector<ll>> a, ll b){
    if(b==0){
        vector<vector<ll>> r ={{1,0,0},{0,1,0},{0,0,1}};
        return r;
    }else if(b==1){
        return a;
    }
    vector<vector<ll>> r = matpow(a, b>>1);
    if(b%2 == 1)
        return matmul(a, matmul(r,r));
    else
        return matmul(r,r);
}
vector<ll> matact(vector<vector<ll>> a, vector<ll> v){
    vector<ll> rv(3);
    rep(i,3) rep(j,3) rv[i] = (rv[i] + a[i][j]*v[j]) % mod;
    return rv;
}

ll powll(ll a,ll n){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a){
        if(n%2==1)ret=(ret*a);
    }
    return ret;
}
int main(){
    ll l,a,b,m; cin >> l >> a >> b >> mod;
    vector<long long int> c(19);
    c[0] = 0;
    for(ll i=1;i<19;i++){
        ll tp = powll(10,i);
        tp--;
        if(tp-a < 0) tp = 0;
        else tp = (tp-a)/b;
        c[i] = tp+1;
    }
//   cout << "c :";
  //  for(auto x: c) cout << x << " ";
    //cout << endl;
    vector<ll> ans = {0,a%mod,b%mod};
    for(ll i=1;i<19;i++){
        ll cd = c[i] - c[i-1];
        if(l <= cd){cd = l; l=0; }
        else l -= cd;
        vector<vector<ll>> mat = {
            {powll(10,i)%mod, 1, 0},
            {0,1,1},
            {0,0,1}
        };
      // cout << cd << endl;
        vector<vector<ll>> mm = matpow(mat, cd);
        for(auto vv: mm){
       //     for(auto e: vv) cout << e << " ";
        //    cout << endl;
        }
        vector<ll> ma = matact(matpow(mat, cd), ans);
        //rep(i,3) cout << ma[i] << " ";
        //cout << endl;
        rep(i,3) ans[i] = ma[i]%mod;
        if(l==0) break;
    } 
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include <string.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll k,a,b;
  cin >> k >> a >> b;
  if(a+2>=b)cout << k+1 << endl;
  else{
    ll x=0;
    x=max(x,(k-(a-1))/2);
    cout << 1+x*(b-a)+min(a-1,k)+(k-(a-1))%2 << endl;
  }
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>

using namespace std;
using ll = long long;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, p; cin >> n >> p;
  string s; cin >> s;
  ll ans = 0;

  if(p == 2 || p == 5){
    for(int i = 0; i < n; i++){
      if((s[i]-'0')%p == 0){
        ans += i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  map<int, int> mp;
  vector<int> U(n+1, 0);
  mp[0] = 1;
  int ten = 1;
  for(int i = n-1; i >= 0; i--){
    U[i] = (U[i+1] + ((s[i]-'0')*ten)%p) % p;
    mp[U[i]]++;
    ten *= 10; ten %= p;
  }
  for(int i = 0; i < n; i++){
    mp[U[i]]--;
    ans += mp[U[i]];
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 1684
main :: IO ()
main = do
    n <- readLn
    mapM_ print $ solve n

solve :: Int -> [Int]
solve n = filter (\i -> sum [1 .. highest n] - i /= n) [1 .. highest n]

highest :: Int -> Int
highest n = head [ i | i <- [1 ..], i * (i + 1) `div` 2 >= n ]

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

typedef pair<ll,int> P;
vector<P> g[100010],g2[100010];
ll dist[100010],dist2[100010];

int main(){
    int n,m,s,t; scanf("%d%d%d%d",&n,&m,&s,&t);
    s--; t--;
    rep(i,0,m){
        int u,v,w,w2; scanf("%d%d%d%d",&u,&v,&w,&w2);
        u--; v--;
        g[u].push_back({v,w}); g[v].push_back({u,w});
        g2[u].push_back({v,w2}); g2[v].push_back({u,w2});
    }
    rep(i,0,n)dist[i]=dist2[i]=INF; dist[s]=0; dist2[t]=0;
    priority_queue<P,vector<P>,greater<P>> pq,pq2;
    pq.push({0,s});
    while(!pq.empty()){
        auto p=pq.top(); pq.pop();
        ll d=p.first; int v=p.second;
        if(dist[v]<d)continue;
        for(P to:g[v]){
            if(chmin(dist[to.first],dist[v]+to.second))pq.push({dist[to.first],to.first});
        }
    }
    pq2.push({0,t});
    while(!pq2.empty()){
        auto p=pq2.top(); pq2.pop();
        ll d=p.first; int v=p.second;
        if(dist2[v]<d)continue;
        for(P to:g2[v]){
            if(chmin(dist2[to.first],dist2[v]+to.second))pq2.push({dist2[to.first],to.first});
        }
    }
    vector<ll> ans(n);
    priority_queue<ll,vector<ll>,greater<ll>> pq3;
    rrep(i,n-1,-1){
        pq3.push(dist[i]+dist2[i]);
        ans[i]=pq3.top();
    }
    rep(i,0,n)printf("%lld\n",1000000000000000-ans[i]);
    return 0;
}

Measured memory_bytes: 20984
#include <stdio.h>

int main(void) {
	int n, x, count;
	int i, j, k;
	
	while (scanf("%d %d", &n, &x), n || x){
		count = 0;
		for (i = 1; i <= n; i++){
			for (j = i+1; j <= n; j++){
				for (k = j+1; k <= n; k++){
					if (i+j+k == x) count++;
				}
			}
		}
		printf("%d\n", count);
	}
		
	return 0;
}

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

using namespace std;

bool solve() {
  int N;
  string S;
  cin >> N >> S;
  return (N % 2 == 0) && S.substr(0, N / 2) == S.substr(N / 2, N - N / 2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cout << (solve() ? "Yes" : "No") << endl;
}


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

int main() {
	int n; cin >> n;
	rrep(i,1,1000001) {
		if(n==1||n==2||n==4) {
			cout << i+3 << endl;
			return 0;
		}
		if(n%2==0) n=n/2;
		else n=n*3+1;
	}
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define N 3005
#define p 1000000007
#define ll long long
using namespace std;

int a[N],f[2][N][N][2],tag[N][N][2],n,m,l[N],r[N],bin[N];

inline void get(int &x,int &y,int k)
{
	if(y<=x) return;
	f[1][x][y][0]=(ll)f[0][x][y][0]*bin[tag[x][y][0]-k]%p;
	f[1][x][y][1]=(ll)f[0][x][y][1]*bin[tag[x][y][1]-k]%p;
}

inline void tt(int &x,int &y,int &k)
{
	tag[x][y][0]=tag[x][y][1]=k;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=m;++i) scanf("%d%d",&l[i],&r[i]);
	bin[0]=1;
	for(int i=1;i<=m;++i) bin[i]=(bin[i-1]<<1)%p;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			f[0][i][j][0]=1,tag[i][j][0]=tag[i][j][1]=m+1;
	for(int k=m;k;k--)
	{
		if(l[k]>r[k]) swap(l[k],r[k]);
		int x=l[k],y=r[k];
		for(int i=1;i<=n;++i)
			get(x,i,k+1),get(y,i,k+1),
			get(i,x,k+1),get(i,y,k+1);
		f[0][x][y][0]=(f[1][x][y][0]+f[1][x][y][1])%p,tt(x,y,k);
		f[0][x][y][1]=(f[1][x][y][1]+f[1][x][y][0])%p;
		for(int j=x+1;j<=n;++j)
			if(j<y)
				f[0][x][j][0]=(f[1][x][j][0]+f[1][j][y][1])%p,tt(x,j,k),
				f[0][x][j][1]=(f[1][x][j][1]+f[1][j][y][0])%p;
			else if(j>y)
				f[0][x][j][0]=(f[1][x][j][0]+f[1][y][j][0])%p,tt(x,j,k),
				f[0][x][j][1]=(f[1][x][j][1]+f[1][y][j][1])%p;
		for(int i=1;i<y;++i)
			if(i<x)
				f[0][i][y][0]=(f[1][i][y][0]+f[1][i][x][0])%p,tt(i,y,k),
				f[0][i][y][1]=(f[1][i][y][1]+f[1][i][x][1])%p;
			else if(i>x)
				f[0][i][y][0]=(f[1][i][y][0]+f[1][x][i][1])%p,tt(i,y,k),
				f[0][i][y][1]=(f[1][i][y][1]+f[1][x][i][0])%p;
		for(int j=y+1;j<=n;++j)
			f[0][y][j][0]=(f[1][y][j][0]+f[1][x][j][0])%p,tt(y,j,k),
			f[0][y][j][1]=(f[1][y][j][1]+f[1][x][j][1])%p;
		for(int i=1;i<x;++i)
			f[0][i][x][0]=(f[1][i][x][0]+f[1][i][y][0])%p,tt(i,x,k),
			f[0][i][x][1]=(f[1][i][x][1]+f[1][i][y][1])%p;
//		for(int i=1;i<=n;++i)
//			for(int j=i+1;j<=n;++j)
//				get(i,j,k),printf("%d %d %d %d\n",i,j,f[1][i][j][0],f[1][i][j][1]);
	}
	int k=1;
	for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j)
				get(i,j,k);//,printf("%d %d %d %d\n",i,j,f[1][i][j][0],f[1][i][j][1]);
	int ans=0;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(a[i]>a[j]) ans=(ans+f[1][i][j][0])%p;//,printf("%d %d %d\n",i,j,f[1][i][j][0]);
			else if(a[j]>a[i]) ans=(ans+f[1][i][j][1])%p;//,printf("%d %d %d\n",i,j,f[1][i][j][1]);
	cout<<ans;
}


Measured memory_bytes: 211328
import itertools
a = int(input())
ar = ["3","5","7"]
c = 0
for i in range(3,len(str(a))+1):
    for j in itertools.product(ar,repeat=i):
        if j.count("3") >= 1 and j.count("5") >= 1 and j.count("7") >= 1:
            if a >= int("".join(list(j))):
                c += 1
print(c)

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

int main() {
	
	int n = 0;
	int b = 0, c = 0, d = 0, e = 0;
	int a[4][3][10];
	for (int h = 0;h < 4;h++) {
		for (int i = 0;i < 3;i++) {
			for (int j = 0;j < 10;j++) {
				a[h][i][j] = 0;
			}
		}
	}



	
	scanf("%d", &n);
	for (int i = 0;i < n;i++) {
		scanf("%d %d %d %d", &b, &c, &d, &e);
	    a[b - 1][c - 1][d - 1] += e;
	}


	for (int h = 0;h < 4;h++) {
		for (int i = 0;i < 3;i++) {
			for (int j = 0;j < 10;j++) {
				printf(" %d", a[h][i][j]);
			}
			printf("\n");
		}
		if (h != 3) {
			printf("####################\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2700
a,b,c=[int(i) for i in input().split()]
cnt=0
if c<=b:
    cnt=b+c
else:
    cnt+=min(b,c)*2
    c-=b
    if c>0:
        cnt+=min(a,c)
        c-=a
        if c>0:
            cnt+=1

print(cnt)

Measured memory_bytes: 3060
from collections import Counter
from itertools import combinations
from functools import reduce
from operator import mul
n = int(input())
S = [input()[0] for _ in range(n)]
S = [s for s in S if s in {"M","A","R","C","H"}]
cs = Counter(S)
ptn = combinations(cs.keys(), 3)

ans = 0
for p in ptn:
  arr = [cs[i] for i in p]
  ans += reduce(mul, arr)
print(ans)

Measured memory_bytes: 5252
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

bool isGood(ll n, ll k, const vi &a, const vi &f, ll m){
    ll cnt = 0;
    rep(i, n) cnt += max(0LL, a[i]-(ll)floor(1.0*m/f[i]));
    return (cnt <= k) ? true : false;
}

int main(){
    Init();
    ll n, k; cin >> n >> k;
    vi a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(all(a));
    sort(all(f), greater<ll>());

    // 目標スコアを二分探索
    ll r = 10e12 , l=-1;
    while(abs(r-l) > 1){
        ll m = (r+l)/2;
        isGood(n, k, a, f, m) ? r = m : l = m;
    }
    cout << r << endl;
}

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

sub main() {
  my($A,$B,$C)=split(/ /,<>);
  chomp($C);
  my $ans = prob($A,$B,$C);
  print $ans;
}

sub prob() {
  my($A,$B,$C) = @_;
  for my $i(1..$A){
    my $tmp = $B * $i + $C;
    if($tmp%$A == 0){
      return "YES";
    }
  }
  return "NO";
}

&main();

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

int main() {
    int a,b,c,d,e,k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    if(e-a > k){
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = new int[n];
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(input[i]);
        }

        int max = 0;
        int cnt = 0;
        for (int i = 0; i < n - 1; i++)
        {
            if(d[i] >= d[i+1])
            {
                cnt++;
            }
            else
            {
                max = Math.Max(max, cnt);
                cnt = 0;
            }
        }
        max = Math.Max(max, cnt);

        Console.WriteLine(max);
    }

   
}

Measured memory_bytes: 23004
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a,b;

int main(){
	cin >> a >> b;
	
	cout << (a+b)/2+(a+b)%2 << endl;
	return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
A=[list(input()) for i  in range(h)]
black=[] ;seen=[[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if A[i][j]=="#":
            black.append((i,j))
            
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
dx=[1,0,-1,0]
dy=[0,1,0,-1]
ans=0

# print(seen)

for i,j in black:
    # print(i,j)
    if seen[i][j]:continue
    seen[i][j]=1
    color=[0,1]
    queue= deque([(i,j,1)])
    while queue:
        x,y,c= queue.pop()
        # print(i,j,x,y,c)
        for xx,yy in zip(dx,dy):
            if 0<=x+xx<h and 0<=y+yy<w and seen[x+xx][y+yy]==0 and A[x+xx][y+yy]==".#"[1-c]:
                color[1-c]+=1
                seen[x+xx][y+yy]=1 
                queue.appendleft((x+xx,y+yy,1-c))
    ans+= color[0] * color[1]
print(ans)
    
    

Measured memory_bytes: 95720
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;

#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 SHOW(a) cout << #a << " = " << a << endl;

void solve(){
	int n, a, b, ans = 0;
	cin >> n >> a >> b;
	rep(i,n+1){
		string str = to_string(i);
		int sum = 0;
		for(char t : str){
			sum += t - '0';
		}
		if(a <= sum && sum <= b){
			ans += i;
		}
	}

	cout << ans << endl;
}

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

Measured memory_bytes: 256
using System;
using System.Linq;

namespace atcoder.abc170.c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputArray = getIntParams();
            int X = inputArray[0];
            int N = inputArray[1];

            int ret = 0;
            if (N == 0)
            {
                ret = X;
            }
            else
            {
                int[] paramArray = getIntParams();

                if (!paramArray.Contains(X))
                {
                    ret = X;
                }
                else
                {
                    for (int i = 1; i <= 100; i++)
                    {
                        if (!paramArray.Contains(X - i))
                        {
                            ret = X - i;
                            break;
                        }
                        if (!paramArray.Contains(X + i))
                        {
                            ret = X + i;
                            break;
                        }
                    }
                }
            }
            Console.WriteLine(ret);
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


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

int main(){

  int n;
  cin>>n;
  int a[10000];
  for(int i=0;i<n;i++) cin>>a[i];

  int mn = a[0], mx = a[0];
  long long sum = 0;
  for(int i=0;i<n;i++){
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout<<mn<<" "<<mx<<" "<<sum<<endl;

  return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
int a[114514];
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	int n;
	cin>>n;
	rep(0,i,n)cin>>a[i];
	sort(a,a+n);
	c(a[n/2]-a[n/2-1])
}


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

int main() {
    int K, X;
    cin >> K >> X;
    if (K * 500 >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int bubble(int *r, int n){
    int flag=1;
    int tmp;
    while(flag){
        flag=0;
        for(int i=n-1;i>0;i--){
            if(r[i]<r[i-1]){
                tmp=r[i];
                r[i]=r[i-1];
                r[i-1]=tmp;
                flag=1;
               
            }
        }
    }

    //for(int k=0;k<n;k++){
      //  if(k!=n-1) cout<<r[k]<<' ';
        //else cout<<r[k]<<endl;
    //}
    return 0;

}

long long int drr(long long int n, long long int k){
    long long int a, b;
    a = abs(n-k);
    b = abs(n+k);
    if(n<a && n<b && n>0) return n;
    else if(a<b) return drr(a, k);
    else return drr(b, k);
}


int main(){
    long long int n,k;
    cin>>n>>k;
    cout<<min(n%k, min(abs(n%k+k), abs(n%k-k)))<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10001
#define NIL -1

void Preorder(int);
void Inorder(int);
void Postorder(int);
typedef struct Node{int p,l,r;}Node;
Node T[MAX];
int n;
 
int main(){
  int i,u,l,r,id;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
    if(l != NIL) T[l].p = id;
    if(r != NIL) T[r].p = id;
  }
  for(i = 0; i < n; i++) if(T[i].p == NIL) u = i;
  printf("Preorder\n");
  Preorder(u);
  printf("\nInorder\n");
  Inorder(u);
  printf("\nPostorder\n");
  Postorder(u);
  printf("\n");
  return 0;
}
 
 
void Preorder(int u){
  if(u == NIL) return;
  printf(" %d",u);
  Preorder(T[u].l);
  Preorder(T[u].r);
}
 
void Inorder(int u){
  if(u == NIL) return;
  Inorder(T[u].l);
  printf(" %d",u);
  Inorder(T[u].r);
}
 
void Postorder(int u){
  if(u == NIL) return;
  Postorder(T[u].l);
  Postorder(T[u].r);
  printf(" %d",u);
}

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

void fnInput(string& rsNum, bool& rbRslt)
{
  int nDigit, nInfSiz;
  cin >> nDigit >> nInfSiz;
  rsNum.resize(nDigit, ' ');

  rbRslt = true;

  for (int i = 0; i < nInfSiz; i++)
  {
    int nPos, nNum;
    cin >> nPos >> nNum;

    if (nPos == 1 && nNum == 0 && nDigit > 1)
      rbRslt = false;
    else if (rsNum[nPos - 1] == ' ')
      rsNum[nPos - 1] = ('0' + nNum);
    else if (rsNum[nPos - 1] != ('0' + nNum) )
      rbRslt = false;
    else
      continue;
  }
  return;
}
  
string fnNumstrGet(string sNum)
{
  for (int i = 0; i < sNum.size(); i++)
    if (sNum[i] == ' ')
      if ( !i )
        if (sNum.size() == 1) sNum[i] = '0';
        else                  sNum[i] = '1';
      else                    sNum[i] = '0';

  return sNum;
}
  
int main()
{
  string sNum;
  bool bRslt;

  fnInput(sNum, bRslt);
  if (!bRslt)
    cout << "-1" << endl;
  else
    cout << fnNumstrGet(sNum) << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [ int(input()) for i in range(n)]
dp = [[0 for _ in range(n+1)] for _ in range(n) ]

for i in range(1, n + 1):
  dp[0][i] = s[0]

for i in range(1, n):
  for  j in range(n + 1):
    if (i == j):
      dp[i][j] = dp[i - 1][j]
    else:
      dp[i][j] = dp[i - 1][j] + s[i]

print(max([it if (it % 10 != 0) else 0 for it in dp[n - 1]]))

Measured memory_bytes: 38768
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int Z = 0;
  for(int i = 1; n-1 > i; i++){
    if(max({a[i-1],a[i],a[i+1]}) != a[i] && min({a[i-1],a[i],a[i+1]}) != a[i])Z++;
  }
  cout << Z << endl;
}
      


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

using namespace std;

#define ll long long

// aの下からk-bit目の数字を返す(0か1)
int bit(ll a, int k) {
	if (k > 60) return 0;
	if (a & (1LL << k))
		return 1;
	else
		return 0;
}

signed main() {
	ll a, b;
	cin >> a >> b;

	if (a == b) {
		cout << 1 << endl;
		return 0;
	}

	int dif = 60;
	while (bit(a, dif) == bit(b, dif))
		--dif;

	ll tmp = (1LL << (dif + 1)) - 1LL;
	a &= tmp;
	b &= tmp;

	ll ans = 0;
	ans += (1LL << dif) - a; // 0～の形

	if (a <= (b - (1LL << dif))) {
		ans += (1LL << dif);
		cout << ans << endl;
	}
	else {
		b -= (1LL << dif);
		ll br1, br2;
		if (b != 0) {
			int br1_ = 60;
			while (bit(b, br1_) == 0)
				--br1_;
			br1 = (1LL << (br1_ + 1)) - 1;
		}
		else {
			br1 = 0LL;
		}
		br2 = a;
		if (br2 > br1) {
			ans += (1LL << (dif)) - (br2 - br1 - 1);
			cout << ans << endl;
		}
		else {
			ans += (1LL << (dif));
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

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

int min(int X, int Y) {
    return X < Y ? X : Y;
}

int main() {
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);

    printf("%d\n", min(A, B) + min(C, D));

    return 0;
}


Measured memory_bytes: 128