akhauriyash/Code-Regression huggingface dataset:
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int W,H,x,y,r;
            string[] str = Console.ReadLine().Split(' ');
            W = int.Parse(str[0]);
            H = int.Parse(str[1]);
            x = int.Parse(str[2]);
            y = int.Parse(str[3]);
            r = int.Parse(str[4]);

            if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");
        }
    }
}



Measured memory_bytes: 9004
import sys
from itertools import accumulate
 
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

import bisect

n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def hand(x):
  cnt=0
  for i in range(n):
    p=x-A[-i-1]
    k=n-bisect.bisect_left(A,p)
    if k==0:
      break
    cnt+=k
  return cnt

def main():
  l=0
  h=2*10**5+1
  mid=(l+h)//2
  
  while l+1<h:
    mid=(l+h)//2
    if hand(mid)<m:
      h=mid
    else:
      l=mid
  
  B = list(accumulate(A[::-1]))[::-1]

  ans=0
  cnt=0
  
  
  for i in range(n):
    y=l-A[i]+1
    index=bisect.bisect_left(A,y)
    if n==index:
      continue
    else:
      ans+=(n-index)*A[i]+B[index]
      cnt+=(n-index)
  
  ans+=(m-cnt)*l
  print(ans)

if __name__ == "__main__":
	main()
  

  
  

Measured memory_bytes: 55216
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<cstdio>

#define endl '\n'
#define ll long long
#define ull unsigned ll
#define x first
#define y second

using namespace std;

int shuzihe(int x){
    int ans=0;
    while(x){
        ans+=x%10;
        x/=10;
    }
    return ans;
}
int main(){
    int n,a,b;
    cin>>n;
    cin>>a>>b;
    int temp;
    int ans=0;
    for(int i=1;i<=n;i++){
        temp=shuzihe(i);
        if(temp>=a && temp<=b){
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>
#include <atcoder/lazysegtree>

using namespace std;
using namespace atcoder;

#define ll long long
#define ld long double

constexpr ll mod = 998244353LL;

ll many_ones[200001];
ll ten_pow[200001];

void prepare(void){
	many_ones[1] = 1;
	ten_pow[0] = 1, ten_pow[1] = 10;
	for (int i = 2; i <= 200000; ++i){
		many_ones[i] = (many_ones[i - 1] * 10 + 1) % mod;
		ten_pow[i] = ten_pow[i - 1] * 10 % mod;
	}
}

struct S{
    ll value;
    int size;
};

using F = int;

const F ID = int(2e9);

S op(S a, S b){ return {(a.value * ten_pow[b.size] % mod + b.value) % mod, a.size + b.size}; }

S e(){ return {0, 0}; }

S mapping(F f, S x){
    if(f != ID) x.value = many_ones[x.size] * f % mod;
    return x;
}

F composition(F f, F g){ return (f == ID ? g : f); }

F id(){ return ID; }

int main(void){
	prepare();
	int N, Q; cin >> N >> Q;
	vector<S> v(N, {1, 1});
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
	for (int i = 0; i < Q; ++i){
		int L, R, D;
		cin >> L >> R >> D;
		--L;
		seg.apply(L, R, D);
		cout << seg.prod(0, N).value << endl;
	}
	return 0;
}

Measured memory_bytes: 18836
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, a, b, m;
struct matrix {
	vector<vector<int>>mat;
	matrix(int x, int y) {
		mat.resize(x);
		rep(i, x)mat[i].resize(y);
		rep(i, x)rep(j, y)mat[i][j] = 0;
	}
	matrix operator+(matrix const& c) {
		assert(mat.size() == c.mat.size() && mat[0].size() == c.mat[0].size());
		matrix d = c;
		rep(i, mat.size())rep(j, mat[0].size()) {
			d.mat[i][j] += mat[i][j];
		}
		return d;
	}
	matrix operator-(matrix const& c) {
		assert(mat.size() == c.mat.size() && mat[0].size() == c.mat[0].size());
		matrix d = c;
		rep(i, mat.size())rep(j, mat[0].size()) {
			d.mat[i][j] -= mat[i][j];
		}
		return d;
	}
	matrix operator*(matrix const& c) {
		assert(mat[0].size() == c.mat.size());
		matrix res(mat.size(), c.mat[0].size());
		rep(i, res.mat.size())rep(j, res.mat[0].size())rep(k, mat[0].size()) {
			res.mat[i][j] += mat[i][k] * c.mat[k][j];
			res.mat[i][j] %= m;
		}
		return res;
	}
	matrix pow(int x) {
		assert(mat.size() == mat[0].size());
		matrix res(mat.size(), mat[0].size()), p(mat.size(), mat[0].size()); p.mat = mat;
		rep(i, mat.size())res.mat[i][i] = 1;
		while (x > 0) {
			if (x & 1)res = res * p;
			p = p * p;
			x >>= 1;
		}
		return res;
	}
};
signed main() {
	cin >> n >> a >> b >> m;
	matrix ans(1, 3);
	ans.mat = { {0,a % m,1} };
	for (int i = 1; i <= 18; i++) {
		int ma = min(mod_pow(10, i, inf) - 1, a + b * (n - 1));
		int mi = mod_pow(10, i - 1, inf) - 1;
		if (ma < a)continue;
		int ko = ((ma - a) / b + 1);
		if (mi >= a)ko -= (mi - a) / b + 1;
		if (ko < 0)continue;
		matrix p(3, 3);
		p.mat[0] = { mod_pow(10,i,m),0,0 };
		p.mat[1] = { 1,1,0 };
		p.mat[2] = { 0,b % m,1 };
		ans = ans * p.pow(ko);
	}
	cout << ans.mat[0][0] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		string S = GetString();
		string T = "CODEFESTIVAL2016";
		int ans = 0;
		for(int i = 0; i < S.Length; i++)
			if(S[i] != T[i])
				ans++;
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
# import math
# import bisect
#import numpy as np
import itertools
import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int,input().split()))
    a = list(map(int,input().split()))

    cmb = list(itertools.combinations([i for i in range(1, n)], k-1))
    ans = INF

    if k > 1:
            for ele in cmb:
                prc = 0
                prev = a[0]
                acp = copy.copy(a)
                for idx in ele:
                    if acp[idx] - prev <= 0:
                        prc += prev - acp[idx] + 1
                        acp[idx] = prev + 1
                    prev = acp[idx]
                cnt = 1
                mh = acp[0]
                for i in range(1, n):
                    if mh < acp[i]:
                        cnt += 1
                        mh = acp[i]
                if cnt >= k:
                    ans = min(ans, prc)
    else:
        ans = 0

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 41200
#include "bits/stdc++.h"
#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
    int n;
    cin >> n;
    int f[n][10];
    rep(i, n)
        rep(j, 10)
            cin >> f[i][j];
    int p[n][11];
    rep(i, n)
        rep(j, 11)
            cin >> p[i][j];

    bitset<10> bb;
    int ans = -INF;
    loop(i, 1, pow(2, 10)){
        bb = bitset<10> (i);
        int cnt = 0, sum = 0;
        rep(j, n){
            cnt = 0;
            rep(k, 10){
                cnt += (bb[k] == true && f[j][k] == true);
            }
            sum += p[j][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod = 998244353;
const int maxN = 1000010;
vector<int> d[maxN];
ll pre[maxN], inv[maxN];
int a[200010];
ll b[maxN];
int maxE = 0;
int n;
ll ans = 0;
ll powmod(ll base, ll times)
{
    ll res = 1;
    while (times > 0)
    {
        if (times&1) res = res * base % mod;
        times >>= 1;
        base = base * base % mod;
    }
    return res;
}
void init(int x)
{
    pre[0] = inv[0] = 1;
    for (ll i = 1; i <= x; i++)
        pre[i] = pre[i-1] * i % mod;
    inv[x] = powmod(pre[x], mod - 2);
    for (int i = x-1; i >= 1; i--)
        inv[i] = inv[i+1] * (i+1) % mod;
    ans = 0;
    for (int i = 1; i <= x; i++)
        for (int j = i; j <= x; j += i)
            d[j].push_back(i);

    for (int i = 1; i <= n; i++)
        for (auto p : d[a[i]])
            b[p] += a[i];

    for (int i = 1; i <= x; i++)
    {
        if (b[i] == 0) continue;
        b[i] %= mod;
        b[i] = b[i] * b[i] % mod;
    }

    for (int i = x; i >= 1; i--)
    {
        if (b[i] == 0) continue;
        ans = (ans + b[i] * (inv[i]*pre[i-1]%mod) % mod) % mod;
        for (auto p : d[i])
        {
            if (p != i)
                b[p] = (b[p] - b[i] + mod) % mod;
        }
    }
}
ll solve()
{
    ll res = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            res = (res + 1ll*a[i] / __gcd(a[i], a[j]) * a[j] % mod) % mod;
    return res;
}
int main()
{
    ll sum = 0;
    ll inv2 = powmod(2ll, mod - 2);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    maxE = *max_element(a + 1, a + n + 1);
    //printf("%lld\n", solve());
    sum %= mod;
    init(maxE);
    ans = (ans + mod - sum) % mod;
    ans = ans * inv2 % mod;
    printf("%lld\n", ans);
    return 0;
}



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

int main() {
  int n,k=1;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) scanf("%d",&a[i]);
  while(k<n&&a[k-1]==a[k]) k++;
  if(n==k) {
    cout << 1 << endl;
    return 0;
  }
  int f=a[k-1]<a[k],x=2;
  int ans=x;
  for(int i=k+1; i<n; i++) {
    while(i<n&&a[i-1]==a[i]) i++;
    if(i==n) break;
    if(!f&&a[i-1]>a[i]||f&&a[i-1]<a[i]) x++;
    else {
      f^=1;
      x=2;
    }
    ans=max(ans,x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3524
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

void print(int n,string s)
{
    // if(ch >= ('a'+n)) return;
    if(s.sze == n)
    {
        cout<<s<<endl;
        return;
    }


    set<char> st;

    forn(i,0,s.sze)
    {
        st.insert(s[i]);
    }
    st.insert((*(st.rbegin())+1));

    forv(i,st)
    {
        s += i;
        print(n,s);
        s.pop_back();
    }
}


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    int n;
    cin>>n;
        
    print(n,"a");    












    return 0;
}

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

#define infint 0x7fffffff //32-bit int
#define ninfint 0x80000000
#define EPS 1e-9

#define mp(A,B) make_pair(A,B)
#define pb push_back
#define pque priority_queue

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

#define endl '\n'

int N, K;
int H[100000], dp[100000];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        int min_j = i-1, min_cost = dp[min_j]+abs(H[min_j]-H[i]);
        for (int j = i-2; j >= i-1-K+1 && j >= 0; j--) {
            if (dp[j]+abs(H[j]-H[i]) < min_cost) {
                min_j = j;
                min_cost = dp[min_j]+abs(H[min_j]-H[i]);
            }
        }
        dp[i] = min_cost;
    }
    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R;
    cin >> R;
    if(R < 1200) cout<< "ABC" << endl;
    else if(R < 2800) cout << "ARC" << endl;
    else cout << "AGC" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    int a,b,c,x,y,z;
    cin >> a >> b >> c;
    x = std::min(b,c);
    y = (b+c)-a;
    if (y >=0) {
        z = y;
    }else
    {
        z = 0;
    }
    cout << x << " " << z << endl;
    
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

const MaxBufferSize = 1000000

func NextStr() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	buf := make([]byte, 10000)
	scanner.Buffer(buf, MaxBufferSize)
	scanner.Split(bufio.ScanWords)
	s := NextStr()

	var res int
	for _, c := range s {
		res += int(c - '0')
	}
	if res%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2500
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    const int num3=2200;
    vector<ll> a2(num3+1);
    vector<ll> a3(num3+1);

    int i,j;
    for(i=1; i<=num3; i++) {
        a2[i]=(ll)i*i;
        a3[i]=a2[i]*i;
    }

    int n;
    scanf("%d", &n);

    map<ll,int> cnt;
    for(i=0; i<n; i++) {
        ll s;
        scanf("%lld", &s);
        for(j=2; j<=num3; j++) {
            if(s<a3[j]) break;
            while(s%a3[j]==0) {
                s/=a3[j];
            }
        }
        cnt[s]++;
    }

    int ans=0;
    if(cnt.find(1)!=cnt.end()) {
        ans++;
        cnt.erase(1);
    }

    queue<ll> que;
    {
        auto it=cnt.begin();
        for(; it!=cnt.end(); ++it) {
            que.push(it->first);
        }
    }

    while(!que.empty()) {
        ll tt=que.front();
        que.pop();

        auto it=cnt.find(tt);
        if(it==cnt.end()) continue;

        ll curr=it->first;
        ll sub=1;
        for(j=2; j<=num3; j++) {
            if(curr<a2[j]) break;
            while(curr%a2[j]==0) {
                curr/=a2[j];
                sub*=j;
            }
            if(sub>num3) break;
        }
        if(sub>num3) continue;
        double chk=(double)curr*curr*sub;
        if(chk>1e12) continue;
        ll tmp=curr*curr*sub;
        auto it2=cnt.find(tmp);
        if(it2!=cnt.end()) {
            ans += MAX(it->second, it2->second);
            ll tmp0=it->first;
            ll tmp1=it2->first;
            cnt.erase(tmp0);
            cnt.erase(tmp1);
        }
    }

    auto it=cnt.begin();
    for(; it!=cnt.end(); ++it) {
        ans+=it->second;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<stdio.h>
using namespace std;
double DP[3010][3010];
double X[3010];
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>X[i];
  DP[0][0]=1;
  for(int i=0;i<N;i++)
    for(int j=0;j<=i;j++)
      DP[i+1][j+1]+=DP[i][j]*X[i],
      DP[i+1][j]+=DP[i][j]*(1-X[i]);
  double ans=0;
  for(int i=(N+1)/2;i<=N;i++)
    ans+=DP[N][i];
  printf("%.9lf\n",ans);
  return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    int mi = INF;
    int ans = 0;
    rep(i, n) {
        int p;
        cin >> p;
        if (chmin(mi, p)) ans++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
const char endk = '\n';
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll mod = 1e9 + 7;
	//const ll mod = 998244353;

	ll n;
	cin >> n;
	ll m = sqrt(n) + 1;
	vector<ll> ans(n + 1);
	for (ll i = 1; i <= m; i++) {
		for (ll j = 1; j <= m; j++) {
			for (ll k = 1; k <= m; k++) {
				ll x = i * i + j * j + k * k + i * j + j * k + k * i;
				if (x <= n) ans[x]++;
			}
		}
	}
	for (ll i = 1; i <= n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    string S, T;
    cin >> S >> T;
    rep(i, 26){
        char x = 'a'+i;
        if(S+x == T) {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
l = [int(input()) for i in range(5)]
l2 = [0,0,0,0,0]
m = 0
s = 0
for i in range(5):
  l2[i] = (l[i]+9)//10*10
  m = max(m,l2[i]-l[i])
  s += l2[i]
print(s-m)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s; cin >> s;
    
    int min = 10000;
    for (int i = 0; i < s.size() - 2; i++) {
        int tmp = 0, index = 100;
        for (int j = 0; j < 3; j++) {
            tmp += index * (s[i+j] - '0');
            index /= 10;
        }
        if (abs(tmp - 753) < min) {
            min = abs(tmp - 753);
        }
    }
    cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <ctime>
#include <queue>
#include <iostream>
#include <map>
using namespace std;
#define lol long long

int n,x,q[100000000],head,tail,ans,a[10000000],s;
map<int,int> flag;

inline int read()
{
	int x = 0 , f = 1;char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1;ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
	return x * f;
}
inline void out(int x)
{
	if (x < 0) putchar('-'),x=-x;
	if (x > 9) out(x / 10);
	putchar(x % 10 + 48);
}

inline int gcd(int a,int b)
{
	int r=a%b;
	if (!r) return b;
	else return gcd(b,a%b);
}

int main()
{
	n=read();
	ans=0x7fffffff;
	a[1]=read();
	s=a[1];
	for (int i=2; i<=n; i++)
	{
		a[i]=read();
		s=gcd(s,a[i]);
		//ans=min(a[i],ans);
	}
	/*sort(a+1,a+n+1);
	for (int i=1; i<=n; i++) q[i]=a[i];
	//for (int i=1; i<=n; i++) cout<<a[i]<<' ';cout<<endl;
	head=1;tail=n;
	while (head<=tail)
	{
		x=q[head++];
		//cout<<head<<' '<<tail<<' '<<x<<endl;
		//for (int i=head; i<=tail; i++)
		for (int i=1; i<=n; i++)
		{
			if (flag[q[i]%x]==0 && q[i]%x)
			{
				ans=min(ans,q[i]%x);
				q[++tail]=q[i]%x;
				flag[q[i]%x]=1;
			}
		}
	}*/
	cout<<s;
	return 0;
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  cout<<fixed<<setprecision(10);

  ll n,x,y; cin>>n>>x>>y;
  x--; y--;

  vint ans(n-1, 0);

  rep(i, n){
    rep(j, n){
      if(!(i<j)) continue;

      ll tmp = min(j - i, abs(x-i)+1+abs(y-j));

      ans[tmp-1]++;

    }
  }

  for(auto e:ans) cout<<e<<endl;


}






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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n, k;
  cin >> n >> k;

  ld total = 0;

  FOR(i, 1, n) {
    if (k <= i) {
      total++;
    }
    else {
      ld a = ceil(log2((ld)k/i));
      // COUT(a);
      total += (ld)1/pow(2, a);
    }
  }
  COUT(total/n);
}

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

/*
4 3
1 2
2 3
2 4
2 10
1 100
3 1
*/


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

#define M 10000

int main(){
  int i, j, n, C[M + 1];
  int *A, *B;

  scanf("%d", &n);

  A = (int *)malloc(sizeof(int) * n + 1);
  B = (int *)malloc(sizeof(int) * n + 1);
  
  for(i = 0; i <= M; i++)
    C[i] = 0;

  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    C[A[i]]++;
  }
  
  for(i = 1; i <= M ; i++)
    C[i] = C[i] + C[i - 1];
  
  for(j = 1; j <= n; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    if(i > 1)
      printf(" ");

    printf("%d", B[i]);
  }

  printf("\n");
}

  
  



Measured memory_bytes: 17404
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;
const int maxn = 100002;

int n, m, ind[maxn], f[maxn];
vector<vector<int> > g;

int main() {

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

	cin >> n >> m;
	g = vector<vector<int> >(n);

	int u, v;
	for (int i = 0; i < m; ++i)
	{
		cin >> u >> v;
		if (u == v)
			continue;

		--u;
		--v;

		g[u].push_back(v);
		++ind[v];
	}

	vector<int> qu;
	for (int i = 0; i < n; ++i)
		if (ind[i] == 0) {
			qu.push_back(i);
			ind[i] = -1;
		}
	
	int h = 0;
	while (qu.size() < n) {

		int cur = qu[h];
		++h;

		for (int i = 0; i < g[cur].size(); ++i) {
			v = g[cur][i];
			if (ind[v] > 0) {
				--ind[v];

				if (ind[v] == 0) {
					ind[v] = -1;
					qu.push_back(v);
				}
			}
		}
	}

	for (int i = 0; i < qu.size(); ++i) {
		int u = qu[i];
		for (int j = 0; j < g[u].size(); ++j) {
			int v = g[u][j];
			f[v] = max(f[v], f[u]+1);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i)
		ans = max(ans, f[i]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
int n;
vector<int> v[100100];
vector<int> v2[100100];
int ans[100100];
void go(int cr,int par,int las)
{
    int c=1;
    for(int i=0;i<v[cr].size();i++){
        if(v[cr][i]==par)continue;
        while(c==las)c++;
        ans[v2[cr][i]]=c;
        go(v[cr][i],cr,c);
        c++;
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n;
    int an=0;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        v2[a].pb(i);
        v2[b].pb(i);
        v[a].pb(b);
        v[b].pb(a);
        int o=max(v[a].size(),v[b].size());
        an=max(an,o);
    }
    cout<<an<<endl;
    go(1,0,an+100);
    for(int i=0;i<n-1;i++){cout<<ans[i]<<endl;}
    return 0;
    }


Measured memory_bytes: 13440
import collections
import itertools
def resolve():
    n = int(input())
    l = list(map(int, input().split()))
    c = collections.Counter(l)
    keys = c.keys()
    key_combinations = set(itertools.combinations(keys, 3))

    result = 0
    for combination in key_combinations:
        max_key = max(combination)
        if sum(combination) - max_key > max_key:
            # 三角形になる
            one_combination_result = 1
            for key in combination:
                one_combination_result = one_combination_result * c[key]
            result += one_combination_result
    print(result)
resolve()

Measured memory_bytes: 87148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	string S; cin >> S;
	int N = S.size();
	int ans = 0;
	rep(i,N-1){
		if(S[i] != S[i+1]) ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

template<class T> inline bool chmax(T& a, T b) {
    // chmax: change maximum
    // a より b の方が大きかったら，a の値を b の値に置き換える．
    // 書き換えた場合，true を返す
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    vector<vector<ll>> vec(N, vector<ll>(3));
    REP(i, N) {
        REP(j, 3) {
            cin >> vec[i][j];
        }
    }
    
    // calculation
    // init dp table
    vector<vector<ll>> dp(N+1, vector<ll>(3, 0));
    for (ll i = 0; i < N; ++i) {
        REP(j, 3) {
            REP(k, 3) {
                // j: i 日目に何を選んだか
                // k: i+1 日目に何を選ぶか
                if (j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + vec[i][k]);
            }
        }
    }
    
    ll res = 0;
    REP(i, 3) chmax(res, dp[N][i]);
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    string s, t; cin >> s >> t;
    set<char> S;
    for (auto &ch : s) {
        S.insert(ch);
    }
    for (auto &ch : t) {
        if (!S.count(ch)) {
            cout << "-1\n";
            exit(0);
        }
    }
    int n = SZ(s), m = SZ(t);
    vector<set<int>> all(30);
    for (int i = 0; i < n; i++) {
        all[s[i] - 'a'].insert(i);
    }
    int last = -1;
    ll totStrings = 0;
    for (int j = 0; j < m; j++) {
//        cerr << "cur letter: " << t[j] << "\n";
        int x = (t[j] - 'a');
        if (all[x].upper_bound(last) == all[x].end()) {
//            cerr << "here\n";
            totStrings++;
            last = -1;
            j--;
            continue;
        } else {
            int idx = (*(all[x].upper_bound(last)));
            last = idx;
//            cout << "new last: " << last << "\n";
        }
    }
    cout << totStrings * n + last + 1 << "\n";
}


Measured memory_bytes: 5200
#線分交差問題

import bisect

class BIT:
    def __init__(self, n):
        self.tree = [0]*(n+1)
        self.n = n
    
    def add(self, i, v):
        while i <= self.n:
            self.tree[i] += v
            i += i & -i
        
    
    def _sum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i -= i & -i
        return ret
    
    def sum(self, l, h):
        return self._sum(h) - self._sum(l-1)
    
n = int(input())
vx = []
xs = set()
for _ in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if x1 == x2:
        if y1 > y2:
            y1, y2 = y2, y1
        vx.append((y1, float('-inf'),x1))
        vx.append((y2, float('inf'),x2))
        xs.add(x1)
    else:
        if x1 > x2:
            x1, x2 = x2, x1
        vx.append((y1, x1, x2))
vx.sort()

bit = BIT(len(xs))
xs = [float('-inf')] + sorted(xs)
ix = {v: i for i, v in enumerate(xs)}
ans = 0

for y, j, x2 in vx:
    if j == float('-inf'):
        bit.add(ix[x2],1)
    elif j == float('inf'):
        bit.add(ix[x2], -1)
    else:
        l = bisect.bisect_left(xs, j)
        r = bisect.bisect(xs, x2) - 1
        ans += bit.sum(l, r)
        
print(ans)



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
    string key = "keyence";

    REP(xxx, 8) {
        bool check = true;
        REP(i, xxx) {
            if(key[i] != S[i]) check = false;
        }

        REP2(i, xxx, 7) {
            if(key[i] != S[S.size()-7+i]) check = false; 
        }

        if(check) {
            cout << YES << endl;
            return;
        }
    }

    cout << NO << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
from itertools import product
while True:
    d, w = map(int, input().split())  # 高さdと幅w
    if d == 0:
        break
    gridgraph = [list(map(int, input().split())) for _ in range(d)]
    ans = 0
    for si, sj in product(range(1, d-1), range(1, w-1)):
        for ti, tj in product(range(si, d-1), range(sj, w-1)):
            # これで内部の池の範囲が指定できた
            # 内部の最大値を考えたい
            max_in_area = 0
            for i, j in product(range(si, ti+1), range(sj, tj+1)):
                max_in_area = max(max_in_area, gridgraph[i][j])

            # 周囲の最小値を考えたい
            huti_min = 100
            # 右方向を考えたい
            for i, j in product([si-1, ti+1], range(sj-1, tj+2)):  # rangeの仕様に注意
                huti_min = min(huti_min, gridgraph[i][j])

            # 下方向を考えたい
            for i, j in product(range(si-1, ti+2), [sj-1, tj+1]):  # rangeの仕様に注意
                huti_min = min(huti_min, gridgraph[i][j])

            if max_in_area >= huti_min:
                continue

            tmp = 0
            for i, j in product(range(si, ti+1), range(sj, tj+1)):
                tmp += huti_min - gridgraph[i][j]
            ans = max(ans, tmp)

    print(ans)



Measured memory_bytes: 5676
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll oo = 1e15, N = 2e5 + 10;
vector < char > ans;
int A, B, C, n;
string s[N];
void _do(string s){
	if(s[0] == 'A')A++;
	if(s[0] == 'B')B++;
	if(s[0] == 'C')C++;
	if(s[1] == 'A')A--;
	if(s[1] == 'B')B--;
	if(s[1] == 'C')C--;
	ans.push_back(s[0]);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> A >> B >> C;
	for(int i = 1; i <= n; ++i){
		cin >> s[i];
	}
	for(int i = 1; i <= n; ++i){
		if(s[i] == "AB"){
			if(A == 0 && B == 0){
				cout << "No\n";
				return 0;
			}
			if(B == 0){
				_do("BA");
				continue;
			}
			if(A == 0){
				_do("AB");
				continue;
			}
			if(A > 1 && B > 1){
				_do("AB");
				continue;
			}
			if(A == 1 && B > 1){
				_do("AB");
				continue;
			}
			if(B == 1 && A > 1){
				_do("BA");
				continue;
			}
			if(i == n){
				_do("BA");
				continue;
			}
			if(s[i + 1] == "AC" || s[i + 1] == "AB"){
				_do("AB");
			}else{
				_do("BA");
			}
		}
		if(s[i] == "AC"){
			if(A == 0 && C == 0){
				cout << "No\n";
				return 0;
			}
			if(A == 0){
				_do("AC");
				continue;
			}
			if(C == 0){
				_do("CA");
				continue;
			}
			if(A > 1 && C > 1){
				_do("AC");
				continue;
			}
			if(A == 1 && C > 1){
				_do("AC");
				continue;
			}
			if(C == 1 && A > 1){
				_do("CA");
				continue;
			}
			if(i == n){
				_do("AC");
				continue;
			}
			if(s[i + 1] == "AB" || s[i + 1] == "AC"){
				_do("AC");
			}else{
				_do("CA");
			}
		}
		if(s[i] == "BC"){
			if(B == 0 && C == 0){
				cout << "No\n";
				return 0;
			}
			if(B == 0){
				_do("BC");
				continue;
			}
			if(C == 0){
				_do("CB");
				continue;
			}
			if(B > 1 && C > 1){
				_do("BC");
				continue;
			}
			if(B == 1 && C > 1){
				_do("BC");
				continue;
			}
			if(C == 1 && B > 1){
				_do("CB");
				continue;
			}
			if(i == n){
				_do("BC");
				continue;
			}
			if(s[i + 1] == "AB" || s[i + 1] == "BC"){
				_do("BC");
			}else{
				_do("CB");
			}
		}
	}
	cout << "Yes\n";
	for(int i = 0; i < n; ++i){
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 10048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int q;
    cin >> q;
    int a, x, y;
    multiset<int> s;
    while(q--){
        cin >> a >> x;
        if(a==0){
            s.insert(x);
            cout << s.size() << "\n";
        }else if(a==1){
            cout << s.count(x) << "\n";
        }else if(a==2){
            s.erase(x);
        }else{
            cin >> y;
            set<int>:: iterator start, end;
            end=s.upper_bound(y);
            for(start=s.lower_bound(x); start!=end; start++){
                cout << *start << "\n";
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 12272
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
mini = 0
maxi = max(A)
while maxi - mini > 1:
    mid = (maxi+mini)//2
    s = sum(math.ceil(a/mid)-1 for a in A)
    if s>K:
      mini = mid
    else:
      maxi = mid
print(mini+1)

Measured memory_bytes: 31044
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int i, j, x, y;
    int n, m, t;
    
    scanf("%d %d", &t, &m);
    n=min(t, m);
    m=max(t, m);
    if(n==2 or m==2)
        printf("0");
    else if(n==1 and m==1)
        printf("1");
    else if(n==1)
        printf("%d", m-2);
    else
        printf("%lld", 1LL*(n-2)*(m-2));
    return 0;
}

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

using namespace std;

void Solve(){
    int a, b, c;
    cin>>a>>b>>c;
    swap(a, b);
    swap(a, c);
    cout<<a<<" "<<b<<" "<<c<<endl;

}
int main(){
    int q = 1;
    while(q--){
        Solve();
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

int n,k,y,x;

int main()
{
    cin >> n >> k >> x >> y;
    int ans;
    if(k < n){
        cout << x*k + y*(n-k) << endl;
    }
    else cout << x*n << endl;
}



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

int main(void){
  int n; cin>>n;
  string s; cin>>s;
  int k; cin>>k;
  for(int i=0; i<s.length(); ++i){
    if( s[i] != s[k-1]) s[i] = '*';
  }
  cout << s << endl;
}



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

const int INF = 1<<29;
int road[100][100];

int main() {
  int N,M,L,K,A,H;
  while(cin>>N>>M>>L>>K>>A>>H, N|M|L|K|A|H) {
    for(int i=0; i<100; ++i) {
      for(int j=0; j<100; ++j)
	road[i][j] = INF;
      road[i][i] = 0;
    }

    vector<int> coooooool;
    int t;
    for(int i=0; i<L; ++i) {
      cin>>t;
      coooooool.push_back(t);
    }
    coooooool.push_back(A);
    coooooool.push_back(H);

    int X,Y,T;
    for(int i=0; i<K; ++i) {
      cin>>X>>Y>>T;
      road[X][Y] = T;
      road[Y][X] = T;
    }

    for(int k=0; k<N; ++k)
      for(int i=0; i<N; ++i)
	for(int j=0; j<N; ++j)
	  road[i][j] = min(road[i][j], road[i][k]+road[k][j]);

    for(int i=0; i<N; ++i) {
      if(find(coooooool.begin(), coooooool.end(), i) == coooooool.end())
	for(int j=0; j<N; ++j) {
	  road[i][j] = road[j][i] = INF;
	}
    }

  for(int i=0; i<N; ++i)
    for(int j=0; j<N; ++j)
      if(road[i][j] > M)
	road[i][j] = INF;

    for(int k=0; k<N; ++k)
      for(int i=0; i<N; ++i)
	for(int j=0; j<N; ++j)
	  road[i][j] = min(road[i][j], road[i][k]+road[k][j]);

    if(road[A][H] == INF) cout<<"Help!"<<endl;
    else cout<<road[A][H] + max(0, road[A][H]-M)<<endl;
  }
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int main()
{
  fastio();

  string s,t;
  cin >> s;

  if (s == "Sunny")
    t = "Cloudy";
  else if (s == "Cloudy")
    t = "Rainy";
  else
    t = "Sunny";

  cout << t << endl;


  return 0;
}


Measured memory_bytes: 256