akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int n,m;
  ll z;
  cin>>n>>m>>z;
  
  vector<int> a(m);
  vector<int> b(m);
  vector<ll> c(m);
  vector<vector<int>> g(n);
  vector<vector<int>> gr(n);
  vector<bool> ok(n,true);
  rep(i,m) {
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    c[i]-=z;
    g[a[i]].pb(b[i]);
    gr[b[i]].pb(a[i]);
  }
  
  //頂点１からいけない場所をok falseに
  vector<ll> dist(n,-1);
  deque<int> que;
  dist[0]=0;
  que.pb(0);

  while(!que.empty()){
    int v=que.front();
    que.pop_front();
    for(int nv : g[v]){
      if(dist[nv]!=-1) continue;
      dist[nv]=dist[v]+1;
      que.pb(nv);
    }
  }

  rep(i,n){
    if(dist[i]==-1) ok[i]=false;
    dist[i]=-1;
  }

  //頂点nにいけない場所をok falseに
  dist[n-1]=0;
  que.pb(n-1);

  while(!que.empty()){
    int v=que.front();
    que.pop_front();
    for(int nv : gr[v]){
      if(dist[nv]!=-1) continue;
      dist[nv]=dist[v]+1;
      que.pb(nv);
    }
  }

  rep(i,n){
    if(dist[i]==-1) ok[i]=false;
    dist[i]=-INF;
  }

  
  //ok true同志にだけ変をはる
  vector<vector<pair<int,ll>>> gp(n);
  rep(i,m){
    if(ok[a[i]]&&ok[b[i]]) {
      if(a[i]!=b[i]) gp[a[i]].pb({b[i],c[i]});
      else {
        if(c[i]>0) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }

  dist[0]=0;
  que.pb(0);
  int cnt=0;
  while(!que.empty()){
    cnt++;
    if(cnt>1e6) {
      cout << -1 << endl;
      return 0;
    }
    int v=que.front();
    que.pop_front();
    for(auto x : gp[v]){
      int nv=x.fi;
      ll y=x.se;
      if(dist[nv]>=dist[v]+y) continue;
      dist[nv]=dist[v]+y;
      que.pb(nv);
    }
  }

  cout << max(0ll,dist[n-1]) << endl;
}

Measured memory_bytes: 4588
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n, m; cin>>n>>m;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    int asum = accumulate(all(a), 0);

    double g = 1. * asum / (4 * m);

    int cnt = 0;
    for(int i=0; i<n; i++){
        if(a[i] >= g) cnt++;
    }

    cout << (cnt >= m ? "Yes" : "No") << endl;

    return 0;
}

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

#define VOLUME_PRE_LEVEL ((long long)pow(2.0, (double)(level + 1)) - 3)
#define PUTTY_PRE_LEVEL ((long long)pow(2.0, (double)level) - 1)

int n;
long long x;

void input() {
	cin >> n >> x;
}

long long puttyInBurger(int level, long long bottom){
    if(level == 0) return 1;
    if(bottom <= 1) return 0;
    if(bottom <= 1 + VOLUME_PRE_LEVEL) return puttyInBurger(level - 1, bottom - 1);
    if(bottom <= 1 + VOLUME_PRE_LEVEL + 1) return PUTTY_PRE_LEVEL + 1;
    if(bottom <= 1 + (2 * VOLUME_PRE_LEVEL)) return PUTTY_PRE_LEVEL + 1 + puttyInBurger(level - 1, bottom - 1 - VOLUME_PRE_LEVEL - 1);
    return 2 * PUTTY_PRE_LEVEL + 1;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	input();
	
	cout << puttyInBurger(n, x) << "\n";
 
	return 0;
}


Measured memory_bytes: 256
n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
low, high = 0, max(arr) + 1
while high - low > 1:
  mid = (high + low) // 2
  curr = 0
  for i in arr:
    curr += (i - 1)//mid
  if curr > k:
    low = mid
  else:
    high =  mid
print(high)    

Measured memory_bytes: 30880
l=input().split()

a=int(l[0])
b=int(l[1])
c=int(l[2])

def judge(c,n):
    if c%n==0:
        return 1
    else:
        return 0
n=a
result=0
while n<=b:
    result=result+judge(c,n)
    n=n+1

print(result)


Measured memory_bytes: 5600
"use strict"
function Main(input){
  input=input.split(/\s+/);
  for(let i=0;i<input.length;i++)
    input[i]=parseInt(input[i]);
  var N=input.shift();
  var ABC=input.splice(0,3);
  var L=input;
  var abc=[];
  var M=Math.pow(4,N);
  for(let i=0;i<M;i++){
    abc[i]=[0,0,0,10*(N-3)];
    var str=zeroFill(i.toString(4) , N);
    for(let j=0;j<N;j++)
      switch(str[j]){//abc[i]の0番目、1番目、2番目をＡＢＣにぶつける。3番目は合成に用いた消費ＭＰを記録
        case "0":
          abc[i][0]+=L[j];
          break;
        case "1":
          abc[i][1]+=L[j];
          break;
        case "2":
          abc[i][2]+=L[j];
          break;
        case "3":
          abc[i][3]-=10;
          break;
      }
    for(let k=0;k<3;k++)
      if(abc[i][k]===0)abc[i][k]=Infinity;
  }
  function dst(abc){
    var sum=0;
    for(let i=0;i<3;i++)
      sum+=Math.abs(ABC[i]-abc[i]);
      sum+=abc[3];
    return sum;
  }
  
  var Dst=[];
  for(let i=0;i<M;i++){
    Dst[i]=dst(abc[i]);
  }
  console.log(Math.min.apply(null,Dst));
}

function zeroFill(str,n){
  return ("00000000"+str).slice(-n);
}

Main(require('fs').readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 28492
//2019.12.22
//s1270188 xxxmk2
//alds1_06c

#include<stdio.h>

#define N 100000

//prototype
int partition(int,int);
void quicksort(int,int);
void swap(int,int);
int judge(void);

//global
char Aa[N], Bb[N];
int A[N], B[N], num;

int main(){
  int i;

  //input
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf(" %c %d",&Aa[i],&A[i]);
    Bb[i]=Aa[i];
    B[i]=A[i];
  }
  
  //quicksort
  quicksort(0,num-1);

  //judge
  if(judge()==0) printf("Stable\n");
  else printf("Not stable\n");
  
  //output
  for(i=0;i<num;i++) printf("%c %d\n",Aa[i],A[i]);
    
  return 0;
}

int partition(int p,int r){
  int x, i, j, sub;

  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
 
      swap(i,j);
    }
  }

  swap(i+1,r);

  return i+1;
}

void quicksort(int p,int r){
  int q;
  
  if(p<r){
    q=partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }
}

void swap(int a, int b){
  int manami;
  char momo;

  momo=Aa[a];
  Aa[a]=Aa[b];
  Aa[b]=momo;

  manami=A[a];
  A[a]=A[b];
  A[b]=manami;
}

int judge(void){
  int i, j;

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){

      if(A[i]==B[j]){
	B[j]=-1;
	if(Aa[i]!=Bb[j]) return 1;
	else break;
      }
    }
  }
  
  return 0;
}




Measured memory_bytes: 2744
#include<bits/stdc++.h>
using namespace std;
char la(string a)
{
	return a[a.size()-1];
}
char fi(string a)
{
	return a[0];
}
bool bl(string a,string b)
{
	if(la(a)!=fi(b))return false;
	else return true;
}
int main()
{
	int a;
	cin>>a;
	vector<string>svec;
	string input;
	for(int i=0;i<a;i++)
	{
		cin>>input;
		svec.push_back(input);
		input="";
	}
	set<string>sset;
	for(int i=0;i<svec.size();i++)sset.insert(svec[i]);
	bool bl2=true;
	for(int i=0;i<svec.size()-1;i++)if(bl(svec[i],svec[i+1])==false)bl2=false;
	if(sset.size()!=svec.size()||bl2==false)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <stack>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <cctype>
#include <unordered_set>
#include <unordered_map>
#include <numeric>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N, T; cin >> N >> T;
	vll A(N + 1);
	rep(i, N) cin >> A[i];
	A[N] = INFll;
	ll ans = 0;
	repr(i, 1, N) {
		ans += min<ll>(T, A[i] - A[i - 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	ll maxi = 0;
	ll ans = 0;
	rep(i, n) {
		ll x;
		cin >> x;
		if (i == 0) maxi = x;
		else {
			if (chmax(maxi, x)) continue;
			else ans += abs(maxi - x);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import os
import sys

import numpy as np


def solve(inp):
    def bitree_sum(bit, t, i):
        s = 0
        while i > 0:
            s += bit[t, i]
            i ^= i & -i
        return s

    def bitree_add(bit, n, t, i, x):
        while i <= n:
            bit[t, i] += x
            i += i & -i

    def bitree_lower_bound(bit, n, d, t, x):
        sum_ = 0
        pos = 0
        for i in range(d, -1, -1):
            k = pos + (1 << i)
            if k <= n and sum_ + bit[t, k] < x:
                sum_ += bit[t, k]
                pos += 1 << i
        return pos + 1

    def initial_score(d, ccc, sss):
        bit_n = d + 3
        bit = np.zeros((26, bit_n), dtype=np.int64)
        INF = 10 ** 18
        # for t in range(26):
        #     bitree_add(bit, bit_n, t, bit_n - 1, INF)

        ttt = np.zeros(d, dtype=np.int64)
        last = np.full(26, -1, dtype=np.int64)
        score = 0

        for i in range(d):
            best_t = 0
            best_diff = -INF
            for t in range(26):
                tmp_diff = sss[i, t]
                for u in range(26):
                    if u == t:
                        continue
                    tmp_diff -= ccc[u] * (i - last[u])
                if best_diff < tmp_diff:
                    best_t = t
                    best_diff = tmp_diff
            ttt[i] = best_t
            score += best_diff

        return bit, score, ttt

    def update_score(bit, bit_n, bit_d, ccc, sss, ttt, d, q):
        diff = 0
        t = ttt[d]
        k = bitree_sum(bit, t, d + 2)
        c = bitree_lower_bound(bit, bit_n, bit_d, t, k - 1) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, t, k + 1) - 2
        b = ccc[t]
        diff -= b * (d - c) * (e - d)
        diff -= sss[d, t]

        k = bitree_sum(bit, q, d + 2)
        c = bitree_lower_bound(bit, bit_n, bit_d, q, k) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, q, k + 1) - 2
        b = ccc[q]
        diff += b * (d - c) * (e - d)
        diff += sss[d, q]

        return diff

    d = inp[0]
    ccc = inp[1:27]
    sss = np.zeros((d, 26), dtype=np.int64)
    for r in range(d):
        sss[r] = inp[27 + r * 26:27 + (r + 1) * 26]

    bit, score, ttt = initial_score(d, ccc, sss)
    bit_n = d + 3
    bit_d = int(np.log2(bit_n))

    for _ in range(5 * 10 ** 6):
        cd = np.random.randint(0, d)
        ct = np.random.randint(0, 26)
        diff = update_score(bit, bit_n, bit_d, ccc, sss, ttt, cd, ct)
        if diff > 0:
            score += diff
            bitree_add(bit, bit_n, ttt[cd], cd + 2, -1)
            bitree_add(bit, bit_n, ct, cd + 2, 1)
            ttt[cd] = ct

    return ttt + 1


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 27736
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;

int main()
{
    ll n;
    ll ans=1e12;
    while(cin>>n)
    {
        ans=1e12;
        for(int i=1;i<=sqrt(n);i++)
        {
            if(n%i==0)
            {
                ll tmp=i-1+n/i-1;
                ans=min(ans,tmp);
            }
        }
        cout<<ans<<"\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

int a,b,c;
int main(){
  cin>>a>>b>>c;
  int t=a%b;
  bool flag=false;
  int memo=t;
  t+=b;
  while(t!=memo){
    if(c==t){
      flag=true;
      break;
    }
    t+=memo;
    t%=b;

  }
  if(flag)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

int main()
{
  long long n,i,j,ans=0;
  cin>>n;
  string s[n];
  priority_queue<char> que;
  priority_queue<string> que2;
  for(i=0;i<n;i++){
    cin>>s[i];
    for(j=0;j<10;j++){
      que.push(s[i][j]);
    }
    for(j=0;j<10;j++){
      s[i][j]=que.top();
      que.pop();
    }
  }
  for(i=0;i<n;i++){
    que2.push(s[i]);
  }
  for(i=0;i<n;i++){
    s[i]=que2.top();
    que2.pop();
  }
  j=0;
  for(i=1;i<n;i++){
    if(s[i]==s[i-1]){
      j++;
      if(i==n-1||s[i+1]!=s[i]){
        ans+=j*(j+1)/2;
        j=0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12788
N=int(input())
S=input()

alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

ans =''
for i in range(len(S)):
    tmp_str=S[i]
    
    index = alphabet.find(tmp_str)

    rpl_str=alphabet[index+N]

    ans+=rpl_str

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  string s;
  cin >> s;
  int tempf=0,tempe=s.size()-1;
  int ans=0;
  while(tempf<=tempe){
    if(s[tempf]==s[tempe]){
      tempf++;
      tempe--;
    }
    else if(s[tempf]=='x'){
      ans++;
      tempf++;
    }
    else if(s[tempe]=='x'){
      ans++;
      tempe--;
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 512
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[h,w]=i2()
s=[]
c=0
for i in range(h):
 s.append(input())
 c+=s[-1].count("#")
d=[[float("inf") for i in range(w)]for j in range(h)]
import sys
sys.setrecursionlimit(10000)

def dfs(x,y):
   global d
   d[x][y]=0
   q=[[x,y]]
   while len(q):
    v=q.pop(0)
    for i in [[0,1],[1,0],[0,-1],[-1,0]]:
      if 0<=v[0]+i[0]<h and 0<=v[1]+i[1]<w and d[v[0]+i[0]][v[1]+i[1]]==float("inf") and s[v[0]+i[0]][v[1]+i[1]]!="#":
         d[v[0]+i[0]][v[1]+i[1]]=min(d[v[0]+i[0]][v[1]+i[1]],d[v[0]][v[1]]+1)
         q.append([v[0]+i[0],v[1]+i[1]])
dfs(0,0)
if d[h-1][w-1]==float("inf"):
 print(-1)
else:
 print(h*w-c-d[h-1][w-1]-1)

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

int main() 
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    long long ans = pow(2, 29);
    for (int i = -100; i <= 100; i++) 
    {
        long long sum = 0;
        for (int j = 0; j < N; j++) 
        {
            sum += pow(a[j] - i, 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))

int main(){
  INT(k);
  vector<vector<int>> vvi(55);
  vector<int> v(k, -1);
  v[1] = 1;
  vvi[1].PB(1);
  REP(i, 1, 55){
    if (0 < v[0]){break;}
    int j = 0;
    while (j < SZ(vvi[i])){
      int n = (vvi[i][j] * 10) % k;
      if (v[n] < 0){
        v[n] = i;
        vvi[i].PB(n);
      }
      j++;
    }
    for(int ni: vvi[i]){
      int n = (ni + 1) % k;
      if (v[n] < 0){
        v[n] = i + 1;
        vvi[i + 1].PB(n);
      }
    }
  }
  printf("%d\n", v[0]);
  return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
 
using namespace std;
 
typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;
 
static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);
 
int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
 
    bool flag = false;

    int l = 0, r = s.size() - 7;

    do {
        int cnt = 1;
        bool fl = true;
        for(int i = 0; i < l; ++i) {
            if(cnt == 1 && s[i] == 'k') ++cnt;
            else if(cnt == 2 && s[i] == 'e') ++cnt;
            else if(cnt == 3 && s[i] == 'y') ++cnt;
            else if(cnt == 4 && s[i] == 'e') ++cnt;
            else if(cnt == 5 && s[i] == 'n') ++cnt;
            else if(cnt == 6 && s[i] == 'c') ++cnt;
            else if(cnt == 7 && s[i] == 'e') ++cnt;
        }

        for(int i = r; i < s.size(); ++i) {
            if(cnt == 1 && s[i] == 'k') ++cnt;
            else if(cnt == 2 && s[i] == 'e') ++cnt;
            else if(cnt == 3 && s[i] == 'y') ++cnt;
            else if(cnt == 4 && s[i] == 'e') ++cnt;
            else if(cnt == 5 && s[i] == 'n') ++cnt;
            else if(cnt == 6 && s[i] == 'c') ++cnt;
            else if(cnt == 7 && s[i] == 'e') ++cnt;
        }
        if(cnt == 8) flag = true;
        ++l; ++r;

    } while(r <= s.size());

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


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

template<typename Tp, typename Op>
class segtree{
    size_t length;
    Tp vid;
    Op fid;
    Tp (*action)(Op, Tp);
    Op (*composite)(Op, Op);
    Op *otree;
    Tp *value;

    void eval(size_t pos){
        if(otree[pos] == fid) return;        
        size_t ch = pos << 1;
        if(ch < length){
            otree[ch+0] = composite(otree[pos], otree[ch+0]);
            otree[ch+1] = composite(otree[pos], otree[ch+1]);
        }else{
            ch -= length;
            value[ch+0] = action(otree[pos], value[ch+0]);
            value[ch+1] = action(otree[pos], value[ch+1]);
        }
        otree[pos] = fid;
    }
public:
    segtree(size_t n, Tp e, Op id, Tp (*action_)(Op, Tp), Op (*composite_)(Op, Op))
    : length(n), vid(e), fid(id), action(action_), composite(composite_){
        otree = new Op[n];
        value = new Tp[n];
        for(size_t i=0;i<length;++i){ otree[i] = fid; value[i] = vid; }
    }
    void operate(Op f, size_t left, size_t right){
        left  += length;
        right += length;
        for(size_t pos = 1, b = sizeof(unsigned int) * CHAR_BIT - __builtin_clz(left ) - 1; b > 0; pos = (pos << 1) | (left  >> --b & 1)) eval(pos);
        for(size_t pos = 1, b = sizeof(unsigned int) * CHAR_BIT - __builtin_clz(right) - 1; b > 0; pos = (pos << 1) | (right >> --b & 1)) eval(pos);

        if(left  & 1){ value[left    - length] = action(f, value[left    - length]); left++; }
        if(right & 1){ value[right-1 - length] = action(f, value[right-1 - length]); }
        left >>= 1; right >>= 1;
        while(left < right){
            if(left  & 1){ otree[left   ] = composite(f, otree[left   ]); ++left; }
            if(right & 1){ otree[right-1] = composite(f, otree[right-1]); }
            left >>= 1; right >>= 1;
        }
    }
    void set(size_t i, Tp val){
        i += length;
        for(size_t pos = 1, b = sizeof(unsigned int) * CHAR_BIT - __builtin_clz(i) - 1; b > 0; pos = (pos << 1) | (i >> --b & 1)) eval(pos);
        value[i - length] = val;
    }
    Tp get(size_t i){
        i += length;
        for(size_t pos = 1, b = sizeof(unsigned int) * CHAR_BIT - __builtin_clz(i) - 1; b > 0; pos = (pos << 1) | (i >> --b & 1)) eval(pos);
        return value[i - length];
    }
};

using namespace std;
int main(){
    size_t n, q;
    cin >> n >> q;
    segtree<int, int> st{ n, (1U<<31) - 1, (1U<<31) - 1, [](int f, int x){ return f; }, [](int y, int x){ return y; }};
    while(q--){
        int tp, i, s, t, x;
        cin >> tp;
        if(tp == 0){
            cin >> s >> t >> x;
            st.operate(x, s, t+1);
        }else{
            cin >> i;
            cout << st.get(i) << endl;
        }
    }
}



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

using namespace std;

bool c(int x,int n,int k,vector<int> &w){
    int t;
    for(int i = 0 ; i < n ; i++,k--){
        t = 0;
        if(w[i] > x) return false;
        while(i < n && t + w[i] <= x){
            t += w[i++];
        }
        i--;
    }
    return (k >= 0);
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> w(n);
    for(int i = 0 ; i < n ; i++){
        cin >> w[i];
    }
    int l = 0, r = 1000000000;
    while(r-l > 0){
        int mid = (l + r) / 2;
        if(c(mid,n,k,w)){
            r = mid;
        }else{
            l = mid + 1;
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1532
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  string s,t;
  int check=0;
  lint ans=0,p1=0,p2=0;
  cin >> s >> t;
  int Ls=s.length(),Lt=t.length();
  set<lint> alf[26];
  rep(i,Ls) alf[s[i]-'a'].insert(i+1);
  rep(i,Lt) if(alf[t[i]-'a'].empty()) check=1;
  rep(i,26) alf[i].insert(INF);
  if(check==0){
    rep(i,Lt){
      p1=*alf[t[i]-'a'].upper_bound(p1);
      if(p1==INF){
        p1=0;
        p1=*alf[t[i]-'a'].upper_bound(p1);
      }
      if(p1>p2) ans+=p1-p2;
      else ans+=Ls-(p2-p1);
      p2=p1;
    }
  }
  if(check==1) cout << "-1" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 5200
#include <iostream>

using namespace std;

int main() {
    int x,a,b,c;
    int cnt = 0;
    cin >> a >> b >> c >> x;
    for(int i=0; i<=a; ++i) {
        for(int j=0; j<=b; ++j) {
            for(int k=0; k<=c; ++k) {
                int sum = i*500+j*100+k*50;
                if(sum == x) {
                    ++cnt;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
let () =
  let s = read_line () in
  let rec shrink a ss c =
    let sl = String.length ss in
    if  sl = 1 || (ss = String.make sl c) then a
    else
      let ns = String.init (sl - 1) (fun i -> if ss.[i] = c || ss.[i+1] = c then c else ss.[i]) in
      shrink (a+1) ns c in
  let tbl = ['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z'] in
  List.map (shrink 0 s) tbl |> List.sort compare |> List.hd |> string_of_int |> print_endline



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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vi v1(n);
  rep(i,n){
    if (i == 0){
      v1.at(i) = 0;
      continue;
    }
    v1.at(i) += v1.at(i-1) ;
    if (s.at(i-1) == 'W') v1.at(i)++;
  }
  vi v2(n);
  rep(i,n){
    if (i == 0){
      v2.at(i) = 0;
      continue;
    }
    v2.at(i) += v2.at(i-1);
    if (s.at(n-i) == 'E') v2.at(i)++;
  }
  vi v3(n);
  rep(i,n){
    v3.at(i) = v1.at(i) + v2.at(n-1-i);
  }
  sort(v3.begin(),v3.end());
  cout << v3.at(0) << endl;
  return 0;
}


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

#define ll int64
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
     
using namespace std;

const int maxn=110000;
int n,h[maxn],f[maxn],k;
int main(){
    IO;    
    scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	memset(f,0x3f,sizeof(f)),f[1]=0;
	for(int i=2;i<=n;i++) for(int j=1;j<i&&j<=k;j++) f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
	printf("%d",f[n]);
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int maximum(int a[],int s){
int n,i, ans,mini;
	ans=-1000000000;
	mini=1000000000;
	for(i=1;i<s;i++){
		mini=min(mini,a[i-1]);
		n=a[i]-mini;
		ans=max(ans,n);
	}
	return ans;
}

main(){
	int n, ans;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	ans=maximum(a,n);
	printf("%d\n",ans);
	return 0;
}



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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;


ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

string mat[50];

int dist[50][50];

int n,m;
bool on(int x, int y)
{
  return x >= 0 && x < n && y >= 0 && y < m && dist[x][y] == -1 && mat[x][y] == '.';
}

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


int bfs(int x, int y, int a, int b)
{
  MSET(dist, -1);
  queue<pair<int,int>>q;
  q.push({x,y});
  dist[x][y] = 0;
  while(q.size())
  {
    auto at = q.front();
    q.pop();
    for(int i = 0 ; i < 4; i++)
    {
      int nx = at.first + dx[i];
      int ny = at.second + dy[i];
      if(on(nx, ny))
      {
        dist[nx][ny] = dist[at.first][at.second] + 1;
        q.push({nx,ny});
      }
    }
  }
  return dist[a][b];
}

int main()
{
  ios::sync_with_stdio(0);
  cin >> n >> m;
  
  for(int i = 0; i < n ; i++)
    cin >> mat[i];


  int ans = 0;
  for(int i = 0; i < n ; i++)
  {
    for(int j = 0; j < m; j++)
    {
      for(int k = 0; k < n; k++)
      {
        for(int l = 0 ; l < m; l++)
        {
          if(i == k && j == l)
            continue;
          if(mat[i][j] == '#' || mat[k][l] == '#' )
            continue;
          ans = max(ans, bfs(i,j,k,l));
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll x; std::cin >> x;
  ll ans = 0;
  ans = (x / 11) * 2, x %= 11;
  if (x > 0) {
    if (x < 7) ans++;
    else ans += 2;
  }
  std::cout << ans << "\n";
}


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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x; cin >> x;
    int ans;
    while(true){
        if (x == 1) continue;
        bool isprime = true;
        rep2(i, 2, sqrt(x)+1){
            if (x % i == 0) isprime = false;
        }
        if (isprime){
            ans = x;
            break;
        }
        x++;
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
  
  long long A,B,X;
  cin >> A >> B >> X;

  long long num = X/B;
  if(num >= 1) {
    cout << (A*(B-1)/B) << endl;
  }else {
    cout << (A*X/B) - A*(X/B) << endl;
  }

}


Measured memory_bytes: 3588
import math

n,m = map(int,input().split())

if abs(n-m) >= 2:
  print(0)
  exit()
  
if n == m:
  print((math.factorial(n) * math.factorial(m) * 2)%(10**9 + 7))
  
elif n+1 == m:
  print((math.factorial(m) * math.factorial(n))%(10**9 + 7))
elif m+1 == n:
  print((math.factorial(n) * math.factorial(m))%(10**9 + 7))

Measured memory_bytes: 5192
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"i=lambda:map(int,input().split());n,m=i();a=[0]+[1]*n;b=[0,1]+[0]*n\n"
"for _ in[0]*m:x,y=i();a[x]-=1;a[y]+=1;b[y]|=b[x];b[x]&=a[x]>0\n"
"print(sum(b))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 5696
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000007)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;


ll sum[200010];

int main(void){
    int X,Y;
    cin>>X>>Y;
    for(int i=0;i<=50;i++){
        for(int j=0;j<=50;j++){
            if(i+j==X && 2*i+4*j==Y){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3636
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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

#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        A: u32,
        B: u32,
        K: u32,
    }

    let mut count = 0;

    for divisor in (1..(std::cmp::min(A,B)+1)).rev() { 
        if A % divisor == 0 && B % divisor == 0 {
            count += 1;
            if count == K {
                println!("{}", divisor);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
typedef pair<double, string> P;

bool solve(){
	int n;
	string name;
	int p, a, b, c, d, e, f, s, m;
	P data[50];
	
	cin >> n;
	if( n == 0 ) return false;
	for( int i = 0; i < n; i++ ){
		char buf[25];
		name = buf;
		cin >> name >> p >> a >> b >> c >> d >> e >> f >> s >> m;
		double income = s * f * m - p;
		double timer = a + b + c + m * (d + e);
		double effect = income / timer;
		data[i].first = -effect;	//Swap Order Technic.
		data[i].second = name;
	}
	sort(data, data + n);
	
	for( int i = 0; i < n; i++ ){
		cout << data[i].second << endl;
	}
}

int main(){
	while(1){
		if( !solve() )
			break;
		else
			cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
N = int(input())
eat = list(map(int, input().split(" ")))
satisfication = list(map(int, input().split(" ")))
add_satisfication = list(map(int, input().split(" ")))

total = 0
previous_eat = ""
for i in eat:
  total = total + satisfication[i-1]
  if previous_eat == i-1:
    total = total + add_satisfication[previous_eat-1]
  previous_eat = i

print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,K;
ll H[200010];
int main(){
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        cin>>H[i];
    }
    sort(H,H+N,greater<ll>());
    ll ans=0;
    for(ll i=K;i<N;i++){
        ans+=H[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X,K,D = map(int, readline().split())

Y = abs(X)
n = Y // D 
s = Y % D

N = K-n
if N < 0:
    print(Y-K*D)
    sys.exit()
    
if N % 2 == 0:
    print(s)
else:
    print(abs(D)-s)

Measured memory_bytes: 9236
using System;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split();
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);

        if (a * b % 2 == 0) WriteLine("No");
        else WriteLine("Yes");
    }
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N;
    cin >> N;
    int64_t sum = 0L;
    for (int i = 1; i <= N ; ++i) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3588
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

mod rolling_hash {
    const MASK30: u64 = (1 << 30) - 1;
    const MASK31: u64 = (1 << 31) - 1;
    const MOD: u64 = (1 << 61) - 1;
    const MASK61: u64 = (1 << 61) - 1;
    const BASE: u64 = 1_000_000_000 + 9;
    pub struct RollingHash {
        h: Vec<u64>,
        p: Vec<u64>,
    }
    impl RollingHash {
        pub fn new(s: &[u64]) -> Self {
            let n = s.len();
            let mut h = vec![0; n + 1];
            let mut p = vec![0; n + 1];
            p[0] = 1;
            for i in 0..n {
                h[i + 1] = mul(h[i], BASE) + s[i];
                p[i + 1] = mul(p[i], BASE);
            }
            Self { h, p }
        }
        pub fn get(&self, range: std::ops::Range<usize>) -> u64 {
            let l = range.start;
            let r = range.end;
            let mut res = self.h[r] + MOD - mul(self.h[l], self.p[r - l]);
            if res >= MOD {
                res -= MOD;
            }
            res
        }
    }
    fn mul(a: u64, b: u64) -> u64 {
        let au = a >> 31;
        let ad = a & MASK31;
        let bu = b >> 31;
        let bd = b & MASK31;
        let mid = ad * bu + au * bd;
        let midu = mid >> 30;
        let midd = mid & MASK30;
        calc_mod(au * bu * 2 + midu + (midd << 31) + ad * bd)
    }
    fn calc_mod(x: u64) -> u64 {
        let xu = x >> 61;
        let xd = x & MASK61;
        let mut res = xu + xd;
        if res >= MOD {
            res -= MOD;
        }
        res
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    use rolling_hash::RollingHash;

    let n: usize = rd.get();
    let s: String = rd.get();
    let t = s.chars().map(|c| c as u64).collect::<Vec<_>>();
    let rh = RollingHash::new(&t);
    let mut ans = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            let mut ok = 0;
            let mut ng = std::cmp::min(j - i, n - j) + 1;
            while ng - ok > 1 {
                let m = (ng + ok) / 2;
                if rh.get(i..(i + m)) == rh.get(j..(j + m)) {
                    ok = m;
                } else {
                    ng = m;
                }
            }
            ans = std::cmp::max(ans, ok);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2288
alphabet=list("abcdefghijklmnopqrstuvwxyz")
bun=""
while 1:
    try:
        string=input().lower()
        bun+=str(string)
    except:
        break
    
for i in range(len(alphabet)):
    alp=alphabet[i]
    print(alp,":",bun.count(alp))


Measured memory_bytes: 5572
n = int(input())
c = [[0] * 10 for _ in range(10)]
for k in range(1, n+1):
    i = int(str(k)[0])
    j = k % 10
    c[i][j] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)


Measured memory_bytes: 40300
/*
    Problem 3
    https://atcoder.jp/contests/abc122/tasks/abc122_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<char> atcg {'A', 'T', 'C', 'G'};
/* function */
void solve1() {
    string S;
    cin >> S;
    int lenATCG = 0;
    int r = 0;
    for (int l = 0; l < S.size(); l++) {
        while (r < S.size() && count(atcg.begin(), atcg.end(), S[r]))
            r++;
        lenATCG = max(lenATCG, r - l);
        l = r;
        r++;
    }
    cout << lenATCG << '\n';
}

void solve2() {
    string S;
    cin >> S;
    int lenATCG = 0;
    for (int i = 0; i < S.size(); i++) {
        for (int j = i; j < S.size(); j++) {
            bool isATCG = true;
            for (int k = i; k <= j; k++)
                if (count(atcg.begin(), atcg.end(), S[k]) == 0) isATCG = false;
            if (isATCG) lenATCG = max(lenATCG, j - i + 1);
        }
    }
    cout << lenATCG << '\n';
}
/* main */
int main(){
    solve2();
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define INF 1000000007
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    long long a[114514];
    vector<long long> k;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i-1]==a[i]){
            k.push_back(a[i]);
            i++;
        }
    }
    long long ans=0;
    if(k.size()>=2)ans=k[k.size()-1]*k[k.size()-2];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	string w;
	string t;
	cin>>w;
	int i;
	for(i=0;i<w.size();i++) {
		if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
	}
	int o=0;
	cin>>t;
	while(t!="END_OF_TEXT"){
    for(i=0;i<t.size();i++){
		if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
	}
    if(w==t) o++;
    cin>>t;
	}
	cout<< o <<endl;
	return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>

int main()
{
    int a, b;

    scanf("%d %d", &a, &b);

    if (a >= 13) {
        printf("%d\n", b);
    }
    else if (a >= 6) {
        printf("%d\n", b / 2);
    }
    else {
        printf("0\n");
    }

    return 0;
}


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

int main() {
  int n, left, right;
  vector<int> p;

  while (cin >> n >> left >> right, n) {
    p.resize(n);
    rep (i, n) cin >> p[i];

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());

    int n_passed = 0;
    int max_gap = 0;

    rep (i, n-1) {
      // cout << "i: " << i << endl;
      if (! (left <= i+1 && i+1 <= right) ) continue;
      // cout << "passed " << i+1 << " students (lowest: " << left << ", highest: " << right << ")" << endl;
      // cout << "current gap: " << p[i] - p[i+1] << endl;

      if (max_gap <= p[i] - p[i+1]) {
        // cout << "new gap: " << p[i] - p[i+1] << endl;
        // cout << left << ", " << i+1 << ", " << right << endl;
        // cout << "update" << endl;
        n_passed = i+1;
        max_gap = p[i] - p[i+1];
      }
    }
    cout << n_passed << endl;
  }
  return 0;
}

Measured memory_bytes: 3080