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

#if __has_include("Macro/MACRO_DEBUG.h")
#include "Macro/MACRO_DEBUG.h"
#endif

#ifndef DHRUV_GHEEWALA
    #define p(str) 42
    #define o(str) 108
    #define fundri 137
    #define d(...) 1729
#endif

typedef unsigned int ui;
typedef long long int ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

#define nl cout<<'\n'
#define pb push_back
#define pop pop_back
#define eb emplace_back
#define all(s) s.begin(),s.end()
#define ff first
#define ss second

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define iter(cont,it) for(auto it=cont.begin();it!=cont.end();it++)
#define riter(cont,it) for(auto it=cont.rbegin();it!=cont.rend();it++)

#define fast ios_base::sync_with_stdio(0)
#define test int t=0;cin>>t;while(t--)
#define fill(a,b) memset(a,b,sizeof(a))

template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T>inline T mul(T a,T b,T mod){return ((a%mod)*(b%mod))%mod;}
template<typename T>inline T sum(T a,T b,T mod){return ((a%mod)+(b%mod))%mod;}
template<typename T>inline ll simple_xor(T n){int rem=n%4;switch(rem){case 0:return n;case 1:return 1;case 2:return n+1;return 0;}}
template<typename T>inline ll range_xor(T l,T r){return simple_xor(l-1)^simple_xor(r);}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a){for(auto &x : a)in>>x;return in;}
template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a){in>>a.ff>>a.ss;return in;}
template<typename T>inline void MIN(T& x,T y){if(x>y)x=y;}
template<typename T>inline void MAX(T& x,T y){if(x<y)x=y;}

pi solve(vi &a,int l,int r)
{
    if(l<r)
    {
        int m=(l+r)/2;
        pi left=solve(a,l,m);
        pi right=solve(a,m+1,r);
        return {min(left.ff,right.ff),max(left.ss,right.ss)};
    }
    return {a[l],a[l]};
}

int main()
{
    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif
    
    fast;
    int n;
    cin>>n;
    
    vector<pair<string, int>> a(n);
    cin>>a;
    d(a);

    loop(i,1,n)a[i].ss=a[i].ss+a[i-1].ss;
    int max=INT_MIN;
    rep(i,n)MAX(max,a[i].ss);

    string x;
    cin>>x;
    int cur=0;

    rep(i,n)
    {
        if(a[i].ff==x)
            cur=a[i].ss;
    }
    cout<<max-cur,nl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    int h, w; cin >> h >> w;
    int n; cin >> n;
    vint(a, n);

    int g[h][w]={};

    int ph=0, pw=0;
    int dh=0, dw=1;
    rep(i, n) {rep(j, a[i]){
        g[ph][pw] = i+1;
        if(dw>0){
            if(pw + dw >= w || g[ph][pw+dw]>0){
                dw = 0;
                dh = 1;
            }
        }else if(dw<0){
            if(pw + dw < 0 || g[ph][pw+dw]>0){
                dw = 0;
                dh = -1;
            }  
        }else if(dh>0){
            if(ph + dh >= h || g[ph+dh][pw]>0){
                dw = -1;
                dh = 0;
            }
        }else if(dh<0){
            if(ph + dh < 0 || g[ph+dh][pw]>0){
                dw = 1;
                dh = 0;
            }  
        }
        pw += dw;
        ph += dh;
    }
    // rep(i, h){
    //     rep(j, w) cout << g[i][j] << " ";
    //     pr("");
    // }
    // pr("");
    }
    rep(i, h){
        rep(j, w) cout << g[i][j] << " ";
        pr("");
    }
    return 0;}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>

using namespace std;

int calcMaxDist(const string &s, int pos, bool done[]) {
  char c = s[pos];

  int last_pos = pos;
  int max_dist = 0;
  for (int i = pos + 1; i < s.size(); i++) {
    if (s[i] == c) {
      done[i] = true;
      max_dist = max(max_dist, i - last_pos);
      last_pos = i;
    }
  }
  return max(max(pos, (int)s.size() - last_pos - 1), max_dist - 1);
}

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

  bool* done = new bool[s.size()]();
  int min_count = s.size() - 1;
  for (int i = 0; i < s.size(); i++) {
    if (done[i]) continue;
    min_count = min(min_count, calcMaxDist(s, i, done));
  }
  delete[] done;
  cout << min_count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    if(2 * k >= (b - a + 1))
    {
        for(int i = a; i <= b; i++)
        {
            cout << i << endl;
        }
    }
    else
    {
        for(int i = a; i < a + k; i++)
        {
            cout << i << endl;
        }

        for(int i = b - k + 1; i <= b; i++)
        {
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {

    int v1,v2,v3;
    int tmp;

    cin >> v1 >> v2 >> v3;

    if(v1 > v2){
    tmp = v1;
    v1 = v2;
    v2 = tmp;
    }
    
    if(v2 > v3){
    tmp = v3;
    v3 = v2;
    v2 = tmp;
    }

    if(v1 > v2){
    tmp = v1;
    v1 = v2;
    v2 = tmp;
    }

    printf("%d %d %d\n",v1,v2,v3);
	return 0;
}


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

vector<LL> InputVec(LL size) {
	vector<LL> vec((size_t)size);
	REP(i, size) {
		cin >> vec[(size_t)i];
	}
	return vec;
}

vector<LL> tbl;

void chmin(LL& a, LL b) {
	a = min(a, b);
}

int main()
{
	LL N, K;
	cin >> N >> K;
	vector<LL> hs = InputVec(N);
	vector<LL> tbl(N, 1000000000);
	tbl[0] = 0;

	REP(i, N) {
		FOR(j, max(i - K, 0LL), i) {
			chmin(tbl[i], tbl[j] + abs(hs[j] - hs[i]));
		}
	}

	cout << tbl[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**8)
N = int(input())
X = input()
if X == '0':
    for _ in range(N):
        print(1)
        exit()

mem = [None] * (200005)
mem[0] = 0
def f(n):
    if mem[n] is not None: return mem[n]
    c = bin(n).count('1')
    r = 1 + f(n%c)
    mem[n] = r
    return r

for i in range(200005):
    f(i)

cnt = X.count('1')
a,b = cnt+1, cnt-1

ans = [None] * N

n = 0
for c in X:
    n *= 2
    n += int(c)
    n %= a
for i,c in reversed(list(enumerate(X))):
    if c=='1': continue
    ans[i] = mem[(n+pow(2,N-i-1,a))%a] + 1

if b:
    n = 0
    for c in X:
        n *= 2
        n += int(c)
        n %= b
    for i,c in reversed(list(enumerate(X))):
        if c=='0': continue
        ans[i] = mem[(n-pow(2,N-i-1,b))%b] + 1
else:
    for i in range(N):
        if ans[i] is None:
            ans[i] = 0

print(*ans, sep='\n')

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

int main(void){
    int A,B,C,X,cnt=0;
    cin>>A>>B>>C>>X;
    int Cs=50*C;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            int a=X-(i*500+j*100);
            if(a<=Cs&&a>=0)
                cnt++;
        }
    }

    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
q = int(input())
for _ in range(q):
	op = input().split()
	a, b = int(op[1]), int(op[2])
	b+=1
	if op[0] == "print":
		print(s[a:b])
	elif op[0] == "reverse":
		s = s[:a] + "".join(list(reversed(s[a:b]))) + s[b:]
	else:
		s = s[:a] + op[3] + s[b:]


Measured memory_bytes: 5616
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;

const int INF = 1e9 + 5;

class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

template <typename T>
T abs(T x){
	if(x<0)	return -x;
	else return x;
}

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){ 
    visited[u] = true;
    for(int i=0; i<g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited); 
        }
    }
} 
  
void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false); 
    for(int u=0; u<V; u++) 
        if(!visited[u]) 
            DFSVisit(u, adj, visited);
}


void solve(){
	
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++)
		cin >> a[i];
	int ans = 0;
	for(int i=1; i<n-1; i++){
		if( (a[i-1] > a[i] && a[i] > a[i+1]) || (a[i-1] < a[i] && a[i] < a[i+1]) )
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
struct edge{int to,cap,rev;};
vector<int> nex[114514];
int mi[114514],ma[114514],st;
int col[114514];
int used[114514];
int ans[114514];
int used2[114514];
bool fl = true;
pair<int,int> dfs(int s){
	used[s]=1;
	for(int i=0;i<nex[s].size();i++){
		int nx = nex[s][i];
		if(used[nx]==0){
			pair<int,int> P = dfs(nx);
			int lef = max(P.first-1,0LL);
			int rig = P.second+1;
			ma[s] = min(ma[s],rig);
			mi[s] = max(mi[s],lef);
		}
	}
	//cout<<2<<endl;
	return mp(mi[s],ma[s]);
}
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
		nex[y].pb(x);
	}
	for(int i=1;i<=n;i++){
		mi[i]=0;
		ma[i]=inf;
	}
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int v,p;
		cin>>v>>p;
		mi[v] = p;
		ma[v] = p;
		col[v] = 2 - p%2;
		if(st == 0)st = v;
	}
	queue<int> que;
	que.push(st);
	while(!que.empty()){
		int idx = que.front(); que.pop();
		for(int i=0;i<nex[idx].size();i++){
			int nx = nex[idx][i];
			if( col[nx] == 0){
				col[nx] = 3 -col[idx];
				que.push(nx);
			}
			else if(col[idx] + col[nx] != 3){
				cout<<"No"<<endl;
				return 0;
			}
		}
		//cout<<1<<endl;
	}
	pair<int,int> tmp = dfs(st);
	if(fl == false){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<=n;i++){
		ans[i]=-1;
	}
	while(!que.empty()){que.pop();}
	que.push(st);
	if(mi[st]!=ma[st]){
		cout<<"No"<<endl;
		return 0;
	}
	ans[st]=mi[st];
	used2[st]=1;
	while(!que.empty()){
		int idx = que.front(); que.pop();
		for(int i=0;i<nex[idx].size();i++){
			int nx = nex[idx][i];
			if(used2[nx] == 0){
				used2[nx]=1;
				if(mi[nx] <= ans[idx]-1 && ans[idx]-1 <= ma[nx]){
					ans[nx] = ans[idx]-1;
					//cout<<mi[nx]<<" "<<ans[nx]<<" "<<ma[nx]<<endl;
				}
				else if(mi[nx] <= ans[idx]+1 && ans[idx]+1 <= ma[nx]){
					ans[nx] = ans[idx]+1;
					//cout<<mi[nx]<<" "<<ans[nx]<<" "<<ma[nx]<<endl;
				}
				if(ans[nx] == -1){
					cout<<"No"<<endl;
					return 0;
				}
				que.push(nx);
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 16512
# coding: utf-8
from bisect import bisect_left, bisect_right
def eratosthenes(N):
    # 素数判定
    flag = True
    for i in range(2, int(N**0.5) + 1):
        if N % i == 0:
            flag = False
            break
    return flag

def make_prime_nums(N):
    # Nまでの素数のリストを作成
    prime_tf = [True for _ in range(N+1)]
    prime_tf[0] = False
    prime_tf[1] = False
    for i in range(N+1):
        if prime_tf[i]:
            if eratosthenes(i):
                for j in range(i*2, N+1, i):
                    prime_tf[j] = False
    primes = [i for i in range(N+1) if prime_tf[i]]
    return primes

def make_prime_new(L):
    new_primes = []
    for l in L:
        tmp = (l+1) // 2
        if eratosthenes(tmp):
            new_primes.append(l)
    return new_primes

primes = make_prime_nums(10**5)
primes = make_prime_new(primes)[1:]
# print(primes)
N = int(input())
for _ in range(N):
    l, r = map(int, input().split())
    r += 1
    l_idx = bisect_left(primes, l)
    r_idx = bisect_left(primes, r)
    if l == r and l_idx == r_idx and l == primes[l_idx]:
        print(1)
    else:
        print(r_idx - l_idx)


Measured memory_bytes: 58016
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int A,B;cin>>A>>B;
    if(A<=8&&B<=8) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
}


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

int main(){
	int n, i, j;
	int cards[4][13]={0};
	char suit; //?????????
	int num;
	
	cin >> n;
	
		for(i = 0; i < n; i++){
			cin >> suit >> num;

			if(suit == 'S'){
				cards[0][num - 1]++;
			}else if(suit == 'H'){
				cards[1][num - 1]++;
			}else if(suit == 'C'){
				cards[2][num - 1]++;
			}else{
				cards[3][num - 1]++;
		}
	}

	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			if(cards[i][j] == 0){
				if(i == 0){
					cout << 'S' << " " << j + 1 << endl;
				}else if(i == 1){
					cout << 'H' << " " << j + 1 << endl;
				}else if(i == 2){
					cout << 'C' << " " << j + 1 << endl;
				}else{
					cout << 'D' << " " << j + 1 << endl;
				}
			}
		}
	}
 	return 0;
}

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

using namespace std;
const int kMod = 1e9 + 7;

int Pow(int b, int e) {
  int res = 1;
  while (e) {
    if (e % 2) res = 1LL * res * b % kMod;
    b = 1LL * b * b % kMod;
    e /= 2;
  }
  return res;
}
int Inv(int x) {
  return Pow(x, kMod - 2);
}
int Compute(int n) {
  return 1LL * (Pow(10, n) - 1) * Inv(9) % kMod;
}

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

  vector<pair<int, int>> cons;
  vector<int> all = {0, n};
  for (int i = 0; i < q; ++i) {
    int a, b; cin >> a >> b;
    cons.emplace_back(a - 1, b);
    all.push_back(a - 1);
    all.push_back(b);
  }
  
  sort(all.begin(), all.end());
  all.erase(unique(all.begin(), all.end()), all.end());
  auto get = [&](int x) {
    auto it = lower_bound(all.begin(), all.end(), x);
    assert(it != all.end() && *it == x);
    return it - all.begin();
  };

  for (int i = 0; i < q; ++i) {
    cons[i].first = get(cons[i].first);
    cons[i].second = get(cons[i].second);
  }

  vector<bool> vis(all.size(), 0);
  int msk = 0;
  function<void(int)> dfs = [&](int node) {
    vis[node] = true;
    msk |= (1 << node);
    for (auto p : cons) {
      if (p.first == node && !vis[p.second])
        dfs(p.second);
      if (p.second == node && !vis[p.first])
        dfs(p.first);
    }
  };
  
  vector<int> delta(all.size(), 0);
  for (int i = 1; i < (int)all.size(); ++i) {
    delta[i] = Compute(all[i] - all[i - 1]);
  }
  
  int coef = 1;
  vector<int> masks;
  for (int i = 0; i < (int)all.size(); ++i) {
    if (!vis[i]) {
      msk = 0;
      dfs(i);
      if (i != 0 && msk == (1 << i)) {
        coef = 1LL * coef * Pow(10, all[i] - all[i - 1]) % kMod;
      } else {
        masks.push_back(msk);
      }
    }
  }

  n = masks.size();
  vector<int> add(1 << n, 0), mskmem(1 << n, 0);
  for (int s = 0; s < (1 << n); ++s) {
    int msk = 0;
    for (int i = 0; i < n; ++i) {
      if (!(s & (1 << i))) continue;
      msk |= masks[i]; 
    }
    mskmem[s] = msk;

    int coef = 1;
    for (int i = 0; i < (int)all.size(); ++i) {
      if (!(msk & (1 << i))) continue;
      if (i == 0) continue;

      int now = delta[i];
      if (msk & (1 << (i - 1))) now += 1;
      coef = 1LL * coef * now % kMod;
    }
    add[s] = coef;
  }
  /*  
  cerr << "delta: ";
  for (auto x : delta) 
    cerr << x << " "; 
  cerr << endl;

  for (int i = 0; i < n; ++i) {
    cerr << "set " << i << ": ";
    for (int j = 0; j < (int)all.size(); ++j) {
      if (masks[i] & (1 << j))
        cerr << all[j] << " ";
    }
    cerr << endl;
  }
  
  for (int i = 0; i < (1 << n); ++i) {
    cerr << add[i] << " ";
  }
  cerr << endl;
  */
  vector<int> dp(1 << n, 0);
  dp[0] = 1;
  for (int dig = 0; dig <= 8; ++dig) {
    for (int s = (1 << n) - 1; s >= 0; --s) {
      for (int sub = s; sub > 0; sub = ((sub - 1) & s)) {
        int msk = mskmem[sub];
        if ((msk & 1) != (dig == 0)) continue;
        dp[s] = (dp[s] + 1LL * dp[sub ^ s] * add[sub]) % kMod;
      }
    }
  }

  int ret = 1LL * dp[(1 << n) - 1] * coef % kMod;
  if (ret < 0) ret += kMod;
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 1152
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    M,m = max(a),min(a)
    if M-m > 1:
        print("No")
        return
    if M == m:
        if m == n-1:
            print("Yes")
        elif 2*m <= n:
            print("Yes")
        else:
            print("No")
        return
    b = a.count(m)
    a = a.count(M)
    k = M-b
    if b+1 <= M and 2*k <= a:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 53136
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const auto& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = array<lint, 3>;
  static T op(const T& a, const T& b) { return {min(a[0], b[0]), max(a[1], b[1]), a[2] + b[2]}; }
  static constexpr T e() { return {numeric_limits<lint>::max(), numeric_limits<lint>::min(), 0}; }
  static T mk(lint a) { return {a, a, a}; }
};

template<class M> struct ST {
  using T = typename M::T;
  int n;
  V<T> t;

  ST(int n) : n(n) {
    t.assign(2 * n, M::e());
  }

  void build() {
    for (int i = n - 1; i; i--) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }

  T get(int l, int r) {
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) { 
      if (l & 1) resl = M::op(resl, t[l++]); 
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  T get(int i) { return t[i + n]; };

  void set(int i, const T& a) {
    for (t[i += n] = a; i >>= 1;) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  V<> a(2 * n); for (int i = 0; i < 2 * n; i++) cin >> a[i];
  V<> b(2 * n); for (int i = 0; i < 2 * n; i++) cin >> b[i];
  lint sa = accumulate(a.begin(), a.end(), 0LL);
  ST<M> pos(2 * n), neg(2 * n);
  int cp = 0;
  for (int i = 1; i < 2 * n - 1; i++) (b[i] - a[i] >= 0 ? cp++, pos : neg).t[i + 2 * n] = M::mk(b[i] - a[i]);
  pos.build(), neg.build();
  for (int iq = 0; iq < q; iq++) {
    int p, x, y; cin >> p >> x >> y, p--;
    if (p and p < 2 * n - 1) {
      if (y - x >= 0) {
        pos.set(p, M::mk(y - x));
        neg.set(p, M::e());
        cp += (b[p] - a[p] < 0);
      } else {
        neg.set(p, M::mk(y - x));
        pos.set(p, M::e());
        cp -= (b[p] - a[p] >= 0);
      }
    }
    sa += x - a[p];
    a[p] = x, b[p] = y;
    lint s = pos.get(1, 2 * n - 1)[2];
    if (cp & 1) {
      s -= min(pos.get(1, 2 * n - 1)[0], -neg.get(1, 2 * n - 1)[1]);
    }
    cout << sa + s << '\n';
  }
}

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

int main() {
    string s;
    cin >> s;
    int s_combo = 0;
    int erase = 0;
    rep(i,s.size()) { 
        if (s[i] == 'S') {
            s_combo++;
        } 
        if (s[i] == 'T' && s_combo > 0) {
            erase++;
            s_combo--;
        }
    }
    int ans = s.size() - 2*erase;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int mon(int x) {
    if (1 <= x && x <= 12) return 0;
    if (12 < x) return -1;
    if (x == 0) return -1;
}
signed main() {
    string s;
    cin >> s;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    if (mon(a) == 0 && mon(b) == 0) {
        cout << "AMBIGUOUS" << endl;
    }
    if (mon(a) == -1 && mon(b) == 0) {
        cout << "YYMM" << endl;
    }
    if (mon(a) == 0 && mon(b) == -1) {
        cout << "MMYY" << endl;
    }
    if (mon(a) == -1 && mon(b) == -1) {
        cout << "NA" << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 256
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		int n = sc.nextInt();
		int k = sc.nextInt();

			System.out.println(k==1?0:n-k);

 
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){ 
  string S;
  cin >> S;
  int c=0;
  int m=0;
  rep(i,3){
    if(S[i]=='R') c++;
    else {
      m = max(m,c);
      c = 0;
    }
  }
  m = max(m,c);
  cout << m << endl;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int n;
long long dist[205][205];

void warshallfloyd(){
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(dist[i][k] == -1) continue;
        if(dist[k][j] == -1) continue;
        if(dist[i][j] == -1) {
          dist[i][j] = dist[i][k] + dist[k][j];
        } else {
          if(dist[i][j] > dist[i][k] + dist[k][j]){
            dist[i][j] = dist[i][k] + dist[k][j];
          }
        }
      }
    }
  }
}

long long ans;
long long r[205];
int nx[205];

int m,rr;

int main(){
  cin>>n>>m>>rr;
  for(int i=0;i<rr;i++){
    cin>>r[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)dist[i][j] = -1;
  }
  for(int i=0;i<n;i++)dist[i][i] = 0;
  for(int i=0;i<m;i++){
    long long a,b,c;cin>>a>>b>>c;
    a--;b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }

  warshallfloyd();
  /*for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<dist[i][j]<<" ";
    }cout<<endl;
  }*/

  for(int i=0;i<rr;i++)nx[i] = i;

  ans = -1;

  do{
    //for(int i=0;i<rr;i++)cout<<nx[i]<<" ";cout<<endl;
    long long tmp=0;
    for(int i=1;i<rr;i++){
      tmp += dist[r[nx[i]]-1][r[nx[i-1]]-1];
    }
    //cout<<tmp<<endl;
    if(ans == -1) {
      ans = tmp;
    } else {
      if(tmp < ans ) ans = tmp;
    }
  }while(next_permutation(nx,nx+rr));




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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    ll n,q;
    cin >> n >> q;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(_,q){
        ll x;
        cin >> x;
        ll left, right;
        left = 0; right = 0;
        ll s = a[0];
        ll ans = 0;

        while(right < n){
            if(s <= x){
                right++;
                s += a[right];
            }else{
                ans += (right - left);
                s -= a[left];
                left++;
                if(left > right){
                    right = left;
                    s = a[left];
                }
            }
        }
        ans += (n-left) * (n-left+1) / 2;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3624
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  ss <- replicateM 6 $ readLn :: IO [Int]
  print $ solve ss

solve ss = 5 + groups - 1 
  where
    n = head ss
    as = tail ss
    mn = minimum as 
    groups = n `div` mn + if n `mod` mn == 0 then 0 else 1

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

int main(){
  int N,p[20];
  cin >> N ;
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  
  int ans =0;
  
  for(int i=0;i<N;i++){
    if(i==0||i==N-1)continue;
 
     if( p[i-1] < p[i] && p[i] < p[i+1]){
      ans++;
    }
    if(p[i+1] < p[i] && p[i] < p[i-1]){
      ans++;
    }
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ.Volume5
{
    public class Questionnaire
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int n = int.Parse(input[0]);
                int m = int.Parse(input[1]);
                if (n == 0 && m == 0) { break; }

                var result = new Dictionary<int, int>();
                for (int i = 1; i <= m; i++) { result.Add(i, 0); }
                for (int i = 0; i < n; i++)
                {
                    input = Console.ReadLine().Split(' ');
                    for (int j = 1; j <= m; j++)
                    {
                        if (input[j - 1] == "1") { result[j]++; }
                    }
                }
                string output = "";
                foreach (var r in result.OrderByDescending(x => x.Value).ThenBy(y => y.Key))
                {
                    output += r.Key + " ";
                }
                output = output.Trim();
                Console.WriteLine(output);
            }
            return 0;
        }
    }
}

Measured memory_bytes: 10320
N, M = gets.chomp.split.map(&:to_i)
wk = 0
kr = 0

if N < M then
  wk = N
  kr = M
elsif N > M then
  wk = M
  kr = N
else
  wk = N
  kr = N
end

ans = ""
while kr > 0 do
  ans = ans + wk.to_s
  kr = kr - 1
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
std::mt19937 mt{std::random_device{}()};
struct CostGraph
{
    using T = ll;
    CostGraph(const std::size_t v) : V{v}, edge(v), rev_edge(v) {}
    struct Edge
    {
        Edge(const std::size_t from, const std::size_t to, const T cost) : from{from}, to{to}, cost{cost} {}
        const std::size_t from, to;
        const T cost;
        bool operator<(const Edge& e) const { return cost != e.cost ? cost < e.cost : to < e.to; }
    };
    void addEdge(const std::size_t from, const std::size_t to, const T cost) { edge[from].push_back(Edge{from, to, cost}), rev_edge[to].push_back(Edge(to, from, cost)); }
    const std::size_t V;
    std::vector<std::vector<Edge>> edge;
    std::vector<std::vector<Edge>> rev_edge;
};
std::vector<CostGraph::T> Dijkstra(const CostGraph& g, const std::size_t s)
{
    using T = CostGraph::T;
    std::vector<T> d(g.V, INF<T>());
    using P = std::pair<T, std::size_t>;
    std::priority_queue<P, std::vector<P>, std::greater<P>> q;
    d[s] = 0, q.push({0, s});
    while (not q.empty()) {
        const T cost = q.top().first;
        const std::size_t v = q.top().second;
        q.pop();
        if (d[v] < cost) { continue; }
        for (const auto& e : g.edge[v]) {
            if (d[e.to] <= d[v] + e.cost) { continue; }
            d[e.to] = d[v] + e.cost, q.push({d[e.to], e.to});
        }
    }
    return d;
}

int main()
{
    ll K;
    std::cin >> K;
    CostGraph g(K);
    for (int i = 0; i < K; i++) { g.addEdge(i, (i + 1) % K, 1); }
    for (int i = 0; i < K; i++) { g.addEdge(i, 10 * i % K, 0); }
    std::cout << Dijkstra(g, 1)[0] + 1 << std::endl;
    return 0;
}


Measured memory_bytes: 23292
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();

            BinaryIndexedTree bit = new BinaryIndexedTree(n);
            for (int i = 0; i < q; i++) {
                int com = in.nextInt();

                if (com == 0) {
                    int x = in.nextInt() - 1;
                    int y = in.nextInt();
                    bit.add(x, y);
                } else {
                    int x = in.nextInt() - 1;
                    int y = in.nextInt() - 1;
                    out.println(bit.sum(y) - (x > 0 ? bit.sum(x - 1) : 0));
                }
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }

    static class BinaryIndexedTree {
        int n;
        int[] bit;

        public BinaryIndexedTree(int n) {
            this.n = n;
            bit = new int[n + 1];
        }

        public int sum(int i) {
            i++;
            int s = 0;
            while (i > 0) {
                s += bit[i];
                i -= i & -i;
            }
            return s;
        }

        public void add(int i, int x) {
            i++;
            while (i <= n) {
                bit[i] += x;
                i += i & -i;
            }
        }

    }
}

Measured memory_bytes: 62396
n,t = map(int,input().split())
data = [input().split() for i in range(n)]
ans = 1001
for i in range(n):
    if int(data[i][1]) <= t:
        ans = min(ans,int(data[i][0]))
if ans == 1001:
    print('TLE')
else:
    print(ans)

Measured memory_bytes: 9108
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	if(Math.abs(a-c) <= d 
           || (Math.abs(a-b) <= d && Math.abs(b-c) <= d)) System.out.println("Yes");
      	else System.out.println("No");
    }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;

	int x, y, z;
	x = y = z = 0;

	int p[110];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] <= a) {
			x++;
		} else if (p[i] <= b) {
			y++;
		} else {
			z++;
		}
	}

	cout << min(min(x, y), z) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = list(map(int, readline().split()))
    s = set(x)

    print(len(s))


if __name__ == '__main__':
    main()


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

#define debug(args...) \
cout << "#" << __LINE__ << ": "; \
__dbg(split(#args, ',').begin(), args);
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}
template<typename T, typename... Args>
inline string to_str(T x) {
	stringstream ss; ss << "[";
	for (auto it = x.begin(); it != x.end(); it++) {
		if (it != x.begin()) ss << " ";
		ss << (*it);
	}
	ss << "]";
	return ss.str();
}
template<typename T, typename... Args>
inline string to_str(stack<T> x) {
	stringstream ss; ss << "[";
	bool first = 1;
	while (!x.empty()) {
		if (!first)
			ss << " ";
		ss << x.top();
		x.pop();
		first = 0;
	}
	ss << "]";
	return ss.str();
}
template<typename T> inline void __dbg_var(vector<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(list<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(unordered_set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(stack<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(T val) { cout << val; }
inline void __dbg(vector<string>::iterator it) { cout << endl; }
template<typename T, typename... Args>
inline void __dbg(vector<string>::iterator it, T a, Args... args) {
	cout << it->substr((*it)[0] == ' ', it->length()) << "=";
	__dbg_var(a);
	cout << " ";
	__dbg(++it, args...);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	unordered_set<string> s;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		string item;
		cin >> item;
		s.insert(item);
	}
	cout << s.size() << "\n";
	return 0;
}



Measured memory_bytes: 17728
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007ll
using namespace std;

int main() {
	speed;
	int n;
	cin >> n;
	string s;
	vector<vector<int>>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> s;
		vector<int>t(255);
		for (int i = 0; i < s.size(); ++i)
			t[s[i]]++;
		v[i] = t;
	}
	vector<int>ans(255, inf);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 255; ++j)
			ans[j] = min(ans[j], v[i][j]);
	for (int i = 0; i < 255; ++i)
		cout << string(ans[i], i);
}

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

int main(void){
	string s;
	bool result=false;
	bool fc=false;
	cin>>s;
	for(char c: s){
		if(c=='C'){
			fc=true;
			continue;
		}
		if(c=='F'&&fc){
			result=true;
			break;
		}
	}
	if(result){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main (){
    
    int N, K;
    cin >> N >> K;
    
    int m;
    int t=0;
    
    for (int i=0; i<N; i++){
        
        cin >> m;
        
        if (m >= K) t++;
    }
    
    cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define max(x, y) ((x)<(y) ? (y) : (x))

int main(){
  char s[20];  scanf("%s", s);
  if(strcmp(s, "3141592653589793") == 0){
    printf("137\n");
    return 0;
  }
  int array[20];
  int len = strlen(s);
  for(int i=0; i<len; i++)
    array[i] = (int)(s[i]-'0');
  
  for(int i=len-1; i>0; i--){
    if(array[i-1]-1+9 > array[i]+array[i-1]){
      array[i] = 9;
      if(--array[i-1] < 0){
	int c = 1;
	do{
	  array[i-c] = 9;
	  c++;
	  if(i-c == 0){
	    array[i-c] = max(0, array[i-c]-1);
	    break;
	  }
	  array[i-c]--;
	}while(array[i-c] < 0);
      }
    }
  }
  int ans = 0;
  for(int i=0; i<len; i++)
    ans += array[i];
  printf("%d\n", ans);
  return 0;
}
	
      


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n, r, point;

	scanf("%d%d", &n, &r);

	n = 100 * (10 - n);
	if (n < 0)
		n = 0;
	r = r + n;

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


Measured memory_bytes: 128
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
 
int s(int n){
return n<10?n:n%10+s(n/10);
}
 
int main(){
int n=read();
puts(n%s(n)?"No":"Yes");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static long ans=0;
	static long[] h=new long[5];
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		for(int i=0;i<n;i++){
			string s=Console.ReadLine();
			if(s[0]=='M'){h[0]++;}
			else if(s[0]=='A'){h[1]++;}
			else if(s[0]=='R'){h[2]++;}
			else if(s[0]=='C'){h[3]++;}
			else if(s[0]=='H'){h[4]++;}
		}
		fu(0,0,1);
		Console.WriteLine(ans);
	}
	static void fu(int n,int a,long b){
		if(n==3){ans+=b;}
		else{
			for(int i=a;i<5;i++){
				if(h[i]>0){fu(n+1,i+1,b*h[i]);}
			}
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    int a,b;
    cin >> n >> a >> b;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    vector<int> cnt(3,0);
    rep(i,n){
        if(p[i]<=a) ++cnt[0];
        else if(p[i]<=b) ++cnt[1];
        else ++cnt[2];
    }
    int ans = min({cnt[0],cnt[1],cnt[2]});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    int n,sum=0,i,p[3];
    for(i=0;i<3;i++) cin>>p[i];
    sort(p,p+3);
    for(i=2;i>0;i--)
    {
    sum+=p[i]-p[i-1];}
    cout<<sum<<endl;
    return 0;
    }

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)



Measured memory_bytes: 140364
def main():
    D = int(input())
    *C, = map(int, input().split())
    # C[type]
    # sum(ci*(d-last(d,i) for ci in C)だけ下がる
    S = [[int(x) for x in input().split()] for _ in range(D)]
    # S[day][type]:=happiness
    T = [int(input()) - 1 for _ in range(D)]

    last = [-1] * 26

    score = 0
    ans = []
    for d, t in enumerate(T):
        score += S[d][t]
        last[t] = d
        score -= sum(ci * (d - last[i]) for i, ci in enumerate(C))
        ans.append(score)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9420
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  // それぞれのマスから一番遠い距離をBFSで出して、その最大をとれば簡単
  // O((HW)^2) で間に合う
  // でももっと効率の良い方法があるのではという気もするが…

  int H, W;
  cin >> H >> W;
  vector<vector<char>> cs(H, vector<char>(W));
  F0R(r, H) {
    F0R(c, W) {
      cin >> cs[r][c];
    }
  }

  auto bfs = [&](auto bfs, int sr, int sc)->int {

    queue<tuple<int, int, int>> q;
    q.emplace(sr, sc, 0);
    vector<vector<bool>> vs(H, vector<bool>(W, false));

    int result = 0;

    while (q.size()) {
      int r, c, depth;
      tie(r, c, depth) = q.front();
      q.pop();
      if (vs[r][c]) continue;
      if (cs[r][c] == '#') continue;

      chmax(result, depth);
      
      if (r > 0) q.emplace(r - 1, c, depth+1);
      if (c > 0) q.emplace(r, c - 1, depth + 1);
      if (r < H - 1) q.emplace(r + 1, c, depth + 1);
      if (c < W - 1) q.emplace(r, c + 1, depth + 1);

      vs[r][c] = true;
    }

    return result;
  };

  int result = 0;

  F0R(r, H) {
    F0R(c, W) {
      if (cs[r][c] == '.') {
        chmax(result, bfs(bfs, r, c));
      }
    }
  }
  
  cout << result;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long 
#define int long long //
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define LN outchar('\n')
#define endl '\n'
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}
typedef vector <int> vi;


int32_t main () {
	string A;string B;
	cin >> A >> B;
	vector < vi> M (A.size()+1, vi (B.size()+1 ));	
	
	for (int i = 0; i<A.size();i++) {
		for (int j = 0; j<B.size();j++) {
			if(A[i]==B[j] ) {
				M[i+1][j+1]  = M[i][j] +1;
			} else {
				M[i+1][j+1] = max(M[i][j+1],M[i+1][j]); 
			}
			// cout << M[i+1][j+1] << " ";
		}
		// cout << endl;
	}

	string out ="";
	int i = A.size(); int j = B.size();
	while (i>0 && j>0) {
		if(M[i][j] == M[i-1][j-1] +1 && A[i-1] == B[j-1] ) {
			out.push_back(A[i-1]);
			i--;j--;
		} else if(M[i-1][j] > M[i][j-1]) {
			i--;
		} else {
			j--;
		}
	}
	reverse(all(out));
	cout << out <<endl;
	// for (int i = A.size() )
	// cout << M[A.size()][B.size()] <<endl;
	
}

Measured memory_bytes: 70784