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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
//#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  1e9 + 7;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
   	ll h,w;
   	cin>>h>>w;

   	ll a[1005][1005] = {0};

   	for(int i=1;i<=h;i++)
   	{
   		string s;
   		cin>>s;
   		for(int j=1;j<=w;j++)
   		{
   			a[i][j] = s[j-1];
   		}
   	}

   	ll dp[1005][1005] = {0};

   	dp[1][1] = 1;
   	for(int i=2;i<=h;i++)
   	{
   		if(a[i][1]=='#')dp[i][1] = 0;
   		else dp[i][1] = dp[i-1][1];
   	}

   	for(int j=2;j<=w;j++)
   	{
   		if(a[1][j]=='#')dp[1][j] = 0;
   		else dp[1][j] = dp[1][j-1];
   	}

   	for(int i=2;i<=h;i++)
   	{
   		for(int j=2;j<=w;j++)
   		{
   			if(a[i][j]=='#')
   			{
   				dp[i][j] = 0;
   			}
   			else
   			{
   				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
   			}
   		}
   	}

   	cout << dp[h][w] << "\n";
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
  int r,D,h;
  cin>>r>>D>>h;
  for(int i=0;i<10;i++){
    h=r*h-D;
    cout<<h<<endl;
    
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// https://ei1333.github.io/luzhiled/snippets/structure/trie.html
template< int char_size >
struct TrieNode {
  int par;
  int depth;
  array<int,char_size> childs;
  int exist;
  vector< int > accept;

  array<int,char_size> hist;

  TrieNode(int par, int depth) : par(par), depth(depth), exist(0) {
    childs.fill(-1);
    hist={};
  }
};

template< int char_size, int margin >
struct Trie {
  using Node = TrieNode< char_size >;

  vector< Node > nodes;
  int root;

  Trie() : root(0) {
    nodes.push_back(Node(-1,0));
  }

  void add(const string &str, int id) {
    int depth=0;
    int cur=root;
    while(depth<str.size()){
      const int c=str[depth]-margin;
      if(nodes[cur].childs[c]==-1) {
        nodes[cur].childs[c]=(int)nodes.size();
        nodes.push_back(Node(cur,depth+1));
      }
      cur=nodes[cur].childs[c];
      depth++;
    }
    nodes[cur].accept.push_back(id);

    array<int,char_size> itemhist={};
    cur=nodes[cur].par; //add対象文字列は長さ1以上なのでok
    while(true){
      const int c=str[nodes[cur].depth]-margin;

      itemhist[c]=1;
      nodes[cur].exist++;
      rep(c,char_size) nodes[cur].hist[c]+=itemhist[c];

      cur=nodes[cur].par;
      if(cur==-1) break;
    }
  }

  void add(const string &str) {
    add(str, nodes[0].exist);
  }

  void query(const string &str, const function< void(array<int,char_size>) > &f, int str_index, int node_index) {
    if(str_index == str.size()) {
      f(nodes[node_index].hist);
      return;
    } else {
      const int c = str[str_index] - margin;
      if(nodes[node_index].childs[c] == -1) return;
      query(str, f, str_index + 1, nodes[node_index].childs[c]);
    }
  }

  void query(const string &str, const function< void(array<int,char_size>) > &f) {
    query(str, f, 0, 0);
  }

  int count() const {
    return (nodes[0].exist);
  }

  int size() const {
    return ((int) nodes.size());
  }

};

lint app() {
  Trie< 26, 'a' > trie;

  int n;
  cin>>n;

  vector<string> s(n);
  rep(i,n){
    string st;
    cin>>st;
    reverse(st.begin(),st.end());
    s[i]=st;
    trie.add(st);
  }

  lint ans=0;
  rep(i,n){
    string q=s[i].substr(0,s[i].size()-1);
    char c=s[i].back();

    auto f=[&](array<int,26> hist){
      //rep(i,26) cout<<hist[i];
      //cout<<endl;
      //cout<<q<<' '<<c<<endl;
      ans+=hist[c-'a']-1;
    };
    trie.query(q,f);
  }
  return ans;
}

int main(){cout<<app()<<endl;return 0;}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, a, b;
  cin >> n >> a >> b;

  vector<int> vp(n);
  for (int i = 0; i < n; ++i) {
    cin >> vp[i];
  }

  int cnt1, cnt2, cnt3;
  cnt1 = cnt2 = cnt3 = 0;
  for (int i = 0; i < n; ++i) {
    int p = vp[i];
    if (p <= a) {
      cnt1++;
    } else if (p <= b) {
      cnt2++;
    } else {
      cnt3++;
    }
  }

  cout << min({cnt1, cnt2, cnt3}) << '\n';
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int c[10][10];

string make(string k){
  int a = 0;
  rep(i,4){
    int j = k[i] - '0';
    a = c[a][j];
  }
  k.resize(5);
  k[4] = a + '0';
  return k;
}

int check(string s){
  int a = 0;
  rep(i,5){
    int j = s[i] - '0';
    a = c[a][j];
  }
  return a;
}

bool safe(string t){
  string s = t;
  rep(k,4){
    swap(s[k],s[k+1]);
    if(!check(s) && s != t){
      return false;
    }
    swap(s[k],s[k+1]);
  }
  rep(i,5){
    rep(j,10){
      s = t;
      s[i] = char('0' + j);
      if(!check(s) && s != t){
        return false;
      }
    }
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  rep(i,10){
    rep(j,10){
      cin >> c[i][j];
    }
  }
  string t = "2016";
  ll cnt = 0;
  rep(i,10)rep(j,10)rep(k,10)rep(l,10){
    t[0] = char('0' + i);
    t[1] = char('0' + j);
    t[2] = char('0' + k);
    t[3] = char('0' + l);
    if(!safe(make(t))) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3164
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, x, y = map(int, input().split()) 
  x -= 1
  y -= 1
  counts = [0] * (n)
  for i in range(n):
    s = 0
    for j in range(i+1, n):
      nv = min((j - i + 1), abs(i-x) + 1 + abs(j-y) + 1)
      if nv-2 < 0 or nv-2 >= n:
        continue
      counts[nv-2] += 1

  print('\n'.join(map(str, counts[:n-1])))

if __name__=='__main__':
  main()



Measured memory_bytes: 3188
N, D, A = gets.split.map(&:to_i)
XH = N.times.map{gets.split.map(&:to_i)}.sort{|a,b|a[0]<=>b[0]}

que = []
res = 0
attack_n = 0
XH.each do |x, h|
  while que.size > 0 && que[0][0] < x
    attack_n -= que[0][1]
    que.shift
  end
  h -= A * attack_n
  next if h < 1
  count = Rational(h, A).ceil
  attack_n += count 
  res += count
  que << [x + 2 * D, count]
end
p res

Measured memory_bytes: 21224
#include <iostream>

using namespace std;

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

  int ans = 700;
  for (int i=0; i<3; i++){
    if(s[i] == 'o'){
      ans += 100;
    }
  }
  cout << ans << endl;

  return 0;
}


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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll MOD = 1000000007;//大きい素数

int n,m,q;
vector<int>a,b,c,d;
int ans;//グローバル変数

void dfs(vector<int>A){
  if((int)A.size()== n+1){
    int now=0;
    rep(i,q){
      if(A[b[i]]-A[a[i]]==c[i]) now+=d[i];
    }
    ans = max(ans,now);
    return;
  }
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}


int main(){
    
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,q){
      cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(vector<int>(1,1));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    int y,m,d;
    cin >> y >> m >> d;
    int ans = 0;
    if(y % 3 == 0 || m % 2 == 1) ans += 20-d;
    else ans += 19 - d;
    for(int j=m+1; j<=10; j++){
      if(y % 3 == 0 || j % 2 == 1) ans += 20;
      else ans += 19;
    }
    for(int j=y+1; j<=999; j++){
      if(j % 3 == 0) ans += 200;
      else ans += 195;
    }
    cout << ans+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    ll x,y;
    scanf("%lld%lld", &x, &y);

    if(abs(x-y)<=1) {
        printf("Brown\n");
    }
    else {
        printf("Alice\n");
    }

    return 0;
}



Measured memory_bytes: 128
/*input
10 10 20
*/
macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = String::new();
        std::io::stdin().read_line(&mut return_).ok();
        return_.pop();
        return_
    }};
}

fn main() {
    let v: Vec<i32> = input_vec!();
    println!("{}", v.iter().sum::<i32>());
}



Measured memory_bytes: 5036
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
ll ppow(ll x, ll n) {
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1)ans = ans * x;
		x = x * x;
		n >>= 1;
		x %= mod;
		ans %= mod;
	}
	return ans;
}
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n,ans[2000020];
pp v[200020];
int main() {
	cin >> n;
	rep(i, n)cin >> v[i].first, v[i].second = i;
	sort(v, v + n);
	rep(i, n) {
		if (i < n / 2)ans[v[i].second] = v[n / 2].first;
		else ans[v[i].second] = v[n / 2 - 1].first;
	}
	rep(i, n)cout << ans[i] <<endl;
	return 0;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer p = nil->next;
  while(1){
    if(p->key == key) break;
    if(p->next == nil) return nil;
    p = p->next;
  }
  return p;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
  return;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
  return;
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
  return;  
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
  return;
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
  return;
}

void delete(int key){
  NodePointer x;
  x = listSearch(key);
  if(x != nil) deleteNode(x);
  return;
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->prev = nil;
  if(nil->next == nil){
    nil->next = x;
    x->next =nil;
    nil->prev = x;
  } else {
    nil->next->prev = x;
    x->next = nil->next;
    nil->next = x;
  } 
  return;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      scanf("%d", &key);
      insert(key);
      np++;
      size++;
    }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
        scanf("%d", &key);
        delete(key);
        nd++; 
      }
      size--;
    } 
  } 

  printList();
  return 0;
}

Measured memory_bytes: 31784
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
 
using i64 = long long;
 
struct Graph {
  struct edge {
    int to;
    i64 cap;
    i64 rev;
    bool alive;
  };
 
  int n;
  vector<vector<edge>> edges;
 
  Graph(int N) {
    n = N;
    edges.resize(n, vector<edge>());
  }
 
  int size() const { return n; }
 
  vector<edge> &operator[](int v) { return edges[v]; }
};
 
struct Dinic_Reverse {
  int N;
  vector<int> level;
  vector<int> itr;
  Graph G;
 
  Dinic_Reverse(int n) : G(n) { N = n; }
 
  void add_edge(int from, int to, i64 cap, i64 rev_cap) {
    G[from].push_back({to, cap, (int)G[to].size(),true});
    G[to].push_back({from, rev_cap, (int)G[from].size() - 1,true});
  }
 
  bool g_level(int s, int t) {
    level.assign(N, -1);
    queue<int> que;
    que.push(s);
    level[s] = 0;
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      for (auto &e : G[v]) {
          if(!e.alive) continue;
        if (e.cap > 0 && level[e.to] == -1) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
    return level[t] >= 0;
  }
 
  i64 dfs(int v, int t, i64 f) {
    if (v == t)
      return f;
 
    for (int &i = itr[v]; i < (int)G[v].size(); i++) {
      auto &e = G[v][i];
      if(!e.alive) continue;
      if (e.cap > 0 && level[e.to] > level[v]) {
        i64 mi_f = dfs(e.to, t, min(f, e.cap));
        if (mi_f > 0) {
          e.cap -= mi_f;
          G[e.to][e.rev].cap += mi_f;
          return mi_f;
        }
      }
    }
    return 0;
  }
 
  i64 max_flow(int s, int t , i64 limit = 1e9) {
    i64 result = 0;
    i64 flow;
    while (g_level(s, t) && limit > 0) {
      itr.assign(N, 0);
      while ((flow = dfs(s, t, limit)) > 0)
      {
        result += flow;
        limit -= flow;
      }
    }
    return result;
  }
 
  bool back_edge(int from,int to,int s,int t){
      for(auto& e : G[from]){
          if(e.to == to && e.alive){
              e.alive = false;
              if(e.cap == 0 && max_flow(from, to, 1) == 0){
                  max_flow(from, s, 1);
                  max_flow(t,to,1);
                  return 1;
              }
              else{
                  return 0;
              }
          }
      }
  }
};
 
/*
 
checked
    http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2723921#1
*/
int n;
int e;
int q;
 
int main(){
    cin >> n >> e >> q;
    Dinic_Reverse dinic(n);
    int s = 0;
    int t = n - 1;
    for(int i = 0;i < e;i++){
        int a,b;;
        cin >> a >> b;
    a--;
    b--;
        dinic.add_edge(a, b , 1, 1);
    }
    int flow = dinic.max_flow(s, t );
    for(int i = 0;i < q;i++){
        int m,a,b;
        cin >> m >> a >> b;
        a--;
        b--;
        if(m == 1){
            dinic.add_edge(a , b, 1 , 1);
            flow += dinic.max_flow(s , t , 1);
        }
        else{
            flow -= dinic.back_edge(a, b , s , t);
            flow -= dinic.back_edge(b, a, s , t);
        }
        cout << flow << endl;
    }
}


Measured memory_bytes: 4872
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<int, int> P;
#define fs first
#define sc second

ll p[100000], q[100000], r[100000];
ll sump[100001];
ll sumq[100001];
ll sumr[100001];
ll mx[100001];

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    for(int i = 0; i < a; i++) cin >> p[i];
    for(int i = 0; i < b; i++) cin >> q[i];
    for(int i = 0; i < c; i++) cin >> r[i];

    sort(p, p + a, greater<ll>());
    sort(q, q + b, greater<ll>());
    sort(r, r + c, greater<ll>());

    sump[0] = 0;
    sumq[0] = 0;
    sumr[0] = 0;
    for(int i = 0; i < a; i++) sump[i + 1] = sump[i] + p[i];
    for(int i = 0; i < b; i++) sumq[i + 1] = sumq[i] + q[i];
    for(int i = 0; i < c; i++) sumr[i + 1] = sumr[i] + r[i];

    //cの残りがi個の状態でYを作ったときのmax
    mx[0] = sumq[y];
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 0; i < y; i++) que.push(q[i]);
    for(int i = 1; i <= c; i++) {
        ll res = mx[i - 1];
        res += r[c - i];
        que.push(r[c - i]);
        res -= que.top();
        que.pop();
        mx[i] = res;
    }

    //for(int i = 0; i <= c; i++) cout << mx[i] << endl;

    ll ans = 0;
    //aからi個食べるとき最大値
    for(int i = 0; i <= a; i++) {
        ll res = 0;

        //cから補填する数
        int n = x - i;
        if(n > c || n < 0) continue;

        res += sump[i];
        res += sumr[n];

        //緑をY個たべる(cの残りがc - n個で)
        res += mx[c - n];
        ans = max(ans, res);
        //cout << i << " " << res << endl;
    }

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

Measured memory_bytes: 6516
from fractions import gcd
a, b, k = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    print(divisors[len(divisors) - k])
make_divisors(gcd(a, b))

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i < N; i++){
    cin >> vec.at(i);
    }
    int ans = -1;
    bool even = true;
    while(even){

        ans++;

        for(int i=0; i<N; i++){
            if(vec.at(i) % 2 == 0){
                vec.at(i) = vec.at(i)/2;
            }else{
                even = false;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
///BigMod , efficinet bitwise OR in a range [L,R] in O(1) 
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
#define MAX 100005 
#define bitscount 32
 
using namespace std;


int main()
{
__

string s;

cin >> s;

for(int i=0;i<s.size();i++)
{
if(i%2==0 && s[i]=='L'){
cout << "No";
exit(0);
}

else if(i%2==1 && s[i]=='R'){
cout << "No";
exit(0);
}
}

cout << "Yes";
return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque

def main():
    n = int(input())
    idx = [-1] * n
    for i in range(n):
        p = int(input())
        p -= 1
        idx[p] = i
    
    ans = 1
    tmp = 1
    for i in range(1,n):
        if idx[i - 1] < idx[i]:
            tmp += 1
        else:
            ans = max(ans,tmp)
            tmp = 1
    ans = max(ans,tmp)
    print(n - ans)

if __name__ =='__main__':
    main()  


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

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
const int M = N << 1;

int n, m, val[M];
bool vis[M];
int head[M], to[M<<1], nxt[M<<1];

void add(int a, int b){
	to[m] = b;
	nxt[m] = head[a];
	head[a] = m++;
}

int ans;
void dfs(int x){
    ans += val[x];
    vis[x] = 1;
    for(int i=head[x]; ~i; i=nxt[i]){
		int j = to[i];
		if(!vis[j]){
			dfs(j);
		}
    }
}

int main(){
	while(~scanf("%d %d", &n, &m)){
		memset(vis, 0, sizeof(vis));
        for(int i=1; i<=n; i++){
			val[i] = 1;
			head[i] = -1;
        }
        for(int i=1; i<=m; i++){
			val[i+n] = 0;
			head[i+n] = -1;
        }
        m = 0;
        int p, a;
        for(int i=1; i<=n; i++){
			scanf("%d", &p);
			while(p--){
				scanf("%d", &a);
				add(i, a+n);
				add(a+n, i);
			}
        }
        ans = 0;
        dfs(1);
        puts(ans == n ? "YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 3584
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{n:usize, v:[(i64,i64);n]};
    let mut v = v;
    v.sort();
    v.reverse();
    println!("{}", v[0].1 + v[0].0);
}


Measured memory_bytes: 6396
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>

using namespace std;


int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	while (x >= b) {
		x -= b;
	}
	cout << x;
	return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 202000;
string s;
int n,p2[MAXN],p3[MAXN];

int get(int x){
  if(!x)return 1;
  int ans = 1;
  while(x){
    x = x%(__builtin_popcount(x));
    ans++;
  }
  return ans;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  cin >> s;
  int x = 0;
  for(int i=0;i<n;i++){
    if(s[i]=='1')x++;
  }
  x--;
  if(x!=0){
    p2[0]=1;
    for(int i=1;i<=n;i++){
      p2[i] = p2[i-1]*2%x;
    }
  }
  x++;
  x++;
  p3[0]=1;
  for(int i=1;i<=n;i++){
    p3[i] = p3[i-1]*2%x;
  }
  x--;
  int r2 = 0, r3 = 0;
  for(int i=0;i<n;i++){
    if(s[i]=='1'){
      if(x!=1)
      r2 = (r2+p2[n-i-1])%(x-1);
      r3 = (r3+p3[n-i-1])%(x+1);
    }
  }
  for(int i=0;i<n;i++){
    if(s[i]=='1'){
      if(x!=1){
        int r2n = (r2-p2[n-i-1]+x-1)%(x-1);
        cout<<get(r2n)<<endl;
      }
      else {
        cout<<0<<endl;
      }
    }
    else {
      int r3n = (r3+p3[n-i-1])%(x+1);
      cout<<get(r3n)<<endl;
    }
  }



return 0;
}
///....


Measured memory_bytes: 6908
N = int(input())
A = [int(a) for a in input().split()]

K = 10000
C = [0] * K

for i in range(N):
    C[A[i]] += 1

for i in range(1, K):
    C[i] += C[i - 1]

B = [0] * N
for i in reversed(range(N)):
    C[A[i]] -= 1
    B[C[A[i]]] = A[i]

print(*B)


Measured memory_bytes: 224144
from collections import deque
n=int(input())
b=list(map(int,input().split()))
a=[]
while b:
    maxpoint=0
    for i in range(len(b)):
        if i+1==b[i]:
            maxpoint=max(maxpoint, i+1)
    if maxpoint==0:
        print(-1)
        exit()
    else:
        a.append(maxpoint)
        b=b[:maxpoint-1]+b[maxpoint:]

for i in range(len(a)):
    print(a[-i-1])

Measured memory_bytes: 38640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int a,n;
    
    cin >> n >> a;
    
    cout << n*n-a << endl;
    
    
    

return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    int a,b,c;
    set<int>s;
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }




}









Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

W, H, N = MAP()

w, h = np.zeros(W), np.zeros(H)

for _ in range(N):
	x, y, a = MAP()
	if a == 1:
		w[:x] = 1
	elif a == 2:
		w[x:] = 1
	elif a == 3:
		h[:y] = 1
	elif a == 4:
		h[y:] = 1

print(list(w).count(0) * list(h).count(0))


Measured memory_bytes: 13792
def between(sx,sy,mx,my,ex,ey):
    # y軸方向への移動
    if sx == mx and mx == ex:
        if sy <= my and my <= ey:
            return True
        elif ey <= my and my <= sy:
            return True
    elif sy == my and my == ey:
        if sx <= mx and mx <= ex:
            return True
        elif ex <= mx and mx <= sx:
            return True
    return False

while True:
    n = int(input())
    if n == 0: break
    stones = []
    picked = [False for i in range(n)]
    for i in range(n):
        tx, ty = map(int, input().split())
        stones.append([tx, ty])

    """
    print("stones::")
    for i in range(n):
        print(stones[i])
    print("------------")
    """
    m = int(input())

    cx = 10
    cy = 10
    for i in range(m):
        hoge, foo = map(str, input().split())
        drc = hoge
        dist = int(foo)

        if drc == 'N':
            ex = cx
            ey = cy + dist
        elif drc == 'E':
            ex = cx + dist
            ey = cy
        elif drc == 'W':
            ex = cx - dist
            ey = cy
        else:
            ex = cx
            ey = cy - dist

        #print("moving from {},{} to {},{}".format(cx, cy, ex, ey))

        for j in range(len(stones)):
            if between(cx, cy, stones[j][0], stones[j][1], ex, ey):
                picked[j] = True
                #print("stone {} picked".format(j))

        cx = ex
        cy = ey

    """
    print("picked???")
    for i in picked:
        print(i)
    print("----------")
    """
        
    for i in picked:
        if i == False:
            print("No")
            break
    else:
        print("Yes")



Measured memory_bytes: 5640
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;



int main(){
	int l;
	cin >> l;
	double a = l/3.0, b = a, c = a;
	double ans = a*b*c;
	cout << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;

#define N 100005

int cnt[N];
pair<int,pii> ar[N];
pii br[N]; 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
 
    int n,m,x,y,id;

    cin >> n >> m;

    rep(i,m) {
        gi(x); gi(y);

        ar[i] = MP(y, MP(x,i) );
    }

    sort(ar+1, ar+m+1);

    rep(i,m) {
        x = ar[i].ss.ff;
        id = ar[i].ss.ss;

        cnt[x]++;
        y = cnt[x]; 
        
        br[id].ff = x;
        br[id].ss = y;
    }

    rep(i,m) {
        pf("%06d",br[i].ff);
        pf("%06d",br[i].ss);
        nl;
    }
	
 
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
	string s;
	cin>>s;
	x=y=-1;
	for(auto p:s){
		if(p=='A') x++;
		else y++;
	}
	if(x==-1||y==-1) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int N;
	cin >> N;
	vector<int> A(N+1);
	vector<int> n(N+1,0);

	for(int i=1; i<=N; i++) cin >> A.at(i);

	for(int i=1; i<=N; i++){ n.at(A.at(i))++; }

	long long max=0;
	for(int i=1; i<=N; i++){
		max += (ll)n.at(i)*(n.at(i)-1)/2;
	}

	for(int i=1; i<=N; i++){
		int t=A.at(i);
		long long max_cp = max;

		max_cp -= n.at(t)*(n.at(t)-1)/2;
		max_cp += (n.at(t)-1)*(n.at(t)-2)/2;

		cout << max_cp << endl;
	}

}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include<map>
#include<cmath>
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int main() {
    unsigned long long N;
    vector<unsigned long long> pri;
    cin >> N;
    const auto &res = prime_factorize(N);
    for (auto p : res) {
        for (unsigned long long i = 0; i < p.second; ++i) pri.push_back(p.first);
    }
    map<unsigned long long, unsigned long long> count;
    unsigned long long P=pri.size();

    for(unsigned long long i=0; i<P; i++){
        count[pri[i]]++;
    } 

    unsigned long long ans=0;
    if(pri.size()==1 || is_prime(N)){
        cout << 1 << endl;
        return 0;
    }
    else{
        for(auto i=count.begin(); i!=count.end(); i++){
            if(i->second==1){
                ans+=1;
            }
            else{
                ans+=(-1+sqrt(i->second*4*2+1))/2;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
int main (void){
    int i,j,n,p,st[55],wan=0;
    while(-1){
        scanf("%d %d",&n,&p);
        wan=p;
        if(n==0){break;}
        for(i=0;i<n;i++){st[i]=0;}
        i=0;
        while(-1){
            if(wan>0){wan--;st[i]++;}else{wan+=st[i];st[i]=0;}
            if(st[i]==p){printf("%d\n",i);break;}
            i++;
            if(i==n){i=0;}
        }
    }
    return 0;
        
}

Measured memory_bytes: 600
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N;
	cin >> N;
	int V[20];
	int C[20];
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	int cost;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cost = V[i] - C[i];
		if (cost > 0) ans += cost;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)


n, k = map(int, input().split())
x = Base_10_to_n(n, k)
print(len(x))


Measured memory_bytes: 38384
#include<stdio.h>
	int main(){
	int N,K,X,Y;
	scanf("%d %d %d %d", &N,&K,&X,&Y);
	if(N <= K){
	printf("%d\n",N * X );
	}
	if(N>K){
	printf("%d\n",K * X + (N-K) * Y );
		}
		}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long a[n+1];
    a[0] = 0;
    long long ans = 0, b = 0;
    for(int i = 1; i <= n; i++){
        long long a;
        cin >> a;
        if(b+1 < a || (i == 1 && a > 0)){
            ans = -1;
            break;
        }
        if(b+1 == a) ans++;
        else ans += a;
        b = a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	int n;
	int a[100001] = {};
	int count = 0;
	int dp[100001] = {};

	cin >> n;
	FOR(i, 1, n) {
		cin >> a[i];
		if (a[i] <= 100000) {
			dp[a[i]]++;
		}
		else {
			count++;
		}
	}
	FOR(i, 1, 100000) {
		if (dp[i] > i) {
			count += dp[i] - i;
		}
		if (dp[i] < i) {
			count += dp[i];
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int H, W, K;
	scanf("%d %d %d", &H, &W, &K);
	char c[H][W];
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) scanf(" %c", &c[i][j]);
	}
	int ans = 0;
	for (int i = 0; i < (1 << H); ++i) {
		for (int j = 0; j < (1 << W); ++j) {
			int cnt = 0;
			for (int k = 0; k < H; ++k) {
				for (int l = 0; l < W; ++l) {
					if (!(i & (1 << k)) && !(j & (1 << l)) && c[k][l] == '#') ++cnt;
				}
			}
			if (cnt == K) ++ans;
		}
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 1732
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[5],x;
double f[305][305][305];
bool vis[305][305][305];
double dfs(int i,int j,int k)
{
	if(i==0 && j==0 && k==0)return 0;
	if(vis[i][j][k])return f[i][j][k];
	vis[i][j][k]=1;
	if(k)f[i][j][k]+=dfs(i,j+1,k-1)*k/n;
	if(j)f[i][j][k]+=dfs(i+1,j-1,k)*j/n;
	if(i)f[i][j][k]+=dfs(i-1,j,k)*i/n;
	return f[i][j][k]=(f[i][j][k]+1)*n/(i+j+k);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&x);
		++a[x];
	}
	printf("%.10lf\n",dfs(a[1],a[2],a[3]));
	return 0;
}

Measured memory_bytes: 243968
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

using block = pair<char, lint>;
int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    assert(S.size() == N);
    vec<block> blocks;
    lint res = 0;
    range(i, 0, N - 1) {
        if (S.at(i) == S.at(i + 1)) res += 1;
    }
    res += 2 * K;
    cout << min(N - 1, res) << "\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	ll N, D;
	cin >> N >> D;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= D * D) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cassert>

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 1e5+1;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define FAILNO {printf("NO\n"); return 0;}
#define FAIL1 {printf("-1\n"); return 0;}

int N;
int A[MAXN];

int main() {
#ifdef OJ
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif

	scanf("%d", &N);
	int zero = 0, neg = 0;
	int mnabs = 1e9+1;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);

		if (A[i] == 0) zero++;
		else {
			if (A[i] < 0) neg++;
			mnabs = min(mnabs, abs(A[i]));
		}
	}

	LL ans = 0;
	if (zero) {
		for (int i = 0; i < N; i++) 
			ans += abs(A[i]);
	} else if (neg % 2 == 0) {
		for (int i = 0; i < N; i++) 
			ans += abs(A[i]);
	} else {
		int f = 0;
		for (int i = 0; i < N; i++) {
			if (abs(A[i]) == mnabs) {
				if (!f) ans -= abs(A[i]);
				else ans += abs(A[i]);
				f = 1;
			} else {
				ans += abs(A[i]);
			}
		}
	}

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



Measured memory_bytes: 640
N,K = map(int,input().split())
A = list(map(int,input().split()))
Acu = [0]
Acu_p = [0]
for i in range(N):
  if i == 0:
    Acu.append(A[i])
  else:
    Acu.append(A[i]+Acu[-1])
#print(Acu)
for i in range(N):
  if i == 0:
    Acu_p.append(max(A[i],0))
  else:
    Acu_p.append(max(A[i],0)+Acu_p[-1])
#print(Acu_p)
ans = -float("inf")
for i in range(N-K+1):
  tmp = Acu_p[-1]
  tmp += max(Acu[i+K]-Acu[i],0)
  tmp -= Acu_p[i+K]-Acu_p[i]
  ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 16832