akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  string left = "qwertasdfgzxcvb";
  string s;
  while(cin >> s, s!="#") {
    int res = 0;
    int l = -1;
    REP(i,s.size()) {
      if (find(ALL(left), s[i])!=left.end()) {
        if (l!=1) {
          res++;
          l = 1;
        }
      } else {
        if (l!=0) {
          res++;
          l = 0;
        }
      }
    }
    cout << res-1 << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	while(1){
        string a;
        cin >> a;
        if(a[0] == '#') break;
        string word = "yuiophjklnm";
        bool flg[50] = {0};
        for(int i = 0; i < a.size(); i++){
            for(int j = 0; j < word.size(); j++){
                if(a[i] == word[j]) flg[i] = 1;
            }
        }
        int cnt = 0;
        for(int i = 1; i < a.size(); i++){
            if(flg[i-1] != flg[i]) cnt++;
        }
        cout << cnt << endl;
	}
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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 int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    string s;
    cin >> s;

    auto dp = make_vec<ll>(s.size()+1,4);
    fill_v(dp,0);
    dp[0][0] = 1;

    for(int i = 0;i < s.size();i++) for(int j=0;j<=3;j++){
        if(j==3) {
            dp[i+1][j]   = (dp[i+1][j]+((s[i]=='?'?3:1)*dp[i][j]))%MOD;
        } else {
            dp[i+1][j]   = (dp[i+1][j] +((s[i]=='?'?3:1)*dp[i][j]))%MOD;
            dp[i+1][j+1] = (dp[i+1][j+1]+(s[i]=='?' || s[i]=="ABC"[j]?1:0)*dp[i][j])%MOD;
        } 
    }

/*
    REP(j,4) {
        REP(i,s.size()+1) cout << dp[i][j] << " ";
        cout << endl;
    }
    */

    pl(dp[s.size()][3])

    return 0;
}


Measured memory_bytes: 7424
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    as <- sort <$> getIntList
    bs <- sort <$> getIntList
    cs <- sort <$> getIntList
    let ab = zip bs . tail . map fst $ scanl' solveAB (0,as) bs
        bc = map fst $ scanl' solveBC (0,ab) cs
    print $ sum bc

solveAB (k,as) b = let (ts,ds) = span (< b) as in (k + length ts, ds)
solveBC (k,ab) c = let (ts,ds) = span ((< c) . fst) ab in (k + sum (map snd ts), ds)

Measured memory_bytes: 47356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, s, t; cin >> n >> s >> t;
    --s, --t;
    vector<VI> g(n);
    FOR(i, 0, n - 1) {
        int a, b; cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    VI adis(n, INF);
    adis[t] = 0;
    queue<int> bfs;
    bfs.push(t);
    while (!bfs.empty()) {
        int now = bfs.front(); bfs.pop();
        each(to, g[now]) {
            if (chmin(adis[to], adis[now] + 1)) {
                bfs.push(to);
            }
        }
    }

    VI tdis(n, INF);
    tdis[s] = 0;
    bfs.push(s);
    while (!bfs.empty()) {
        int now = bfs.front(); bfs.pop();

        each(to, g[now]) {
            if (chmin(tdis[to], tdis[now] + 1)) {
                bfs.push(to);
            }
        }
    }

    int ans = 0;
    FOR(i, 0, n) {
        if (adis[i] < tdis[i])continue;
        chmax(ans, adis[i] - 1);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define int long long
int sum,tot;
int d[1000001];
int c[1000001];
int n;
signed main()
{
	int n;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&c[i],&d[i]);
		tot+=d[i];
		sum+=d[i]*c[i];
	}
	printf("%lld",(sum-1)/9+tot-1);
	return 0;
}


Measured memory_bytes: 5888
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

X, Y = map(int, input().split())

# 移動回数
if (X + Y) % 3 != 0:
    print(0)
    exit()

nm = (X + Y) // 3
n = X - nm
m = Y - nm

if n < 0 or m < 0:
    print(0)
    exit()


# 階乗、Combinationコンビネーション(numpyを使う)

def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


# def mod_comb_k(n, k, mod):
    # return fact[n] * fact_inv[k] % mod * fact_inv[n-k] % mod

MOD = 10 ** 9 + 7
U = 10**6
fact, fact_inv = make_fact(U, MOD)
ans = fact[nm] * fact_inv[n] % MOD * fact_inv[nm-n] % MOD
print(ans)


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

int main(){
    string S, T;
    cin >> S >> T;
    int Slen = S.length();
    int Tlen = T.length();

    for(int i=Slen-Tlen;i>=0;i--){
        bool flag = true;
        for(int j=0;j<Tlen;j++){
            if(S[i+j] == T[j] || S[i+j] == '?'){
                // ok;
            }
            else{
                flag = false;
            }
        }
        if(flag){
            string trueS = S;
            for(int k=0;k<i;k++){
                if(trueS[k] == '?'){
                    trueS[k] = 'a';
                }
            }
            for(int k=i;k<i+Tlen;k++){
                if(trueS[k] == '?'){
                    trueS[k] = T[k-i];
                }
            }
            for(int k=i+Tlen;k<Slen;k++){
                if(trueS[k] == '?'){
                    trueS[k] = 'a';
                }
            }
            cout << trueS << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
N,K = map(int,input().split())
acc = list(accumulate(range(N+1), lambda x,y:x+y))
ans = 0
mod = 10**9+7
for i in range(K, N+1):
    r = acc[N] - acc[N-i]
    l = acc[i-1]
    ans = (ans+r-l+1) % mod
ans += 1
print(ans % mod)

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

int main() {
  int A,B;
  cin >> A >> B;
  
  if((A < 10) && (B < 10)){
    cout << A * B << endl;
  }else{
    cout << "-1" << endl;
  }

 
  return 0;
}


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

using namespace std;

int main() {
    int n;
    cin>>n;
    long len[n];
    for (int i = 0; i < n; ++i) {
        cin>>len[i];
    }
    sort(len,len+n);
    long a=0,b=0,flag=1;
    for (int j = n-1; j >=1; --j) {
        if(len[j]==len[j-1] && flag){
            a=len[j];
            j--;
            flag=0;
        }
        else if(len[j]==len[j-1]){
            b=len[j];
            cout<<a*b<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

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

int main(){
    int W,H,x,y;
    cin >> W >> H >> x >> y;
    double ans = (double)W * (double)H / 2;
    int ptn = 0;
    if (W==x*2 && H==y*2) ptn = 1;
    printf("%10f %d\n",ans,ptn);
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    map<int, int> cnt;
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      ++cnt[a];
      ++cnt[b];
    }
    bool f = true;
    each (i, cnt) f = f && (i.second % 2 == 0);
    cout << (f ? "YES" : "NO") << endl;
  }
  
  return 0;
}



Measured memory_bytes: 5632
N, K = map(int, input().split())
li = []
for i in range(N):
    a, b = map(int, input().split())
    li.append((a, b))

li.sort(key=lambda x: x[0])

cnt = 0
for i in range(N):
    cnt += li[i][1]
    if cnt >= K:
        print(li[i][0])
        exit()

Measured memory_bytes: 56920
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S, T;
    cin >> N >> S >> T;
    rep(i, 0, N) cout << S[i] << T[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

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

void Main(){
    int X;
    cin >> X;
    vec<bool> memo(X+1);
    FOR(i, sqrt(X)+1, 2){
        int tmp = i*i;
        while(tmp<=X){
            memo[tmp] = true;
            tmp *= i;
        }
    }
    REPR(i, X){
        if(memo[i]){
            cout << i << el;return;
        }
    }
    cout << 1 << el;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
d = []
for i in range(m):
    b, c = map(int, input().split())
    bc.append((b, c))
a.sort()
bc.sort(key=lambda x: x[1])
bc = bc[::-1]
cnt = 0
flg = False
for t in bc:
    for i in range(t[0]):
        d.append(t[1])
        cnt += 1
        if cnt == n:
            flg = True
            break
    if flg:
        break
for i, k in enumerate(d):
    if a[i] > k:
        i -= 1
        break
ans = sum(a[i + 1:] + d[:i + 1])
print(ans)

Measured memory_bytes: 80920
/**
 *    author:  zjsdut
 *    created: 2020/03/09 11:59:12
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int h, n;
  scan(h, n);
  vi a(n);
  scan(a);
  int sum = accumulate(all(a), 0);
  println(sum >= h ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	ll N;
	cin >> N;
	vector<ll> a(3 * N), s(N + 1, 0);
	priority_queue<ll, vector<ll>, greater<ll>> que0;
	priority_queue<ll> que1;
	for (ll i = 0; i < 3 * N; i++) {
		cin >> a[i];
		if (i < N) que0.push(a[i]);
		if (i >= 2*N)que1.push(a[i]);
	}

	ll sum0 = accumulate(a.begin(), a.begin() + N, 0ll);
	s[0] += sum0;
	for (ll i = 0; i < N; i++) {
		que0.push(a[N + i]);
		sum0 = sum0 + a[N + i] - que0.top();
		que0.pop();
		s[i + 1] += sum0;
	}

	ll sum1 = accumulate(a.end() - N, a.end(), 0ll);
	s[N] -= sum1;
	for (ll i = N - 1; i >= 0; i--) {
		que1.push(a[N + i]);
		sum1 = sum1 + a[N + i] - que1.top();
		que1.pop();
		s[i] -= sum1;
	}
		
	sort(s.begin(), s.end(), greater<ll>());
	cout << s[0] << endl;
	return 0;
}

Measured memory_bytes: 5748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int c[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			scanf("%d", &c[i][j]);
		}
	}
	int k[4];
	int d[3];
	for(int i=0;i<3;i++){
		d[i] = c[i][1] - c[i][0];
	}
	if(d[0]!=d[1] || d[1]!=d[2]){
		printf("No\n");
		return 0;
	}
	k[0] = d[0];

	for(int i=0;i<3;i++){
		d[i] = c[i][2] - c[i][1];
	}
	if(d[0]!=d[1] || d[1]!=d[2]){
		printf("No\n");
		return 0;
	}
	k[1] = d[0];

	for(int i=0;i<3;i++){
		d[i] = c[1][i] - c[0][i];
	}
	if(d[0]!=d[1] || d[1]!=d[2]){
		printf("No\n");
		return 0;
	}
	k[2] = d[0];

	for(int i=0;i<3;i++){
		d[i] = c[2][i] - c[1][i];
	}
	if(d[0]!=d[1] || d[1]!=d[2]){
		printf("No\n");
		return 0;
	}
	k[3] = d[0];


	printf("Yes\n");
	/*
	if(abs(k[0])+abs(k[1])<=100 && abs(k[2])+abs(k[3])<=100){

	}else{
		printf("No\n");
	}
	*/

	return 0;
}


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

int main( int argc, char *argv[] )
{
int i;
int H;
int W;
char S[ 110 ][ 110 ];

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

	cin >> H;
	cin >> W;
	for( i = 1; i <= H; i++ ) cin >> S[ i ];

	memset( S[ 0 ], '#', W );
	S[ 0 ][ W ] = '\0';

	memset( S[ H + 1 ], '#', W );
	S[ H + 1 ][ W ] = '\0';

	for( i = 0; i <= H + 1; i++ )
	{
		cout << "#" << S[ i ] << "#" << endl;
	}

	return 0;
}




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

int main()
{
    int N;
    float ans=0;
    cin >> N;
    int V[N];
    for(int i=0;i<N;i++) {
        cin >> V[i];
    }
    sort(V,V+N);
    ans = V[0];
    for(int i=1;i<N;i++) {
        ans = (ans+V[i])/2;
    }
    cout << ans << endl;
    return 0;
}


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

struct StGoods
{
  StGoods() : m_nPrice(0), m_nNum(0) { }

  int m_nPrice;
  int m_nNum;

  bool operator<(const StGoods& rhs) const
  {
    return m_nPrice < rhs.m_nPrice;
  }
};

void fnInput(int& rnTrgNum, vector<StGoods>& rvoGoods)
{
  int nGoodsSiz;
  cin >> nGoodsSiz >> rnTrgNum;
  rvoGoods.resize(nGoodsSiz);

  for (StGoods& roGoods : rvoGoods)
    cin >> roGoods.m_nPrice >> roGoods.m_nNum;
}

llong fnMinCost(int nTrgNum, vector<StGoods>& rvoGoods)
{
  sort(begin(rvoGoods), end(rvoGoods));

  llong nCost = 0;

  for (StGoods oGoods : rvoGoods)
  {
    int nUsedNum = min(nTrgNum, oGoods.m_nNum);
    nCost += (llong)oGoods.m_nPrice * nUsedNum;
    nTrgNum -= nUsedNum;

    if ( !nTrgNum ) break;
  }
  return nCost;
}
 
int main()
{
  int nTrgNum;
  vector<StGoods> voGoods;

  fnInput(nTrgNum, voGoods);
  cout << fnMinCost(nTrgNum, voGoods) << endl;

  return 0;
}

Measured memory_bytes: 4036
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int n, m;
    cin >> n >> m;
    int ans;
    ans = (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
    cout << ans << 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 count0 = 0,count2 = 0,count4 = 0;
		for(int i=0;i<n;i++){
			int a = scanner.nextInt();
			if(a % 2 == 0){
				a /= 2;
				if(a % 2 == 0){
					count4++;
				}else{
					count2++;
				}
			}else{
				count0++;
			}
		}
		if(count4 + 1 < count0){
			System.out.println("No");
		}else{
			if(count2 % 2 != 0){
				if(count4 < count0){
					System.out.println("No");
				}else{
					System.out.println("Yes");
				}
			}else{
				System.out.println("Yes");
			}
		}
	}

}


Measured memory_bytes: 46300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);


        while(true){
           int x = sc.nextInt();
           int y = sc.nextInt();
            if ( x == 0 && y == 0 ) break;

            if ( x < y ){
                System.out.println(x +" " + y);
            } else {
                System.out.println(y +" " + x);
            }
        }


}
}




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

int main() {
  int n, k, sum;
  cin >> n >> k;
  
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    int a = x;
    int b = x - k;
    if (b < 0) {
      b *= -1;
    }
    
    if (a < b) {
      sum += a;      
    }
    else {
      sum += b;
    }
  }
  
  cout << sum * 2 << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Data.Word
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U

-- Input: s t
-- Output: arr
--   (arr ! i) ! j == length of lcs of (drop i s, drop j t)
lcsTable :: BS.ByteString -> BS.ByteString -> V.Vector (U.Vector Word16)
lcsTable s t = V.scanr' (\ !x !v ->
                           -- for some i (0 <= i < m),
                           --   x = BS.index s i :: Char
                           --   v = arr ! (i+1) :: U.Vector Word16
                           U.scanr (\(!y,!w,!u) !l ->
                                      -- for some j (0 <= j < n)
                                      --   y = BS.index t j :: Char
                                      --   w = (arr ! (i+1)) ! j :: Word16
                                      --   u = (arr ! (i+1)) ! (j+1) :: Word16
                                      --   l = (arr ! i) ! (j+1) :: Word16
                                      if x == y
                                      then u + 1
                                      else max w l
                                   ) 0 (U.zip3 t' (U.init v) (U.tail v))
                        ) (U.replicate (n+1) 0) (V.fromListN m $ BS.unpack s)
  where !m = BS.length s
        !n = BS.length t
        !t' = U.fromListN n (BS.unpack t)

solve :: BS.ByteString -> BS.ByteString -> BS.ByteString
solve s t = let !table = lcsTable s t
                !m = BS.length s
                !n = BS.length t
                recon !i !j | i >= m || j >= n = Nothing
                            | x == y = let !i' = i+1 ; !j' = j+1
                                       in Just (x, (i', j'))
                            | (table V.! (i+1)) U.! j >= (table V.! i) U.! (j+1) = recon (i+1) j
                            | otherwise = recon i (j+1)
                  where x = BS.index s i
                        y = BS.index t j
                (result, _) = BS.unfoldrN (fromIntegral $ (table V.! 0) U.! 0) (\(!i,!j) -> recon i j) (0,0)
            in result

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  BS.putStrLn (solve s t)


Measured memory_bytes: 25468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			int n = sc.nextInt();

			int[][] result = new int[h][w];
			int x = 0;
			int y = 0;
			int number = 1;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();

				for (int j = 0; j < a; j++) {
					result[x][y] = number;
					if (x == h - 1 && y % 2 == 0) {
						y++;
					} else if(x == 0 && y % 2 == 1) {
						y++;
					} else {
						if (y % 2 == 0) {
							x++;
						} else {
							x--;
						}
					}
				}
				number++;
			}

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					System.out.print(result[i][j]);
					if (j != w - 1) {
						System.out.print(" ");
					}
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 30836
def p_i():
    n = int(input())
    *p, = map(float, input().split())
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1

    for i in range(n):
        for j in range(n):
            dp[i + 1][j + 1] += dp[i][j] * p[i]
            dp[i + 1][j] += dp[i][j] * (1 - p[i])

    print(sum(dp[-1][(n + 1) // 2:]))


if __name__ == '__main__':
    p_i()


Measured memory_bytes: 259336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	bool chk=false;
	cin>>N;
 
	int arr[11][11];
	memset(arr, -1, sizeof(arr));
	for(int i=1; i<10; ++i){
		for(int j=1; j<10; ++j){
			arr[i][j] = i*j;
		}
	}
 
	for(int i=1; i<10; ++i){
		for(int j=1; j<10; ++j){
			if( N == arr[i][j]) chk=true;
		}
	}
 
	if(chk==true)	cout<<"Yes";
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define SIZE 10028
int main() {

	int n,i,j,sum,num;
	int A[20][20];
	char str[SIZE],*line;

	for( ; ; ){
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d",&n);
	if(n==0)
		return 0;
	for(i=0;i<n;i++){
		sum=0;
		fgets(str,sizeof(str),stdin);
		line=strtok(str," ");
		sscanf(line,"%d",&A[i][0]);
		sum+=A[i][0];
		for(j=1;j<n;j++){
			line=strtok(NULL," "); 
			sscanf(line,"%d",&A[i][j]);
			sum+=A[i][j];
		}
		A[i][n]=sum;
	}
	for(i=0;i<=n;i++){
		num=0;
		for(j=0;j<n;j++)
			num+=A[j][i];
		A[n][i]=num;
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++)
			printf("%5d",A[i][j]);
		printf("\n");
	}
	}
}

Measured memory_bytes: 632
from math import gcd

N=int(input())
A=list(map(int,input().split()))


data = [0]*(10**6+1)

for a in A:
    data[a] += 1

pair = True

for i in range(2,10**6+1):
    check = 0
    for j in range(1,(10**6)//i+1):
        check += data[i*j]
    if check>1:
        pair = False

if pair:
    print("pairwise coprime")
else:
    res=A[0]
    for i in range(1,N):
        res=gcd(res,A[i])
    if res==1:
        print("setwise coprime")
    else:
        print("not coprime")


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

int main() {
	string n;
	cin >> n;
	int c = 0;
	for(int i = 0;i < 4;i++)
	{
		if(n.at(i) == '2')
		{
			c++;
		}
	}
	cout << c <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

//#define DEBUG


int main(void)
{
  int a,b,c,d;
  cin >> a >> b >> c;
  d= a+b+c;
  if(d>=22)
  {
    cout << "bust";
  }
  else
  {
    cout << "win";
  }
  
  return 0;
} 

Measured memory_bytes: 256
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = []

for i in range(1,n):
  b.append(a[i] - a[i - 1])
b.append(k - a[n-1] + a[0])

b = sorted(b)
print(sum(b[:-1]))


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

int main() {
  int N;
  cin >> N;
  vector<int> sosu;
  for (int i = 2; i <= N; i++) {
    int p = sqrt(i);
    bool b = true;
    for (int j = 2; j <= p; j++) {
      if (i%j == 0) b = false;
    }
    if (b) sosu.push_back(i);
  }
  
  long long yk = 1;
  for (int e : sosu) {
    int c = 0;
    int n = N;
    while (n > 0) {
      c += (n/e);
      n /= e;
    }
    yk *= c+1;
    yk %= 1000000007;
  }
  cout << yk << endl;
}

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

S = []

for i in range(N):
  S.append([0,0])
  for j in range(i):
    S[i][0] += Wi[j]
  for j in range(N-i):
    S[i][1] += Wi[i+j]

S_pair = []
for i in range(len(S)):
  S_pair.append(abs(S[i][1]-S[i][0]))
  
print(min(S_pair))

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int c, o1, o2;
  int ans = 0;
  cin >> o2;
  cin >> o1;
  for(int i = 2; i < n; i++){
    cin >> c;
    if(max(o1, max(o2, c)) != o1 && min(o1, min(o2, c)) != o1 ){
      //cout << o1 << endl;
      ans++;
    }
    o2 = o1;
    o1 = c;
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    map<string, int> cnt;
    vector<pair<int, string>> a;
    int n;
    cin >> n;
    forn(i, n) {
        cin >> s;
        cnt[s]++;
    }
    for (auto p : cnt) a.pb({p.snd, p.fst});
    sort(all(a));
    int pos = 0;
    forn(i, sz(a)) {
        if (a[i].fst < a.back().fst) pos++;
        else break;
    }
    forab(i, pos, sz(a)) {
        cout << a[i].snd << "\n";
    }
    return 0;
}

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

int main(void){
	string str;
	int n;
	scanf("%d\n",&n);
	for(int i=0;i<n;i++){
		getline(cin,str);
		for(int j=0;j<26;j++){
			for(int l=0;l<26;l++){
				string str2;
				for(int k=0;k<str.size();k++){
					if(str[k]!=' ')str2+=((str[k]-'a')*l+j)%26+'a';
					if(str[k]==' ')str2+=' ';
				}
				if( str2.find( "this" ) != string::npos || str2.find( "that" ) != string::npos){
					cout << str2 << endl;
					break;
				}
			}
		}
	}
    return 0;
}

Measured memory_bytes: 0
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 2e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <ll> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

ll a[N];

void solve() {
    ll k , n;
    cin >> k >> n;
    ll ans = 0 , mx = 0;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
        if(i > 1)
            chmax(mx , a[i] - a[i-1]);
    }
    chmax(mx , k - a[n] + a[1]);
    cout << k - mx;

}

main() {
    srand(time(0));
//    ios;
    int tt = 1;
//    cin >> tt;
    while(tt --) {
        solve();
//        brute();
    }
    return 0;
}
/*
2 2
2 1

01
10

01
10
11
*/


Measured memory_bytes: 1920
#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 show(x) cout << #x << " = " << (x) << endl
#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>>;
int main(){
	int N;
	cin>>N;
	V<int> a(N);
	rep(i,N) cin>>a[i];
	int inf = 1e9;
	V<int> dp(N+1,inf);
	dp[0] = 0;
	rep(i,N){
		rep1(t,2){
			int j = i+t;
			if(j<N) chmin(dp[j],dp[i] + abs(a[i]-a[j]));
		}
	}
	cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    vector<PLL> vp;
    rp(i,n){
        ll x,y;
        cin >> x >> y;
        vp.pb(mp(x,y));
    }
    ll ans=1ll<<63-1;
    sort(all(vp));
    rp(i,n-k+1){
        repi(j,i+k-1,n){
            ll width=vp[j].first-vp[i].first;
            Vi y_co;
            repi(c,i,j+1){
                y_co.pb(vp[c].second);
            }
            sort(all(y_co));
            rp(s,(j-i+1)-k+1){
                chmin(ans,width*(y_co[s+k-1]-y_co[s]));
            }
        }
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int X = in.nextInt();
		int Y = in.nextInt();
		int ans=A*X+B*Y;
		int N=X+Y;
		for(int i=0;i<100001;i++){
			ans=Math.min(ans,2*C*i+A*Math.max(0,X-i)+B*Math.max(0,Y-i));
		}
		System.out.println(ans);
	}

}

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

using namespace std;

struct BellmanFord {
    BellmanFord() = default;

    explicit BellmanFord(int n) { init(n); }

    struct edge {
        edge() = default;
        edge(int to, int cost) : to(to), cost(cost) {}
        int to, cost;
    };

    const long long linf = 1001001001001001001ll;

    bool f;
    vector<vector<edge>> G;
    vector<long long> d;

    void init(int n) {
        f = false;
        G.resize(n);
    }

    void add(int u, int v, int c) {
        G[u].push_back(edge(v, c));
    }

    void bellman_ford(int s) {
        d = vector<long long>(G.size(), linf);
        d[s] = 0;

        for (int i = 0; i < G.size(); ++i) {
            for (int v = 0; v < G.size(); ++v) {
                for (auto &e : G[v]) {
                    if (d[v] != linf && d[e.to] > d[v] + e.cost) {
                        d[e.to] = d[v] + e.cost;
                        if (i == G.size() - 1) f = true;
                    }
                }
            }
        }
    }
};


int main() {
    int v, e, r;
    cin >> v >> e >> r;

    auto bf = BellmanFord(v);
    for (int i = 0; i < e; ++i) {
        int s, t, d;
        cin >> s >> t >> d;

        bf.add(s, t, d);
    }

    bf.bellman_ford(r);
    if (bf.f) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < v; ++i) {
            if (bf.d[i] == bf.linf) cout << "INF" << endl;
            else cout << bf.d[i] << endl;
        }
    }
}


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

int main()
{
	char s[4];
	cin >> s;
	for(char t = 0; t < (1 << 3); t++){
		int ans = s[0] - '0';
		for(int i = 0; i < 3; i++){
			if(t & (1 << i)){
				ans += s[i+1] - '0';
			}else{
				ans -= s[i+1] - '0';
			}
		}
		//cout << ans << "\n";
		if(ans == 7){
			cout << s[0] << ((t & (1 << 0))?'+':'-') << s[1] << ((t & (1 << 1))?'+':'-') << s[2] << ((t & (1 << 2))?'+':'-') << s[3] << "=7\n";
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll a,k=0,m=100;
int main()
{
	cin>>a;
	while(m<a)
	{
		k++;
		m=m/100+m;
	}
	re(k)
	return 0;}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  int count=0;
  bool hantei;
    
  for(int i=1; i< N+1 ;i++){
    if(i%2==0){
     hantei = false;
    } else {
     int yakusu=0;
      for(int j=1; j< i+1; j++){
        if(i%j==0){
           yakusu++;
           }
      }
      
     if(yakusu==8){
        hantei=true;
     }else{
        hantei=false;
      }
    
  }
  //elseの終了
    
  if(hantei==true){
    count++;
  }
 }
 //forの終了
  
  cout << count <<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
l = [0 for _ in range(n)]
r = [0 for _ in range(n)]
def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while y:
        x, y = y, x % y
    return x
for i in range(n):
    if i == 0:
        l[0] = a[0]
    else:
        l[i] = gcd(l[i-1], a[i])
    j = n - 1 - i
    if j == n - 1:
        r[n-1] = a[n-1]
    else:
        r[j] = gcd(r[j+1], a[j])
m = [0 for _ in range(n)]
for i in range(n):
    if i == 0:
        m[0] = r[1]
    elif i == n - 1:
        m[n-1] = l[n-2]
    else:
        m[i] = gcd(l[i-1], r[i+1])
print(max(m))

Measured memory_bytes: 68972
#include<stdio.h>
#include<math.h>
int main(){
  int n,i,j,r,f=0,count=0;
  int a[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    if(a[i]!=2){
      for(j=2;j<=sqrt(a[i]);j++){
	r=a[i]%j;
	if(r==0){
	  f=1;
	  break;
	}
      }
    }
    if(f==0) count++;
    f=0;
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2120
V, E, r = map(int, input().split())
nodes = [list(map(int, input().split())) for _ in range(E)] #e = from, to, cost

def shortest_path(s):
    d = [float('inf') for i in range(V)]
    d[s] = 0
    for _ in range(V):
        update = False
        for i in range(E):
            e = nodes[i]
            if d[e[0]] != float('inf') and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True
    if update:
        return None
    else:
        return d

if not shortest_path(r):
    print('NEGATIVE CYCLE')
else:
    d = shortest_path(r)
    for i in range(V):
        if d[i] == float('inf'):
            print('INF')
        else:
            print(d[i])



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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n - 1);
    for (int i = 0; i < n; i++){
        cin >> A.at(i);
    }
    for (int i = 0; i < n; i++){
        cin >> B.at(i);
    }
    for (int i = 0; i < n - 1; i++){
        cin >> C.at(i);
    }
    int sum = 0;
    int prev;
    for (int i = 0; i < A.size(); i++){
        if (i == 0){
            sum += B[A[i] - 1];
            prev = A[i];
        }else{
            if (prev+1 == A[i]){
                sum += B[A[i] - 1];
                sum += C[A[i] - 1 - 1];
            }else{
                sum += B[A[i] - 1];
            }
            // if (A[i] == n){
            //     sum += B[n - 1];
            // }else{
            //     if (prev+1 == A[i]){
            //         sum += B[A[i] - 1];
            //         sum += C[A[i] - 1 - 1];
            //     }else{
            //         sum += B[A[i] - 1];
            //     }
            // }
            prev = A[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 5000005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"Yes\n";
#define N cout<<"No\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

void solve()
{

    lli n;
    cin>>n;
    lli arr[n+100]={0};
    for(lli i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    lli ans=0;

    for(lli i=1;i<=n;i++)
    {
        for(lli j=i+1;j<=n;j++)
        {
            for(lli k=j+1;k<=n;k++)
            {
                if(arr[i]+arr[j]>arr[k]&&arr[j]+arr[k]>arr[i]&&arr[i]+arr[k]>arr[j]&&arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[i]!=arr[k])
                    ans++;
            }
        }
    }
    cout<<ans;
}
int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

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

int knapsack(vector<int> &v,vector<int> &w,int W){
	int n=v.size();
	vector<vector<int> > val(W+1,vector<int>(n+1,0) );
	for(int i=0;i<n;i++){
		for(int j=1;j<=W;j++){
			if(j>=w[i]){
				val[j][i+1] = max(val[j][i],val[j-w[i]][i+1]+v[i]);
			}else{
				val[j][i+1] = val[j][i];
			}
		}
	}
	return val[W][n];
}

int main(){
	int n,d,x;
	cin>>n>>d>>x;
	vector<vector<int> > p(d,vector<int>(n,0) );
	for(int i=0;i<d;i++)
		for(int j=0;j<n;j++)
			cin>>p[i][j];
	for(int i=0;i<d-1;i++){
		vector<int> v(n);
		vector<int> w(n);
		for(int j=0;j<n;j++){
		       	v[j] = p[i+1][j]-p[i][j];
			w[j] = p[i][j];
		}
		 x = x + knapsack(v,w,x);

	}
	cout<<x<<endl;


	return 0;
}



Measured memory_bytes: 5092
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<iostream>
#define MAXN 15
#define LL long long
#define ULL unsigned LL
#define rg register
#define lowbit(x) (-(x) & (x))
#define ENDL putchar('\n')
#define DB double
//#pragma GCC optimize(2)
//#pragma G++ optimize(3) 
//#define int LL
using namespace std;
inline int read() {
	int f = 1,x = 0;char s = getchar();
	while(s < '0' || s > '9') {if(s == '-') f = -1;s = getchar();}
	while(s >= '0' && s <= '9') {x = x * 10 - '0' + s;s = getchar();}
	return x * f;
}
int n,m,i,j,s,o,k;
signed main() {
	char ss[MAXN];
	scanf("%s",ss + 1);
	if(ss[2] == 'B') ss[2] = 'R';
	else ss[2] = 'B';
	printf("%s\n",ss + 1);
	return 0;
}  

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>

int n = 0, a[100001], b[100000];
long long ans = 0;

int main() {

	std::cin >> n;

	for (int i = 0; i <= n; i++) {
		std::cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		std::cin >> b[i];
	}

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

		if (a[i] >= b[i]) {
			ans += b[i];
		}
		else if(a[i + 1] + a[i] > b[i]){
			ans += b[i];
			a[i + 1] = a[i + 1] + a[i] - b[i];
		}
		else {
			ans += a[i + 1] + a[i];
			a[i + 1] = 0;
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 1024