akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N; scanf("%d", &N);
	int L;
	int sum = 0;
	int m = -1;

	REP(i,N){
		scanf("%d", &L);
		m = max(m,L);
		sum += L;
	}
	sum -= m;
	if(m<sum)
		printf("Yes\n");
	else
		printf("No\n");



	return 0;

}


Measured memory_bytes: 256
import numpy as np
import math
inp = [int(v) for v in input().split(' ')]
N = inp[0]
D = inp[1]
data = []
for i in range(N):
    data.append(np.array([float(v) for v in input().split(' ')]))

cnt = 0
for n1 in range(N):
    for n2 in range(n1 + 1, N):
        l = math.sqrt(np.sum((data[n1] - data[n2]) ** 2)) 
        if int(l) == l:
            cnt += 1

print(cnt)



Measured memory_bytes: 12436
/*=======================
Author    : Shounak Dey
Filename  : d.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	string a;
	cin >> a;
	ll turn = 0;
	while(a.length()>2){
		ll f=0;
		FOR(i,1,a.length()-1){
			if(a[i-1] != a[i+1]){
				f=1;
				a.erase(i,1);
				break;
			}
		}
		if(f)
			turn ^= 1;
		else
			break;
	}
	// cout << a << endl;
	// error(turn);
	cout << (!turn?"Second":"First") << endl;
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int main(){
	int a=read(),b=read(),c=read();
	cout<<min(a*b,c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
int n,k,a,b;
void solve(){
    cin>>k>>a>>b;
    int po = 0;
    for(int i=a ; i<=b ; i++){
        if(i%k==0){
            cout<<"OK\n";
            po = 1;
            break;
        }
    }
    if(po)return;
    cout<<"NG\n";
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    solve();
}

Measured memory_bytes: 3652
def main():
    n = input().rstrip()

    n = n.replace('BC','z')

    op = 0
    cz = 0
    isZ = False
    for i in reversed(n):
        if i == 'z':
            isZ = True
            cz += 1
        elif i == 'A' and isZ:
            op += cz
        else:
            isZ = False
            cz = 0
    print(op)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3500
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;

void solve(){
    S[3] = '8';
    cout << S << endl;
}

int main(){
    cin >> S;

    solve();
}

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

main(){
    string line;
    while(1){
	getline(cin, line);
	if ( line == "0" ) break;
	stringstream sin(line);
	int x, one = 0, sum = 0;
	while( sin >> x ){
	    if ( 10 <= x ) x = 10;
	    if ( x == 1 ) one++;
	    sum += x;
	}

	for ( int i = 0; i < one; i++ ){
	    if ( sum + 10 <= 21 ) sum += 10;
	}
	if ( sum > 21 ) sum = 0;
	cout << sum << endl;
    }
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

typedef double Double;

const Double EPS = 1e-9;
const Double PI = acos(-1);

typedef struct Point {
	Double x, y;
	Point(Double x_, Double y_) : x(x_), y(y_) {}
	
	Point operator + (const Point& a) const {
		return Point(x + a.x, y + a.y);
	}
	
	Point operator - (const Point& a) const {
		return Point(x - a.x, y - a.y);
	}
} Vector;

Double norm(const Point& a) {
	return a.x * a.x + a.y * a.y;
}

Double abs(const Point& a) {
	return sqrt(norm(a));
}

Double dot(const Vector& a, const Vector& b) {
	return a.x * b.x + a.y * b.y;
}

Double cross(const Vector& a, const Vector& b) {
	return a.x * b.y - a.y * b.x;
}

Double dist(const Point& a, const Point& b) {
	return abs(a - b);
}

Point rotate(const Point& p, Double s) {
	return Point(p.x * cos(s) - p.y * sin(s),
				 p.x * sin(s) + p.y * cos(s));
}

int ccw(const Point& _a, const Point& _b, const Point&  _c) {
	Vector ba = _b - _a, ca = _c - _a;
	if (cross(ba, ca) > EPS) return +1; // ccw
	if (cross(ba, ca) < -EPS) return -1; // cw
	if (dot(ba, ca) < -EPS) return +2; // c-a-b
	if (abs(ba) + EPS < abs(ca)) return -2; // a-b-c
	return 0; // a-c-b
}

typedef struct Line {
	Point s, e;
	Line(Point s_, Point e_) : s(s_), e(e_) {}
} Segment;

bool is_cross(const Segment& _a, const Segment& _b) {
	return (ccw(_a.s, _a.e, _b.s) * ccw(_a.s, _a.e, _b.e) <= 0
			&& ccw(_b.s, _b.e, _a.s) * ccw(_b.s, _b.e, _a.e) <= 0);
}

Double dist_point_line(const Point& p, const Line& l) {
	return fabs(cross(p - l.s, l.e - l.s)) / abs(l.e - l.s);
}

Double dist_point_seg(const Point& p, const Segment& s) {
	if (dot(s.e - s.s, p - s.s) < EPS) return abs(p - s.s);
	if (dot(s.s - s.e, p - s.e) < EPS) return abs(p - s.e);
	return dist_point_line(p, s);
}

struct Star {
	vector< Segment > vs;
	
	Star(Point c, Double a, Double r) {
		vector< Point > vp;
		Point uc(0, r);
		vp.push_back(rotate(uc, a * PI / 180.));
		
		for_(i,0,4)	vp.push_back(rotate(vp[i], 0.4 * PI));
		
		vs.push_back(Segment(vp[0] + c, vp[2] + c));
		vs.push_back(Segment(vp[2] + c, vp[4] + c));
		vs.push_back(Segment(vp[4] + c, vp[1] + c));
		vs.push_back(Segment(vp[1] + c, vp[3] + c));
		vs.push_back(Segment(vp[3] + c, vp[0] + c));
	}
};

int N, M, L;
vector< Star > vst;

Double dst[111][111];

Double dist_star(const Star& a, const Star& b) {
	Double res = 1e5;
	for_(i,0,5) for_(j,0,5) if (is_cross(a.vs[i], b.vs[j])) return 0.0;
	for_(i,0,5) for_(j,0,5) res = min(res, dist_point_seg(a.vs[i].s, b.vs[j]));
	for_(i,0,5) for_(j,0,5) res = min(res, dist_point_seg(b.vs[i].s, a.vs[j]));
	return res;
}

void solve() {
	for_(i,0,N) for_(j,i+1,N) {
		dst[i][j] = dst[j][i] = dist_star(vst[i], vst[j]);
	}
	
	for_(k,0,N) for_(i,0,N) for_(j,0,N) {
		dst[i][j] = min(dst[i][j], dst[i][k] + dst[k][j]);
	}
	
	printf("%.20lf\n", dst[M-1][L-1]);
}

int main() {
	while (cin >> N >> M >> L, N) {
		vst.clear();
		
		for_(i,0,N) {
			Double x, y, a, r;
			scanf("%lf %lf %lf %lf", &x, &y, &a, &r);
			vst.push_back(Star(Point(x, y), a, r));
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1400
import sys
def q(a,h):
 d[a]=h
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
n=int(input())
for e in sys.stdin:
 e=e.split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,range(n))))


Measured memory_bytes: 59692
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s;

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)
int main(void){
    int n;
    string a[101];
    bool result = true;
    cin >> n;
    set <string> sets;
    REP(i,n)cin>>a[i];
    REP(i,n){
        if( i<n-1 && a[i][a[i].length() - 1] != a[i+1][0]){
            result = false;
        }else if(sets.count(a[i])){
            result = false;
        }
        sets.insert(a[i]);
    }
    if(result){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

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

bool yaku(int n){
  int re = 0;
  for(int i = 1; i <= n; i++){
    if(n % i == 0) re++;
  }
  return re == 8;
}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i += 2){
    if(yaku(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
const int MOD = 1e9+7;
//}}}

int S(int n){
	int res=0;
	while(n){
		res+=n%10;
		n/=10;
	}
	return res;
}

int main(){
	int N;
	cin >> N;
	bool ans=N%S(N)==0;
	puts(ans?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	VI ana(26,0);
	string str;
	cin>>str;
	fr(i,0,str.size()){
		ana[str[i]-'a']++;
	}
	int flag=1;
	fr(i,0,26){
		if(ana[i]%2==1)
			flag=0;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
#include <list>
#include <algorithm>

using namespace std;

struct col{
	double L;
	double a;
	double b;
};

double dist( col c1, col c2 ) {
	double d =
		( c1.L - c2.L ) * ( c1.L - c2.L )
		+ ( c1.a - c2.a ) * ( c1.a - c2.a ) 
		+ ( c1.b - c2.b ) * ( c1.b - c2.b );
	return d;
}

void print_bit(unsigned int  S, int n=64){
  for(int i=n-1; i>=0; i--){
    if(S>>i & 1) std::cout << 1;
    else std::cout << 0;
  }
  std::cout << std::endl;
}

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	vector< unsigned int > bits;
	vector< col > cols;
	vector< double > ds;

	int N, M;
	cin >> N >> M;
	for(int i = 0; i < N; i++ ) {
		col c;
		cin >> c.L >> c.a >> c.b;
		cols.push_back( c );
	}
	
	if( M == 0 ) {
		printf("%lf\n" , 0.0);
		return 0;
	}

	//ビットテーブル作成
	unsigned long long  S = ( 1ULL << M ) - 1ULL;
	unsigned long long  E = ~(( 1ULL << N ) - 1ULL );
	while( !( S & E ) ) {
		bits.push_back(S);
		unsigned long long smallest  = S & -S;
		unsigned long long ripple = S + smallest;
		unsigned long long nsmallest = ripple & -ripple;
		S = ripple | (( ( nsmallest / smallest ) >> 1 ) - 1);
	}

	for(int i = 0; i < bits.size(); i++) {
		double d = 0.0;
		for(int j = 0; j < N; j++) {
			if( !( bits[i] & (1 << j) ) ) continue;
			for(int k = j + 1; k < N; k++) {
				if( !( bits[i] & ( 1 << k ) ) ) continue;
				d += dist( cols[j], cols[k] );
			}
		}
		ds.push_back( d );
	}

	double max = 0.0;
	for(int i = 0; i < ds.size(); i++)
		if( max < ds[i] ) max = ds[i];

	printf("%.8lf\n", max);
	//while(1){}
    return 0;
}

Measured memory_bytes: 3888
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<cstring>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
ll a[1111111];
ll b[1111111];
ll c[1111111];

int main()
{
	//ios::sync_with_stdio(false);
	ll n,k,q,x;
	cin>>n>>k>>q;
	for(ll i=0;i<n;i++)
		a[i]=k;
	set<ll> st; 
	for(ll i=0;i<q;i++)
	{
		scanf("%lld",&x);
		a[x-1]++;
	}
	

	for(ll j=0;j<n;j++)
		if(a[j]-q>0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 2688
class WeightedUnionFind:

    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.level = [0] * n
        self.weight = [0] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            px = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = px
            return px

    def union(self, x, y, w):
        px = self.find(x)
        py = self.find(y)
        if self.level[px] < self.level[py]:
            self.par[px] = py
            self.weight[px] = -self.weight[x] + self.weight[y] + w
        else:
            self.par[py] = px
            self.weight[py] = + self.weight[x] - self.weight[y] - w
            if self.level[px] == self.level[py]:
                self.level[px] += 1

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

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

def solve(N, M):
    wuf = WeightedUnionFind(N+1)
    for i in range(M):
        L, R, D = map(int, input().split())
        if wuf.same(L, R):
            if wuf.diff(L, R) != D:
                return False
        else:
            wuf.union(L, R, D)
    return True

N, M = map(int, input().split())
if solve(N, M):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10240
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>


using namespace std;

long long k, n, d, x, s, mn = pow(10, 9), a[100005];


int main () {
    cin >> n;
    for ( int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for ( int i = 1; i <= n; i++) {
        if ( a[i] % 3 != 0 && a[i] % 5 != 0 && a[i] % 2 == 0 ) {
            k = 1;
        }
    }
    if ( k == 1 ){
        cout <<"DENIED";
    }
    else {
    cout << "APPROVED";
    }
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
void some(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		if(i==3)cout<<" ";
	}
	cout<<endl;
}
int main(){
	some();
	/*long int n,a[100000],ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(){
			ans++;
		}
	}
	cout<<ans<<std::endl;*/
	return 0;
}

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

using namespace std;

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

#define mp make_pair
#define F first
#define S second

const ll N = 2e5;
const ll M = 20;
const ll SQ = 320;
const ll INF = 1e16;
const ll MOD = 1e9+7;

int n,w,s,e;

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

	string t;
	cin >> t;
	int l = t.size();
	for (int i = 0; i<l; i++)
	{
		if (t[i]=='N') n = 1;
		if (t[i]=='W') w = 1;
		if (t[i]=='S') s = 1;
		if (t[i]=='E') e = 1;
	}
	if (((n && s) || (!n && !s)) && ((w && e) || (!w && !e)))
		cout << "Yes\n";
	else
		cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    int n;
    IN n;
    vll v(n+1);
    loop(i,0,n+1)
    {
        IN v[i];
    }
    bool ok=true;
  	if(n==0 && v[0]==1) return OUT 1, 0;
    vll ans(n+1,0);
    ll last_level_nodes=1;
    ll last_level_leaves=0;
    if(v[0]!=0)
    {
        OUT -1<<endl
        return 0;
    }
    // vll ans(n+1,0)
    ans[n]=v[n];
    rloop(i,n-1,0)
    {
        ans[i]=ans[i+1]+v[i];
    }
    ans[0]=min(ans[0],1LL);
    loop(i,1,n+1)
    {
        // OUT i<<" "<<last_level_nodes<<" "<<last_level_leaves<<endl
        ll curr_nodes=2LL*last_level_nodes;
        // curr_nodes-=last_level_leaves;
        // last_level_leaves=v[i];
        // last_level_nodes=curr_nodes-v[i];
        // OUT curr_nodes-v[i]<<endl
        // OUT curr_nodes<<endl
        ans[i]=min(ans[i],curr_nodes);
        last_level_nodes=ans[i]-v[i];
        // OUT ans[i]<<endl
        // OUT i<<" "<<last_level_nodes<<" "<<last_level_leaves<<endl
    }
    if(!ok)
    {
        OUT -1<<endl
    }
    else
    {
        rloop(i,n,0)
        {
            if(ans[i]<v[i])
            {
                OUT -1<<endl
                return 0;
            }
        }
        ll res=0LL;
        loop(i,0,n+1)
        {
            // OUT ans[i]<<endl
            res+=ans[i];
        }
        OUT res<<endl
    }
    return 0;
}


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

long long dp[100009], n, k, a[100009];
long long solve(long long x)
{
    if(x == 0)
        return 0;
    if(dp[x] != -1)
        return dp[x];
    dp[x] = 1e9;
    for(long long i = 1; i <= k; i++)
    {
        if(x - i >= 0)
        dp[x] = min(dp[x], abs(a[x] - a[x - i]) + solve(x - i));
    }
    return dp[x];
}
main()
{
    cin>>n>>k;
    memset(dp, - 1, sizeof(dp));
    for(long long i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    cout<<solve(n - 1);

}


Measured memory_bytes: 6528
#include<iostream>
#include <string>
using namespace std;
int main()
{
  int n;
  int a,b;
  int res2=0;
  cin >> n >> a >> b;
  for(int i=0;i<=n;i++){
    int res=0;
    string strNum = to_string(i);
    for(int j=0;j<strNum.length();j++){
      res += strNum[j] - '0';
      //cout << res << '\n';
    }
    if(res >= a && res <= b){
      res2 += i;
      //cout << res2 << '\n';
    }
  }
  cout << res2 << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static long[] maxPas = new long[5];
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A >= 13) {
			System.out.println(B);
		} else if(6 <= A && A <= 12) {
			System.out.println(B/2);
		} else {
			System.out.println(0);
		}
		
	}

}


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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vchar vector<char>
#define vool vector<bool>
#define pb() pushback()

main(){
    int A,B,c,count=0,count2=0;
    double a,b,f;
    str S;
    vint fivr={64,32,16,8,4,2,1};
    cin>>a>>b;
    A=a;
    B=b;
    c=a/b;
    count=A%B;
    f=a/b;
    cout<<c<<" "<<count<<" ";
    printf("%.8f\n",f );
}



Measured memory_bytes: 3208
N,K = gets.split.map &:to_i

k = K; x = 1.0; A = [k]; X = [x]
while k > 1
  k = (k+1)/2; x /= 2; A << k; X << x
end

q = 0
N.times do |n|
  i = A.index{|k|k <= n+1}
  q += X[i]
end
puts q / N

Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
#include <map>

using namespace std;



int main(){


	int N;
	do{cin>>N;} while(N<1||N>2*pow(10,5));

	map<string, int> mp;
	string S[N];
	for(int i=0;i<N;i++){
		cin>>S[i];
		mp[S[i]]=i;
	}

	cout<<mp.size()<<endl;

}


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

int main(void) {
    long long n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        double b = 1 / (double)n;
        int a    = i;
        while (a < k) {
            a *= 2;
            b *= 0.5;
        }
        ans += b;
    }

    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 256
a,b= map(int,input().split(" "))
c = int(input())
ar = list(map(int,input().split(" ")))
br = [[0 for i in range(b)] for j in range(a)]
go = "M"
ap = 1
for i in range(a):
    if go == "M":
        for j in range(b):
            if ar[0] == 0:
                del ar[0]
                ap += 1
            br[i][j] = ap
            ar[0] -= 1
        go = "U"
    else:
        for j in range(b-1,-1,-1):
            if ar[0] == 0:
                del ar[0]
                ap += 1
            br[i][j] = ap
            ar[0] -= 1
        go = "M"
for r in br:
    for i in range(b-1):
        print(r[i],end=" ")
    print(r[b-1])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"Bad"<<endl;return 0;}
//template

//main
signed main(){
  string s;cin>>s;
  for(int i=0;i<3;i++)if(s[i]==s[i+1])fin
  cout<<"Good"<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {

		while (sc.hasNext()) {
			String str = sc.next();
			String[] st = str.split(",");
			int[] stn = new int[st.length];
			int[] num = new int[13];
			String ans = "null";

			Arrays.fill(num, 0);

			// ??????????????°????????????
			for (int i = 0; i < st.length; i++) {
				stn[i] = Integer.parseInt(st[i]);
			}

			// ??°?????????????????????
			for (int i = 0; i < stn.length; i++) {

				num[stn[i] - 1]++;

			}

			// ??????
			// ???????????¢
			if (maxone(num) == 2 && maxtwo(num) == 1) {
				ans = "one pair";
			}
			// ???????????¢
			else if (maxone(num) == 2 && maxtwo(num) == 2) {
				ans = "two pair";
			}
			// ??????????????¢
			else if (maxone(num) == 3 && maxtwo(num) == 1) {
				ans = "three card";
			}
			// ???????????????
			else if (maxone(num) == 3 && maxtwo(num) == 2) {
				ans = "full house";
			}
			// ??????????????????
			else if (maxone(num) == 4) {
				ans = "four card";
			}
			// ????????¬??????
			else {
				for (int i = 0; i < 9; i++) {
					if (num[i] == 1 && num[i + 1] == 1 && num[i + 2] == 1 && num[i + 3] == 1 && num[i + 4] == 1) {
						ans = "straight";
					}
				}
				if (num[9] == 1 && num[10] == 1 && num[11] == 1 && num[12] == 1 && num[0] == 1) {
					ans = "straight";
				}
			}

			System.out.println(ans);
		}

	}

	// ??°????????????????????§????????????
	public static int maxone(int[] num) {
		int max = 0;
		for (int i = 0; i < num.length; i++) {
			if (max < num[i]) {
				max = num[i];
			}

		}
		return max;
	}

	// ??°???????????????2??????????????§?????°?????????
	public static int maxtwo(int[] num) {
		int max1 = 0;
		int max2 = 0;
		if (num[0] > num[1]) {
			max1 = num[0];
			max2 = num[1];
		} else {
			max1 = num[1];
			max2 = num[0];
		}
		for (int i = 2; i < num.length; i++) {
			if (max1 < num[i]) {
				max2 = max1;
				max1 = num[i];
			} else if (max2 < num[i]) {
				max2 = num[i];
			}
		}
		return max2;

	}

}

Measured memory_bytes: 25872
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007
const double PI=3.14159265358979323846;

int main(){
    double a;
    scanf("%lf",&a);
    a*=2;
    a*=PI;
    
    printf("%lf",a);
}

Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	ll c; cin >> c;
	vector<ll> x(n);
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> x[i] >> v[i];
	}
	ll ans=0;
	for(int t=0;t<2;t++){
		ll sum=0;
		for(int i=0;i<n;i++){
			sum+=v[i];
		}
		ll mx=0;
		ll cnt=0;
		for(int i=n-1;i>=-1;i--){
			ll now=sum-(i>=0?x[i]:0);
			ans=max(ans,now+mx);
			if(i>=0){
				cnt+=v[i];
				mx=max(mx,cnt-2*(c-x[i]));
				sum-=v[i];
			}
		}
		for(int i=0;i<n;i++){
			x[i]=c-x[i];
		}
		reverse(x.begin(),x.end());
		reverse(v.begin(),v.end());
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <array>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    std::array<int, 3> sorted = {0, 0, 0};
    sorted.at(0) = (a < b && a < c) ? a : (b < a && b < c) ? b : c;
    sorted.at(2) = (a > b && a > c) ? a : (b > a && b > c) ? b : c;
    sorted.at(1) = a + b + c - sorted.at(0) - sorted.at(2);
    std::cout << sorted.at(0) << ' ' << sorted.at(1) << ' ' << sorted.at(2) << std::endl;
    return 0;
}

Measured memory_bytes: 3088
N = int(input())
A = list(map(int, input().split()))

from collections import defaultdict
dict = defaultdict(int)
for a in A:
    dict[a] += 1

ans = 0
for key, value in list(dict.items()):
    ans += value*(value-1) // 2

for a in A:
    tmp = ans - dict[a]*(dict[a]-1)//2 + (dict[a]-1)*(dict[a]-2)//2
    print(tmp)


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

int main(){
    int n, k;
    cin >> n >> k;

    ll cou = 0;
    ll ans = 0;

    if(k % 2 == 0){
        ll t = 0;
        for(int i= 1; i <= n; i++){
            if(i % k == 0){
                cou++;
            }
            
            if(i % k == k / 2){
                t++;
            }
        }
        ans += cou * cou * cou;
        ans += t * t * t;
    }else{
        for(int i= 1; i <= n; i++){
            if(i % k == 0){
                cou++;
            }
        }
        ans += cou * cou * cou;
    }

    cout << ans << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    
    char s[232323];

    Scs(s);

    bool bl = false;
    int tmp = 0;
    Rep(i,N){
        if( s[i] == '.' )
        tmp++;
    }
    int ans = tmp;
    Rep(i,N){
        if( s[i] == '#' )
            tmp++;
        else if( s[i] == '.' )
            tmp--;
        ans = min(ans,tmp);
    }


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


    return 0;
}



Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strInput = br.readLine();
		int numInput = Integer.parseInt(strInput);
		System.out.println(numInput*numInput*numInput);
	}
}

Measured memory_bytes: 24220
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdio.h>
#include <cmath>
#include <limits.h>
using namespace std;

typedef long long ll;

#define min(a, b) (((a) < (b))? (a):(b))
#define max(a, b) (((a) > (b))? (a):(b))
#define REP(i, a, n) for(int i=(a); i<(n); ++i)
#define rep(i, n) REP(i, 0, (n))
#define square(a) (a)*(a)
#define pb push_back

int a,b,c,d,t,s;
int main(void) {
    
    cin >> a >> b >> c >> d;
    if(a>=c) t=a;
    if(a<c)  t=c;
    if(b>=d) s=d;
    if(b<d)  s=b;
    
    if(s-t<=0)cout << 0 << endl;
    if(s-t>0)cout << s-t << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3
#coding: utf-8

from itertools import permutations

N = int(input())
P = input().strip()
Q = input().strip()

nth = 0
np = -1 
nq = -1
for i in permutations(range(N)):
    nth += 1
    s = " ".join([str(x+1) for x in i])
    if s == P:
        np = nth
    if s == Q:
        nq = nth

print(abs(np - nq))


Measured memory_bytes: 9012
import bisect
n = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        k = bisect.bisect_left(L, L[i]+L[j])
        ans += k-1 - j
print(ans)


Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define INF 1000000009
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define so sizeof 
#define pii pair<ll,ll>
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define repe(i,a) for(auto i:a)
#define st string
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=b;i>=a;i--)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); 
void solve(){
  ll n,m;
  cin>>n>>m;
  char grid[n][m];
  ll dp[n][m];
  rep(i,0,n-1){
    rep(j,0,m-1){
      dp[i][j]=-1;
    }
  }
  rep(i,0,n-1){
    rep(j,0,m-1){
        cin>>grid[i][j];
    }
  }
  rep(i,0,n-1){
    rep(j,0,m-1){
        if(grid[i][j]=='#'){
            dp[i][j]=0;
        }
    }
  }
  rep(i,0,m-1){
     if(dp[0][i]!=0){
        dp[0][i]=1;
     }
     else{
        rep(j,i,m-1){
            dp[0][j]=0;
        }
        break;
     }
  }
  rep(i,0,n-1){
     if(dp[i][0]!=0){
        dp[i][0]=1;
     }
     else{
        rep(j,i,n-1){
            dp[j][0]=0;
        }
        break;
     }
  }
  rep(i,1,n-1){
    rep(j,1,m-1){
       if(dp[i][j]!=0)
       dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    }
  }
  cout<<dp[n-1][m-1]<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    fast
    solve();
    return 0;
}

Measured memory_bytes: 12432
import java.util.*;class Main{public static void main(String[]z){Scanner w=new Scanner(System.in);for(long n,s,c,m,a,r,b,y,i,x;(n=w.nextInt())+(s=w.nextInt())>0;System.out.println(c))for(x=(1L<<n)-1,c=0;(x&~((1L<<10)-1))<1;a=x&-x,r=x+a,b=r&-r,x=r|(((b/a)>>1)-1),c+=m==s?1:0)for(m=i=0,y=x;i<10;++i,y>>>=1)m+=(y&1)>0?i:0;}}

Measured memory_bytes: 12000
def main():
    A,B = list(map(int, input().split()))

    ans = 0
    if A < B:
        ans += B
        B = B - 1
    else:
        ans += A
        A = A - 1

    if A < B:
        ans += B
        B = B - 1
    else:
        ans += A
        A = A - 1

    print(ans)

    return

if __name__ == '__main__' :
    main()



Measured memory_bytes: 3060
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) {   //素数判定
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

signed main() {
    int K, A, B;
    cin >> K >> A >> B;
    if ((B - A) <= 2) {
        cout << K + 1 << endl;
        return 0;
    }
    int bis = A - 1;
    if (K < bis + 2) {
        cout << K + 1 << endl;
        return 0;
    }
    K -= bis;
    int ans = K % 2;
    cout << (B - A) * (K / 2) + A + ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,x,y,z=1,answer=0;

    scanf("%d",&a);

    for(x=1;x<=31;x++){
        z*=x;
        for(y=1;y<=8;y++){
            z*=x;

            if(z>a){
                z/=x;
                break;
            }
            if(answer<z){
                answer=z;
            }
        }
        z=1;
    }
    printf("%d",answer);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll A, B;
    double b;
    cin >> A >> b;
    B = b * 100.001;
    //cout << B;
    ll ans = A * (ll)(b * 100.001) / 100;
    cout << ans << endl;
    //cout << (664706138336385 * 979);

    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>

using namespace std;

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

int N,M;

signed main()
{
	cin >>N >>M;
	cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}


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

using ll = long long;

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

    ll n,m;cin>>n>>m;

    ll ans=0;

    if(n>=2&&m>=2)
    {
        ans+=(n-2)*(m-2);
    }
    else
    {
        if(max(n,m)>=2)ans=max(n,m)-2;
        else ans=1;
    }    

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s; cin >> s;
    int cnt = 0;
    for (int i = 0; i < 2; i++) if (s[i] == 'R' && s[i] == s[i + 1]) cnt++;
    if (cnt) cout << cnt + 1;
    else cout << !!count(s.begin(), s.end(), 'R') ;
    return 0;
}

Measured memory_bytes: 3612
h, w = map(int, input().split())
c = [list(input()) for i in range(h)]
queue = []
visited = [[0 for i in range(w)] for i in range(h)]
ans = 0

for i in range(h):
  for j in range(w):
    if c[i][j] == '.':
      queue.append([i, j])
      visited[i][j] = 1
      dy_dx = [[1, 0], [0, 1], [-1, 0], [0, -1]]
      while len(queue) > 0:
        now = queue.pop(0)
        for k in range(4):
          y = now[0] + dy_dx[k][0]
          x = now[1] + dy_dx[k][1]
          if 0 <= y < h and 0 <= x < w:
            if c[y][x] != '#' and visited[y][x] == 0:
              visited[y][x] = visited[now[0]][now[1]] + 1
              queue.append([y, x])
    for l in range(h):
      for m in range(w):
        ans = max(ans, visited[l][m])
    queue = []
    visited = [[0 for i in range(w)] for i in range(h)]
               
print(ans - 1)


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main(){
string n;
cin>>n;
int s=n.size();
for(int i=0;i<s/2;i++){
	if(n[i]!=n[s-1-i]){
		cout<<"No";
		return 0;
	}
}
for(int i=0;i<=(s-1)/2/2;i++){
	if(n[i]!=n[(s-1)/2-1-i]){
		cout<<"No";
		return 0;
	}
}
int a=(s+3)/2-1;
for(int i=a;i<s;i++){
	if(n[i-a]!=n[s-1-i]){
		cout<<"No";
		return 0;
	}
}
cout<<"Yes";
return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
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; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


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


    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++) cin >> x[i];
    for(int i = 0; i < N; i++) cin >> y[i];

    vector<double> ans;
    for(int p : {1, 2, 3}){
        double sum = 0;
        for(int i = 0;i < N; i++){
            sum += pow(abs(x[i] - y[i]),p);
        }
        ans.push_back(pow(sum, 1.0 / p));
    }
    int max_n = 0;
    for(int i = 0; i < N; i++){
        max_n = max(max_n, abs(x[i] - y[i]));
    }
    ans.push_back(max_n);
    for(double a : ans) cout << a << endl;
}



Measured memory_bytes: 3456
#include<stdio.h>

int M,N;
int K;
char map[1003];
int ***data;	//前処理
int look[4];

void seach(int *ans){
	int i;
	for(i = 0;i < 3;i++){
		ans[i] = data[look[2]][look[3]][i]-data[look[2]][look[1]-1][i];
		ans[i] += -data[look[0]-1][look[3]][i]+data[look[0]-1][look[1]-1][i];
	}
}
int main(){
	int i,j,k;
	int **ans;
	int J = 0,O = 0,I = 0;
	scanf("%d%d%d",&M,&N,&K);
	data = new int**[M+1];
	ans = new int*[K];
	for(i = 0;i < K;i++){
		ans[i] = new int[3];
	}
	for(i = 0;i < M+1;i++){
		data[i] = new int*[N+1];
		for(j = 0;j < N+1;j++){
			data[i][j] = new int[3];
			for(k = 0;k < 3;k++){
				data[i][j][k] = 0;
			}
		}
	}
	for(i = 1;i < M+1;i++){
		scanf("%s",map+1);
		for(j = 1;j < N+1;j++){
			//前処理
			switch(map[j]){
			case 'J':
				J++;
				break;
			case 'O':
				O++;
				break;
			case 'I':
				I++;
				break;
			}
			data[i][j][0] = J-data[i-1][N][0]+data[i-1][j][0];
			data[i][j][1] = O-data[i-1][N][1]+data[i-1][j][1];
			data[i][j][2] = I-data[i-1][N][2]+data[i-1][j][2];
		}
	}
	//それでは始めよう！！
	for(i = 0;i < K;i++){
		for(j = 0;j < 4;j++){
			scanf("%d",look+j);
		}
		seach(ans[i]);
	}
	for(i = 0;i < K;i++){
		printf("%d %d %d\n",ans[i][0],ans[i][1],ans[i][2]);
	}
	for(i = 0;i < M+1;i++){
		for(j = 0;j < N+1;j++){
			delete[] data[i][j];
		}
		delete[] data[i];
	}
	delete[] data;
	for(i = 0;i < K;i++)
		delete[] ans[i];
	delete[] ans;
	return 0;
}

Measured memory_bytes: 43508
#include<stdio.h>

int main(void) {
  int n;
  int a[20];
  int tmp;
  int sum = 0;
  int c[20];
  int i;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &a[i]);
  }
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &tmp);
    sum += tmp;
  }
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &c[i]);
  }
  for ( i = 0; i < n - 1; i++ ) {
    if ( a[i] + 1 == a[i + 1] ) {
      sum += c[a[i]-1];
    }
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(void){
    ll N;cin>>N;
    vector<ll>V(N);for(ll i=0;i<N;i++)cin>>V[i];
    ll ans=gcd(V[0],V[1]);
    for(ll i=2;i<N;i++){
        ans=gcd(ans,V[i]);
    }
    cout<<ans<<endl;
}

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

int n;
int dp[100005];

void solve(int a) {
	for (int i = a; i <= n; i *= a) {
		for (int j = 0; j + i <= n; j++)
			dp[j + i] = min(dp[j + i], dp[j] + 1);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i <= n; i++)
		dp[i] = i;
	dp[0] = 0;
	
	solve(6);
	solve(9);

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 1e5+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
//const int INF = 2e9+9;
const int MOD = 1e9+7;

int n;
ll a[maxN];
ll b[maxN];
int main()
{
	scanf("%d",&n);
	ll sum = 0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	a[n+1] = a[1];
	b[0] = 0;
	b[n+1] = 0;
	for(int i=3;i<=n;i+=2)
	{
		b[i] = b[i-2] + 2*(a[i-1] - a[i-2]);
	}
	for(int i = n-1;i>=2;i--)
	{
		b[i] = b[i+2] + 2*(a[i] - a[i+1]);
	}
	ll cnt = 0;
	for(int i=1;i<=n;i++)
	{
		cnt += b[i];
	}
	ll x = (sum - cnt)/n;
	for(int i=1;i<=n;i++)
	{
		b[i] += x;
		if(i<n)
			printf("%d ",b[i]);
	}
	printf("%d\n",b[n]);
	return 0;
}


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

int main() {
    int N,L;
    cin >> N >> L;
    vector<int> taste(N);
    vector<int> tasteAbs(N);
    for (int i = 0; i < N; i++)
    {
        taste[i] = L+i;
        tasteAbs[i] = abs(taste[i]);   
    }
    int min = 99999999;
    int minNum = 0;
    for (int i = 0; i < N; i++)
    {
        if (tasteAbs[i] <= min)
        {
            min = tasteAbs[i];
            minNum = i;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (i != minNum)
        {
            ans += taste[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N=2e5;
vector<int>B(N+1);
void insert(int I,int val){
    while( I<=N ){
        B[I]=max(B[I],val);
        I+=I&-I;
    }
}
int query(int I){
    int mx=0;
    while( I > 0){
        mx=max(mx,B[I]);
        I-=I&-I;
    }
    return mx;
}
 main(){
       IOS
       int n;
       cin>>n;
       vector<int>h(n+1);
       vector<int>b(n+1);
       int ans=0;
       for(int i=1;i<=n;i++)
       cin>>h[i];
       for(int i=1;i<=n;i++)
       cin>>b[i];
       for(int i=1;i<=n;i++){
    	   int mx=query(h[i]);
    	   insert(h[i],mx+b[i]);
    	   ans=max(ans,mx+b[i]);
       }
       cout<< ans << endl;

}


Measured memory_bytes: 4992
using System;

class Program
{
    static void Main(string[] args)
    {
        var abc = Console.ReadLine().Split(' ');
        var a = int.Parse(abc[0]);
        var b = int.Parse(abc[1]);
        var c = int.Parse(abc[2]);

        if (a <= c && c <= b)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
from collections import deque
 
n = int(input())
ans = [0] * n
visited = [False] * n
G = [[] for _ in range(n)]
 
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append([v, w])
    G[v].append([u, w])
 
q = deque([])
q.append(0)
visited[0] = True
 
def dfs():
    while q:
        p = q.pop()
        for u, w in G[p]:
            if visited[u]: continue
            else:
                ans[u] = (ans[p] + w) % 2
                visited[u] = True
                q.append(u)
 
dfs()
 
for i in range(n):
    print(ans[i])

Measured memory_bytes: 46100