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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

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

int main()
{
  rep(i, in()){
    int field[128][128] = {};
    int n = in();
    if (i != 0) puts("");
    rep(i, n + 1){
      field[0][i] = 1;
      field[n + 1][i] = 1;
      field[i][0] = 1;
      field[i][n + 1] = 1;
    }

    int x, y, d;
    x = 1;
    y = n;
    d = 0;
    while (1){
      field[y][x] = 2;
      int ny, nx;
      nx = x + dx[d];
      ny = y + dy[d];
      if (field[ny][nx] > 0){
        d = (d + 1) % 4;
        nx = x + dx[d];
        ny = y + dy[d];
        if (field[ny][nx] > 0){
          break;
        }
      }
      rep(i, 4){
        int nnx, nny;
        nnx = x + dx[i];
        nny = y + dy[i];
        if (nnx == nx && nny == ny) continue;
        if (field[nny][nnx] != 0) continue;
        field[nny][nnx] = 1;
      }
      x = nx;
      y = ny;
    }
    lep(i, n){
      lep(j, n){
        printf("%c", " #"[field[i][j] == 2]);
      }
      puts("");
    }
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int X, t;
    cin >> X >> t;
    int remain = X - t;
    if(remain < 0) { remain = 0; }
    printf("%lld\n", remain);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> s;
  int r_l = 0;
  REP(i, n) {
    if(s[i] == 'R') r_l++;
  }

  int ans = 0;
  REP(i, r_l) {
    if(s[i] == 'W') ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  vector<P> V;
  int l = 0;
  int r = 0;
  REP(i, N) {
    cin >> A[i];
  }
  vector<int> B;

  B.push_back(A[N - 1]);

  for(int i = N - 2; i >= 0; i--){
    if (A[i] >= *(B.end() - 1)) B.push_back(A[i]);
    else{
      *upper_bound(B.begin(), B.end(), A[i]) = A[i];
    }
    //for(auto tmp : B) cout << tmp;
    //cout << endl;
  }

  cout << B.size() << endl;




  return 0;
}


Measured memory_bytes: 1276
(defun mul (a b)
  (let* ((dim (list (array-dimension a 0)
                    (array-dimension b 1)))
         (result (make-array dim :initial-element 0)))
    (loop for i below (array-dimension a 0)
          do (loop for j below (array-dimension b 1)
                   do (let ((acc 0))
                        (loop for k below (array-dimension a 1)
                              do (incf acc (* (aref a i k) (aref b k j))))
                        (setf (aref result i j) acc))))
    result))

(defparameter *S* #2a((-1 -1  1)
                      ( 0  1  1)
                      ( 1  0  1)))

(defparameter *J* #(-1 -1 2))

;; (defparameter *J2* #2a((-1  0  0)
;;                        ( 0 -1  0)
;;                        ( 0  0  2)))

(defparameter *S^-1* #2a((-1/3 -1/3  2/3)
                         (-1/3  2/3 -1/3)
                         ( 1/3  1/3  1/3)))

(defun make-diag (x y z)
  (let ((result (make-array '(3 3) :initial-element 0)))
    (setf (aref result 0 0) x
          (aref result 1 1) y
          (aref result 2 2) z)
    result))

(defun solve (a b c k)
  (let* ((diag (make-diag (expt -1 k)
                          (expt -1 k)
                          (expt  0 k)))
         (x (make-array '(3 1) :initial-contents `((,a) (,b) (,c))))
         (m (mul *S* (mul diag (mul *S^-1* x))))
         (a (- (aref m 0 0) (aref m 1 0))))
    (if (> a 1e18)
        "Unfair"
        a)))

(let ((a (read))
      (b (read))
      (c (read))
      (k (read)))
  (princ (solve a b c k))
  (terpri))


Measured memory_bytes: 19044
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;
void input(){
    fast_io();
    cin >> S;
}

#define NO do{cout << -1 << endl; return 0;}while(false);

int solve(){
    int N = S.length();
    if(S[0]!='1' || S[N-1]!='0') NO
    for (int i = 0; i < N-1; i++) if(S[i]!=S[N-2-i]) NO
    int lastone = 0;
    for (int i = 1; i < N; i++)
    {
        cout << lastone+1 << " " << i+1 << "\n";
        if(S[i-1]=='1') lastone = i;
    }
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3792
n, k = map(int, input().split())
mod = 10 ** 9 + 7


def cmb_r(n, r):
    n += r - 1
    return cmb(n, r)


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


def make_table2(n, mod=10 ** 9 + 7):
    # 元テーブル
    g1 = [0] * (n + 1)
    g1[0] = 1
    g1[1] = 1
    tmp = 1

    for i in range(2, n + 1):
        tmp = tmp * i % mod
        g1[i] = tmp

    # 逆元テーブル
    g2 = [0] * (n + 1)
    g2[-1] = pow(g1[-1], mod - 2, mod)
    tmp = g2[-1]

    for i in range(n - 1, -1, -1):
        tmp = tmp * (i + 1) % mod
        g2[i] = tmp

    return g1, g2


g1, g2 = make_table2(2 * 10 ** 5 + 2)
answer = 0
for i in range(min(n, k) + 1):
    answer += cmb(n, i) * cmb_r(n - i, i) % mod
    answer %= mod

print(answer)

Measured memory_bytes: 18804
n = gets.to_i
height_array = gets.split(" ").map(&:to_i)

cntStand = 0

(1...n).each do |i|
  if height_array[i-1] > height_array[i]
    cntStand += height_array[i-1] - height_array[i]
    height_array[i] = height_array[i-1]
  end
end

puts cntStand

Measured memory_bytes: 28108
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> A(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
    }
    vector<int64_t> sum(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + A[i];
    }

    vector<int64_t> dpl(n + 1, 0), dpr(n + 1, 0), dp(n + 1, 0);
    deque<int> d;
    for (int i = 1; i <= n; ++i) {
        while (!d.empty() && d.front() <= i - k) {
            d.pop_front();
        }
        dpl[i] = dpl[i - 1];
        dpr[i] = dpr[i - 1];
        if (i - k >= 0) {
            dpl[i] = max(dpl[i], sum[i] - sum[i - k] + dp[i - k]);
            dpr[i] = max(dpr[i], sum[i] - sum[i - k] + dp[i - k]);
            dpl[i] = max(dpl[i], dp[i - k]);
            dpr[i] = max(dpr[i], dp[i - k]);
        }
        if (!d.empty()) {
            dpl[i] = max(dpl[i], sum[i] + dpl[d.back()] - sum[d.back()]);
        }
        dpr[i] = max(dpr[i], dpr[i - 1] + A[i]);
        dp[i] = max({dp[i - 1], dpl[i], dpr[i]});

        if (i - k >= 0) {
            while (!d.empty() && dpl[i] - sum[i] >= dpl[d.back()] - sum[d.back()]) {
                d.pop_back();
            }
            d.push_back(i);
        }
    }
    int64_t ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, dpl[i]);
    }
    for (int i = 1; i + k <= n; ++i) {
        ans = max(ans, dpr[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <regex>

using namespace std;

int main(){
    string temp, s, p;
    cin >> temp;
    s = temp + temp;
    cin >> p;
  
    regex re(p); 
    smatch match;
  
    if(regex_search(s, match, re)){
      cout << "Yes";
    }else{
      cout << "No";
    }
      cout << endl;
  
  return 0;
}




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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n), b(n), c(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    sort(all(a));
    a.push_back(INF);
    sort(all(b));
    sort(all(c));
    c.push_back(INF);
    Int res = 0;
    rep(i, 0, n) {
        Int x = lower_bound(all(a), b[i]) - a.begin();
        Int y = upper_bound(all(c), b[i]) - c.begin();
        //cout << x << " "  << y << endl;
        res += x * (n - y);
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 5e5 + 5;
int n;

int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	string ans = "";
	cin >> n;
	while(n)
	{	
		int ch = n % 26 - 1;
		if(ch < 0)	ch = 25;
		n--;
		ans += (char)('a' + ch);
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
    	return 0;
}

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

int main() {
  long N;
  cin>>N;
  vector<long> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  vector<long> b(N);
  for(int i=0;i<N;i++) cin>>b[i];
  long asum=0,bsum=0;
  for(int i=0;i<N;i++){
    asum+=a[i];
    bsum+=b[i];
  }
  if(bsum>asum){
    cout<<-1<<endl;
    return 0;
  }
  long ans=0;
  long res=0;
  vector<long> r(N);
  for(int i=0;i<N;i++) r[i]=a[i]-b[i];
  for(int i=0;i<N;i++){
    if(r[i]<0){
      ans++;
      res -= r[i];
      r[i]=0;
    }
  }

  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());
  int idx=0;
  while(res>=1){
    ans++;
    res-= r[idx];
    idx++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int n;
vector<vector<bool>> arr;
vector<int>data;
int dp(int ind,int W){
      int cnt=0;
      if(ind==n)return 1;
      for(int j=0;j<n;j++){
            if((W&(1<<j))||arr[ind][j]==false)continue;
            if(data[W|(1<<j)]==-1)data[W|(1<<j)]=dp(ind+1,W|(1<<j));
            cnt=(cnt+data[W|(1<<j)])%modulo;
      }
      return cnt;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      cin>>n;
      arr.resize(n,vector<bool>(n,false));
      for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                  int x;
                  cin>>x;
                  arr[i][j]=x;
            }
      }
      data.resize(1<<n,-1);
      cout<<dp(0,0);
}


Measured memory_bytes: 16640
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int N,sum=0,i,f;
  int a[3001];
  cin >> N;
  REP(i,N)cin >> a[i];
  REP(i,N){
    sum += a[i] - 1;

  }
  cout << sum << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    
    ll ans = 0;
    rep(i, n) {
        ans += a[i]/2;
        if (a[i]%2==1 && a[i+1]>0 && i < n-1) {
            ans++;
            a[i+1]--;
        }
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 18;
const int INF = 1e18 + 239;

pair<int, int> conq(pair<int, int> a, pair<int, int> b) {
	if (a.first < b.first) swap(a, b);
	return make_pair(a.first, max(a.second, b.first));
}

int a[1 << N];
pair<int, int> mn[1 << N];

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

	int n;
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		cin >> a[i];
		mn[i] = {a[i], -INF};
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1 << n); j++) {
			if ((j >> i) & 1) {
				mn[j] = conq(mn[j], mn[j ^ (1 << i)]);
			}
		}
	}
	int c = 0;
	for (int i = 0; i < (1 << n); i++) {
		c = max(c, mn[i].first + mn[i].second);
		if (i > 0) cout << c << '\n';
	}
}


Measured memory_bytes: 9216
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
int A,B,C,K,max;
cin>>A>>B>>C>>K;
if(A>=B&&A>=C) max=A;
else if(B>=C&&B>=A) max=B;
else max=C;
int v=max;
for(int i=0;i<K;i++){
    max=max*2;}
    cout<<A+B+C-v+max;
    return 0;
}


Measured memory_bytes: 256
"""
if a monster is not attacked, it doesn't do anything, so we can
deal with each living monster as a separate problem that takes
a certain number of moves to kill it and all of its offspring.
when x is not 1,
num(x) = 2*num(floor(x/2))+1
(because it took one move to kill it, and there will be two offspring)
and when x is 2 or 3,
num(x) = 3
so we can do some recursion, or memoization, or tabulation
"""

from math import floor


def get_num_attacks(H):
  if H>3:
    return 2*get_num_attacks(floor(H/2))+1
  if H==2 or H==3:
    return 3
  if H==1:
    return 1


if __name__ == "__main__":
  H = int(input())
  print(get_num_attacks(H))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main(void) {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll t = 0;
  while (b <= a) {
    b *= 2;
    t++;
  }
  while (c <= b) {
    c *= 2;
    t++;
  }
  cout << (t <= k ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3572
from collections import *
h,w,K = map(int,input().split())
a = []
for i in range(h):
	a.append(list(input()))
ans = 0
for i in range(1 << h):
	for j in range(1 << w):
		c = [[a[J][I] for I in range(w)] for J in range(h)]
		for k in range(h):
			if(i&(1 << k)):
				for kk in range(w):
					c[k][kk] = 'R'
		for k in range(w):
			if(j&(1 << k)):
				for kk in range(h):
					c[kk][k] = 'R'
		ct = 0
		for k in range(h):
			ct += c[k].count('#')
		if(ct == K):
			ans += 1
print(ans)

Measured memory_bytes: 69380
#include <stdio.h>

int main()
{
	int n;
	long int max = -1000001, min = 1000001,sum=0;
	int i,a;

	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &a);
		if(max<a)max=a;
		if(min>a)min=a;
		sum+=a;
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#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 _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////

int main() {
    ll h, w, n; cin >> h >> w >> n;
    map<pair<ll, ll>, ll> ma;
    rep(i, 0, n){
        ll a, b; cin >> a >> b;
        if(a-1 >= 2 && b-1 >= 2) ma[{a-1, b-1}]++;
        if(a-1 >= 2) ma[{a-1, b}]++;
        if(a-1 >= 2 && b+1 < w) ma[{a-1, b+1}]++;
        if(b >= 2) ma[{a, b-1}]++;
        ma[{a, b}]++;
        if(b+1 < w) ma[{a, b+1}]++;
        if(a+1 < h && b-1 >= 2) ma[{a+1, b-1}]++;
        if(a+1 < h) ma[{a+1, b}]++;
        if(a+1 < h && b+1 < w) ma[{a+1, b+1}]++;
    }
    Vl ans(10, 0);
    ll mi = 0;
    for(auto m : ma){
        ll c, d; c = m.first.first, d = m.first.second;
        if(c == 1 || c == h) continue;
        if(d == 1 || d == w) continue;
        mi++;
        ans[m.second]++;
    }
    //9マスすべて白 (h-2)(w-2) - 黒が現れる個数
    ans[0] = (h-2)*(w-2)-mi;
    rep(i, 0, 10) co(ans[i]);

    return 0;
}


Measured memory_bytes: 56448
import scala.io.StdIn._

object Main  {
  def main(args: Array[String]): Unit = {
    val K = readToInts()(1)
    val dice = readToVectorInts()
    println(solve(K, dice))
  }

  def solve(K: Int, dice: Vector[Int]): Double = {
    val diceAvg = dice.map(Dice.avg)

    val initial = Iterator.iterate(0)(n => n + 1)
      .takeWhile(n => n < K)
      .map(n => diceAvg(n))
      .toList
      .foldLeft(0d)((total, next) => total + next)

    Iterator.iterate(Dice(0, initial))(d => d.getNewDice(diceAvg, K))
      .takeWhile(d => d.index <= dice.length - K)
      .maxBy(dice => dice.total)
      .total
  }

  def readToInts(): Array[Int] = readLine.split(" ").map(_.toInt)
  def readToListInts(): List[Int] = readLine.split(" ").map(_.toInt).toList
  def readToVectorInts(): Vector[Int] = readLine.split(" ").map(_.toInt).toVector

}

case class Dice(index: Int, total: Double) {

  def getNewDice(vec: Vector[Double], K: Int): Dice = {
    if (index + K >= vec.length) {
      Dice(index + 1, 0.0)
    } else {
      Dice(index + 1, total + vec(index + K) - vec(index))
    }
  }

  override def toString: String = s"$index - $total"
}

object Dice {
  def avg(v: Int): Double = (v + 1.0) / 2.0
}

Measured memory_bytes: 83372
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	ll a1,a2,a3,m1,m2,m3;
	while(1)
	{
		cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
		if(a1==0&&m1==0&&a2==0&&m2==0&&a3==0&&m3==0)break;
		ll c1=1,c2=1,c3=1;
		//cin >> c1 >> c2 >> c3;
		ll res=a1%m1;
		//bool flag=true;
		while(res!=1)
		{
			c1++;
			res=(res*a1)%m1;
		}
		res=a2%m2;
		while(res!=1)
		{
			c2++;
			res=(res*a2)%m2;
		}
		res=a3%m3;
		while(res!=1)
		{
			c3++;
			res=(res*a3)%m3;
		}
		ll gcd_all=__gcd(c1,__gcd(c2,c3));
		c1/=gcd_all;c2/=gcd_all;c3/=gcd_all;
		ll gcd1=__gcd(c1,c2);
		c1/=gcd1;c2/=gcd1;
		ll gcd2=__gcd(c2,c3);
		c2/=gcd2;c3/=gcd2;
		ll gcd3=__gcd(c1,c3);
		c1/=gcd3;c3/=gcd3;
		cout << gcd_all*gcd1*gcd2*gcd3*c1*c2*c3 << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int maxi(int x,int y){
  if(y==0 || x==y) return x;
  else if(x==1 || y==1) return 1;
  else if(x>y) return maxi(y,x%y);
  else return maxi(x,y%x);
}

int powx(int x){
  return x*x;
}

int main(){
  int w,h,c;
  cin >> w >> h >> c;

  cout << (w*h/powx(maxi(w,h)))*c << endl;
    
  return 0;
}



Measured memory_bytes: 3104
S = int(input())
mod = 10**9+7
def comb_mod(n,r,mod):
  ans = 1
  for i in range(r):
    ans *= (n-i)*pow(i+1,mod-2,mod)
    ans %= mod
  return ans
ans = 0
for k in range(1,S+1):
  if S-2*k-1<0:
    continue
  ans += comb_mod(S-2*k-1,k-1,mod)
  ans %= mod
print(ans)

Measured memory_bytes: 67620
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = (0 until n).map { readLine()!! }

    var ans = 0
    var c1 = 0 // B..A
    var c2 = 0 // ..A
    var c3 = 0 // B..

    for (i in s.indices) {

        for (j in 1 until s[i].length) {
            if (s[i][j - 1] == 'A' && s[i][j] == 'B') ans++
        }

        when {
            s[i].first() == 'B' && s[i].last() == 'A' -> c1++
            s[i].last() == 'A' -> c2++
            s[i].first() == 'B' -> c3++
        }
    }

    when {
        c1 == 0 -> ans += Math.min(c2, c3)
        c2 + c3 > 0 -> ans += c1 + Math.min(c2, c3)
        c2 + c3 == 0 -> ans += c1 - 1
    }

    println(ans)
}


Measured memory_bytes: 34828
n = int(input())
d = {}
for i in range(n):
  s,p = input().split()
  if d.get(s,-1)==-1:
    d[s] = {int(p):i+1}
  else:
    d[s][int(p)] = i+1
d = sorted(d.items(), key=lambda x:x[0])
for k in d:
  l = sorted(k[1].items(), key=lambda x:x[0])[::-1]
  for t in l:
    print(t[1])

Measured memory_bytes: 9172
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  int ans = 1;
  int now = n;
  while(1) {
    if(now == 0) break;
    now += n;
    ans++;
    now %= 360;
  }
  cout << ans << endl;

  return 0;
}


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

char data[8+3*2][8+3*2];

void recurse(int x,int y){
	data[x][y] = '0';
	
	for(int i=1;i<=3;i++){
		if(data[x+i][y] == '1')recurse(x+i,y);
		if(data[x-i][y] == '1')recurse(x-i,y);
		if(data[x][y+i] == '1')recurse(x,y+i);
		if(data[x][y-i] == '1')recurse(x,y-i);
	}
}

int main(){
	int sx,sy;
	int n;
	cin >> n;
	for(int k=0;k<n;k++){
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cin >> data[3+j][3+i];
			}
		}
		cin >> sx >> sy;
		sx--;sy--;
	
		recurse(3+sx,3+sy);
	
		printf("Data %d:\n",k+1);
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				cout << data[3+j][3+i];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
def partition(A, p, r):
    x = A[r]
    i = p-1
    for k in range(p, r):
        if A[k] <= x:
            i += 1
            A[i], A[k] = A[k], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

n = int(input())
a = list(map(int, input().split()))
std = partition(a, 0, n-1)
for idx, i in enumerate(a):
    if idx == std:
        print("[{0:}]".format(i), end = "")
    else:
        print(i, end = "")
    if idx != n-1:
        print(" ", end = "")
print("")


Measured memory_bytes: 16384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String n = sc.nextLine();
	    String[] list = n.split("");
	    int sum = 0;
	    for (int i = 0; i < list.length; i++) {
	    	sum += Integer.parseInt(list[i]);
	    }
	    if (sum % 9 == 0 ) {
	    	System.out.println("Yes");
	    } else {
	    	System.out.println("No");
	    }
	}
}

Measured memory_bytes: 65800
#include <iostream>
#include <iomanip>

using namespace std;

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

int main() {
  int n, k;
  cin >> n >> k;
  int p[n];
  rep(i,n) cin >> p[i];
  
  int a[n];
  rep(i,n) a[i] = p[i] + 1;
  
  int s[n+1];
  s[0] = 0;
  rep(i,k) s[i+1] = s[i] + a[i];
  rep(i,n-k) s[i+k+1] = s[i+k] + a[i+k] - a[i];
  
  int m = 0;
  rep(i,n+1) if(s[i] > m) m = s[i];
  
  cout << fixed << setprecision(1) << (double)m / 2 << endl;
  return 0;
}

Measured memory_bytes: 6084
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        lp = j+1
        rp = n-1
        while lp <= rp:
            mp = (lp+rp)//2
            if l[mp] < l[i] + l[j]:
                lp = mp+1
            else:
                rp = mp-1
        ans += lp-j-1
print(ans)

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

typedef long long ll;

int main() {
	int n, x, t;
	cin >> n >> x >> t;

	int m = n / x;
	if (m * x < n) ++m;
	cout << m * t << endl;

	return 0;
}


Measured memory_bytes: 3108
def main() :

    N = int(input())
    N_list = [int(i) for i in input().split()]
    res = 1

    if (N_list.count(0) > 0) :
        print(0)
        return

    for i in range(len(N_list)) :
        res = res * N_list[i]
        if (res > 1000000000000000000) :
            print(-1)
            return
    
    print(res)

main()

Measured memory_bytes: 21656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m, x, y;
  bool iswar=true;
  cin >> n >> m >> x >> y;
  vector<int> xn(n);
  for (int i = 0; i < n; i++) cin >> xn.at(i);
  vector<int> ym(m);
  for (int i = 0; i < m; i++) cin >> ym.at(i);

  for (int z = x+1; z <= y; z++) {
    if (iswar) {
      iswar = false;
      for (int i = 0; i < n; i++) {
        if (xn.at(i) >= z) {
          iswar = true;
          break;
        }
      }
      for (int i = 0; i < m; i++) {
         if (ym.at(i) < z) {
           iswar = true;
           break;
        }
      }
    }
    else {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll=long long;
using namespace std;
int main(){
    int x,a;
    cin >> x >> a;
    if(x<a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    ll n, k;
    cin >> n >> k;
    Combination com(500000);
    if(k >= n - 1){
        cout << com.com(n + n - 1, n) << endl;
    }
    else if(k == 1){
        cout << n * (n - 1) % MOD << endl;
    }
    else{
        ll ans = 0;
        for(ll i = 0; i <= k; i++){
            ans = (ans + com.com(n, i) * com.com(n - i - 1 + i, i)) % MOD;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 21376
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

class BIT():
    def __init__(self, n, data=None):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sub_sum(self, idx):
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s

    def sum(self, i, j):
        a = 0
        if j != 0:
            a += self.sub_sum(j)
        if i != 0:
            a -= self.sub_sum(i)
        return a

n,q=nii()
a=lnii()
bit=BIT(n,a)
for i in range(q):
    t,x,y=nii()
    if t==0:
        bit.add(x+1,y)
    else:
        print(bit.sum(x,y))

Measured memory_bytes: 65220
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b+c||b==a+c||c==a+b) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
tmp = "R"
index = [0]
ans = [0 ] * len(S)
for i, s in enumerate(S):
    if tmp != s:
        index.append(i)
        if tmp == "R":
            tmp = "L"
        else:
            tmp = "R"
index.append(len(S))

for i in range(len(index)-1):
    left = index[i]
    right = index[i+1]
    tmp = S[left:right]
    same_num = right - left
    if tmp[0] == "R":
        # rinsetu L
        ans[right] += same_num // 2
        # rinsetu R
        ans[right-1] += ceil(same_num / 2)

    else:#L renzoku
        # L
        ans[left] += ceil(same_num / 2)
        # R
        ans[left-1] += same_num // 2
print(*ans)


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

long long n, m, w, v, dp[101][100001], ans; 

int main() {
	cin>>n>>m;
	for (int i=1; i<=n; i++) {
		cin>>w>>v;
		for (int j=1; j<=m; j++) {
			dp[i][j] = max(
				dp[i-1][j],
				j<w ? 0 : dp[i-1][j-w]+v
			);
			if (i==n) ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 78336
N, K, *H = map(int, open(0).read().split())
H.extend([float('inf')] * K)
dp = [float('inf')] * (N + K)
dp[0] = 0
for i, hi in enumerate(H[1:], 1):
    dp[i] = min(dp[i - k] + abs(H[i - k] - hi) for k in range(1, K + 1))
print(dp[N - 1])

Measured memory_bytes: 61592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

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

    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}
int main(void)
{
  ll n, ans =0;
  cin >> n;
  vector<ll> A(n);
  RAP(i, n){
    cin >> A[i];
  }
  FOR(i, 1, n){
    if(A[i-1]>A[i]){
      ans += A[i-1]-A[i];
      A[i] = A[i-1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, k;
  cin >> n >> k;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll num = 1;
  rep(i,k){
    num *= a[i];
  }
  for (ll i = k; i < n;i++){
    if(a[i]>a[i-k]){
      print("Yes");
    }
    else{
      print("No");
    }
  }
}

Measured memory_bytes: 4840
#include <iostream>
using namespace std;
const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
        visited[v] = true;
        for (int v2 = 0; v2 < n; ++v2) {
                if (graph[v][v2] == false) continue;
                if (visited[v2] == true) continue;
                dfs(v2);
        }
}

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

        for (int i = 0; i < m; ++i) {
                cin >> a[i] >> b[i];
                a[i]--, b[i]--;
                graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }

        int ans = 0;

        for (int i = 0; i < m; ++i) {
                graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

                for (int j = 0; j < n; ++j) visited[j] = false;

                dfs(0);

                bool bridge = false;
                for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;
                if (bridge) ans += 1;

                graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
        }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,1){
        cin >> A[i];
    }
    char S[1000];
    cin >> S;
    //sort(A,A+3);
    cout << (A[0]>=3200 ? S : "red") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<int> p(n);
    vector<P> a(n);
    rep(i,n) {
        cin>>p[i];
        a[i].first = p[i];
        a[i].second = i;
    }

    multiset<int> st;
    st.insert(-1); st.insert(n);
    st.insert(-1); st.insert(n);
    sort(a.begin(), a.end(), greater<>());
    st.insert(a[0].second);

    ll ans = 0;

    for (int i = 1; i < n; ++i) {
        auto r1 = st.lower_bound(a[i].second);
        auto r2 = next(r1);
        auto l2 = prev(r1);
        auto l1 = prev(l2);
        ll c = a[i].second;
        ll x = a[i].first;
        ll tmp = (c-*l2)*(*r2-*r1) + (*r1-c)*(*l2-*l1);
        tmp *= x;
        ans += tmp;
        st.insert(c);
    }

    cout << ans << '\n';
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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

const long long INF = 1LL << 60;

bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; ++i) {
      if (N % i == 0) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x; cin>>x;
  
  int time = 0;
  int sum = 0;

  while(x>sum) {
    ++time;
    sum += time;
  }
  
  cout<<time;
}

Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int n,m,a[501][501],k,x1[2000001],x2[2000001],y1[2000001],y2[2000001];
int main()
{ cin>>n>>m;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
      cin>>a[i][j];
  for(int i=1;i<=n;i++)
    for(int j=1;j<m;j++)
      if(a[i][j]%2==1)
         x1[k]=i,x2[k]=i,y1[k]=j,y2[k]=j+1,k++,a[i][j]--,a[i][j+1]++;
  for(int i=1;i<n;i++)
    if(a[i][m]%2==1)
       x1[k]=i,x2[k]=i+1,y1[k]=m,y2[k]=m,k++,a[i][m]--,a[i+1][m]++;
  cout<<k<<'\n';
  for(int i=0;i<k;i++)
    cout<<x1[i]<<" "<<y1[i]<<" "<<x2[i]<<" "<<y2[i]<<'\n';
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
ll a[2002];
bitset<4194303> dp,tmp,one;

int main(){
  cin>>n;
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sum=(sum+1)/2;
  dp=1;
  one=1;
  rep(i,n){
    dp|=(dp<<a[i]);
  }
  repl(i,sum,4194303){
    if(((dp>>i)&one)==one){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


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

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

ll func(ll num, ll X, ll D){
    X = fabs(X);
    ll mn_sub = pow(10, 16);
    ll near = num;
    for(int i = -1; i <= 1; i++){
        ll val = fabs(X - (num+i) * D);
        if(mn_sub > val){
            mn_sub = val;
            near = num + i;
        }
    }
    return near;
}

int main(){
    ll X, K, D;
    cin >> X >> K >> D;
    ll probably_near = fabs(X) / D;
    ll near = func(probably_near, X, D);
    ll ans;
    if(near >= K){
        ans = fabs(fabs(X) - K * D);
    }else{
        ll sub = near - K;
        ans = fabs(fabs(X) - near * D);
        if(sub % 2 != 0){
            ans = min(fabs(ans + D), fabs(ans - D));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int n;
string s;

int main(){ 
  cin >> n >> s;
  int ans = 0;
  string abc = "ABC";
  for (int i = 0; i < s.size() - abc.size() + 1; i++)
    if (s.substr(i, 3) == abc) ans ++;
  cout << ans;
  return 0;
}

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

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

    if(n % k == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        k: i64,
        n: usize,
        a: [i64; n],
    }

    let mut max_dist = a[0] + k - a.last().unwrap();

    for a in a.windows(2) {
        max_dist = max_dist.max(a[1] - a[0]);
    }

    let ans = k - max_dist;

    println!("{}", ans);
}


Measured memory_bytes: 4860
#include <stdio.h>

int main(void)
{
  int k, a, b;

  scanf("%d%d%d", &k, &a, &b);
  /*
  (a/k != b/k) ? printf("Yes\n");
  : (a%k==0 || b%k ==0) ? printf("Yes\n");
      : printf("No\n");
  */


  if (a/k != b/k)
    printf("OK\n");
  else if (a%k == 0 || b%k == 0)
    printf("OK\n");
  else 
    printf("NG\n");

  return 0;
}


Measured memory_bytes: 1648
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_6-B: Partition

#include <algorithm>
#include <cstdio>

using uint = unsigned int;

static void print_partition_ints(const int as[], const uint q, const uint n)
{
  auto out_sep = "";
  for (auto i = 0u; i < n; ++i) {
    auto format = (i != q ? "%s%d" : "%s[%d]");
    std::printf(format, out_sep, as[i]);
    out_sep = " ";
  }
  std::printf("\n");
}

static uint partition(int as[], const uint first, const uint last)
{
  // as[last] is pivot
  auto less = first; // next index for smaller element
  for (auto i = first; i < last; ++i) {
    if (as[i] <= as[last]) {
      std::swap(as[less], as[i]);
      ++less;
    }
  }
  std::swap(as[less], as[last]);
  return less;
}

int main()
{
  uint n;
  std::scanf("%u", &n);
  int as[n];
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%d", &as[i]);
  }

  auto q = partition(as, 0, n-1);
  print_partition_ints(as, q, n);
}

// eof

Measured memory_bytes: 2960