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

using namespace std;

#define li long long int

const int N = 5e3 + 3;

int n;
string s;
int dp[N][N];
int sz;

int go(int lft, int rgt) {
	if (lft > sz) return 0;
	if (rgt > n) return 0;
	if (dp[lft][rgt] != -1) return dp[lft][rgt];
	int ans = 0;
	if (s[lft - 1] == s[rgt - 1]) {
		ans = 1 + go(lft + 1, rgt + 1);
	}
	return dp[lft][rgt] = ans;
}

void solve() {
	cin >> n >> s;
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			sz = j - 1;
			ans = max(ans, go(i, j));
		}
	}
	cout << ans;
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

const int INF = 100200;

int main(){

    int N, T; cin >> N >> T;
    int ans = INF;
    for(int i = 0; i < N; i++){
        int c, t; cin >> c >> t;
        if(t <= T) ans = min(ans, c);
    }

    if(ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}

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

int main() {
    int N, d[107];
	cin>>N;
	int i;
	for(i=0; i<N; i++)
	    cin>>d[i];
	sort(d, d+N);
	int cnt=1;
	for(i=1; i<N; i++)
	{
	    if(d[i] != d[i-1])
	       cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 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--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vvll X(N,vll(2));
    vll cnt1(N);
    REP(i,N){cin >> X[i][0] >> X[i][1];
    cnt1[i] = X[i][0]+X[i][1];
    }
    sort(ALL(cnt1));
    ll ans1=cnt1[N-1]-cnt1[0];

    vvll X2(N,vll(2));
    vll cnt2(N);
    REP(i,N){
      X2[i][0]=-X[i][0];
      X2[i][1]=X[i][1];
      cnt2[i] = X2[i][0]+ X2[i][1];
    }
    sort(ALL(cnt2));
    ll ans2=cnt2[N-1]-cnt2[0];

    

    //本文
    ll ans = max(ans1,ans2);

    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}


Measured memory_bytes: 40728
#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 main() {
    int n, m;
    cin >> n >> m;
    int box[n+1];
    rep(i,n) box[i+1] = 1;
    bool red[n+1];
    red[1] = 1;
    rep(i,m) {
        int x, y;
        cin >> x >> y;
        box[x]--;
        box[y]++;
        if (red[x]) {
            red[y] = 1;
        }
        if (box[x] == 0) {
            red[x] = false;
        }
    }
    int ans = 0;
    rep(i,n) {
        if (red[i+1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
from itertools import *
n,*s=open(0).read().split()
u=[[min(accumulate(t,lambda a,b: a+(1 if b=="(" else -1),initial=0)),2*t.count("(")-len(t)] for t in s]
m=0
for c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[1]-z[0])[::-1]):
    if m+c<0:print("No");break
    m+=d
else:
    print("No" if m else "Yes")

Measured memory_bytes: 119408
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  int in[6];
  rep(i, 6) {
    cin >> in[i];
  }
  sort(in, in+6);
  if (in[0] == 1 && in[2] == 2 && in[1] == 2 && in[3] == 3 && in[4] == 3 && in[5] == 4) {
    cout << "YES" << endl;
  }else {
    cout << "NO" <<endl;
  }
}


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

using namespace std;

const int N=1e6+6,MOD=998244353;

int fac[N],invfac[N],siz,n,m,ans;

int plu(int u,int v){
	return (u+v)%MOD;
}

int dec(int u,int v){
	return u<v?u-v+MOD:u-v;
}

int mul(int u,int v){
	return (int)(1LL*u*v%MOD);
}

int qpow(int u,int v){
	int rep=1;
	while(v){
		if(v&1){
			rep=mul(rep,u);
		}
		u=mul(u,u);
		v>>=1;
	}
	return rep;
}

int c(int u,int v){
	return mul(mul(invfac[v],invfac[u-v]),fac[u]);
}

int main(){
	scanf("%d%d",&n,&m);
	if(n>m){
		swap(n,m);
	}
	siz=n+m;
	fac[0]=1;
	for(int i=1;i<=siz;i++){
		fac[i]=mul(fac[i-1],i);
	}
	invfac[siz]=qpow(fac[siz],MOD-2);
	for(int i=siz-1;~i;i--){
		invfac[i]=mul(invfac[i+1],i+1);
	}
	for(int i=1;i<=n;i++){
		ans=plu(ans,mul(c(n+m-i-i,n-i),c(i+i,i)));
	}
	ans=mul(ans,qpow(mul(2,c(n+m,n)),MOD-2));
	ans=plu(ans,m);
	printf("%d\n",ans);
//	for(int i=0;i<=5;i++){
//		for(int j=0;j<=i;j++){
//			printf("%d%c",c(i,j)," \n"[i==j]);
//		}
//	}
	return 0;
}

Measured memory_bytes: 8064
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e6+9;

vector<int>Div[MAXN];

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    for(i=1; i<=1000000; i++)
    {
        for(j=i; j<=1000000; j+=i)
            Div[j].push_back(i);
    }

    multiset<int>st;
    n = in(); int a[n+9];
    for(i=1; i<=n; i++)
    {
        a[i] = in();
        st.insert(a[i]);
    }

    int cnt = 0;

    for(i=1; i<=n; i++)
    {
        st.erase(st.find(a[i]));
        bool flag = true;
        for(j=0; j<Div[a[i]].size(); j++)
        {
            if(st.find(Div[a[i]][j])!=st.end()){
                flag = false; break;
            }
        }

        if(flag) cnt++;

        st.insert(a[i]);
    }

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

  //  main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b;
  cin >> a >> b;

  int x = b-a;
  int y = x*(x+1)/2;

  cout << y - b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod (1000000007)
const int MAX=100010;
ll n,k,a[MAX],ans=0;
ll fact[MAX];
ll fact_inv[MAX];

ll power(ll x,ll n)
{
    ll res=1;
    while(n){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
void init(){
    fact[0]=1;
    for(int i=0;i<n;i++)fact[i+1]=fact[i]*(i+1)%mod;
    fact_inv[n]=power(fact[n],mod-2);
    for(int i=n-1;i>=0;i--)fact_inv[i]=fact_inv[i+1]*(i+1)%mod;
}
ll comb(ll n,ll r){
    if(n<0||r<0||n<r)return 0;
    return (fact[n]*fact_inv[r])%mod*fact_inv[n-r]%mod;
}
void solve() {
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    init();
    for(int i=0;i<n;i++)ans-=a[i]*comb(n-i-1,k-1),ans=(ans+a[i]*comb(i,k-1))%mod;
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  string s;
  cin >> s;
  int n = 0;
  for (int i; i < s.size(); i++){
    if (s[i] == '+'){
      n += 1;
    }
    else{
      n -= 1;
    }
  }

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		char[] cs =  S.toCharArray();
		String ans = "Good";
		for(int i = 0; i< cs.length - 1; i++) {
			if (cs[i] == cs[i + 1]) {
				ans = "Bad";
			}
		}
		System.out.println(ans);

	}

}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const ll mod = 1e9+7;


int fnc(const string& ms, char tg){
	string s=ms, t;
	for(int z=0;z<100;z++){
		int n=sz(s);
		t="";
		set<char> st;
		for(auto x: s) st.insert(x);
		if(sz(st) <=1){
			//printf("%d\n", z);
			return z;
		}
		rep(i,n-1){
			if(s[i]==tg || s[i+1]==tg) t+= tg;
			else t+=s[i];
		}
		//cout << t <<"\n";
		s=t;
	}
	return -1;
}


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int ans = 999999;
	for(char ix='a' ; ix <='z'; ix++){
		int rc = fnc(s, ix);
		ans = min(ans, rc);
	}
	cout << ans << endl;
	return 0;
}


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

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

  int left = x - (k - 1);
  int right = x + (k - 1);

  for (int i = left; i <= right; i++){
    cout << i;
    if (i != right){
      cout << " ";
    }else {
      cout << endl;
    }
  }

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vec;
typedef vector<Vec> DVec;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

#define fi             first
#define se             second
#define pb             push_back
#define INF            LLONG_MAX/3
#define MOD            1000000007
#define bcnt           __builtin_popcount
#define all(x)         (x).begin(),(x).end()
#define uni(x)         x.erase(unique(all(x)),x.end())
#define ub(x,y)        (upper_bound(x.begin(),x.end(),y)-x.begin())
#define lb(x,y)        (lower_bound(x.begin(),x.end(),y)-x.begin())
#define ssort(x)       sort(all(x))
#define rep(i,n)       repl(i,0,n-1)
#define mkp(x,y)       make_pair(x,y)
#define mmax(x,y)      (x>y?x:y)
#define mmin(x,y)      (x<y?x:y)
#define maxch(x,y)     x=mmax(x,y)
#define minch(x,y)     x=mmin(x,y)
#define exist(x,y)     (find(all(x),y)!=x.end())
#define each(itr,v)    for(auto itr:v)
#define repl(i,a,b)    for(ll i=(ll)(a);i<=(ll)(b);i++)
#define dvec(n1,n2,i)  DVec(n1,Vec(n2,i))

int main() {
  cin.sync_with_stdio(false);
  ll N; cin >> N;
  Vec a1;
  Vec a2;
  rep(i,N){
    ll ta;
    cin >> ta;
    a1.pb(ta);
    a2.pb(-ta);
  }

  ssort(a1);
  ssort(a2);
  double A = a1[N-1];
  ll b1 = a1[lb(a1, A/2)];
  ll b2 = a2[lb(a2, -A/2)];
  if(N == 2)cout << (ll)A << " " << a1[0] << endl;
  else if(abs(b1*2-A) < abs(-b2*2 - A) || abs((A-b1)*2 - A) < abs((A+b2)*2 - A))cout << (ll)A << " " << b1 << endl;
  else cout << (ll)A << " " << -b2 << endl;
  return 0;
}



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

int main(){
  int N,W;
  string S;
  
  cin >> N >>W;
  
  vector<string> vec (W+2,"#");
  
  for(int i=0;i<W+2;i++)
  cout << vec.at(i);
  
  cout <<endl;
  
  for(int i=0;i<N;i++){
    cin >>S;
    cout << '#'+S+'#' <<endl;
  }
  for(int i=0;i<W+2;i++)
  cout << vec.at(i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i*j==n){
				if(i<=9&&j<=9){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)


def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p]

n,k,l = map(int, input().split())
pq = []
road = [i for i in range(n+1)]
rcnt = [set([i]) for i in range(n+1)]
rail = [i for i in range(n+1)]
acnt = [set([i]) for i in range(n+1)]
for i in range(k):
    p,q = map(int,input().split())
    pq.append((p,q))
    aa = get_par(road, p)
    bb = get_par(road, q)
    if aa == bb:
        continue
    # unite
    if aa < bb:
        road[bb] = aa
        rcnt[aa] |= rcnt[bb]
    else:
        road[aa] = bb
        rcnt[bb] |= rcnt[aa]

rs = []
for i in range(l):
    p,q = map(int,input().split())
    rs.append((p,q))
    aa = get_par(rail, p)
    bb = get_par(rail, q)
    if aa == bb:
        continue
    # unite
    if aa < bb:
        rail[bb] = aa
        acnt[aa] |= acnt[bb]
        # acnt[aa] += acnt[bb]
    else:
        rail[aa] = bb
        acnt[bb] |= acnt[aa]

ans = [(road[get_par(road, i)], rail[get_par(rail, i)]) for i in range(1,n+1)]
from collections import Counter
c = Counter(ans)
print(*[c[(road[get_par(road, i)], rail[get_par(rail, i)])] for i in range(1,n+1)])
# print(acnt)
# print(rcnt)


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

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

struct Node *root, *Nil;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);

int main(){
  int n, i, x;
  char s[20];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", s);

    if(strcmp(s, "insert")==0){
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp(s, "print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  struct Node *y = Nil, *x = root,*z;

  z = malloc(sizeof(struct Node));
  z->key = k;
  z->left = Nil;
  z->right = Nil;

  while(x != Nil){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == Nil)root = z;
  else {
    if(z->key < y->key)y->left = z;
    else y->right = z;
  }
}

void inorder(struct Node *u){

  if(u == Nil) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){

  if(u == Nil) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


Measured memory_bytes: 25204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,ans=0;
  cin >> a >> b;
  if(a==3)ans+=100000;
  else if(a==2)ans+=200000;
  else if(a==1)ans+=300000;
  else ans+=0;
  if(b==3)ans+=100000;
  else if(b==2)ans+=200000;
  else if(b==1)ans+=300000;
  else ans+=0;
  if(a==1 && b==1)ans+=400000;
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{   
    ll n,suma=0,sumb=0;cin>>n;
    ll a[n],b[n];
    REP(i,n)cin>>a[i],suma+=a[i];
    REP(i,n)cin>>b[i],sumb+=b[i];
    if(suma<sumb)cout<<-1<<endl;
    else{
        ll count=0,sum=0;
        vector<ll>temp;
        REP(i,n){
            if(a[i]<b[i])sum+=b[i]-a[i],count++;
            else temp.pb(a[i]-b[i]);
        }
        if(!count){cout<<0<<endl;return;}
        sort(temp.begin(),temp.end(),greater<ll>());
        ll ans=0;
        for(int i=0;sum>0;sum-=temp[i],ans++,i++);
        cout<<ans+count<<endl;
    }
}

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


Measured memory_bytes: 2936
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int A, B;
	cin >> A >> B;
	if (A >= 13) cout << B << endl;
	else if (A >= 6) cout << B/2 << endl;
	else cout << 0 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
cnt = 100
for i in range(N):
  if cnt + 1 == A[i]:
    ans += C[cnt-1]
  cnt = A[i]
  ans += B[A[i]-1]
  
print(ans)

Measured memory_bytes: 8932
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
int main()
{


        ll a,b,c,k;
        lscf(a),lscf(b),lscf(c),lscf(k);

        if(k<=a)
        lprin(k);

        else if(k>a&&k<=a+b)
        lprin(a);

        else
        {
            ll val=k-(a+b);
            lprin(a-val);
        
        }

        
  
    
    
    
    
}  

Measured memory_bytes: 3824
#n=int(input())
#li=input().split()
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#import math

lis=[]
#N Q
li=list(map(int,input().split()))
S=input()
for i in range(li[1]):
    #l_i r_i
    lr=list(map(int,input().split()))
    lis.append(lr)
L=[0]*(li[0])
for i in range(li[0]-1):
    L[i+1]+=L[i]
    if S[i:i+2]=="AC":
        L[i+1]+=1
for i in range(li[1]):
    print(L[lis[i][1]-1]-L[lis[i][0]-1])


Measured memory_bytes: 32248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a,b,c; cin>>a>>b>>c;
    if(b-a == c-b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int max = 0;
		for (int i = 0, h, left = scanner.nextInt(), count = 0; i < n - 1; i++) {
			h = scanner.nextInt();
			if (h <= left) {
				count++;
				if (count > max)
					max = count;
			} else
				count = 0;
			left = h;
		}
		System.out.println(max);
	}
}

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

int main() {
  int a, b, c, d;
  cin >>a>>b>>c>>d;
  if (a+b>c+d)
    cout <<"Left"<< endl;
  else if (a+b<c+d)
    cout <<"Right"<< endl;
  else
    cout <<"Balanced"<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0577 ; Unique number **/
int main()
{
	int N;
	cin>>N;
	int num[N][3];
	rep(i, N) {
		cin>>num[i][0]>>num[i][1]>>num[i][2];
	}
	
	rep(i, N) {
		int ans = 0;
		rep(j, 3) {
			bool ok = true;
			rep(k, N) {
				if (i!=k && num[i][j] == num[k][j])
					ok = false;
			}
			if (ok)
				ans += num[i][j];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
//
//  main.cpp
//  B
//
//  Created by 黄宇凡 on 2017/4/16.
//  Copyright © 2017年 黄宇凡. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;

const int maxn = 1e5 + 5;

deque<int> q;
vector<int> G[maxn];
bool vis[maxn];
int n,m;

int main(int argc, const char * argv[]) {
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
        if(i == 1){
            q.push_back(a);
            q.push_back(b);
            vis[a] = true;
            vis[b] = true;
        }
    }
    while(true){
        int p = q.front();
        bool flag = true;
        for(int i = 0;i < G[p].size();i++){
            int v = G[p][i];
            if(!vis[v]){
                q.push_front(v);
                flag = false;
                vis[v] = true;
                break;
            }
        }
        if(flag) break;
    }
    while(true){
        int p = q.back();
        bool flag = true;
        for(int i = 0;i < G[p].size();i++){
            int v = G[p][i];
            if(!vis[v]){
                q.push_back(v);
                flag = false;
                vis[v] = true;
                break;
            }
        }
        if(flag) break;
    }
    cout << q.size() << endl;
    while(!q.empty()){
        int p = q.front();
        printf("%d",p);
        q.pop_front();
        if(q.empty()) printf("\n");
        else printf(" ");
    }
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    string s,t;
    cin>>s>>t;
    bool c = true;
    rep(i,0,s.size()){
        if(s.at(i)!=t.at(i))c=false;
    }
    if(c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 1e9 + 7;
const int N = 1e5 + 10, M = 1e3 + 10;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;

#define pi acos(-1)

int a[N], b[N];

int main()
{
    int min1 = inf, min2 = inf;
    int n, m, t;
    cin >> n >> m >> t;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        min1 = min(min1, a[i]);
    }
    for (int i = 1; i <= m; i++)
    {
        scanf("%d", &b[i]);
        min2 = min(min2, b[i]);
    }
    int ans = min1 + min2;
    while(t--)
    {
        int x, y, c;
        scanf("%d%d%d", &x, &y, &c);
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;
const int MAXW = 1e9;

pair<pii, pii> ee[MAXN];

int v[MAXN];
int w[MAXN];
char col[MAXN];

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REPN(i, 1, n) {
		scanf("%d", &v[i]);
	}
	REP(i, 0, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		ee[i] = mp(mp(max(v[a], v[b]), i), mp(a, b));
	}
	sort(ee, ee + m);
	REP(i, 0, m) {
		int a = ee[i]._2._1, b = ee[i]._2._2;
		int ind = ee[i]._1._2;
		if (!col[a] && !col[b]) {
			if (v[a] != v[b]) {
				printf("-1\n");
				return;
			}
			col[a] = 'B';
			col[b] = 'W';
			w[ind] = v[a];
		} else if (col[a] && col[b]) {
			w[ind] = MAXW;
		} else {
			if (!col[a]) {
				swap(a, b);
			}
			if (v[a] < v[b]) {
				col[b] = col[a];
				w[ind] = v[b] - v[a];
			} else if (v[a] == v[b]) {
				col[b] = 'W' - col[a] + 'B';
				w[ind] = v[a];
			}
		}
	}
	printf("%s\n", col + 1);
	REP(i, 0, m) {
		printf("%d\n", w[i]);
	}
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 6784
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0], 10);
    let xy = [];
    for (let i = 0; i < N; i++){
        xy.push(input[i + 1].map( e => parseInt(e, 10)));
    }
    let ans = 0;

    xy.sort((a, b) => (a[0] - a[1]) - (b[0] - b[1]));
    let p1 = xy[0].slice();
    let p2 = xy[N - 1].slice();
    ans = Math.abs(p1[0] - p2[0]) + Math.abs(p1[1] - p2[1]);

    xy.sort((a, b) => (a[0] + a[1]) - (b[0] + b[1]));
    let p3 = xy[0].slice();
    let p4 = xy[N - 1].slice();
    ans = Math.max(ans, Math.abs(p3[0] - p4[0]) + Math.abs(p3[1] - p4[1]));
    console.log(ans);
    // console.log(p1, p2, p3, p4);
}

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


Measured memory_bytes: 131208
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    if ((A * B) > (C * D)) {
        cout << A * B << endl;
    } else if ((A * B) < (C * D)) {
        cout << C * D << endl;
    } else if ((A * B) == (C * D)) {
        cout << A * B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  int n;
  ll c;
  cin>>n>>c;

  vector<ll> p(n);//きょり
  vector<ll> q(n);
  rep(i,n){
    cin>>p[i]>>q[i];
  }

  vector<ll> r(n);
  vector<ll> l(n);
  vector<ll> qr=q;
  vector<ll> ql(n);
  repo(i,n){
    qr[i]+=qr[i-1];
  }
  rep(i,n){
    r[i]=qr[i]-p[i];
  }
  chmax(r[0],0ll);
  repo(i,n){
    chmax(r[i],r[i-1]);
  }

  for(int i=n-1;i>=0;i--){
    ql[n-1-i]=q[i];
  }
  repo(i,n){
    ql[i]+=ql[i-1];
  }
  rep(i,n){
    l[i]=ql[i]-(c-p[n-1-i]);
  }
  chmax(l[0],0ll);
  repo(i,n){
    chmax(l[i],l[i-1]);
  }

  ll ans=0;
  rep(i,n){
    chmax(ans,r[i]);
    chmax(ans,l[i]);
    if(i!=n-1) chmax(ans,r[i]+l[n-2-i]-p[i]);
    if(i!=n-1) chmax(ans,r[i]+l[n-2-i]-(c-p[i+1]));
  }

  cout << ans << endl;
}

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


const int mod = 200003, g = 2;

const double PI = acos(-1);
struct base {
	double a, b;
	base(double a = 0, double b = 0) : a(a), b(b) {}
	const base operator + (const base &c) const
		{ return base(a + c.a, b + c.b); }
	const base operator - (const base &c) const
		{ return base(a - c.a, b - c.b); }
	const base operator * (const base &c) const
		{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};
void fft(vector<base> &p, bool inv = 0) {
	int n = p.size(), i = 0;
	for(int j = 1; j < n - 1; ++j) {
		for(int k = n >> 1; k > (i ^= k); k >>= 1);
		if(j < i) swap(p[i], p[j]);
	}
	for(int l = 1, m; (m = l << 1) <= n; l <<= 1) {
		double ang = 2 * PI / m;
		base wn = base(cos(ang), (inv ? 1. : -1.) * sin(ang)), w;
		for(int i = 0, j, k; i < n; i += m) {
			for(w = base(1, 0), j = i, k = i + l; j < k; ++j, w = w * wn) {
				base t = w * p[j + l];
				p[j + l] = p[j] - t;
				p[j] = p[j] + t;
			}
		}
	}
	if(inv) for(int i = 0; i < n; ++i) p[i].a /= n, p[i].b /= n;
}
vector<long long> multiply(vector<int> &a, vector<int> &b) {
	int n = a.size(), m = b.size(), t = n + m - 1, sz = 1;
	while(sz < t) sz <<= 1;
	vector<base> x(sz), y(sz), z(sz);
	for(int i = 0 ; i < sz; ++i) {
		x[i] = i < (int)a.size() ? base(a[i], 0) : base(0, 0);
		y[i] = i < (int)b.size() ? base(b[i], 0) : base(0, 0);
	}
	fft(x), fft(y);
	for(int i = 0; i < sz; ++i) z[i] = x[i] * y[i];
	fft(z, 1);
	vector<long long> ret(sz);
	for(int i = 0; i < sz; ++i) ret[i] = (long long) (z[i].a + 0.5);
	while((int)ret.size() > 1 && ret.back() == 0) ret.pop_back();
	return ret;
}

int pw[2 * mod], inv[mod];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	pw[0] = 1;
	for (int i = 1; i < 2 * mod; i++) {
		pw[i] = pw[i - 1] * g % mod;
		if (inv[pw[i]] == 0) inv[pw[i]] = i;
	}
	int n; cin >> n;
	vector<int> a(mod);
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		if (k == 0) continue;
		a[inv[k]]++;
	}
	auto b = multiply(a, a);
	b.resize(2 * mod);
	long long ans = 0;
	for (int i = 0; i < mod; i++) b[2 * i] -= a[i];
	for (int i = 0; i < 2 * mod; i++) {
		b[i] /= 2;
		ans += 1LL * pw[i] * b[i];
	}
	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 35520
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> h(n);
	for(auto i = 0; i < n; ++ i){
		cin >> h[i];
	}
	vector<int> dp(n);
	dp[1] = abs(h[0] - h[1]);
	for(auto i = 2; i < n; ++ i){
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp.back();
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 1024
# AtCoder Beginner Contest 075
# B - Minesweeper

def f(i,j):
    ans[i+1][j+1]+=10**9+7
    ans[i][j]+=1
    ans[i][j+1]+=1
    ans[i][j+2]+=1
    ans[i+1][j]+=1
    # ans[i+1][j+1]+=1
    ans[i+1][j+2]+=1
    ans[i+2][j]+=1
    ans[i+2][j+1]+=1
    ans[i+2][j+2]+=1


H,W=map(int,input().split())

ans=[[0]*(W+2) for i in range (H+2)]

area=[]
for i in range (H):
    area.append(input())

for i in range(H):
    for j in range (W):
        if area[i][j]=="#":
            f(i,j)


for i in range (H):
    A=ans[1+i][1:-1]
    for j in range (len(A)):
        if A[j]>10**9:
            A[j]="#"
        else:
            A[j]=str(A[j])
    print("".join(A))

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

int main()
{
       int n;
        cin >> n;
        vector<vector<int>> points(n, vector<int>(3));
        for (int i = 0; i < n; i++)
            cin >> points[i][0] >> points[i][1] >> points[i][2];
        vector<vector<int>> dp(n, vector<int>(3));
        int _max = -1e9;
        for (int i = 0; i < 3; i++)
        {
            dp[0][i] = points[0][i];
            _max = max(dp[0][i], _max);
        }
        for (int i = 1; i < n; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    if (j == k)
                        continue;
                    dp[i][j] = max(points[i][j] + dp[i - 1][k], dp[i][j]);
                }
                _max = max(dp[i][j], _max);
            }
        }
        cout << _max << endl;
  return 0;
}


Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124
{
    class C
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int[] sum = new int[2] { 0, 0 };
            for (int i = 0; i < s.Length; i++)
            {
                if (int.Parse(s.Substring(i, 1)) != i % 2) { sum[0]++; }
                if (int.Parse(s.Substring(i, 1)) != (i + 1) % 2) { sum[1]++; }
            }
            Console.WriteLine(Math.Min(sum[0], sum[1]));
        }
    }
}


Measured memory_bytes: 17208
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc067/tasks/arc067_a
# C - Factors of Factorial
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
ans = 0
cnt = [0] * 3
for i in range(N):
    s = gw()
    if s[0] == 'B':
        if s[-1] == 'A':
            cnt[0] += 1
        else:
            cnt[1] += 1
    elif s[-1] == 'A':
        cnt[2] += 1

    for j in range(len(s) - 1):
        if s[j] == 'A' and s[j + 1] == 'B':
            ans += 1

if cnt[0] == 0:
    ans += min(cnt[1], cnt[2])
elif (cnt[1] + cnt[2]):
    ans += cnt[0] + min(cnt[1], cnt[2])
else:
    ans += cnt[0] - 1
print(ans)


Measured memory_bytes: 13336
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

void cmax(int& lhs,int rhs){lhs=max(lhs,rhs);}
int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    int half=s.size()/2;
    
    vector<vector<vector<int>>> dp(half+1,vector<vector<int>>(half+1,vector<int>(k+1)));
    for(int i=0;i<=half;i++){
        for(int j=0;j<=half;j++){
            for(int l=0;l<=k;l++){
                if(i<half){
                    cmax(dp[i+1][j][l],dp[i][j][l]);
                }
                if(j<half){
                    cmax(dp[i][j+1][l],dp[i][j][l]);
                }
                if(i<half &&j<half){
                    if(s[i]!=s[s.size()-1-j] && l<k) cmax(dp[i+1][j+1][l+1],dp[i][j][l]+1);
                    if(s[i]==s[s.size()-1-j]) cmax(dp[i+1][j+1][l],dp[i][j][l]+1);
                }
                if(l<k) cmax(dp[i][j][l+1],dp[i][j][l]);
            }
        }
    }
    

    vector<vector<int>> posL(s.size()+1,vector<int>(26,-1));
    for(int i=0;i<s.size();i++) posL[i+1]=posL[i],posL[i+1][s[i]-'a']=i;
    vector<vector<int>> posR(s.size()+1,vector<int>(26,s.size()));
    for(int i=s.size()-1;i<s.size();i--) posR[i]=posR[i+1],posR[i][s[i]-'a']=i;

    vector<vector<vector<int>>> dp2(s.size()+1,vector<vector<int>>(s.size()+1,vector<int>(k+1)));
    for(int i=0;i<s.size();i++) for(int j=0;j<=k;j++) dp2[i][i+1][j]=1;
    for(int v=2;v<=s.size();v++){
        for(int i=0;i<s.size();i++){
        int j=i+v;
        if(i+v>s.size()) continue;
            for(int l=0;l<=k;l++){
                if(l>0){
                    cmax(dp2[i][j][l],dp2[i+1][j-1][l-1]+2);
                    cmax(dp2[i][j][l],dp2[i][j][l-1]);
                }
                cmax(dp2[i][j][l],dp2[i+1][j][l]);
                cmax(dp2[i][j][l],dp2[i][j-1][l]);
                if(i+1<=posL[j][s[i]-'a']) cmax(dp2[i][j][l],dp2[i+1][posL[j][s[i]-'a']][l]+2);
                if(posR[i][s[j-1]-'a']<=j-2) cmax(dp2[i][j][l],dp2[posR[i][s[j-1]-'a']+1][j-1][l]+2);
            }
        }
    }

    int res=0;
    int tmp=s.size()%2;
    for(int i=0;i<=half;i++){
        for(int j=0;j<=half;j++){
            for(int l=0;l<=k;l++){
                cmax(res,dp[i][j][l]*2+dp2[i][half+tmp][k-l]);
                cmax(res,dp[i][j][l]*2+dp2[half][s.size()-j][k-l]);
            }
        }
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 137984
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	V<int> H(N); rep(i,N) cin >> H[i];
	int ans = 0,now = 0;
	rep(i,N-1){
		if(H[i] >= H[i+1]) now++;
		else now=0;
		chmax(ans,now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    ans = int(input())
    N=100000
    i = 1
    r = 6
    k = 9
    G = [1]
    while r <= N:
        G.append(k)
        G.append(r)
        k *= 9
        r *= 6

    number =[10**9] *(N+1)
    number[0]=0

    for i in range(N):
        c = number[i]
        for g in G:
            if i+g <=N:
                number[i+g] =min(c+1,number[i+g])
    print(number[ans])



if __name__ == "__main__":
    main()


Measured memory_bytes: 74204
#include<iostream>

using namespace std;

int main(){
	int A;
	int B;
	cin >> A >> B;
	int sum;
	
	if(B==1){
		cout << 0 << endl;
		return 0;
	} else {
		for(int i=0;i<30;i++){
			sum = (A-1)*i+A;
			if(sum>=B){
				cout << i+1 << endl;
				return 0;
			}
		}
	}
		return 0;
}

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

typedef long long ll;
const int mod=998244353;

ll qpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int pw[800005];

struct SegTree{

    struct node{
        int len,pre,sum,laz;
        node(){
            len=pre=sum=laz=0;
        }
        void pushdown(node &ls,node &rs){
            if(laz){
                ls.len=rs.len=len>>1;
                ls.pre=rs.pre=pw[len>>1];
                ls.laz=rs.laz=laz;
                ls.sum=(ll)ls.pre*laz%mod;
                rs.sum=(ll)rs.pre*laz%mod;
                laz=0;
            }
        }
        void pullup(const node &ls,const node &rs){
            sum=(ls.sum*qpow(10,rs.len)+rs.sum)%mod;
            len=ls.len+rs.len;
            laz=0;
            pre=pw[len];//pre=ls.pre*qpow(10,rs.len)+rs.pre;
        }
    };

    vector<node> dat;
    int sz;

    SegTree(int n=1<<18){
        sz=1;
        while(sz<n)sz<<=1;
        dat.resize(sz<<1);
    }

    void upd(const int &id,const int &l,const int &r,const int &ql,const int &qr,const int &val){
        if(qr<l||r<ql)return;
        if(ql<=l&&r<=qr){
            dat[id].len=r-l+1;
            dat[id].pre=pw[dat[id].len];
            dat[id].laz=val;
            dat[id].sum=(ll)dat[id].pre*val%mod;
            return;
        }
        dat[id].pushdown(dat[id<<1],dat[id<<1|1]);
        upd(id<<1,l,l+r>>1,ql,qr,val);
        upd(id<<1|1,(l+r>>1)+1,r,ql,qr,val);
        dat[id].pullup(dat[id<<1],dat[id<<1|1]);
    }

    node qry(const int &id,const int &l,const int &r,const int &ql,const int &qr){
        if(qr<l||r<ql)return node();
        if(ql<=l&&r<=qr){
            return dat[id];
        }
        dat[id].pushdown(dat[id<<1],dat[id<<1|1]);
        node res;
        res.pullup(qry(id<<1,l,l+r>>1,ql,qr),qry(id<<1|1,(l+r>>1)+1,r,ql,qr));
        return res;
    }

    void upd(const int &l,const int &r,const int &v){
        upd(1,1,sz,l,r,v);
    }

    int qry(const int &l,const int &r){
        return qry(1,1,sz,l,r).sum;
    }
};

int n,q;

int main(){

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

    for(int i=1;i<=800000;i++)pw[i]=((ll)pw[i-1]*10+1)%mod;
    cin>>n>>q;
    SegTree st(n);
    st.upd(1,n,1);
    while(q--){
        int l,r,d;
        cin>>l>>r>>d;
        st.upd(l,r,d);
        cout<<st.qry(1,n)<<'\n';
    }

    return 0;
}

Measured memory_bytes: 14560
#include<stdio.h>

int main(void)

{

   int a,b,d,r;

   double f;

   scanf("%d %d",&a,&b);

   d=a/b;

   r=a%b;

   f=(double)a/(double)b;

   printf("%d %d %lf\n",d,r,f);

   return 0;

}

Measured memory_bytes: 636