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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int ans = 0;
    if (K > A + B){
        int rest = K - A - B;
        ans = A - min(rest,C);
    }else{
        ans = min(A,K);
    }

    cout << ans << endl;
}

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

using namespace std;

string s;
long long MOD = 1e9+7;
long long power[100005][4];

int main(){
    cin >> s;
    int N = s.size();
    long long ans = 0;
    long long pre = 1;
    power[0][2] = power[0][3] = 1;
    for(int k = 2; k<=3; k++){
        for(int i = 1; i<=N; i++){
            power[i][k] = power[i-1][k]*k;
            power[i][k] %= MOD;
        }
    }
    for(int i = 0; i<N; i++){
        if(s[i] == '1'){
            ans += pre*power[N-i-1][3];
            ans %= MOD;
            pre *= 2;
            pre %= MOD;
        }
    }
    ans += pre;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 3584
from collections import deque

H, W = list(map(int, input().split()))
S = []
for i in range(H):
  S.append(input())

def bfs(x,y):
  d = deque()
  d.append([x,y,0])
  visited = [[False for i in range(W)] for j in range(H)]
  will_search = [[False for i in range(W)] for j in range(H)]
  maxd = -1
  while len(d) > 0:
    x,y,w = d.popleft()
    visited[x][y] = True
    next_point = []
    for dx,dy in [[1,0], [-1,0], [0,-1], [0,1]]:
      if 0 <= x + dx and x + dx < H and 0 <= y + dy and y + dy < W and S[x+dx][y+dy] == ".":
        next_point.append([x + dx, y + dy])
    for p, q in next_point:
      if visited[p][q]:
        continue
      if will_search[p][q]:
        continue
      d.append([p,q,w+1])
      will_search[p][q] = True
      maxd = max(maxd, w+1)

  return maxd

ans = -1
for X in range(H):
  for Y in range(W):
    if S[X][Y] == "#":
      continue
    ans = max(bfs(X,Y), ans)
    
print(ans)

Measured memory_bytes: 48748
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 998244353
#define floop(i,a,b) for (int i=(a);i<(b);i++)
#define rloop(i,a,b) for (int i=(a);i>=(b);i--)
#define floopeq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void solve()
{
   ll a;string b;ll ans,c=0;
    cin>>a>>b;
    for(int i=0;i<b.size();i++)
    {
        if(b[i]!='.')
            c = c*10 +( b[i]-'0');

        // cout<<c<<endl;
    }
    // cout<<c<<endl;
    // c = b-int(b);
    // b = (ll)b;
    ans=((a*c)/100);
    cout<<ans<<endl;
    // printf("%lld\n", (ll)(a*b));

}

int main() 
{ 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    
        solve();
        
    
    
    return 0; 
} 


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

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

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

// 第一引数 == 第二引数 ? true : false
template<class T, class U>
bool check(T first, U second) {
    return (first == second);
}

// 約数列挙
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


// 数字和
template<class T>
T digitSum(T num) {
    T dig;
    T sum = 0;
    while (num) {
        dig = num % 10;
        sum += dig;
        num /= 10;
    }
    return sum;
}

string background_black(string s) { return "\x1b[40m" + s; }
string background_red(string s) { return "\x1b[41m" + s + "\x1b[40m"; }
string background_green(string s) { return "\x1b[42m" + s + "\x1b[40m"; }
string background_yellow(string s) { return "\x1b[43m" + s + "\x1b[40m"; }
string background_bleu(string s) { return "\x1b[44m" + s + "\x1b[40m"; }
string background_white(string s) { return "\x1b[47m" + s + "\x1b[40m"; }

string black(string s) { return "\x1b[30m" + s + "\x1b[37m"; }
string red(string s) {return "\x1b[31m" + s + "\x1b[37m"; }
string green(string s) { return "\x1b[32m" + s + "\x1b[37m"; }
string yellow(string s) { return "\x1b[33m" + s + "\x1b[37m"; }
string blue(string s) { return "\x1b[34m" + s + "\x1b[37m"; }
string white(string s) { return "\x1b[37m" + s + "\x1b[37m"; }

const int ten = 10;
const int hundred = 100;
const int thousand = 1000;

typedef long long ll;
typedef unsigned long long ull;

string tolower(string s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) {
        c.push_back((s[i] + 0x20));
    } else {
        c.push_back(s[i]);
    }
  }
  return c;
}
#include <cstdlib>
string solve() {
  string str = "";
// int->string: to_string, string->int: stoi
//=============================================================================


  ull n;
  cin >> n;
  vector<ull> a(n);
  int o = 0, e = 0;
  for (int i = 0; i < a.size(); i++) {
    cin >> a[i];
    if (a[i] % 2 == 1) {
      e++;
    }
  }

  if (e % 2 == 0) {
    str += "YES";
  } else {
    str += "NO";
  }


//=============================================================================
  str += "\n";
  return str;
}

int main() {	
  std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
  cout << solve() << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int c[n], s[n], f[n];
    for(int i =1; i<n; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i =1; i<n; i++){
        int t = s[i] + c[i];
        for(int j = i+1; j<n; j++){
            int tmp = s[j];
            while(tmp < t){
                tmp += f[j];
            }
            t = tmp;
            t += c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  vector<char> c(3);
  int sz = s.size();
  if(sz==1) cout << "YES" << endl;
  else {
    rep(i, sz){
    if(s.at(i)=='a') c[0] += 1;
    else if(s.at(i)=='b') c[1] += 1;
    else c[2] += 1;
  }
  int x = c[0];
  int y = c[1];
  int z = c[2];
  int m1 = min(x, y);
  int m = min(m1, z);
  int x1 = x-m;
  int y1 = y-m;
  int z1 = z-m;
  if(x1==0){
    if(y1==1&&z1==1) cout << "YES" << endl;
    else if(y1==0&&z1==0) cout << "YES" << endl;
    else if(y1==0&&z1==1) cout << "YES" << endl;
    else if(z1==0&&y1==1) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  else if(y1==0){
    if(x1==1&&z1==1) cout << "YES" << endl;
    else if(x1==0&&z1==0) cout << "YES" << endl;
    else if(x1==0&&z1==1) cout << "YES" << endl;
    else if(z1==0&&x1==1) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  else{
    if(x1==1&&y1==1) cout << "YES" << endl;
    else if(x1==0&&y1==0) cout << "YES" << endl;
    else if(x1==0&&y1==1) cout << "YES" << endl;
    else if(y1==0&&x1==1) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  }
  //cout << "NO" << endl;
}

Measured memory_bytes: 512
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<string> cand(n);
rep(i,n)
cin >> cand[i];
ll ab = 0;
ll last_a = 0;
ll start_b = 0;
ll both_la_sb = 0;
rep(i,n){
    rep(j,cand[i].size() - 1){
        if(cand[i][j] == 'A' && cand[i][j + 1] == 'B')
            ab++;
    }
    if(cand[i][cand[i].size() - 1] == 'A' && cand[i][0] != 'B')
        last_a++;
    else if(cand[i][0] == 'B' && cand[i][cand[i].size() - 1] != 'A')
        start_b++;
    else if(cand[i][0] == 'B' && cand[i][cand[i].size() - 1] == 'A')
        both_la_sb++;

}
ll ans = ab;
if(start_b + last_a == 0)
    ans += max(0LL,both_la_sb - 1);
else{
    ans += both_la_sb + min(start_b, last_a);
}
cout << ans << endl;
}

Measured memory_bytes: 768
import sys


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


x, y = [int(_) for _ in input().split()]
n = 1500000
p = 10**9+7
l = []
for i in range(0, n*3//2+1, 3):
    l.append(i)

if x/2 <= y <= 2*x:
    for i in l:
        if y == i - x:
            t = i//3
            N = t
            for i in range( 2, N + 1 ):
                g1.append( ( g1[-1] * i ) % mod )
                inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
                g2.append( (g2[-1] * inverse[-1]) % mod )
            print(cmb(t,x-t,10**9+7))
            sys.exit()
print(0)

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

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

int main(){
    int A,B;
    cin >> A >> B;
    bool over=false;
    int i = 1;
    while (1)
    {
        if(int(i*0.08)==A&&int(i*0.10)==B){
            break;
        }
        if (int(i * 0.08 )> A || int(i * 0.10) > B)
            {
                over = true;
                break;
            }
        i++;
    }
    if(over)
        cout << "-1" << endl;
    else
        cout << i << endl;



}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto h = aryread();
    foreach (i; 0 .. (n - 1))
    {
        if (h[i] > h[i + 1])
        {
            h[i + 1] += 1;
        }
    }
    // writeln(h);
    foreach (i; 0 .. (n - 1))
    {
        if (h[i] <= h[i + 1])
        {
            continue;
        }
        else
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 7124
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
const ld eps = 1e-7;
#define eq(x,y) (fabs((x)-(y)) < eps)
typedef pair<int,int>pii;
const int mod = 998244353;
long double PI = acosl(-1);
const ll infl = 1e18+100;
const int inf = 2e9+100;
const int nmax = 2e5+2;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;



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

//    freopen("bajeces.txt", "r", stdin);
//    freopen("mara.txt", "w", stdout);
    int k,a,b;
    cin>>k>>a>>b;
    if(b/k > (a-1)/k) cout<<"OK";
    else cout<<"NG";
}
/*

*/


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

using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

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

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int N, M, Q;
vector<ll> v;
vector<ll> a, b, c, d;
ll ans = 0;

ll solve(vector<ll> &x) {
    ll res = 0;
    rep(i, Q) {
        if (x[b[i]] - x[a[i]] == c[i]) {
            res += d[i];
        }
    }
    return res;
}

void dfs(int pre = 0) {
    if ((int) v.size() == N) {
        chmax(ans, solve(v));
        return;
    }
    for (int i = pre; i < M; i++) {
        v.push_back(i);
        dfs(i);
        v.pop_back();
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    dfs();
    cout << ans << endl;
}

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

using namespace std;
#define ll long long

const int N = 1e5 + 5;
int dp[N][3];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int val[3];
        for (int j = 0; j < 3; j++)
            cin >> val[j];
        if (i == 0) {
            for (int j = 0; j < 3; j++)
                dp[i][j] = val[j];
        } else {
            for (int activity = 0; activity < 3; activity++) {
                //compute dp[i][act]
                for (int second = 0; second < 3; second++) {
                    if (activity == second)
                        continue;
                    dp[i][activity] = max(dp[i][activity], dp[i - 1][second]);
                }
                dp[i][activity] += val[activity];
            }
        }
    }
        int ans = 0;
    for(int activity = 0; activity < 3; activity++)
        ans = max(ans, dp[n - 1][activity]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
if __name__ =='__main__':
    s = input()
    ans = 0
    seq = 0
    for c in s:
        if c=='A' or c=='T' or c=='G' or c=='C':
            seq+=1
        else:
            ans = max(ans,seq)
            seq=0
    ans = max(ans,seq)
    print(ans)

Measured memory_bytes: 8992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t n = input();
    size_t c = 0;
    for (size_t i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0)
            c += i;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <locale>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

int main() {
    long k, n;
    cin >> k >> n;
    vector<long long> data(n);
    for(int i = 0; i < n; i++) {
        cin >> data[i];
    }
    vector<long long> dis(n);
    for(int i = 0; i < n; i++) {
        if(i == n-1){
            dis[i] = data[0] + k - data[i];
        } else {
            dis[i] = abs(data[i] - data[i+1]);
        }
    }

    long long maximum = *max_element(dis.begin(), dis.end());
    long long sum = accumulate(dis.begin(), dis.end(), 0LL);
    // cout << "sum" << sum << endl;
    // cout << "max" << maximum << endl;
    cout << sum - maximum  << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long a[n+1];
	for(long long i=1;i<=n;i++){
		cin>>a[i];
		a[i]=a[i]-i;
	}
	sort(a+1,a+n+1);
	long long b=a[(1+n)/2];
	long long s=0;
	for(long long i=1;i<=n;i++)
		s+=fabs(a[i]-b);
	cout<<s<<endl;
	return 0;
}

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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

int main(){
	setIO();
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll st = min(k, x/d);
	x -= st*d;
	k -= st;
	if (!k) cout << x << endl;
	else cout << (k&1?abs(x-d):x) << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    long long int A[N];
    long long int B[N];
    long long int ans = 0;
    
    for(int i = 0; i <= N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    
    for(int i = 0; i < N; i++){
        if(B[i] >= A[i]){
            B[i] -= A[i];
            if(B[i] >= A[i+1]){
                ans += A[i] + A[i+1];
                A[i+1] = 0;
            }else{
                ans += A[i] + B[i];
                A[i+1] -= B[i];
            }
        }else{
            ans += B[i];
            A[i] -= B[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a[300];
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(ll i=2;i<n;i++){
		if(a[i-2]<a[i-1]&&a[i-1]<a[i]){
			ans++;
		}
		else if(a[i-2]>a[i-1]&&a[i-1]>a[i]){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

  
int main(){
  int n;
  cin >> n ;
  vector<string> s(n);
  VI p(n);
  rep(i,n){
    cin >> s.at(i) >>p.at(i);
  }
  vector<pair<string , int>> pa(n);
    rep(i,n){
    pa.at(i)=make_pair(s.at(i),(-1)*p.at(i));
  }
 sort(pa.begin(),pa.end());
  rep(i,n){
    rep(j,n){
    if(p.at(j)*(-1)==pa.at(i).second){
      cout << j+1 << endl;
    }
    }
  }
  
   
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
	int h, w;
	cin >> h >> w;
	char arr[h][w];
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			cin >> arr[i][j];
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			if( arr[i][j] == '#' )
			{
				if( i+1 < h and arr[i+1][j] == '#' )
					continue;
				if( i-1 >= 0 and arr[i-1][j] == '#' )
					continue;
				if( j+1 < w and arr[i][j+1] == '#' )
					continue;
				if( j-1 >= 0 and arr[i][j-1] == '#' )
					continue;
				cout << "No";
				return 0;
			}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3616
h, w = map(int, input().split())

grid = [list(input()) for _ in range(h)]
mod = 10 ** 9 + 7

for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            grid[i][j] = 1
            continue

        if grid[i][j] == "#":
            grid[i][j] = 0
            continue

        if i == 0:
            grid[i][j] = grid[i][j-1]
            continue

        if j == 0:
            grid[i][j] = grid[i-1][j]
            continue

        grid[i][j] = grid[i-1][j] + grid[i][j-1]

print(grid[h-1][w-1] % mod)

Measured memory_bytes: 157428
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int k = 0;
  while(n-1>(1<<k)-1){
    k++;
  }
  
  int temp;
  REP(i,n){
    for(int j=i+1;j<n;j++){
      temp = i^j;
      for(int r = 0; r<k; r++){
        if(temp>>r & 1){
          cout<<r+1<<' ';
          break;
        }
      }
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int N,A,j=1;
	bool reset=false;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>A;
		if(A==j)j++;
		else reset=true;
		if(j==N)break;
	}
	j-=1;
	if(reset==false)cout<<0;
	else if(j==0)cout<<-1;
	else cout<<N-j;
	return 0;
}

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

def insertionSort(A, N):
    for i in range(1, N):
        temp = A[i]
        j = i - 1
        while j >= 0 and A[j] > temp:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = temp
        print(*A)
        
print(*A)
insertionSort(A, N)


Measured memory_bytes: 5976
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  set<char> s1;
  s1.insert('a');
  s1.insert('b');
  s1.insert('c');
  string s;
  cin>>s;
  rep(i,0,3){
    s1.erase(s[i]);
  }
  if(s1.size()==0){
    cout<<"Yes\n";
  }
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
 
using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
 
template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}
 
int read(){
	int i;
	scanf("%lld",&i);
	return i;
}
 
void printSpace(){
	printf(" ");
}
 
void printEoln(){
	printf("\n");
}
 
void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}
 
string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}
 
char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}
 
template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}
 
template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}
 
template<class T>
T Sq(const T& t){
	return t*t;
}
 
const int inf=LLONG_MAX/3;
 
signed main(){
	int n=read();
	map<int,int> freq;
	REP(i,n){
		int a=read();
		freq[a-1]++;
		freq[a]++;
		freq[a+1]++;
	}
	int ans=0;
	for(auto kv:freq)
		chmax(ans,kv.second);
	cout<<ans<<endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  string a,b;
  cin>>a>>b;
  int ab=0;
  rep(i,a.size()){
    if(a.at(i)!=b.at(i)){
      ab=1;
      break;
    }
   }
   if(ab==0){
     cout<<"Yes";
   }
       else{
       cout<<"No";
       }  
}
    

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

int main(){
	int n, money = 100000;

	cin >> n;

	for ( int i = 0; i < n; ++i ){
		money *= 1.05;
		if ( money % 1000 ){
			money = ( money / 1000 + 1 ) * 1000;
		}
	}

	cout << money << endl;

	return 0;
}

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

ll f(ll a, ll b) {
	ll r;
	if (b % a) {
		r = 2 * (b / a) * a + f(b % a, a);
	} else {
		r = (2 * (b / a) - 1) * a;
	}
	return r;
}

int main() {
	ll n, x;
	cin >> n >> x;
	cout << n + f(x, n - x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( i = c.begin(); i != c.end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
ll INF=1e18;
const int LIM=1e5+5,MOD=1e9+7;
ll min1(ll a,ll b)
{
    if(a<b)
        return a;
    else return b;
}
int main()
{
    fastio;
    

    int L;
    cin >> L;
    --L;
    int l = L, t = 0;
    for (; (1 << (t + 1)) - 1 <= l; ++t) {
    }
    const int N = t + 1;
    vector<ll > v1,v2,v3;
    forn(i, t) 
    {
        //ans.emplace_back(i + 1, i + 2, 0);
        v1.pb(i+1);
        v2.pb(i+2);
        v3.pb(0);
        v1.pb(i+1);
        v2.pb(i+2);
        v3.pb(1<<i);
        //ans.emplace_back(i + 1, i + 2, 1 << i);
    }
    l -= 1 << t;
    int base = 1 << t;
    while (l >= 0) 
    {
        for (t = 0; (1 << (t + 1)) - 1 <= l; ++t);
        //ans.emplace_back(t + 1, N, base);
        v1.pb(t+1);
        v2.pb(N);
        v3.pb(base);
        base += 1 << t;
        l -= 1 << t;
    }
    cout << N << ' ' << v1.size() << endl;
    forn(i,v1.size()) 
    {
        cout << v1[i] << ' ' << v2[i] << ' ' << v3[i] << endl;
    }
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(ReadLine());

            WriteLine(3 * Math.Pow(N, 2));
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int temp;
int main() {
    int a[10],v=0,j;
    for(int i=1;i<=5;i++) cin >> a[i];
    for(int i=1;i<=5;i++) {
        for(int j=i+1;j<=5;j++) {
            if(a[i]%10!=0 && a[j]%10==0) {swap(a[i],a[j]);}
            else if(a[i]%10!=0 && a[j]%10!=0) {
            if(((floor(a[i]/10)*10)-a[i]) > ((floor(a[j]/10)*10)-a[j])) {swap(a[i],a[j]);}
            }
        }
    }

    for(int i=1;i<=5;i++) {
            if(a[i]%10==0) {v+=a[i];}
            else {
                    if(i<5) {
            v += ((floor(a[i]/10)+1)*10);
                    }
                    else v+=a[i];
            }
    }
    cout << v << endl;

}


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

namespace Atcoder
{

    class Program
    {
        static void Main(string[] args)
        {
            int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(abc[0]*abc[1]/2);

        }

    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

// 素因数分解
vector<LLI> prime_factorize(LLI n){
  vector<LLI> res;
  for(LLI i=2; i*i<=n; ++i){
    if(n%i == 0){
      res.push_back(i);
      n/=i;
      --i;
    }
  }
  if(n!=1) res.push_back(n);
  return res;
}

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

  LLI n,p; cin >> n >> p;

  vector<LLI> primes = prime_factorize(p);

  map<LLI,LLI> m;

  //  join(cerr, ALL(primes));
  
  for(auto a : primes){
    m[a]++;
  }

  LLI ans = 1;

  for(auto &kv : m){
    if(kv.second >= n){
      ans *= powl(kv.first, kv.second/n);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>

using namespace std;

int main() {
  int steps, uac;
  cin >> steps >> uac;
  
  vector<int> patterns(steps + 1);
  patterns[0] = 1;
  for (int i = 0; i < uac; ++i) {
    int sn;
    cin >> sn;
    patterns[sn] = -1;
  }
  
  for (int i = 1; i <= steps; ++i) {
    if (patterns[i] == -1) {
      patterns[i] = 0;
      continue;
    }
  	patterns[i] += i - 1 >= 0 ? patterns[i - 1] % 1000000007 : 0;
    patterns[i] += i - 2 >= 0 ? patterns[i - 2] % 1000000007 : 0;
    patterns[i] %= 1000000007;
  }
  
  cout << patterns[steps] << endl;
  return 0;
}

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

using namespace std;

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

    int n, a = 0, un = 0;
    bool is_ans = true;
    string s;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        if (s == "A") {
            ++a;
        }
        else {
            ++un;
            if (a < un)
                is_ans = false;
        }
    }

    if (is_ans && a == un)
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;
using Int=mp::cpp_int;
const Int MOD=int(1e9)+7;
const int DELAY=1e5;

int main(){
    Int m,n;    
    std::cin>>m>>n;
    Int res=mp::powm(m,n,MOD);
    std::cout<<res<<std::endl;
    return 0;
}


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

using namespace std;

int n, k;
int a[5010], p[5010];
int vis[5010];
long long sum;
vector<long long> pre;

int main()
{
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &p[i]);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);

    long long ans = -1e18;
    
    for(int i = 1; i <= n; ++i)
    {
        memset(vis, 0, sizeof(vis));
        pre.clear();
        int st = i;

        sum = 0;
        while(!vis[st])
        {
            vis[st] = 1;
            pre.push_back(sum += a[st]);
            st = p[st];
        }

        int len = pre.size();
        int t = k/len, m = k%len;
        for(int i = 2; i < len; ++i)
            pre[i] = max(pre[i], pre[i-1]);

        if(t >= 1)
        {
            ans = max(ans, pre[len-1]-pre[0]);
            ans = max(ans, pre[m]-pre[0]+t*sum);
            ans = max(ans, pre[len-1]-pre[0]+(t-1)*sum);
        }else{
            ans = max(ans, pre[m]-pre[0]);
        }

    }
    printf("%lld\n", ans);

}

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

int D;
string ans[4] = {"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> D;
    cout << ans[D-22] << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  ll N; cin >> N;

  map<string, ll> freq;

  while (N--) {
    char S[10]; scanf("%s", S);

    string key = string(S);
    auto result = freq.emplace(key, 1);

    if (!result.second) result.first->second++;
  }

  vector<pair<string, ll>> pairs(freq.size());

  pairs.assign(freq.begin(), freq.end());
  std::sort(pairs.begin(), pairs.end(), [](auto & x, auto & y) {
    if (x.second != y.second) return x.second > y.second;
    return x.first < y.first;
  });

  ll max_freq = -1;

  for (auto p : pairs) {
    if (max_freq == -1) max_freq = p.second;
    else if (max_freq != p.second) break;

    printf("%s\n", p.first.c_str());
  }
}


Measured memory_bytes: 27008
#include <iostream>
#include <cmath>
using namespace std;

int N,h;

int main(){
	cin >> N;
	int sum = 0,pre = 0;
	for(int i=0;i<N;i++){
		cin >> h;
		sum += abs(h-pre);
		pre = h;
	}
	sum += pre;
	cout << sum/2 << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
int p[100][100];
int main(){
memset(p,-1,sizeof(p));
int i,j,n,m,w,h;
string s;
cin>>h>>w;
for(i=0;i<h;i++){
	cin>>s;
	for(j=0;j<w;j++){
		if(s[j]=='c')p[i][j]=0;
		if(p[i][j-1]!=-1&&p[i][j]==-1&&j!=0)p[i][j]=p[i][j-1]+1;
	}
}
for(i=0;i<h;i++){
	for(j=0;j<w;j++){
		cout<<p[i][j];
		if(j!=w-1)cout<<' ';
	}
cout<<endl;
}
return 0;
}

Measured memory_bytes: 3204
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5010];
bool f[5010][5010], g[5010][5010];
int main()
{
    int n, k;
    int i, j, p1, p2;
    scanf("%d%d", &n, &k);
    int ans = 0;
    int num = 0;
    for(i = 1; i <= n; ++i)
    {
        scanf("%d", &a[++num]);
        if(a[i] >= k)
        {
            ans++;
            --num;
        }
    }
    f[0][0] = 1;
    for(i = 1; i <= num; ++i)
    {
        for(j = 0; j <= k - a[i]; ++j)
        {
            if(f[i - 1][j])
                f[i][j + a[i]] = 1;
        }
        for(j = 0; j <= k; ++j)
        {
            if(f[i - 1][j])
                f[i][j] = 1;
        }
    }
    for(i = 0; i <=  num + 1; ++i) g[i][0] = 1;
    for(i = num; i >= 1; --i)
    {
        for(j = 0 ; j <= k - a[i]; ++j)
        {
            if(g[i + 1][j])
                g[i][j + a[i]] = 1;
        }
        for(j = 0; j <= k; ++j)
        {
            if(g[i + 1][j])
                g[i][j] = 1;
        }
    }

    for(i = 1; i <= num; ++i)
    {
        p2 = k - 1;
        int ok = 0;
        for(j = 0; j <= k-1; ++j)
        {
            if(!f[i-1][j]) continue;
            p2 = k - j - 1;
            while(p2 >= 0 && p2 >= k - a[i] - j)
            {
                if(g[i+1][p2])
                {
                    ok = 1;
                    goto c;
                }
                --p2;
            }
        }
        c:;
        if(ok) ++ans;
    }

    printf("%d\n", n - ans);
    return 0;
}


Measured memory_bytes: 49280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = (n - 1); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 100000007;

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  mint total = 0;
  rep(i, n) {
    cin >> a[i];
    total += a[i];
  }
  mint ans = 0;
  rep(i, n - 1) {
    total -= a[i];
    ans += total * a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4800
N, K, S = map(int, input().split())

INF1 = 10 ** 9
if S == 10 ** 9:
    INF1 -= 1

for i in range(N):
    if K > i:
        print(S, end="")
    else:
        print(INF1, end="")

    if i != N - 1:
        print(" ", end="")

print()

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  ll n, m;
  cin >> n >> m;

  ll ans  = 0;
  if(m <= 2*n){
    ans = m/2;
  }
  else{
    ans += n;
    m -= 2*n;
    ans += m/4;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	
	int ans=0;
	if(a>b){
		ans+=a;
		a--;
	}else{
		ans+=b;
		b--;
	}
	
	ans+=max(a,b);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define MOD 1000000007

typedef long long ll;
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<ll> v(n);
	int two=0;
	int four=0;
	int other=n;
	REP(i,n){
		cin >> v[i];
		if(v[i]%4==0){
			other--;
			four++;
		}
		else if(v[i]%2==0){
			other--;
			two++;
		}
	}
	bool state=true;
	if(other-four>1){
		state=false;
	}
	if(two>0&&other>four){
		state=false;
	}
	if(state){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

int main(void)
{
    char c[100], d[100];
    int w;
    int n, move, i, k, l;
    int a[51][2];
    int result[51];

    scanf("%d%d", &w, &n);
    for (k = 1; k <= n; k++){
        // scanf("%s", c);
        // i = 0;
        // l = 0;
        // while (c[i] != ','){
        //     d[l] = c[i];
        //     i++;
        //     l++;
        // }
        // i++;
        // d[i] = '\0';
        // a[k][0] = atoi(d);
        // l = 0;
        // while (c[i] != '\0'){
        //     d[l] = c[i];
        //     i++;
        //     l++;
        // }
        // i++;
        // d[i] = '\0';
        // a[k][1] = atoi(d);
        scanf("%d,%d", &a[k][0], &a[k][1]);        
    }

    // for (k = 1; k <= n; k++){
    //     printf("%d  %d\n", a[k][0], a[k][1]);        
    // }
    for (i = 1; i <= w; i++){
        move = i;
        for (k = 1; k <= n; k++){
            if (move == a[k][0]) move = a[k][1];
            else if (move == a[k][1]) move = a[k][0];
        }
        result[move] = i;
    }

    for (k = 1; k <= w; k++){
        printf("%d\n", result[k]);        
    }
    return (0);
}



Measured memory_bytes: 2028
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;



/*
int bs(int l,int r)
{
    int mid,res=inf;

    while(l<=r)
    {
        mid=l+(r-l)/2;

    }

    return res;
}*/

//--------------------------code starts here---------------------------------------


int main()
{
   LL n;
   sl(n);
   LL res=0;


   while(res<n)
   {
       res+=1000;
   }

   printf("%lld",res-n);

   return 0;

}



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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	string left = s.substr(0, (n-1)/2);
	string right = s.substr((n+3) / 2 - 1);
	string ss = s;
	string l = left;
	string r = right;
	reverse(ss.begin(), ss.end());
	reverse(l.begin(), l.end());
	reverse(r.begin(), r.end());
	if(ss == s and l == left and r == right) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256