akhauriyash/Code-Regression huggingface dataset:
import fractions
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=lcm_list(map(lambda x: x//2, a))
swt=0

for i in range(n):
  if 0==(b//(a[i]//2))%2:
    swt=1
    break

if 0==swt:
  print(math.ceil((m//b)/2))
else:
  print(0)

Measured memory_bytes: 16232
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int ans=0,now=1;
  for(;;){
    if(now==2){
      cout<<ans<<endl;
      return 0;
    }
    if(ans>=n){
      cout<<-1<<endl;
      return 0;
    }
    ans++;
    now=a.at(now-1);
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	int X; cin >> X;
	int ans = 1;
	bool ok = true;
	for (int i = X;i > 0;i--) {
		if (!ok) break;
		for (int j = 0;j < i;j++) {
			if (!ok) break;
			for (int k = 1;k<=i;k++) {
				if (i < pow(j, k)) break;
				if (i == pow(j, k)) {
					ans = i;
					ok = false;
					break;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(){
  int i,k,t,end=0,slen,plen,correct=0;
  char static s[500];
  char static p[500];
  char static c[500];
  scanf("%s",s);
  scanf("%s",p);
  slen=strlen(s);
  plen=strlen(p);
  for(i=0;i<slen;i++){
    for(k=0;k<plen;k++){
      if(k==0)t=i+k;
      c[k]=s[t];
      t++;
      if(i+k+1==slen)t=0;
    }
    if(strcmp(c,p)==0){
      correct=1;
    }
  }
  if(correct==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 2752
#include<stdio.h>

int main(){
	char a,b,c,d,e,f;

scanf("%c%c%c%c%c%c",&a,&b,&c,&d,&e,&f);
if (c==d && e==f){
	printf("Yes");
}
else{
	printf("No");
}
return 0;
}

Measured memory_bytes: 2088
#include <stdio.h>
int main()
{
  int A[100], N, n, i, j = 0, count = 0;

  scanf("%d",&N);
  for (i = 0; i < N; i++)
    scanf("%d",&A[i]);
  while (j < N-1){
    for (i = N-1; i >= j+1; i--){
      if (A[i] < A[i-1]){
	n = A[i];
	A[i] = A[i-1];
	A[i-1] = n;
	count++;
      }
    }
    j++;
  }
  for (i = 0; i < N; i++){
    printf("%d",A[i]);
    if (i != N-1)
      printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2104
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

base = 10^5


main = do
    [n, m] <- getInts
    s <- replicateM (n-1) getInt
    a <- replicateM m getInt
    let ss = listArray (1,n) $ scanl (+) 0 s
    let p = scanl (+) 1 a
    let move = zip p $ tail p
    print $ (`mod` base) $ sum [abs (ss!f - ss!t)| (f,t) <- move]

Measured memory_bytes: 90160
a, b, c, x, y = map(int, input().split())
ans = 10 ** 15
for i in range(max(x, y) * 2 + 1):
  if x - i//2 < 0 and y - i//2 < 0:
    n = c * i 
  elif x - i//2 < 0:
    n = c * i + (y - i//2) * b
  elif y - i//2 < 0:
    n = c * i + (x - i//2) * a
  else:
    n = c * i + (x - i//2) * a + (y - i//2) * b
  ans = min(ans, n)
print(ans)  


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	string a[10]={"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
	scanf("%d",&n);
	m=n%10; 
	cout<<a[m]<<endl;
	return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;

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

    char S[N];
    scanf("%s", S);

    if(C<D && B<C){
        for(int i=A; i<=D-1; i++){
            if (S[i] == '#'){
                if (S[i+1] == '#'){
                    printf("No");
                    return 0;
                }
            }
        }
        printf("Yes");
        return 0;
    }
    else if(D<C && B<D){
        for(int i=A; i<=C-1; i++){
            if (S[i] == '#'){
                if (S[i+1] == '#'){
                    printf("No");
                    return 0;
                }
            }
        }
        for(int i=B-2; i<=D-2; i++){
            if (S[i] == '.'){
                if (S[i+1] == '.'){
                    if (S[i+2] == '.'){
                        printf("Yes");
                        return 0;
                    }
                }
            }
        }
        printf("No");
        return 0;
    }
    else if(C<D && C<B){
        for(int i=A; i<=C-1; i++){
            if (S[i] == '#'){
                if (S[i+1] == '#'){
                    printf("No");
                    return 0;
                }
            }
        }
        for(int i=B; i<=D-1; i++){
            if (S[i] == '#'){
                if (S[i+1] == '#'){
                    printf("No");
                    return 0;
                }
            }
        }
        printf("Yes");
        return 0;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class myTree
{
public:
    myTree() {}
    myTree(int n)
    : g(n), pc(n, 0)
    {}
    ~myTree() {}

    int bfs()
    {
        int ret = 0;
        int u = 0;
        rep (i, g.size())
        {
            if (ret < g[i].size())
            {
                ret = g[i].size();
                u = i;
            }
        }

        queue<int> q;
        q.push(u);
        int div = g[u].size();
        while (!q.empty())
        {
            u = q.front();
            q.pop();
            int color = pc[u];
            rep (j, g[u].size())
            {
                int v = g[u][j];
                pair<int, int> e = (u < v) ? make_pair(u, v) : make_pair(v, u);
                if (col[e] == 0)
                {
                    q.push(v);
                    col[e] = color % div + 1;
                    pc[v] = col[e];
                    color = (color + 1) % div;
                    // cout << "coloring: (" << e.first << ", " << e.second << ")" <<  "\n";
                }
            }
        }

        return ret;
    }

    vector< vs32 > g;
    vs32 pc;
    map< pair<int, int>, int > col;
};

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

    int n;
    cin >> n;

    myTree g(n);
    queue< pair<int, int> > q;
    int u, v;
    rep (i, n - 1)
    {
        cin >> u >> v;
        --u; --v;
        g.g[u].push_back(v);
        g.g[v].push_back(u);
        q.push(make_pair(u, v));
    }

    int K = g.bfs();

    cout << K << "\n";
    pair<int, int> e;
    rep (i, n - 1)
    {
        e = q.front();
        q.pop();
        cout << g.col[e] << "\n";
    }

    return 0;
}



Measured memory_bytes: 13568
/*input
8 10
2 6 2
5 5 1
3 5 2
4 7 3
4 4 1
2 3 1
7 7 1
1 5 2
1 7 3
3 4 2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 301;
vector< pair<int,int> > reqs[N];
int n,m;
int dp[N][N][N];

int rec(int i,int j,int k){
	int ind = max(i,max(j,k));
	if(max(i,max(j,k)) > n)return 1;
	if(dp[i][j][k] != -1)return dp[i][j][k];
	for(auto nice:reqs[ind]){
		int totdis = (i>= nice.f)+(j >= nice.f)+(k >= nice.f);
		if(totdis != nice.s)return 0;
	}
	//int ind = max(i,max(j,k));
	dp[i][j][k] = rec(i,j,ind+1)+rec(i,ind+1,k)+rec(ind+1,j,k);
	dp[i][j][k] %= MOD;
 	return dp[i][j][k];
}

void solve(){
  	cin >> n >> m;
  	REP(i,n+1){
  		REP(j,n+1){
  			REP(k,n+1)dp[i][j][k] = -1;
  		}
  	}
  	REP(i,m){
  		int l,r,x;cin >> l >> r >> x;
  		reqs[r].pb({l,x});
  	}
  	int ans = rec(0,0,0);
  	int inv = raise(3,MOD-2,MOD);
  	ans *= inv;
  	ans %= MOD;
  	cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 213376
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll maze[20][1004];
char s[1004];
ll sum[20][1004]={0};
ll ans=200000000;
ll h,w,k;
void suan(vector<ll> a,ll qie)
{
	a.push_back(h);
	ll left=0,right=1;
	for(ll i=1;i<=w;i++)
	{
		right=i;
		for(ll j=0;j<a.size()-1;j++)
		{	
			ll sum2=0;
			for(ll k1=a[j]+1;k1<=a[j+1];k1++)
			{
				sum2+=sum[k1][right]-sum[k1][left];
			}
			if(sum2>k)
			{
				if(left+1==right)
				{
					return;
				}
				else
				{
					qie++;
					left=i-1;
					right=i;
				}
			}
		}
	}
	ans=min(ans,qie);
}
void dfs(vector<ll> a,ll qie,ll num)
{
	if(num==h)
	{
		suan(a,qie);
		return;
	}
	dfs(a,qie,num+1);
	a.push_back(num);
	dfs(a,qie+1,num+1);
}
int main(){
	scanf("%lld%lld%lld",&h,&w,&k);
	for(ll i=1;i<=h;i++)
	{
		scanf(" %s",s);
		for(ll j=1;j<=w;j++)
		{
			maze[i][j]=s[j-1]-'0';
		}
	}
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			sum[i][j]=sum[i][j-1]+maze[i][j];
		}
	}
	vector<ll> a;
	a.push_back(0);
	dfs(a,0,1);
	printf("%lld",ans);
}

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

int main(){

  long int N;
  cin >> N;
  set <int> A{2, 4, 5, 7, 9};
  set <int> B{0,1,6,8};
  set <int> C{3};

  N = N % 10;
  if(A.count(N)){
    cout << "hon" << endl;
  } else if (B.count(N)){
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int k,q;
  cin>>k>>q;
  vector<Int> ds(k);
  for(Int i=0;i<k;i++) cin>>ds[i];
  for(Int t=0;t<q;t++){
    Int n,x,m;
    cin>>n>>x>>m;
    n--;

    Int sum=x%m;
    Int ans=n;
    for(Int i=0;i<k;i++){
      sum+=(ds[i]%m)*(n/k+(i<n%k));
      if(ds[i]%m==0){
        ans-=n/k;
        if(i<n%k) ans--;
      }
    }
    ans-=sum/m;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N;
	std::cin >> N;

	vll ans(N + 1, 0);
	repeq(x, 1, (N+5)/6) {
		ll xx = x * x;
		repeq(y, x, (N + 5) /6) {
			ll yy = y * y;
			ll xy = x * y;
			repeq(z, y, (N + 5) /6) {
				ll tmp = xx + yy + z * z + xy + y * z + z * x;
				if (tmp <= N) {
					if (x == y && y == z) {
						ans[tmp]++;
					}
					else if (x == y || y == z) {
						ans[tmp] += 3;
					}
					else {
						ans[tmp] += 6;
					}
				}
			}
		}
	}
	repeq(i, 1, N) {
		std::cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
import collections

def prime_factorize(n):
    # 1に注意
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


a, b = map(int, input().split())

if a == 1 or b == 1:
    print(a*b)
    exit()

a_dic = collections.Counter(prime_factorize(a))
b_dic = collections.Counter(prime_factorize(b))

target_list = list(set(list(a_dic.keys()) + list(b_dic.keys())))

result = 1

for i in target_list:
    if i in a_dic and i in b_dic:
        value = max(a_dic[i], b_dic[i])
    elif i not in b_dic:
        value = a_dic[i]
    else:
        value = b_dic[i]
    result *= i ** value

print(result)

Measured memory_bytes: 3316
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^6+3;
long[10^^6+3] F, RF;

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

void main()
{
    init();
    auto Q = readln.chomp.to!int;
    foreach (_; 0..Q) {
        auto xdn = readln.split.to!(long[]);
        auto x = xdn[0];
        auto d = xdn[1];
        auto n = xdn[2];

        if (x == 0) {
            writeln(0);
            continue;
        }

        if (d == 0) {
            writeln(pow(x, n));
            continue;
        }

        x = (x * pow(d, P-2)) % P;
        if (x == 0 || x+n-1 >= P) {
            writeln(0);
            continue;
        }
        auto xton = (F[x+n-1] * RF[x-1]) % P;
        
        writeln((pow(d, n) * xton) % P);
    }
}

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

int main() {
  string s, t;
  char u;
  cin >> s >> t;
  
  int check = 0;
  for(int i = 0; i <= s.size(); i++){
    u = s.at(s.size() - 1);
    for(int j = s.size() - 1; j > 0; j--){
      s.at(j) = s.at(j - 1);
    }
    s.at(0) = u;
    
    if(s == t){
      check++;
      break;
    }
  }
  
  if(check > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

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

void Main()
{
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	if(a1+a2+a3 > 21){
		cout <<"bust" <<endl;
	}
	else{
		cout<<"win"<<endl;
	}

	return;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 200200;
const int M = (int)1e6 + 7;
const int A = 26;
string s[N];
int n;
pii ord[N];
int go[M][A];
int m;
int a[M][A];
int cnt[A];
ll ans = 0;

void solve(int id) {
	int v = 0;
	int L = (int)s[id].length();
	for (int i = 0; i < A; i++)
		cnt[i] = 0;
	for (int i = 0; i < L; i++)
		cnt[(int)(s[id][i] - 'a')]++;
	for (int i = 0; i < L; i++) {
		for (int c = 0; c < A; c++)
			if (cnt[c] > 0)
				ans += a[v][c];
		if (i == L - 1) break;
		int c = (int)(s[id][i] - 'a');
		cnt[c]--;
		if (go[v][c] == 0) go[v][c] = m++;
		v = go[v][c];
	}
	int c = (int)(s[id].back() - 'a');
	a[v][c]++;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

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

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		reverse(all(s[i]));
		ord[i] = mp((int)s[i].length(), i);
	}
	sort(ord, ord + n);
	m = 1;
	for (int i = 0; i < n; i++)
		solve(ord[i].second);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 159000
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int c = sc.nextInt();
    int line;
    int row;
    int[][] matrix = new int[r + 1][c + 1];
    for(int i = 0; i < r; i++) {
      line = 0;
      for(int j = 0; j < c; j++) {
        matrix[i][j] = sc.nextInt();
        line += matrix[i][j];
      }
      matrix[i][c] = line;
    }
    for(int i = 0; i < c + 1; i++) {
      row = 0;
      for(int j = 0; j < r; j++) {
        row += matrix[j][i];
      }
      matrix[r][i] = row;
    }
    for(int i = 0; i < r + 1; i++) {
      for(int j = 0; j < c + 1; j++) {
        if(j == c) {
          System.out.println(matrix[i][j]);
        } else {
          System.out.print(matrix[i][j] + " ");
        }
      }
    }
  }
}



Measured memory_bytes: 41316
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

int main(){
    map<int,int> m;
    int n; cin >> n;
    bool t = true;
    for(int i = 0; i < n; i++){
        int ent;
        cin >> ent;
        m[ent]++;
        if(m[ent] >= 2) t = false;
    }
    if(t)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}


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

int main(){
  int N,a,b,c,d;
  cin >> N;
  a = N/1000 , b = (N-a*1000)/100 , c = (N-a*1000-b*100)/10 , d = N-a*1000-b*100-c*10;
  //cout << d << c << b << a << endl;
  if ((a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

//const int mod = 1000000007;

int main() {
	int N, K, Q;
	scanf("%d %d %d", &N, &K, &Q);
	int *cnt = new int[N];
	for (int i = 0; i < N; i++)cnt[i] = K - Q;
	for (int i = 0; i < Q; i++) {
		int a;
		scanf("%d", &a);
		cnt[a - 1]++;
	}
	for (int i = 0; i < N; i++) {
		printf(cnt[i] > 0 ? "Yes\n" : "No\n");
	}
	return 0;
}


Measured memory_bytes: 1024
import math
import sys

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

if M == 1:
  print(1)
  sys.exit()
  
limit = math.ceil(math.sqrt(M))
A = []
for i in range(2, limit+1):
  if i in visited:
    continue
  j = i
  while j <= limit:
    visited.add(j)
    j += i
  del j
  k = 0
  while M % i == 0:
    M = M // i
    k += 1
  A.append(k)
if M > 1:
  A.append(1)

  
MOD = 10**9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

K = max(A) + N - 1
for i in range(2, K + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# ②事前計算した項を掛け合わせ
def cmb(n, r, MOD):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD
  
ans = 1  
for a in A:
  ans *= cmb(a + N-1, N-1, MOD)
  ans %= MOD
  
print(ans)
#print(A)
  
  
    
    
    

Measured memory_bytes: 97544
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int N,A;
  while (cin >> N >> A){
    string ans;
    if(N%500 <= A)ans = "Yes";
    else ans = "No";
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int output = 0;
      String lastChar = "";
      for(int i = 0; i < input.length(); i++){
        String tmp = input.substring(i , i + 1);
        if(lastChar.equals("")){
           lastChar = tmp;
         }else{
          if(!lastChar.equals(tmp)){
            lastChar = tmp;
            output++;
          }
        }
       }
      System.out.println(output);
	}
}


Measured memory_bytes: 31756
k,a,b=map(int,input().split())
if(b-a<3 or k+1<=a):
  print(k+1)
else:
  bis=a
  k=k-a+1
  if(k%2==0):
    print(bis+(b-a)*(k//2))
  else:
    print(bis+(b-a)*(k//2)+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k)
{
    Node* y = NIL;
    Node* x = root;
    Node* z;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    // xがNILのとき,その上のyは葉である
    // 根->...->葉->NIL
    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    // 葉がNILなら根なしなので根にする
    // 葉がNIL根でないなら葉の右か左かを判断する
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void find(int k)
{
    Node* x = root;
    Node* y = NIL;
    while (x != NIL) {
        y = x;
        if (x->key < k) {
            x = x->right;
        } else if (x->key > k) {
            x = x->left;
        } else {
            break;
        }
    }
    if (y->key == k) {
        puts("yes");
    } else {
        puts("no");
    }
}

void inorder(Node* u)
{
    if (u == NIL) {
        return;
    }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node* u)
{
    if (u == NIL) {
        return;
    }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    string com;
    cin >> n;
    rep(i, n)
    {
        cin >> com;
        if (com == "insert") {
            cin >> x;
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "find") {
            cin >> x;
            find(x);
        }
    }

    return 0;
}


Measured memory_bytes: 22036
'use strict'

function main(s) {

  s = s.split('\n');

  const w = Number(s[0].split(' ')[0]);
  const h = Number(s[0].split(' ')[1]);

  const xyas = s.slice(1, -1).map(l => l.split(' ').map(n => Number(n)));

  const bucket = [...Array(h)].map(l => [...Array(w)].fill(0));

  for (const xya of xyas) {
    const x = xya[0];
    const y = xya[1];
    const a = xya[2] - 1;

    const fromH = [0, 0, 0, y];
    const toH   = [h, h, y, h];
    const fromW = [0, x, 0, 0];
    const toW   = [x, w, w, w];

    for (let i = fromH[a]; i < toH[a]; i++) {
      for (let j = fromW[a]; j < toW[a]; j++) {
        bucket[i][j] = 1;
      }
    }
  }

  let count = 0;
  for (let i = 0; i < h; i++) {
    for (let j = 0; j < w; j++) {
      if (bucket[i][j] === 0) count += 1;
    }
  }

  console.log(count);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S, T;
  cin >> S >> T;
  long ans = 1000000, sub;
  for(int i = 0; i < S.size() - T.size() + 1; i++){
    sub = 0;
    for(int j = 0; j < T.size(); j++){
      if(S.at(i + j) != T.at(j))sub++;
    }
    ans = min(ans, sub);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    t = int(n / 1.08) - 2
    for i in range(t,t+5):
        if i * 108 // 100 == n:
            return i

    return ":("


print(main())





Measured memory_bytes: 6228
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    int active = 0;

    rep(i, n) {
        if(active >= h[i]) {
            active = h[i];
        } else {
            ans += h[i] - active;
            active = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int k;
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2) >> k;
  for (int i = 0; i < k; i++) {
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    vec.at(0) *= 2;
  }
  cout << vec.at(0) + vec.at(1) + vec.at(2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int A, B;
signed main() {
  cin>>A>>B;
  cout<<max(max(A+B,A-B),A*B)<<endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
const int N=1e5+5;
vector<int> v[N];
ll dp[N][2];
int n;
void dfs(int src,int par)
{
    dp[src][0]=dp[src][1]=1;
    for(auto i: v[src])
    {
        if(i==par)
            continue;
        dfs(i,src);
        dp[src][0]*=dp[i][1];
        dp[src][0]%=MOD;
        dp[src][1]=(dp[src][1]*dp[i][0] + dp[src][1]*dp[i][1])%MOD;
    }

}

int main()
{ quick;

    cin>>n;
    fab(0,n-1,i)
    {
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        v[x].pb((y));
        v[y].pb(x);
    }
    dfs(0,-1);
    cout<<(dp[0][0]+dp[0][1])%MOD;

 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 17652
#include <stdio.h>

int main(void)
{
  int N, X;
  int min = 1100;
  int i;
  
  scanf("%d %d", &N, &X);
  for(i = 0; i < N; i++) {
    int m;
    scanf("%d", &m);
    if(m < min) min = m;
    X -= m;
  }
  printf("%d\n", N + X / min);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
int a(void);
int b(void);
int c(void);
int main(void) {
	c();
	return 0;
}

int a(void) {
	int N;
	std::cin >> N;
	int res = N * N;
	std::cout << res;
	return 0;
}

int b(void) {
	int N;
	std::cin >> N;
	std::string S;
	std::cin >> S;

	if (S.size() % 2 == 0) {
		bool flag = true;
		for (int i = 0; i < S.size() / 2; i++) {
			if (S[i] != S[i + S.size() / 2]) {
				flag = false;
			}
		}
		if (flag) {
			std::cout << "Yes";
		}
		else {
			std::cout << "No";
		}
		
	}
	else {
		std::cout << "No";
	}
	return 0;
}

int c(void) {
	int N;
	std::cin >> N;
	int pos[8][2] = { 0 };
	for (int i = 0; i < N; i++) {
		std::cin >> pos[i][0] >> pos[i][1];
		
	}
	double dist[8][8] = { 0 };
	double dist_sum = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			int dx = pos[i][0] - pos[j][0];
			int dy = pos[i][1] - pos[j][1];
			double tmp_dist = sqrt(dx * dx + dy * dy);
			
			dist[i][j] = tmp_dist;
			dist[j][i] = tmp_dist;
			dist_sum += tmp_dist;
		}
	}
	int path_n = 1;
	int count = N - 1;
	while (count > 0) {
		path_n*= count;
		count--;
	}
	std::cout << std::setprecision(10) << dist_sum * 2 /N;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  map<char,int > x;
  
  for(int i=0;i<26;i++){
   char n= (char)i+97 ;
   x[n] = 0;
   //cout << n << endl;
  }
  for(int i=0;i<s.size();i++){
    x[s.at(i)]++;
  }
  
  string ans = "yes";
  for(int i=0;i<26;i++){
   char n= (char)i+97 ;
  // cout << n << ':' << x[n] << endl;
    if(x[n]>1)
      ans = "no";
  }
  
  cout << ans;
}


Measured memory_bytes: 256
N = int(input())

ab_list = []
for i in range(N):
    a,b = map(int,input().split())
    ab_list.append([a,b])

ab_list.sort(key=lambda x:(x[1],x[0]))

def check(ab_list):
    goukei = 0
    for a,b in ab_list:
        goukei += a
        if b < goukei:
#             print(a,b,goukei)
            return False
    return True

if check(ab_list):
    print("Yes")
else:
    print("No")

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

int zf(string& s) {
    int n = sz(s);
    vector<int> z(n);
    int l = 0, r = 0;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        z[i] = max(min(z[i - l], r - i), 0);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
            ++z[i];
        }
        if (i + z[i] > r) {
            r = i + z[i];
            l = i;
        }
        xmax(ans, min(i, z[i]));
    }
    return ans;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    while (sz(s)) {
        xmax(ans, zf(s));
        s.erase(s.begin());
    }
    cout << ans;
    return 0;
}


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

int main() {
    int i, n = 0;
    int a[3], score;
    vector<vector<int> > vec;
    
    while(1) {
        cin >> a[0] >> a[1] >> a[2];
        if(a[0] < 0 && a[1] < 0 && a[2] < 0) break;
        vec.push_back(vector<int>(a, a+sizeof(int)));
        ++n;
    }

    for(i=0; i<n; ++i) {
        if(vec[i][0] < 0 || vec[i][1] < 0) cout << 'F' << endl;
        else if(vec[i][0] + vec[i][1] >= 80) cout << 'A' << endl;
        else if(vec[i][0]+vec[i][1]>=65&&vec[i][0]+vec[i][1]<80)
            cout << 'B' << endl;
        else if(vec[i][0]+vec[i][1]>=50&&vec[i][0]+vec[i][1]<65)
            cout << 'C' << endl;
        else if(vec[i][0]+vec[i][1]>=30&&vec[i][0]+vec[i][1]<50) {
            if(vec[i][2] >= 50) {
                cout << 'C' << endl;
                continue;
            }
            cout << 'D' << endl;
        }
        else cout << 'F' << endl;
    }
    
    return 0;
}

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

#define fr first
#define sc second 
#define pt pair<int, int>
#define ll long long
#define scan(a, n) for(int i = 0; i < n; i++)cin >> a[i]; 

using namespace std;

const int MN = 190;

int dp[2][MN][MN][MN], pef[MN][MN];
string a[MN];

int sum(int r1, int c1, int r2, int c2){
    r1++, c1++, r2++, c2++;
    if(r1 > r2)swap(r1, r2);
    if(c1 > c2)swap(c1, c2);
    int ret = pef[r2][c2]-pef[r2][c1-1]-pef[r1-1][c2]+pef[r1-1][c1-1];
    //int qq = 0;
    //for(int i = r1-1; i < r2; i++){
    //    for(int j = c1-1; j < c2; j++){
    //        if(a[i][j] == '#')qq++;
    //    }
    //}
    //cout << r1-1 << ' ' << c1-1 << ' ' << r2-1 << ' ' << c2-1 << " : " << ret <<  " /--/ " << qq ;
    //if(qq != ret)cout << "\txx";
    //cout << '\n';
    return ret;

}

signed main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 1; i <= n; i++)for(int j = 1; j <= m; j++){
        pef[i][j] = pef[i-1][j]+pef[i][j-1]-pef[i-1][j-1]+(a[i-1][j-1]=='#');
    }
    //for(int i = 0; i <= n; i++){for(int j = 0; j <= m; j++)cout << pef[i][j] << ' '; cout << '\n';}
    for(int mv = 0; mv < 20; mv++){
    int mo = mv&1;
    for(int r1 = 0; r1 < n; r1++){
        for(int c = m-1; c >= 0; c--){
            int po = r1;
            for(int r2 = r1; r2 < n; r2++){
                dp[mo][r1][r2][c] = c-1;
                if(!mv){
                    int sm = sum(r1, c, r2, c);
                    if(sm != 0 && sm != r2-r1+1){
                        continue;
                    }
                    dp[mo][r1][r2][c] = c;
                    if(c == m-1){
                        continue;
                    }
                    if(a[r1][c] == a[r1][c+1])dp[mo][r1][r2][c] = dp[mo][r1][r2][c+1];
                    
                    continue;
                }
                dp[mo][r1][r2][c] = dp[mo^1][r1][r2][c];
                if(dp[mo][r1][r2][c] == m-1)continue;
                if(c == m-1 && r1 == r2){
                    dp[mo][r1][r2][c] = m-1;
                    continue;
                }
                if(c != m-1){
                    dp[mo][r1][r2][c] = max(dp[mo][r1][r2][c], dp[mo^1][r1][r2][dp[mo^1][r1][r2][c]+1]);
                }
                if(r1 != r2){
                    int ls = 0;
                    ls = min(dp[mo^1][r1][po][c], dp[mo^1][po+1][r2][c]);
                    for(int i = po+1; i < r2; i++){    
                        int q = min(dp[mo^1][r1][i][c], dp[mo^1][i+1][r2][c]);
                        if(q < ls)break;
                        ls = q;
                        po = i;
                    }
                    dp[mo][r1][r2][c] = max(dp[mo][r1][r2][c], ls);
                }
            }
            //cout << r1 << ' ' << c << " : ";
            for(int r2 = r1; r2 < n; r2++){
            //    cout << dp[mo][r1][r2][c] << ' ';
            }
            //cout << '\n';
        }
    }
        if(dp[mo][0][n-1][0] == m-1){
            cout << mv << '\n';
            exit(0);
        }
}
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ca=0,cb=0;
    rep(i,n){
        char c = s.at(i);
        if(c == '0'){
            if(i%2==0) ca++;
            else cb++;
        }
        else {
            if(i%2==0) cb++;
            else ca++;
        }
    }
    int res = min(ca,cb);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

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


Measured memory_bytes: 2108
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    x = II()
    return 'ABC' if x <1200 else 'ARC'

print(main())

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define SENTINEL 1000000001
typedef struct
{
  char c;
  int x;
} card;
void quickSort(card*,int,int);
int partition(card*,int,int);
void swap(card*,int,int);
void merge(card*,int,int,int);//almost same function compared to 5B
void mergeSort(card*,int,int);//almost same function compared to 5B
int arrayCompare(card*,card*,int);
void printArray(card*,int);
int main(void)
{
  int i;//counter
  int n;//length of array
  int par;//partition number
  card *arr;
  card *stableArr;
  scanf("%d",&n);
  arr=(card*)malloc(sizeof(card)*n);
  stableArr=(card*)malloc(sizeof(card)*n);
  for(i=0;i<n;i++)
    {
      scanf(" %c %d",&arr[i].c,&arr[i].x);
      stableArr[i]=arr[i];
    }
  quickSort(arr,0,n-1);
  mergeSort(stableArr,0,n);
  if(arrayCompare(arr,stableArr,n)==1) printf("Stable\n");
  else printf("Not stable\n");
  printArray(arr,n);
  return 0;
}
void quickSort(card *arr,int p,int r)
{
  int q;
  if(p<r)
    {
      q=partition(arr,p,r);
      quickSort(arr,p,q-1);
      quickSort(arr,q+1,r);
    }
}
int partition(card *arr,int p,int r)
{
  int i;//counter
  int parlast;//last index of first half part
  int sep=arr[r].x;//separate number
  parlast=p-1;
  for(i=p;i<r;i++)
    {
      if(arr[i].x<=sep)
	{
	  parlast++;
	  swap(arr,parlast,i);
	}
    }
  swap(arr,parlast+1,r);
  return parlast+1;
}
void swap(card *arr,int x,int y)
{
  card temp;
  temp=arr[x];
  arr[x]=arr[y];
  arr[y]=temp;
}
void merge(card *arr,int left,int mid,int right)
{
  int i,j,k;//counter
  int n1=mid-left;//the number of elements in array l
  int n2=right-mid;//the number of elements in array r
  card *l=(card*)malloc(sizeof(card)*(n1+1));
  card *r=(card*)malloc(sizeof(card)*(n2+1));
  for(i=0;i<n1;i++) l[i]=arr[left+i];
  for(i=0;i<n2;i++) r[i]=arr[mid+i];
  l[n1].x=SENTINEL;
  r[n2].x=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++)
    {
      if(l[i].x<=r[j].x)
	{
	  arr[k]=l[i];
	  i++;
	}
      else
	{
	  arr[k]=r[j];
	  j++;
	}
    }
  free(l);
  free(r);
}
void mergeSort(card *arr,int left,int right)
{
  int mid;//separate point of array
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergeSort(arr,left,mid);
      mergeSort(arr,mid,right);
      merge(arr,left,mid,right);
    }
}
int arrayCompare(card *arr1,card *arr2,int n)
{
  int i;
  for(i=0;i<n;i++)
    {
      if(arr1[i].c!=arr2[i].c||arr1[i].x!=arr2[i].x) return 0;
    }
  return 1;
}
void printArray(card *arr,int n)
{
  int i;//counter
  for(i=0;i<n;i++) printf("%c %d\n",arr[i].c,arr[i].x);
}



Measured memory_bytes: 3824
#include <stdio.h>
#include <iostream>

using namespace std;

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && B == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7 ;
#define pb push_back
#define all(v) v.begin(),v.end()
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n,m,k,l,y,x,z=0,ans=0,lang; string s ; bool ok ;
  map < ll , ll > mp ;

void solve()
{
cin>>n>>s;
ll west[n],east[n];
west[0]=(s[0]=='W');
for(int i=1;i<n;i++) west[i]=west[i-1] + (s[i]=='W');
east[n-1]=(s[n-1]=='E');
for(int i = n-2 ;i >=0;i--) east[i] = east[i+1] + (s[i]=='E');
ans = min(east[0],west[n-1]);

for(int i=1;i<n-1;i++)
    ans=min(ans , west[i-1] + east[i+1]);

    cout<<ans<<'\n';







    }



int main()
{


    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    srand (time(NULL));
    //freopen("test.in","r",stdin);
    //freopen("out.txt","w",stdout);
    int t;

     solve();

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  int sum = 0;
  for(int i = 0; i < n-1; i++) sum += a[i];
  if(a[n-1] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256