akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) 			a.begin(),a.end()
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define MOD 			1000000007
#define FOR(i,a,b) 		for(int i = a; i <= b ; i++)
#define forn(i,n) 		for(int i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			int t;cin>>t;while(t--)
#define ll				long long
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define ff				first
#define ss 				second
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vb 				vector<bool>

using namespace std;
using pii = pair<int,int>;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll power(ll a,ll b,ll mod)
{
	ll res = 1;
	a = a % mod;
	while(b)
	{
		if(b & 1)
			res = (res * a) % mod;
		b = b >> 1;
		a = (a * a) % mod;
	}
	return res;
}
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/


int main()
{
	fast
	int n;
	cin>>n;
	vi a(n);
	int ans = 0;
	forn(i,n)cin>>a[i];
	for(int i = 0 ;i < n -2 ; i++)
	{
		int x = a[i + 1];
		vi b = {a[i],a[i + 1] ,a[i + 2]};
		sort(all(b));
		if(b[1] == x)
			ans++;
	}
	cout<<ans<<endl;
}

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

using namespace std;
using namespace atcoder;

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

int op(int a, int b) {return max(a, b);}
int e() {return -1;}

int N, K;
int A[300010];
segtree<int, op, e> seg(300010);

signed main()
{
    cin >> N >> K;
    rep(i, N)cin >> A[i];

    rep(i, N)
    {
        int now = seg.prod(max(0ll, A[i] - K), min(A[i] + K + 1, 300010ll)) + 1;
        now = max(now, 1ll);

        seg.set(A[i], now);
    }

    cout << seg.prod(0, 300010) << endl;

    return 0;
}

Measured memory_bytes: 13668
mod = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort(key=lambda x:-abs(x))

if N==K:
    ans = 1
    for i in range(N):
        ans *= A[i]
        ans %= mod
elif A[K-1]==0:
    ans = 0
else:
    p = []
    p_ = []
    n = []
    n_ = []
    for i in range(N):
        a = A[i]
        if i<K:
            if a>0:
                p.append(a)
            elif a<0:
                n.append(a)
        else:
            if a>0:
                p_.append(a)
            elif a<0:
                n_.append(a)
    if len(n)%2==0:
        ans = 1
        for a in n:
            ans *= a
            ans %= mod
        for a in p:
            ans *= a
            ans %= mod
    else:
        if len(p)+len(p_)==0:
            if len(n)+len(n_)==N:
                n += n_
                ans = 1
                for i in range(K):
                    ans *= n[-i-1]
                    ans %= mod
            else:
                ans = 0
        else:
            if len(p)==0:
                n.pop()
                ans = p_[0]
                for a in n:
                    ans *= a
                    ans %= mod
            else:
                cand = []
                ap = p.pop()
                if p_:
                    cand.append([ap,p_[0]])
                an = n.pop()
                if n_:
                    cand.append([an,n_[0]])
                if len(cand)==2:
                    ap1,ap2 = cand[0]
                    an1,an2 = cand[1]
                    ans = max(ap1*ap2,an1*an2)%mod
                    for a in n:
                        ans *= a
                        ans %= mod
                    for a in p:
                        ans *= a
                        ans %= mod
                else:
                    ans = cand[0][0]*cand[0][1]%mod
                    for a in n:
                        ans *= a
                        ans %= mod
                    for a in p:
                        ans *= a
                        ans %= mod
print(ans)

Measured memory_bytes: 114484
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
ll inf = 1001001000;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, n; cin >> h >> n;
	vl a(n), b(n);
	rep(i, n)cin >> a[i] >>  b[i];
	ll w = h + 1e4;
	vvl dp(n+1, vl(w, inf));
	dp[0][0] = 0;
	rep(i, n)rep(j, w)
	{
		if (j >= a[i])
		{
			chmin(dp[i + 1][j], dp[i][j]);
			chmin(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
		}
		else
		{
			chmin(dp[i + 1][j], dp[i][j]);
		}
	}
	ll ans = inf;
	rep(i, n+1)rep(j,w)
	{
		if(h<=j)chmin(ans, dp[i][j]);
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 160640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define ft first
#define sd second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

string now;
int m[2333][2333],n,num;

bool check_c(int j){
	for(int i=1;i<=n;i++){
		if (m[i][j]==0)	return false;
	}
	return true;
}
int main(){
    num= 0;
	scanf("%d",&n);
	rep(i,0,n){
		cin>>now;
		rep(j,0,n){
			m[i+1][j+1]=(now[j]=='#'?1:0);
            if (m[i+1][j+1])num++;
		}
	}
    if (num ==0){printf("-1\n");return 0;}
	int ans=233333333;
	for(int i=1;i<=n;i++){
		int nowans=0;
		bool flag=false;
		for(int j=1;j<=n;j++){
            if(m[j][i])break;
            if(j==n)nowans++;
		}
        for(int j=1;j<=n;j++){if(!check_c(j))nowans++;if(!m[i][j])nowans++;}
		ans=min(ans,nowans);
	}
	if (ans==233333333)printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 5632
cnt = 0
def merge(L,R):
    global cnt
    A = []
    i = j = 0
    n = len(L)+len(R)
    L.append(float("inf"))
    R.append(float("inf"))
    for _ in range(n):
        cnt += 1
        if L[i] <= R[j]:
            A.append(L[i])
            i += 1
        else:
            A.append(R[j])
            j += 1
    return A

def mergeSort(A):
    if len(A)==1: return A
    m = len(A)//2
    return merge(mergeSort(A[:m]),mergeSort(A[m:])) 
    

if __name__=='__main__':
    n=int(input()) 
    A=list(map(int,input().split()))
    print(*mergeSort(A))
    print(cnt)

Measured memory_bytes: 63772
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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

int main(){
    int K; cin >> K;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[K-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    double ans=0;
    sort(v.begin(),v.end());
    for(int i=0;i<n-1;i++)
    {
        ans=double(v[i]+v[i+1])/2.0;
        v[i+1]=ans;
    }
    printf("%.7lf\n",ans);
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 1e6+1;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// n < 0 にも対応
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

int main(){
  int n,q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> C(26);
  rep(i,n) C[s[i]-'a'].insert(i);
  rep(i,26) C[i].insert(1e9);

  while(q--){
    int f,l,r;
    char c;
    cin >> f;
    if(f == 1){
      cin >> l >> c;
      l--;
      auto p = C[s[l]-'a'].lower_bound(l);
      C[s[l]-'a'].erase(p);
      s[l] = c;
      C[s[l]-'a'].insert(l);
      continue;
    }

    // f = 2
    cin >> l >> r;
    l--; r--;
    int cnt = 0;
    rep(i,26) {
      int p = *C[i].lower_bound(l);
      if(p <= r) cnt++;
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 24196
#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[100005];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",a+1);
	a[m]+=32;
	for(int i=1;i<=n;i++)printf("%c",a[i]);
	return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

vector<ii> _2s;

long double solve(int N, int K)
{
    long double one = 1.0;
    long double ans = 0.0;

//cout << "ans = " << ans << endl;

    for (int i = 1; i <= min(N, K - 1); ++i)
    {
//cout << "-- i = " << i << endl;


        int m = (K + (i - 1)) / i;
        auto it = lower_bound(_2s.begin(), _2s.end(), ii(m, 0));
        auto q = it->second;

//cout << "  case 1 - i = " << i << ", m = " << m << ", q = " << q << ", pot = " << it->first << endl;
//cout << "1/N = " << one / N << endl;
//cout << "1/2 ^ " << q << " = " << powl(one / 2.0, q) << endl;
//cout << "prod = " << (one/N)*(powl(one/2.0, q)) << endl;

        ans += ((one/N)*(powl(one/2.0, q)));
//cout << "  partial ans = " << ans << endl;
    }

    if (N >= K)
    {
        ans += (N - K + 1)*(one / N);
//cout << "  case2 - partial ans = " << ans << endl;
    }
     
    return ans;
}

// 0.000001250000000 
// 0.000001250000000 

// 0.000002500000000 

int main()
{
    for (int i = 0; i < 64; ++i)
        _2s.push_back(ii(1LL << i, i));

    int N, K;
    cin >> N >> K;

    cout.precision(15);
    cout << fixed << solve(N, K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,k; cin >> n >> k;
	ll ans = 0;
	while(n > 0){
		n /= k;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
stdin.ReadLine()
|> fun S ->
    match S with
    | "SUN" -> 7
    | "MON" -> 6
    | "TUE" -> 5
    | "WED" -> 4
    | "THU" -> 3
    | "FRI" -> 2
    | "SAT" -> 1
    | _ -> 0
|> stdout.WriteLine


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 5;
int a[maxn], b[maxn], dp[10 * maxn][maxn];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int h, n; cin >> h >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i] >> b[i];
    for (int i = 1; i <= h; ++i)
        dp[i][0] = 100000000;
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= n; ++j)
            if (a[j] >= i) dp[i][j] = min(b[j], dp[i][j - 1]);
            else dp[i][j] = min(b[j] + dp[i - a[j]][j], dp[i][j - 1]);
    cout << dp[h][n] << '\n';
    return 0;
}

Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) (x).begin(),(x).end()
typedef vector<int> vi;
#define inf 10e18;
#define pb push_back
#define pii pair<int,int>
#define vector<pii> vp
int i=0,j=0;
#define pi atan(1)*4
#define mp make_pair
#define F first
#define S second
#define loop(n) for(int i=0;i<n;++i)
#define ld long double

int main(){
   int n;cin>>n;
   ll ans = 0;
   for(i=1;i<=n;++i){
        if(i%3==0||i%5==0)continue;
        else ans += i;
   }
   cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main(int , char **)
{
	char A[11]={},B[11]={},C[11]={};
	cin >> A >> B >> C;
	size_t lngA=strlen(A);
	size_t lngB=strlen(B);
	if ((A[lngA-1]==B[0])&&(B[lngB-1]==C[0])){printf("YES\n");}else{printf("NO\n");}

	return 0;
}

Measured memory_bytes: 256
s1 = input()
t = input()

ans = list("UNRESTORABLE")
for i in range(len(s1) - len(t), -1, -1):
    if all(list(map(lambda j: s1[i + j] == '?' or s1[i + j] == t[j], range(len(t))))):
        ans = list(s1)
        for j in range(len(t)):
            ans[i + j] = t[j]
        for j in range(len(s1)):
            if ans[j] == '?':
                ans[j] = 'a'
        break

print(''.join(ans))

Measured memory_bytes: 38256
#include<stdio.h>
int main(void){
    int a;
    int b;
    int c;
    int d;
    int count = 0;
    scanf("%d%d%d",&a,&b,&c);
    for(d=a;d<=b;d++){
        if(c%d==0){
        count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 596
N=int(input())
A=list(map(int,input().split()))
kari=[0]*((10**6)+1)
A.sort()
hako=[]
for i in range(N):
    kari[A[i]]+=1

for i in range(N):
    if kari[A[i]]==1:
        hako.append(A[i])
kari=[0]*((10**6)+1)
aru=A.copy()
count=0
aru=list(set(aru))
#print(hako)
for i in aru:
    for j in range(i*2,10**6+1,i):
        kari[j]+=1
for i in hako:
    if kari[i]==0:
        count+=1
print(count)

Measured memory_bytes: 45120
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int solve(vector<int>& height, int n)
{
   vector<int> dp(n+1);
   dp[1] = 0;
   for(int i = 2; i <= n; i++)
   {
       if(i == 2)
         dp[i] = abs(height[i] - height[i-1]) + dp[i-1];
       else dp[i] = min(abs(height[i] - height[i-1]) + dp[i-1], abs(height[i] - height[i-2]) + dp[i-2]);
   }
   return dp[n];
}

int main()
{
   int n,k;
   cin >> n;
   vector<int> height(n+1);
   for(int i=1;i<=n;i++)
   {
       cin>>height[i];
   }
   cout<<solve(height, n);
   return 0;
}


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

using namespace std;

int a[200005],b[200005];

int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
        cin>>a[i], b[i]=a[i];
    sort(b,b+n);
    int unu=b[n/2-1];
    int doi=b[n/2];
    for (int i=0;i<n;i++)
    {
        if (a[i]<=unu)
            cout<<doi<<'\n';
        else cout<<unu<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3712
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x > a:
	x_a = x - a
else:
	x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	


if x_a > x_b:
	print("B")
else:
	print("A")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int a,b,h,ans=0;
  cin>>a>>b>>h;
  ans = (a+b)*h/2;
  cout<<ans<<endl;
}


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

int main()
{
    
    int length;
    char str[1000];
    cin>>str;
    
    length = strlen(str);
    if (str[length-1]=='s')
    {
    strcat(str,"es");
    cout<<str;
    }
    else if(str[length-1]!='s')
    {
    strcat(str, "s");
    cout<<str;
    }
return 0;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

double d(pair<double, double> a, pair<double, double> b)
{
    return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
}

int fact(int n)
{
    if (n <= 1) return 1;
    return n * fact(n-1);
}

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

    int N; cin >> N;
    vector<pair<double, double>> city(N);
    REP(i, N) cin >> city[i].fi >> city[i].se;
    vi p(N); REP(i, N) p[i] = i;
    double ans = 0;
    do
    {
        double dist = 0;
        REP(i, N-1) dist += d(city[p[i]], city[p[i+1]]);
        ans += dist;
    }while(next_permutation(ALL(p)));
    ans /= fact(N); 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int n,m=0,p=0,a[50],b[50],c[50];
int main() {
	scanf("%d",&n);
	while(n>1) {
		++m;
		if(n&1) b[p]=m,c[p]=n-1,++p;
		a[m]=n>>=1;
	}
	printf("%d %d\n",m+1,m*2+p);
	for(int i=1;i<=m;++i) printf("%d %d %d\n%d %d %d\n",i,i+1,a[i],i,i+1,0);
	for(int i=0;i<p;++i) printf("%d %d %d\n",b[i],m+1,c[i]);
	return 0;
}

Measured memory_bytes: 128
import bisect
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

a = getint()
s = input()

print(s if a >= 3200 else "red")

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
using ll = long long ;

const double pi=3.14159265358979323846;

int min(int a, int b){
    if(a<b) return a ;
    else return b ;
}

int max(int a, int b){
    return (a<=b) ? a : b  ;
}

int main() {

    int k ; 
    string s ;
    cin >> k >> s  ;
    int sz = s.size() ;

    if(sz<=k)
     cout << s << endl ;
    else
    {   
        for(int i=0;i<k;++i){
            cout << s[i] ;
        }
        cout << "..." << endl ;
    }
    
  return 0 ;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans=0;
  REP(a2,10) {
    REP(a1,10) {
      REP(a0,10) {
        int fnd = 0;
        REP(i,N) {
          if(fnd==0) {
            if ( a2 == (S[i]-'0') ) fnd++;
          } else if(fnd==1) {
            if ( a1 == (S[i]-'0') ) fnd++;
          } else {
            if ( a0 == (S[i]-'0') ) {
              ans++;
              break;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[22],b[22],c[22];
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		ans+=b[i];
	}
	for(int i=0;i<n-1;i++)
	{
		cin>>c[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]==a[i]+1)
		{
			ans+=c[a[i]-1];
		} 
	}
	cout<<ans;
	return 0;
}

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

class Myon{
    static void Main(string[] args){
        var myon = new Myon();
    }

    public Myon(){
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);

        if(A-B >= 2){
            Console.WriteLine(A + A - 1);
        }else if(B-A >= 2){
            Console.WriteLine(B + B -1);

        }else{
            Console.WriteLine(A + B);
        }
    }
}

Measured memory_bytes: 11092
$s = <STDIN>;
my ($X,$Y,$A,$B,$C) = split(/ /,$s);

@all;
$s = <STDIN>;
@dat = split(/ /,$s);
my @AL = sort{ $b - $a } @dat;

$s = <STDIN>;
@dat = split(/ /,$s);
my @GL = sort{ $b - $a } @dat;

$s = <STDIN>;
@dat = split(/ /,$s);
my @ALL = sort{ $b - $a } @dat;

for($i=0;$i<$X;$i++){
  push ( @ALL ,$AL[$i]);
}
for($i=0;$i<$Y;$i++){
  push ( @ALL ,$GL[$i]);
}

@ALL = sort{ $b - $a } @ALL;

$ans =0;
for($i=0;$i<($X+$Y);$i++){
  $ans = $ans + $ALL[$i];
}
print "$ans";

Measured memory_bytes: 56412
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n,m;
  cin >> n >> m;
  set<int> a;
  rep(i,m) {
    int ai;
    cin >> ai;
    a.emplace(ai);
  }
  vector<mint> dp(n+1);
  dp[0] = 1;
  if(a.count(1)==0) dp[1] = 1;
  rep(i,n-1) if(a.count(i+2)==0) dp[i+2] = dp[i+1] + dp[i];
  cout << dp[n] << endl;
}


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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		for(;;){
			String card = sc.next();
			if(card.equals("-")) break;
			int m = sc.nextInt();
			int l = card.length();
			int idx = 0;
			for(int i = 0; i < m; ++i){
				int h = sc.nextInt();
				idx = (idx + h) % l;
			}
			for(int i = idx; i < l; ++i)
				System.out.print(card.charAt(i));
			for(int i = 0; i < idx; ++i)
				System.out.print(card.charAt(i));
			System.out.println();
		}
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24252
#include <iostream>

using namespace std;

int const cset[] = { 500, 100, 50, 10, 5, 1 };

int main()
{
    int m;
    while( cin >> m ) {
        if ( m == 0 )
            break;

        int r = 1000 - m;
        int sum = 0;
        for( auto const& c : cset ) {
            for(;;) {
                if ( r - c >= 0 ) {
                    ++sum;
                    r -= c;
                } else {
                    break;
                }
            }
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

//Euclidean algorithm
int gcd(long m, long n)
{
	long t;
	while (n != 0) {
		t = n, n = m % n, m = t;
	}
	return m;
}

//gcd(a, b) * lcm(a, b) = a * b
int lcm(long n, long m) {
	return n * m / gcd(n, m); 
}

int main(){
	long m, n;

	while(cin >> m >> n) {
		if(m > n) swap(n, m);
		cout << gcd(n, m) << " " << lcm(n, m) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

int func(int n) {

  int m = 1;
  do {
    m = n*m;
  }while(--n);

  return m;
}

int main() {

  int n;
  double sum = 0;
  cin >> n;
  int x[n], y[n];
  rep(i, n) cin >> x[i] >> y[i];

  for(int i=0; i<n; ++i) {
    for(int j=i+1; j<n; ++j) {
      double a = pow((x[i]-x[j]),2)+pow((y[i]-y[j]),2);
      sum += 2*(func(n-1))*sqrt(a);
    }
  }

  cout << fixed;
  cout << setprecision(7) << (sum)/func(n) << endl;

  return 0;
}


Measured memory_bytes: 256
#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 ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{  int n,x,y;
  cin>>n>>x>>y;MII mr;
   for(int i=1;i<=n;i++)
   {
       for(int j=i;j<=n;j++)
       {
           mr[min(j-i,abs(x-i)+abs(y-j)+1)]++;
       }
   }
   for(int i=1;i<n;i++)cout<<mr[i]<<endl;
    
}


return 0;
}





Measured memory_bytes: 384
url = "https://atcoder.jp/contests/abc087/tasks/arc090_a"
import copy
def main():
    n = int(input())
    t = [list(map(int, input().split())) for _ in range(n-1)]
    for i in range(len(t)):
        time = t[i][0] + t[i][1]
        for j in range(i+1, len(t)):
            st = t[j]
            if time <= st[1]:
                time = st[1]
            elif time % st[2] == 0:
                pass
            else:
                time += st[2] - (time % (st[2]))
            time += st[0]
        print(time)
    print(0)



if __name__ == '__main__':
    main()




Measured memory_bytes: 74880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());
            long ans = Solve(x);
            Console.WriteLine(ans);
        }

        private static long Solve(long x)
        {
            if (x == 1)
            {
                return 1;
            }

            x--;

            long ans = (x / (5 + 6)) * 2;
            long remainder = x % (5 + 6);

            if (remainder > 5)
            {
                ans += 2;
            }
            else
            {
                ans++;
            }

            return ans;
        }
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll a,b,c;cin >>a>>b>>c;
    ll x,y;cin >>x>>y;
    ll mint=min(x,y);
    ll ans=0;
    if((a+b)>2*c){
        ans+=2*c*mint;
        x-=mint;
        y-=mint;
    }
    else {
        ans+=(a+b)*mint;
        x-=mint;
        y-=mint;
    }
    if(a>2*c){
        ans+=x*2*c;
    }
    else ans+=x*a;
    if(b>2*c){
        ans+=y*2*c;
    }
    else ans+=b*y;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		int n;
		cin>>n;
		int a;
		cin>>a;
		int temp;
		ll sum =0;
		for(int i =0;i<a;i++){
			cin>>temp;
			sum += temp;
		}
		if(sum>=n){
			cout<<"Yes";
		}
		else{
			cout<<"No";
		}
	}

};

int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if (a % 3 == 0 || (a + b) % 3 == 0 || b % 3 == 0) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int w[300000], e[300000];

int main()
{
  int n;
  char s[300000];
  int ans = 1e+6;

  memset(w, 0, sizeof(w));
  memset(e, 0, sizeof(e));

  cin >> n >> s;

  for(int i = 1; i < n; i++){
    if(s[i-1] == 'W') w[i] = w[i-1] + 1;
    else w[i] = w[i-1];
  }

  for(int i = n-2; i >= 0; i--){
    if(s[i+1] == 'E') e[i] = e[i+1] + 1;
    else e[i] = e[i+1];
  }

  for(int i = 0; i < n; i++){
    ans = min(ans, e[i] + w[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;


int main() {
  ll x,y,ans=0;
  cin >>x >>y;
  while(x<=y){
    x*=2;
    ans++;
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3500
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MaxN 200000+100
typedef long long LL;
int loca[MaxN];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        int num;
        scanf("%d",&num);
        loca[num]=i;
    }
    int max=1;
    int ans=1;
    for(int i=N-1;i>=1;i--)
    {
        if(loca[i]<loca[i+1])
            ans++,max=max>ans?max:ans;
        else
            ans=1;
    }
    printf("%d\n",N-max);
    return 0;
}


Measured memory_bytes: 896
def gcd(a,b):
    if (a % b) == 0:
        return b
    else:
        return gcd(b, a%b)


def lcm(a, b):
    y = gcd(a,b)
    if (y == 0):
        return a*b

    else:
        return a*b/y


A, B = map(int,input().split())
if A < B:
    t = A
    A = B
    B = t

#最小公倍数
x  = int(lcm(A,B))
print(x)



Measured memory_bytes: 3060
#encoding:utf-8 No.0050 2014.10.7
while gets
  sentence = $_.chomp.split
  
  sentence.length.times do |i|
    if /apple/ =~ sentence[i]
      sentence[i].gsub!(/apple/,"peach")
    elsif /peach/ =~ sentence[i]
      sentence[i].gsub!(/peach/,"apple")
    end

    unless i == sentence.length - 1
      print sentence[i] + " "
    else
      print sentence[i] + "\n"
    end
  end
end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    
    int x,y,z; cin >> x >> y >> z;

    x -= z;
    cout << x/(y+z) << endl;
    
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

high = max(a)
low = min(a)
cost = 0
ans = 10**9

for i in range(low,high+1):
    for j in a:
        cost += pow(j-i,2)
        
    if cost < ans:
        ans = cost
        cost = 0
    else:
        cost = 0
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define MAX 1400

int H, W;
int T[MAX][MAX];
int dp[MAX+1][MAX+1];

int main(void){
    // Your code here!
    cin >> H >> W;
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> T[i][j];
        }
    }
    
    int maxLength = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(T[i][j] == 1){
                dp[i+1][j+1] = 0;
            } else{
                dp[i+1][j+1] = min(dp[i][j], min(dp[i][j+1], dp[i+1][j])) + 1;
                maxLength = max(maxLength, dp[i+1][j+1]);
            }
        }
    }
    
    cout << maxLength*maxLength << endl;
}



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

int main() {
	int R, C, K;
	cin >> R >> C >> K;
	vector<vector<long long>> Map(R, vector<long long>(C, 0));
	for (int i = 0; i < K; i++) {
		int r, c, v;
		cin >> r >> c >> v;
		Map[r - 1][c - 1] = v;
	}
	vector<vector<vector<long long>>>Ans(R, vector<vector<long long>>(C, vector<long long>(4, 0)));

	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			if (i == 0 && j == 0) Ans[i][j][1] = Map[i][j];
			if (i == 0 && j > 0) {
				for (int k = 1; k < 4; k++) Ans[i][j][k] = max(Ans[i][j - 1][k - 1] + Map[i][j], Ans[i][j - 1][k]);
			}
			if (i > 0 && j == 0) {
				Ans[i][j][0] = Ans[i - 1][j][1];
				Ans[i][j][1] = Ans[i - 1][j][1] + Map[i][j];
			}
			if (i > 0 && j > 0) {
				for (int k = 0; k < 4; k++) Ans[i][j][0] = max(Ans[i][j][0], Ans[i - 1][j][k]);
				Ans[i][j][0] = max(Ans[i][j][0], Ans[i][j - 1][0]);
				for (int k = 0; k < 4; k++) Ans[i][j][1] = max(Ans[i][j][1], Ans[i - 1][j][k] + Map[i][j]);
				for (int k = 1; k < 4; k++) {
					Ans[i][j][k] = max(Ans[i][j][k], Ans[i][j - 1][k]);
					Ans[i][j][k] = max(Ans[i][j][k], Ans[i][j - 1][k-1] + Map[i][j]);
				}
			}
		}
	}
	long long ans = 0;
	for (int k = 0; k < 4; k++) ans = max(ans, Ans[R - 1][C - 1][k]);

	cout << ans << endl;
}


Measured memory_bytes: 706720
#include<iostream>
#include<vector>
#include<algorithm>
#define N 10000

using namespace std;

int main(){
  int n, a, b, c, x;

  while(1){
    cin >> n >> a >> b >> c >> x;
    if(!n && !a && !b && !c && !x) break;

    vector<int> data(n,0);
    for(int i=0; i<n; ++i) cin >> data[i];

    int ans=-1;
    for(int i=0; i<=N; ++i){
      if(x==data[0]) data.erase(data.begin());
      if(data.empty()){ ans=i; break; }
      x = (a*x + b)%c;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define maxn 200005
using namespace std;

int n,k,l;
int info[maxn],Prev[maxn*2],to[maxn*2],cnt_e,col[2][maxn],c[maxn],siz[maxn],fa[maxn];
inline void Node(const int &u,const int &v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }
void dfs(int now,int c,int typ)
{
    col[typ][now]=c;
    for(int i=info[now];i;i=Prev[i])
        if(!col[typ][to[i]])
            dfs(to[i],c,typ);
}
inline bool cmp(const int &a,const int &b){ return col[0][a]==col[0][b] ? col[1][a]<col[1][b] : col[0][a] < col[0][b]; }

int main()
{
    scanf("%d%d%d",&n,&k,&l);
    for(int i=1,u,v;i<=k;i++)
    {
        scanf("%d%d",&u,&v);
        Node(u,v),Node(v,u);
    }

    for(int i=1;i<=n;i++)
        if(!col[0][i])
            dfs(i,i,0);

    cnt_e=0;
    memset(info,0,sizeof info);
    for(int i=1,u,v;i<=l;i++)
    {
        scanf("%d%d",&u,&v);
        Node(u,v),Node(v,u);
    }


    for(int i=1;i<=n;i++)
        if(!col[1][i])
            dfs(i,i,1);


    for(int i=1;i<=n;i++)
        c[i]=i;

    sort(c+1,c+1+n,cmp);

    for(int i=1;i<=n;i++)
    {
        fa[c[i]]=c[i];
        if(i!=1 && col[0][c[i]] == col[0][c[i-1]] && col[1][c[i]]== col[1][c[i-1]])
            fa[c[i]] = fa[c[i-1]];
        siz[fa[c[i]]]++;
    }

    for(int i=1;i<n;i++) printf("%d ",siz[fa[i]]);
    printf("%d",siz[fa[n]]);
}


Measured memory_bytes: 7680
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N;
	char S[100000];


	scanf("%d", &N);
	scanf("%s", S);

	int count = 0;

	for (int i = 0; i < N-1; i++)
	{
		if (S[i] != S[i + 1])
			count++;
	}

	printf("%d", count+1);

	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  COMinit();

  long S;cin>>S;
  long ans=0;
  for(long i=0;i<=S/3;i++){
    ans=(ans+COM(S-2*i-1, i-1))%MOD;
  }
  cout<<ans;
}



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

int main(){
    int flag=0;
    int a,b,c,x,y;
    cin >>a>>b>>c>>x>>y;
    int ans=0;

    if(x>y){

        if(2*c < a + b)ans += 2*c*y;
        else ans += (a+b)*y;

        if(2*c < a)ans += 2*c*(x-y);
        else ans += a*(x-y);
    
    }else{

        if(2*c < a + b)ans += 2*c*x;
        else ans += (a+b)*x;

        if(2*c < b)ans += 2*c*(y-x);
        else ans += b*(y-x);

    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a_lines = n.times.map { gets }
b_lines = m.times.map { gets }

a = a_lines.map(&:split).map { |line| line.map(&:to_i) }
b = b_lines.map(&:to_i)

a.each do |ai|
  puts ai.each_with_index.map { |aij, index|
    aij * b[index]
  }.inject(:+)
end

Measured memory_bytes: 6788
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int n;
	cin >> n;
	if(n%10==7 || n/100==7 || (n/10)%10==7) cout << "Yes";
	else cout << "No";

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3820
import sys

n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

divisor_list = make_divisors(n)

for num in divisor_list:
    if num >= n**0.5:
        print(len(str(num)))
        sys.exit()

Measured memory_bytes: 3060