akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, m, q;
	cin >> n >> m;
	vector<int> a(m), b(m);
	vector<vector<int>> path(n);
	REP(i, m) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		path[a[i]].push_back(b[i]);
		path[b[i]].push_back(a[i]);
	}
	cin >> q;
	vector<int> v(q), d(q), c(q);
	REP(i, q) {
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}
	vector<vector<int>> dp(n, vector<int>(11,-1));
	REP(i, q) {
		dp[v[i]][d[i]] = i;
	}
	RREP(j, 10) {
		REP(i, n) {
			REP(k, path[i].size()) {
				chmax(dp[i][j], dp[path[i][k]][j + 1]);
			}
		}
	}
	REP(i, n) {
		int ma = -1;
		REP(j, 11) {
			chmax(ma, dp[i][j]);
		}
		if (ma < 0) {
			put(0);
		} else {
			put(c[ma]);
		}
	}
	return 0;
}


Measured memory_bytes: 17016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}
ll combination(ll n, ll r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1)%MOD + combination(n - 1, r)%MOD);
}
ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}
ll a[110];
int Comb[1010][1010];
int main() {
    int a, b, c; cin >> a >> b >> c;
    map<int, int> mp;
    mp[a]++; mp[b]++; mp[c]++;
    if(mp[5]==2&&mp[7]==1) cout << "YES" << endl;
    else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int h, w;
vector<string> s;
vector<vector<bool>> ok(405,vector<bool>(405,false));
P f(int i, int j){
  int black=0, white=0;
  bool b = (s[i][j] == '#');
  if(b) ++black;
  else ++white;
  ok[i][j] = true;
  int x, y;
  if(i>0 && !ok[i-1][j] && s[i-1][j] == (b? '.':'#')){
    tie(x, y) = f(i-1, j);
    black += x;
    white += y;
  }
  if(j>0 && !ok[i][j-1] && s[i][j-1] == (b? '.':'#')){
    tie(x, y) = f(i, j-1);
    black += x;
    white += y;
  }
  if(i<h-1 && !ok[i+1][j] && s[i+1][j] == (b? '.':'#')){
    tie(x, y) = f(i+1, j);
    black += x;
    white += y;
  }
  if(j<w-1 && !ok[i][j+1] && s[i][j+1] == (b? '.':'#')){
    tie(x, y) = f(i, j+1);
    black += x;
    white += y;
  }
  return P(black,white);
}

int main(){
  cin >> h >> w;
  s.resize(h);
  for(int i=0; i<h; ++i) cin >> s[i];
  long long ans = 0;
  for(int i=0; i<h; ++i) for(int j=0; j<w; ++j){
    if(ok[i][j]) continue;
    int x, y;
    tie(x,y) = f(i, j);
    //cout << "i:j=" << i << ":" << j << " black:white=" << x << ":" << y << endl;
    ans += (long long)x *y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 18796
main = do
  s <- getLine
  putStr . show . minimum $ [(k . f c) s | c <- s]
  
f c ds = [c == d | d <- ds]
 
h n xs
  | n >= length xs = 0
  | xs !! n = 0
  | otherwise = 1 + h (n+1) xs
 
k xs = maximum [h n xs | n <- [0 .. (length xs)]]

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

int main() {
  string S;
  cin >> S;
  if(S=="SSS"){
    cout<<0<<endl;
  }
  else if(S=="RSS"){
    cout<<1<<endl;
  }
  else if(S=="SRS"){
    cout<<1<<endl;
  }
  else if(S=="SSR"){
    cout<<1<<endl;
  }
  else if(S=="RRS"){
    cout<<2<<endl;
  }
  else if(S=="RSR"){
    cout<<1<<endl;
  }
  else if(S=="SRR"){
    cout<<2<<endl;
  }
  else if(S=="RRR"){
    cout<<3<<endl;
  }
}

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

void fnInput(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int fnGcdGet(int nNumA, int nNumB)
{
  int nDividend = max(nNumA, nNumB);
  int nDivisor  = min(nNumA, nNumB);

  while (nDividend % nDivisor != 0)
  {
    int nRemain = nDividend % nDivisor;
    nDividend = nDivisor;
    nDivisor  = nRemain;
  }
  return nDivisor;
}

int fnMaxGcd(const vector<int>& cnrvnNum)
{
  vector<int> vnLeftGcd(cnrvnNum.size());
  vector<int> vnRigtGcd(cnrvnNum.size());

  vnLeftGcd[0] = cnrvnNum[0];
  
  for (int i = 0; i < cnrvnNum.size() - 1; i++)
    vnLeftGcd[i + 1] = fnGcdGet(vnLeftGcd[i], cnrvnNum[i + 1]);
  
  vnRigtGcd[cnrvnNum.size() - 1] = cnrvnNum[cnrvnNum.size() - 1];

  for (int i = cnrvnNum.size() - 1; i > 0; i--)
    vnRigtGcd[i - 1] = fnGcdGet(vnRigtGcd[i], cnrvnNum[i - 1]);

  int nMaxGcd = 0;

  for (int i = 0; i < cnrvnNum.size(); i++)
    if (i == 0)
      nMaxGcd = max(nMaxGcd, vnRigtGcd[i + 1] );
    else if (i == cnrvnNum.size() - 1)
      nMaxGcd = max(nMaxGcd, vnLeftGcd[i - 1] );
    else
      nMaxGcd = max(nMaxGcd, fnGcdGet(vnLeftGcd[i - 1], vnRigtGcd[i + 1] ));
  
  return nMaxGcd;
}
 
int main()
{
  vector<int> vnNum;

  fnInput(vnNum);
  cout << fnMaxGcd(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int n,a,b,x = 0,y = 0;
	string s;
	cin >> n >> a >> b >> s;
	for(int i = 0;i < n;i++){
		if(s[i] == 'a'){
			if(x < a + b){
				x++;
				cout << "Yes" << endl;
			}else cout << "No" << endl;
		}else if(s[i] == 'b'){
			if(x < a + b && y < b){
				x++;
				cout << "Yes" << endl;
			}else cout << "No" << endl;
			y++;
		}else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    LL x,n,x_abs_p,x_abs_m,ans;
    cin >> x >> n;
    vector<LL> p(n);
    vector<LL> n_abs(n);
    vector<LL> n_abs_p;
    vector<LL> n_abs_m;

    bool flg = true;

    for(int i = 0; i < n; i++) {
        cin >> p[i];
        if(p[i] == x) {
            flg = false;            
        }
    }
    if(flg) {
        cout << x << endl;
        return 0;
    }
    if(n == 0) {
        cout << x << endl;
        return 0;
    }

    for(int i = 0; i < n; i++) {
        n_abs[i] = p[i] - x;
    }
    for(int i = 0; i < n; i++) {
        if(n_abs[i] > 0){
            n_abs_p.push_back(n_abs[i]);
        }
        if(n_abs[i] < 0){
            n_abs_m.push_back(n_abs[i]);
        }
    }
    sort(n_abs_p.begin(),n_abs_p.end());
    sort(n_abs_m.begin(),n_abs_m.end());
    reverse(n_abs_m.begin(),n_abs_m.end());

/*
    for(int i = 0; i < (int)n_abs_p.size(); i++) {
        if(i != 0) cout << ":";
        cout << n_abs_p[i];
    }
    cout <<  endl;
    for(int i = 0; i < (int)n_abs_m.size(); i++) {
        if(i != 0) cout << ":";
        cout << n_abs_m[i];
    }
    cout <<  endl;
/*/

    x_abs_p = 1;
    for(int i = 0; i < (int)n_abs_p.size(); i++) {
        if(i == 0){
            x_abs_p = 1;
        }
        if(x_abs_p == n_abs_p[i]){
            x_abs_p = x_abs_p + 1;
        }
    }

    x_abs_m = -1;
    for(int i = 0; i < (int)n_abs_m.size(); i++) {
        if(i == 0){
            x_abs_m = -1;
        }
        if(x_abs_m == n_abs_m[i]){
            x_abs_m = x_abs_m - 1;
        }
    }


    ans = 0;

//    cout << "x_abs_p :" << x_abs_p << endl;
//    cout << "x_abs_m :" << x_abs_m << endl;

    if(x_abs_p == abs(x_abs_m) ){
        ans = x+x_abs_m;
    }else if(x_abs_p < abs(x_abs_m) ) {
        ans = x+x_abs_p;        
    }else if(x_abs_p > abs(x_abs_m) ) {
        ans = x+x_abs_m;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	char b; cin >> b;
	if (b == 'A') printf("T\n");
	else if (b == 'T') printf("A\n");
	else if (b == 'C') printf("G\n");
	else printf("C\n");

	return 0;
}

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

int main() {
    string S;
    ll K;
    cin >> S >> K;
    char pre = 'Z';
    int ans1 = 0;
    unordered_set<char> s;
    for (char c : S) {
        s.insert(c);
        if (c == pre) {
            ans1++;
            pre = 'Z';
        }
        else pre = c;
    }
    if ((s.size() == 1) && (S.size() % 2 == 1)) {
        ll x = (K + 1) / 2;
        ll ans = ans1 * x + (ans1 + 1) * (K - x);
        cout << ans << endl;
        return 0;
    }
    ll ans2 = 0;
    for (char c : S) {
        if (c == pre) {
            ans2++;
            pre = 'Z';
        }
        else pre = c;
    }
    ll ans = ans1 + ans2 * (K - 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

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

int main()
{
    ll n,k;
    cin >> n >> k;
    vll a(n),dp(n);
    rep(i,n) cin >> a[i];
    rep(i,n) dp[i]=9999999999;
    dp[0]=0;
    for(ll i=1;i<n;i++){
        for(ll j=1;j<=k;j++){
            if(i-j<0) continue;
            dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }

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


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
 
vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	rep(i,n){
		fact[i+1]=fact[i]*(i+1)%mod;
		if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
		invfact[i+1]=invfact[i]*inv[i+1]%mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
	k%=mod-1;
	if(k<0)k+=mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%mod;
		n=n*n%mod;
		k>>=1;
	}
	return ret;
}
int main(){
	mod_build(202020);
	ll n,m,k;
	cin>>n>>m>>k;
	ll res1=(m*m*m-m)%mod*n%mod*n%mod*inv[6]%mod;
	ll res2=(n*n*n-n)%mod*m%mod*m%mod*inv[6]%mod;
	ll ans=(res1+res2)*powmod(comb(m*n,2),mod-2)%mod;
	ans*=comb(m*n,k)*comb(k,2)%mod;
	cout<<ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main ()
{
	int h, w, n, suma=0, i=0; cin>>h>>w>>n;
	if (h>=w) for (i=0; suma<n; i++) suma+=h;
	if (h<w) for (i=0; suma<n; i++) suma+=w;
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int cnt=0;
    for(int j=1;j<=i;j++){
      if(i%j==0)cnt++;
    }
    if(i%2==1&&cnt==8)ans++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#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;

int v[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &v[i]);
	}
	sort(v, v + n);
	int ans = v[n - 1] - v[0];
	REP(i, 1, n - 1) {
		ans += abs(v[i]);
	}
	printf("%d\n", ans);
	for(int i = n - 2; i > 0 && v[i] >= 0; i--) {
		printf("%d %d\n", v[0], v[i]);
		v[0] -= v[i];
	}
	for(int i = 1; i < n - 1 && v[i] < 0; i++) {
		printf("%d %d\n", v[n - 1], v[i]);
		v[n - 1] -= v[i];
	}
	printf("%d %d\n", v[n - 1], v[0]);
}   

int main(){

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


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

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    double res = 0;
    
    if((int)W%2 == 0 && W/2 == x && (int)H%2 == 0 && H/2 == y){
        res = (H*W)/2;
        cout << fixed << setprecision(10) << res << " " << 1 << endl;
        return 0;
    }
    res = (H*W)/2;
    cout << fixed << setprecision(10) << res << " " << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int i ,a ,b ,c ;
   for(i=1 ; i<=3000 ; i++ )
   {
   cin >> a >> b;
   if( a==0 && b==0 )
   break;
   if(a > b)
   {
   c=a;
   a=b;
   b=c;
   }
   cout << a << " " << b << endl;
   }
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
const int mod=1e9+7; 
const int N=2e6+3;
ll k,fact[N];

ll modpow(ll a,ll b){
    ll ans=1;
    while(b){
        if(b%2)ans=ans*a%mod;
        a=a*a%mod;
        b=b/2;
    }
    return ans%mod;
}

void factor(){
    fact[0]=1;
    for(int i=1;i<N;i++)fact[i]=fact[i-1]*i%mod;
}


ll cal(ll x,ll p){
    return fact[x]*modpow(fact[p],(mod-2))%mod*modpow(fact[x-p],(mod-2))%mod;
}

int main(){
    fast factor();
    cin>>k;
    string s;cin>>s;
    int p=s.size();
    ll ans=0;
    for(int i=p;i<=p+k;i++){
        ll temp=cal(i-1,p-1)*modpow(25,i-p)%mod*modpow(26,k+p-i);
        ans=(ans+temp)%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 19864
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
 
int n, present[505], cnt[505];
char arr[505][505];
 
 
int main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    cin>>n;
    bool ok = false, good = true;
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    	for(int j=0;j<n;j++){
    		ok |= (arr[i][j] == '#');
    		if(arr[i][j] == '#')
    			present[j] = 1;
    		else{
    			cnt[i]++;
    			good = false;
    		}
    	}
    }
 
    if(!ok){
    	cout<<"-1";
    	return 0;
    }
 
    if(good){
    	cout<<"0";
    	return 0;
    }
 
    int ans = MOD;
    for(int i=0;i<n;i++){
    	if(cnt[i] == 0){
    		ans = 0;
    		break;
    	}
    	if(present[i])
    		ans = min(ans, cnt[i]);
        else
                ans = min(ans, cnt[i]+1);
    }
 
    int z = 0;
    for(int j=0;j<n;j++){
    	int cnt = 0;
    	for(int i=0;i<n;i++)
    		if(arr[i][j]== '.')
    			cnt = 1;
    	if(cnt == 1)	z++;
    }
 
	ans += z;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
	int n;
	while(scanf("%d", &n) != EOF)
	{
		int sum = 0, i = 0, k;
		k = n;
		do{
			sum += k%10;
			k = k/10;
			i++;
		}while(k > 0);
		if(n % sum == 0)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import heapq
n = int(input())
robots = []
for _ in range(n):
    robot = tuple(map(int, input().split()))
    heapq.heappush(robots, robot)

robot = heapq.heappop(robots)
max_right = robot[0] + robot[1]
del_count = 0
for i in range(len(robots)):
    robot = heapq.heappop(robots)
    if max_right > robot[0] - robot[1]:
        del_count += 1
        max_right = min(max_right, robot[0] + robot[1])
    else:
        max_right = robot[0] + robot[1]
print(n-del_count)

Measured memory_bytes: 67032
#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;

int main(){
  int N; cin >> N; vector<ll> lucas(100);
  
  lucas[0] = 2; lucas[1] = 1;
  
  for(int i = 2; i <= 86; i++){
    lucas[i] = lucas[i-1] + lucas[i-2];}
  
  cout << lucas[N] << endl;
  
  return 0;}
  


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

int main() {
    int N;
    cin >> N;

    vector<int> result(N + 1);
    for(int x = 1; x < 101; x++) {
        for(int y = 1; y < 101; y++) {
            for(int z = 1; z < 101; z++) {
                int n = x * x + y * y + z * z + x * y + y * z + z * x;
                if (n > N) break;
                result[n]++;
            }
        }
    }

    for(int i = 1; i < N + 1; i++) {
        cout << result[i] << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
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 lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define 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; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  string s;
  cin>>s;
  int n=s.size();

  if(n==1) {
    cout << s << endl;
    return 0;
  }
  
  vector<int> p(n);
  rep(i,n){
    p[i]=s[i]-'0';
  }

  ll ans=0;
  //——————————————bit全探索——————————————
  rep(i,(1<<n-1)){
    ll sum=p[0];
    rep(j,n-1){
      if(i & (1<<j)){
        ans+=sum;
        sum=p[j+1];
      }
      else sum=sum*10+p[j+1];
    }
    ans+=sum;
  }

  cout << ans << endl;

  //——————————————————————————————————————

}


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

int main(){
	string a,b,c; cin>>a>>b>>c;
	int ak=a.size();
	int bk=b.size();
	if(a[ak-1]==b[0]&&b[bk-1]==c[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 3604
n = int(input())
p = list(map(int, input().split()))

ans = 0
c = 0
for i in range(n):
    if p[i] == i+1:
        c += 1
    if p[i] != i+1:
        if c % 2 == 0:
            ans += c // 2
        else:
            ans += c // 2 + 1
        c = 0

if c % 2 == 0:
    ans += c // 2
else:
    ans += c // 2 + 1 

print(ans)

Measured memory_bytes: 14008
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int ask(int x) {
  printf("%d\n", x);
  fflush(stdout);
  char s[20];
  scanf("%s", s);
  if (s[0] == 'V') {
    exit(0);
  }

  return s[0] == 'M';
}

int main(void) {
  int N;
  scanf("%d", &N);

  int lo = 0, hi = N;
  int l = ask(0);
  int r = l;

  while (lo < hi) {
    int mid = (lo + hi) / 2;
    int m = ask(mid);

    if ((mid - lo) % 2 != (m ^ l)) {
      hi = mid;
      r = m;
    } else {
      lo = mid;
      l = m;
    }
  }
  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxi 10000000
// cout << "YES\n";
// cout << "NO\n";
int main()
{
    ll a, b, c, d, res = -1e18;
    cin >> a >> b >> c >> d;
    res = max({res, a * c, a * d, b * d, b * c});
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function to find special numbers 
void divisibilityCheck(int arr[], int n) 
{ 

	// Storing all array elements in a hash 
	// and finding maximum element in the array 
	unordered_set<int> s; 
	int max_ele = INT_MIN; 
	for (int i = 0; i < n; i++) { 
		s.insert(arr[i]); 

		// Update the maximum element of the array 
		max_ele = max(max_ele, arr[i]); 
	} 

	// Traversing the array elements and storing the array 
	// multiples that are present in s in res 
	unordered_set<int> res; 
	for (int i = 0; i < n; i++) { 

		// Check for non-zero values only 
		if (arr[i] != 0) { 

			// Checking the factors of current element 
			for (int j = arr[i] * 2; j <= max_ele; j += arr[i]) { 

				// If current factor is already part 
				// of the array then store it 
				if (s.find(j) != s.end()) 
					res.insert(j); 
			} 
		} 
	} 

	// For non-distinct elmments 
	// To store the frequency of elements 
	unordered_map<int, int> mp; 
	for (int i = 0; i < n; i++) 
		mp[arr[i]]++; 

	unordered_map<int, int>::iterator it; 
	vector<int> ans; 
	for (it = mp.begin(); it != mp.end(); it++) { 

		if (it->second >= 2) { 
			if (res.find(it->first) == res.end()) { 

				int val = it->second; 

				while (val--) 
					ans.push_back(it->first); 
			} 
		} 
		if (res.find(it->first) != res.end()) { 
			int val = it->second; 
			while (val--) 
				ans.push_back(it->first); 
		} 
	} 
	cout<<n-ans.size();
} 
int main() 
{ 
    int n; cin>>n;int arr[n]; for(int i=0;i<n;i++)cin>>arr[i];
  
    divisibilityCheck(arr, n); 
  
    return 0; 
} 


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

ll dp[101010];

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

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        dp[i] = 1e15;
        //dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        for (int k=1; k<=K; ++k) {
            if (i-k >= 0) {
                dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]));
            }
        }
    }

    cout << dp[N-1] << endl;
}


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

void func(int c){
	ans+='a'+c;
}

int main(){
  ll n;cin>>n;
  while(1){
    n--;
    ll mod=(ll)26;
    int c=(int)(n%mod);
    func(c);
    n/=mod;
    if(n==0) break;
  }
  for(int i=ans.size()-1;i>=0;i--) cout<<ans.at(i);
}

Measured memory_bytes: 3628
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>

#define pi 3.1415926535

using namespace std;

int main(void) {

	long double r;
	cin >> r;
	cout << fixed << setprecision(15) << r * 2 * pi << endl;
	return 0;
}

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

struct Graph {
    static constexpr int INF = 1 << 30;
    struct Edge {
        int i, r, f;
    };
    Graph(int n) : v(n), h(n), q(n), e(n) {}
    void add_edge(int i, int j, int f) {
        int r0 = e[j].size();
        int r1 = e[i].size();
        e[i].push_back({ j, r0, max(+f, 0) });
        e[j].push_back({ i, r1, max(-f, 0) });
    }
    void bfs(int i0, int i1) {
        fill(v.begin(), v.end(), -1);
        v[i0] = 0;
        int j0 = 0, j1 = 0;
        q[j1++] = i0;
        while (j0 < j1) {
            int i = q[j0++];
            for (Edge& o : e[i]) {
                if (v[o.i] >= 0 || o.f == 0) continue;

                v[o.i] = v[i] + 1;
                if (o.i == i1) return;
                q[j1++] = o.i;
            }
        }
    }
    int dfs(int i, int i1, int f0) {
        for (; h[i] < e[i].size(); h[i]++) {
            Edge& o = e[i][h[i]];
            if (v[o.i] <= v[i] || o.f == 0) continue;

            int f = min(f0, o.f);
            if (o.i != i1) f = dfs(o.i, i1, f);
            if (f == 0) continue;

            o.f -= f;
            e[o.i][o.r].f += f;
            return f;
        }
        return 0;
    }
    int64_t max_flow(int i0, int i1) { // i0 != i1
        for (int64_t f = 0;;) {
            bfs(i0, i1);
            if (v[i1] < 0) return f;
            fill(h.begin(), h.end(), 0);
            while (1) {
                int t = dfs(i0, i1, INF);
                if (t == 0) break;
                f += t;
            }
        }
    }
    vector<int> v, h, q;
    vector<vector<Edge>> e;
};

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

    Graph g(n + 2);
    int S = 0, T = n + 1;
    int64_t p = 0;

    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;

        if (a < 0) {
            g.add_edge(S, i, -a);
        } else if (a > 0) {
            g.add_edge(i, T, a);
            p += a;
        }
        for (int j = i * 2; j <= n; j += i) {
            g.add_edge(i, j, Graph::INF);
        }
    }

    cout << p - g.max_flow(S, T) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin>>N;
      vector<int> v(4);
      v.at(0) = N/1000;
      v.at(1) = (N%1000)/100;
      v.at(2) = (N%100)/10;
      v.at(3) = N%10;
      if((v.at(0)==v.at(1)&&v.at(0)==v.at(2))||(v.at(3)==v.at(1)&&v.at(3)==v.at(2))){
      cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }

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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<ll, ll>


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



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//
//-----class-----//
class UnionFind{
    public:
        vector<ll> par; //parents
        vector<ll> siz; // sizes of set
        vector<ll> rank; // rank of each element 
    UnionFind(ll n): par(n), siz(n, 1LL), rank(n){
        LREP(i, 0, n) par[i] = i;
    }
    //initialization
    /*
    void init(ll n){
        par.assign(n);
        siz.assign(n, 1LL);
        rank.assign(n);
        LREP(i, 0, n) par[i] = i;
    }
    */

    // find the root of x
    ll find(ll x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    //Unite two set including x or y
    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //Do x and y belong to the same set?
    bool issame(ll x, ll y){
        return find(x) == find(y);
    }

};

struct edge{ ll to, cost; };
ll n;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<edge> G[n];
    LREP(i, 0, n){
        ll u, k;
        cin >> u >> k;
        LREP(j, 0, k){
            edge e;
            cin >> e.to >> e.cost;
            G[u].push_back(e);
        }
    }
    ll d[n];
    LREP(i, 0, n) d[i] = INF;
    priority_queue<P, vector<P>, greater<P>> q;
    d[0] = 0;
    q.push(P(0, 0));
    while(!q.empty()){
        P p = q.top(); q.pop();
        ll v = p.second;
        if(d[v] < p.first) continue;
        LREP(i, 0, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                q.push(P(d[e.to], e.to));
            }
        }
    }
    LREP(v, 0, n){
        cout << v << ' ' << d[v] << '\n';
    }

}



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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

class CompareDist
{
public:
    bool operator()(P n1, P n2) {
        return n1.first>n2.first;
    }
};

int main() {
    lli n, m;
    cin2(n, m);
    lli a[n];
    lli b[n];
    ncin2(n, a, b);
    priority_queue< P, vector<P>, CompareDist > que;
    REP(i, 0, n) {
        que.push(P(a[i], b[i]));
    }

    lli ans = 0;
    while (true) {
        lli cost, hon;
        tie(cost, hon) = que.top();
        que.pop();

        if (m > hon) {
            m -= hon;
            ans += cost * hon;
        }
        else {
            ans += cost * m;
            break;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 3956
n = int(input())
d = list(map(int,input().split()))

if d[0] != 0:
    print("0")
    exit()

count = 1
dmax = max(d)
num_array = [0] * (dmax+1)

for i in range(len(d)):
    num_array[d[i]] += 1

if num_array[0] != 1:
    print("0")
    exit()
for i in range(1, dmax+1):
    count *= num_array[i-1] ** num_array[i]
    count %= 998244353
print(count)


Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>

using namespace std;

struct Puddle {
	int start; // 始点
	int size; // 面積
};

stack<int> s1;
stack<Puddle> s2;
string input;

int A = 0;
int k;
vector<int> l;

int main() {
	cin >> input;
	int length = input.size();

	for (int i = 0; i < length; i++) {

		if (input[i] == '\\') {
			s1.push(i); // 現在位置を積む

		}
		else if (input[i] == '/') {
			if (s1.empty()) { continue; } // 対応する左崖がないと何もしない

			// 総面積
			int left = s1.top();
			int size = i - s1.top();

			A += size; // 等y座標の左崖を取り出して、距離を総面積に加算する

			// 水たまり個々
			if (s2.empty()) s2.push({left, size});
			else {
				int leftmost = s2.top().start;
				int newsize = size;
				// 今回の水たまりの左位置よりも、水たまりの左位置が内部にある
				while (leftmost > left) {
					newsize += s2.top().size;
					s2.pop();

					if (s2.empty()) break;
					leftmost = s2.top().start;
				}

				// 新しい水たまりを代入する
				s2.push({ left, newsize });
			}

			s1.pop();
		}
		else if (input[i] = '_') {
			// 距離が増える
		}
	}

	cout << A << endl;

	int s2size = s2.size();
	cout << s2size;
	vector<int> output(s2size);
	for (int i = 0; i < s2size; i++) {
		output[s2size - i - 1] = s2.top().size;
		s2.pop();
	}

	for (int i = 0; i < s2size; i++) {
		cout << " " << output[i];
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <string.h>

int main() {
  int N = 0, K = 0;
  int i = 0, j = 0;
  int c = 0;
  int count = 0;
  scanf("%d",&N);

  int b[N];
  for(i = 0; i < N; i++) {
      b[i] = 1;
  }
  scanf("%d",&K);
  
  for(i = 0; i < K; i++) {
    int d = 0;
    scanf("%d",&d);
    
    for(j = 0; j < d; j++) {
      scanf("%d",&c);
      b[c - 1] = 0;
    }
  }

  for(i = 0; i < N; i++) {
    if(b[i] == 1)
      count += 1;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 1728
using System;
class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] p = Console.ReadLine().Split(' ');
    string ans = "YES";
    int htr = -1;
    bool switched = false;
    for (int i = 0; i < N; i++)
    {
      int pi = int.Parse(p[i]);
      if (pi != i + 1)
      {
        if (!switched && int.Parse(p[pi - 1]) == i + 1)
        {
          switched = true;
          htr = pi - 1;
        }
        else if (i != htr)
        {
          ans = "NO";
          break;
        }
      }
    }
    
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

const int MAX = 1000001;
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()
{
    ll N, K;
    cin >> N >> K;
    COMinit();

    ll ans = 0;
    repd(i, 1, K + 1) {
        ll res = COM(N - K + 1, i) * COM(K - 1, i - 1);
        cout << res % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 27044
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };

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

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, 0, N)cin >> A[i];
	vector<ll> L(N + 1), R(N + 1);
	L[0] = 0;
	R[N] = 0;
	REP(i, 1, N + 1) {
		L[i] = gcd(A[i - 1], L[i - 1]);
		R[N - i] = gcd(A[N - i], R[N - i + 1]);
	}
	ll ans = 1;
	REP(i, 1, N + 1) {
		ll tmp = gcd(L[i - 1], R[i]);
		maxs(ans, tmp);
	}
	PRI(ans);
	return 0;
}

Measured memory_bytes: 5624
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  string s;
  cin>>s;
  string ans;
  loop(i,s.size()){
    if(s[i]=='0')ans+='0';
    if(s[i]=='1')ans+='1';
    if(s[i]=='B'&&ans.size()>=1)ans.erase(ans.size()-1);
  }
  putout(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static boolean dfs(
            int n, int u, int c, int[] color, int[][] colorGraph,
            int[] colorCount
    ) {
        color[u] = c;
        colorCount[c]++;
        for (int v = 1; v <= n; ++v) {
            if (u == v || colorGraph[u][v] == 0) {
                continue;
            }
            if (color[v] == 0  && !dfs(n, v, 3 - c, color, colorGraph, colorCount)) {
                return false;
            }
            if (color[v] == c) {
                return false;
            }
        }
        return true;
    }

    public static void main(String [] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int m = sc.nextInt();
        final int [][] road = new int [n + 1][n + 1];
        for (int i = 0; i < m; ++i) {
            final int u = sc.nextInt();
            final int v = sc.nextInt();
            road[u][v] = 1;
            road[v][u] = 1;
        }

        final int [][] colorGraph = new int[n + 1][n + 1];

        for (int u = 1; u <= n; ++u) {
            for (int v = 1; v <= n; ++v) {
                if (u == v) {
                    continue;
                }
                if (road[u][v] != 1) {
                    colorGraph[u][v] = 1;
                    colorGraph[v][u] = 1;
                }
            }
        }

        //all nodes in colorGraph must be 2 color
        //check whether it's possible
        // color : 1 red
        // color : 2 white
        // color: 0 undefined
        final int[] color = new int[n + 1];
        final int[] colorCount = new int[3];
        final int [][] dp = new int[n + 1][n + 1];
        dp[0][0] = 1;
        for (int i = 1; i <= n; ++i) {
            colorCount[1] = colorCount[2] = 0;

            if (color[i] == 0) {
                if (!dfs(n, i, 1, color, colorGraph, colorCount)) {
                    System.out.println(-1);
                    return;
                }
            }
            for (int count = 0; count <= n; ++count) {
                if (dp[i - 1][count] == 1) {
                    dp[i][count + colorCount[1]] = 1;
                    dp[i][count + colorCount[2]] = 1;
                }
            }
        }

        int minCount = Integer.MAX_VALUE;


            for (int red = 0; red <= n; ++red) {
                if (dp[n][red] == 1) {
                    int currentCount = red * (red - 1) / 2 +
                            (n - red) * (n - red - 1) / 2;
                    minCount = Math.min(minCount, currentCount);
                }
            }



        System.out.println(minCount);
    }
}


Measured memory_bytes: 148116
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = n; i < 1000; i++){
        int a = i/100, b = i%100/10, c = i%10;
        if(a == b && b == c){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
typedef unsigned int UINT;
using namespace std;


int main(void) {
    int N, L;
    cin >> N >> L;
    vector<string> mas(N);
    for (string & s : mas) {
        cin >> s;
    }
    sort(mas.begin(), mas.end());

    string ans = "";
    for (string s : mas) {
        ans += s;
    }
    cout << ans << endl;
       
    return 0;
}

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

vector<int> pturn={0,1,2,3,4};

int main(){
  int i,a[5]={0},tmin = 1<<30;
  for(i=0;i<5;i++){
    cin >> a[i];
  }
  
  int cnt;
  do{
    cnt=0;
    for(i=0;i<5;i++){
      if(cnt%10!=0){
        cnt=(cnt/10+1)*10;
      }
      cnt+=a[pturn[i]];
    }
    tmin=min(cnt,tmin);
  }while(next_permutation(pturn.begin(),pturn.end()));
  cout << tmin << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a2.reverse()
ans = 0
for i in range(n):
    for j in range(n-i):
        sum_1 = sum(a1[0:j+1])
        sum_2 = sum(a2[0:i+1])
        sum_a = sum_1 + sum_2
        if sum_a > ans:
            ans = sum_a
print(ans)

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

long a[300][300];
int n;
bool en[300][300];
long ans = 0;

int main(void) {

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%ld",&a[i][j]);
      en[i][j] = 1;
    }
  }

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      if(i == k) continue;
      for(int j=0;j<n;j++){
        if(j == k || j == i) continue;
        if(a[i][j] > a[i][k] + a[k][j]){
          printf("-1\n");
          return 0;
        }
	if(a[i][j] == a[i][k] + a[k][j]){
	  en[i][j] = 0;
        } 
      }
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(en[i][j]) ans += a[i][j];
    }
  }
  ans /= 2;
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 1024