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

using namespace std;

# define REP(i, a, b) for(int i = a; i <= b; ++ i)
# define CLR(i, a) memset(i, a, sizeof(i))
# define REPD(i, a, b) for(int i = a; i >= b; -- i)

const int N = 3e5 + 3, INF = 1e9;

# define gc getchar
inline int rd() {
	char ch = gc(); int ret = 0, sgn = 1;
	while(ch < '0' || ch > '9') { 
		if(ch == '-') sgn = -1;
		ch = gc();
	}
	while(ch >= '0' && ch <= '9') 
		ret = ret * 10 + ch - '0', ch = gc();
	return ret * sgn;
}

struct node {
	int tg, mx;
} tr[N << 2];

# define pii pair<int, int>
# define fir first
# define sec second
# define mkp make_pair

int n, w, h, ans, m;
pii su[N], sd[N];
pii a[N];

# define u tr[x]
# define ls (x << 1)
# define rs (x << 1 | 1)
# define urs tr[rs]
# define uls tr[ls]

void pd(int x) {
	if(!u.tg) return ;
	uls.tg += u.tg, urs.tg += u.tg;
	uls.mx += u.tg, urs.mx += u.tg;
	u.tg = 0;
}

inline void modi(int ql, int qr, int v, int x = 1, int l = 0, int r = m) {
	if(qr < ql) return ;
	// printf("[%d %d] %d %d\n", l, r, ql, qr); 
	if(ql <= l && qr >= r) {
		// if(u.mx == -INF) u.mx = 0;
		u.tg += v, u.mx += v;
		return ;
	}
	pd(x);
	int mid = l + r >> 1;
	if(ql <= mid) modi(ql, qr, v, ls, l, mid);
	if(qr > mid) modi(ql, qr, v, rs, mid + 1, r);
	u.mx = max(uls.mx, urs.mx);
}

void build(int x, int l, int r) {
	u.mx = u.tg = 0;
	if(l == r) return ;
	int mid = l + r >> 1;
	build(ls, l, mid), build(rs, mid + 1, r);
}

# undef u 
# undef ls 
# undef rs 
# undef urs 
# undef uls 

int dis[N], au[N], ad[N];
void solve() {
	REP(i, 1, n) dis[i] = a[i].fir;
	dis[n + 1] = w;
	sort(dis, dis + n + 2);
	m = unique(dis, dis + n + 2) - dis - 1;
	build(1, 0, m);
	// cout << m << " ?? " << endl;
	REP(i, 0, m) ad[i] = 0, au[i] = h;
	REP(i, 1, n) {
		a[i].fir = lower_bound(dis, dis + m + 1, a[i].fir) - dis;
		if(a[i].sec <= h / 2)
			ad[a[i].fir] = max(a[i].sec, ad[a[i].fir]);
		else au[a[i].fir] = min(a[i].sec, au[a[i].fir]);
	}

	int tu = 0, td = 0;
	modi(0, 0, h);
	REP(i, 1, m) {
		// modi(i - 1, i - 1, h);
		ans = max(ans, tr[1].mx + dis[i]);
		
		modi(su[tu].fir, i - 1, au[i] - h);
		while(tu && su[tu].sec >= au[i]) {
			modi(su[tu - 1].fir, su[tu].fir - 1, au[i] - su[tu].sec);
			-- tu;
		}
		su[++ tu] = mkp(i, au[i]);

		modi(sd[td].fir, i - 1, -ad[i]);
		while(td && sd[td].sec <= ad[i]) {
			modi(sd[td - 1].fir, sd[td].fir - 1, sd[td].sec - ad[i]);
			-- td;
		}
		sd[++ td] = mkp(i, ad[i]);

		modi(i, i, h - dis[i]);
	}	

}

int main() {
	w = rd(), h = rd(), n = rd();
	// ++ n;
	REP(i, 1, n) {
		int x = rd(), y = rd();
		a[i] = mkp(x, y);
	}
	// a[1] = mkp(0, 0), a[++ n] = mkp(w, h);
	solve();		
	swap(w, h);
	REP(i, 1, n) a[i].fir = dis[a[i].fir];
	REP(i, 1, n) swap(a[i].fir, a[i].sec);

	solve();

	printf("%d\n", ans << 1);

	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
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);
        AWeatherPrediction solver = new AWeatherPrediction();
        solver.solve(1, in, out);
        out.close();
    }

    static class AWeatherPrediction {
        static final String[] strings = {"Cloudy", "Rainy", "Sunny"};

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();

            String answer = strings[(Arrays.binarySearch(strings, s) + 1) % strings.length];
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;



int main()
{
    idfc;

    int n;
    cin>>n;
    int i;
    vector<int> a;
    int e;
    for(i=0;i<n;i++)
    {
        cin>>e;
        a.pb(e);
    }
    sort(a.begin(),a.end());

    int x=a[n/2]-a[n/2-1];
    cout<<x;
    //int y;

    return 0;
}

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    string S,ans="";
    cin >> S;
    for(int i=0;i<S.size();i++){
        if(S[i]=='0'){
            ans+='0';
        }
        else if(S[i]=='1'){
            ans+='1';
        }
        else{
            if(ans!=""){
                ans.erase(ans.size()-1);
            }
        }
    }
    cout << ans << endl;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    rep(i, 0, s.size()) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <deque>

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

using namespace std;

template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{

    int n;
    cin >> n;
    vec<ll> a(n);

    for (auto& e : a)
        cin >> e;

    ll ans{};

    for (int i = 0; i < n; ++i)
    {
        if (i % 2 == 0 && a[i] % 2 == 1)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}

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

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

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

#define INF INT_MAX/3
vector< vector<int> > g;
vector<bool> re;
vector<int> low;
int ans = 0;
int p = 0;
int func(int current, int parent){
  int pw = ++p;
  if(re[current])return low[current];
  low[current] = pw;
  re[current] = true;
  each(tmp,g[current]) {
    if(tmp == parent)continue;
   minch(low[current],func(tmp, current));
  }
  if(pw == low[current])ans++;
  return low[current];
}
int main(){
  cin.sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  g.resize(n);
  re.resize(n);
  low.resize(n);
  rep(i,n){
    low[i] = i;
    re[i] = false;
  }
  int a,b;
  rep(i,m){
    cin >> a >> b;
    g[a-1].pb(b-1);
    g[b-1].pb(a-1);
  }
  func(0,-1);
  cout << ans-1 << endl;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll dp[n];
  rep(i,n) dp[i]=MOD;
  dp[0]=0;
  Rep(i,n){
    chmin(dp[i],dp[i-1]+abs(v[i]-v[i-1]));
    if(i>=2) chmin(dp[i],dp[i-2]+abs(v[i]-v[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
fn select_type(c: &Vec<usize>, s: &Vec<Vec<isize>>, lastvals: &Vec<usize>, d: usize) -> usize {
    /*
    let current_downval_data: Vec<usize> = lastvals.iter()
        .enumerate()
        .map(|pair| c[pair.0] * (d + 1 - pair.1))
        .collect()
    ;
    s[d].iter().zip(current_downval_data.iter())
        .map(|s_d| *s_d.0 as isize - *s_d.1 as isize)
        .enumerate()
        .max_by_key(|x| x.1)
        .map_or(0, |pair| pair.0)
    + 1
    */
    (d + 17) % 26 + 1
}

fn downval(c: &Vec<usize>, lastvals: &Vec<usize>, d: usize) -> usize {
    lastvals.iter()
        .enumerate()
        .map(|pair| c[pair.0] * (d + 1 - pair.1))
        .sum()
}

fn main() {
    let mut d = String::new();
    std::io::stdin().read_line(&mut d).ok();
    let d: usize = d.trim().parse().unwrap();
    let mut c = String::new();
    std::io::stdin().read_line(&mut c).ok();
    let c: Vec<usize> = c.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut satisfied: Vec<Vec<isize>> = vec![vec![]; d];
    let mut lastvals: Vec<usize> = vec![0; 26];
    for i in 0..d {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let s: Vec<isize> = s.trim().split_whitespace().map(|t| t.parse().unwrap()).collect();
        satisfied[i] = s;
    }
    let mut result: isize = 0;
    for i in 0..d {
        let t = select_type(&c, &satisfied, &lastvals, i);
        lastvals[t-1] = i+1;
        result += satisfied[i][t-1] as isize;
        result -= downval(&c, &lastvals, i) as isize;
        println!("{}", t);
        //println!("{} {}", t, result);
    }
}


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

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

Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

cnt = 1
for i in range(n):
    if a[i]%2==0:
        cnt*=2
    else:
        cnt*=1

print(3**n-cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> V(N);
    ll ans = -INF_64;
    rep(i, N) cin >> V[i];

    for (int l = 0; l <= K; l++) {
        for (int r = 0; r <= K - l; r++) {
            if (l + r > N)
                continue;
            int d = K - l - r; // dump
            ll now = 0;
            vector<ll> neg;
            for (int i = 0; i <= l - 1; i++) {
                now += V[i];
                if (V[i] < 0) {
                    neg.push_back(V[i]);
                }
            }
            for (int i = 0; i <= r - 1; i++) {
                now += V[N - 1 - i];
                if (V[N - 1 - i] < 0) {
                    neg.push_back(V[N - 1 - i]);
                }
            }
            sort(neg.begin(), neg.end());
            int d_max = min(d, (int)neg.size());
            for (int i = 0; i < d_max; i++) {
                now -= neg[i];
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}
// int main()
// {
//     int N, K;
//     cin >> N >> K;
//     vector<ll> V(N);
//     ll ans = -INF_64;
//     rep(i, N) cin >> V[i];
//     for (int c = 0; c <= K; c++) {
//         int a_max = min(K - c, N);
//         for (int a = 0; a <= a_max; a++) {
//             ll s = 0;
//             vector<ll> neg;
//             int b = K - c - a;
//             for (int i = 0; i < a; i++) {
//                 s += V[i];
//                 if (V[i] < 0) {
//                     neg.push_back(V[i]);
//                 }
//             }
//             for (int i = 0; i < min(b, N); i++) {
//                 s += V[N - i];
//                 if (V[N - i] < 0) {
//                     neg.push_back(V[N - i]);
//                 }
//             }
//             sort(V.begin(), V.end());
//             for (int i = 0; i < min((int)neg.size(), c); i++) {
//                 s -= neg[i];
//             }
//             ans = max(ans, s);
//         }
//     }
//     cout << ans << endl;

//     return 0;
// }


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

const ll MAXN = 200000;

ll N, M, ans=0, tmp=0;
vector<pair<ll, ll>> A;

void myfunc(ll num) {
    vector<ll> E[N];
    for(int i=0;i<M;i++) {
        if(i==num) continue;
        pair<ll, ll> p = A[i];
        E[p.first].push_back(p.second);
        E[p.second].push_back(p.first);
    }
    queue<ll> Q;
    ll color[N]={0};
    Q.push(0);
    color[0]=1;
    while(!Q.empty()) {
        ll u = Q.front();
        Q.pop();
        for(int i=0;i<E[u].size();i++) {
            if(color[E[u][i]]==1) continue;
            Q.push(E[u][i]);
            color[E[u][i]]=1;
        }
    }
    for(int i=0;i<N;i++) {
        if(color[i]==0) {
            ans++;
            return;
        }
    }
}

signed main(){
    cin >> N >> M;
    for(int i=0;i<M;i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        A.push_back(make_pair(a,b));
    }
    for(int i=0;i<M;i++) {
        myfunc(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>

using namespace std;

int main() {

	bitset<30> a;
	int N, M;
	cin >> N >> M;

	for(int i = 0; i < M; i++) a[i] = true;

	for(int i = 0; i < N; i++) {
		bitset<30> b;
		int K;
		cin >> K;
		for(int j = 0; j < K; j++) {
			int l;
			cin >> l;
			b[l - 1] = true;
		}
		a &= b;
	}

	cout << a.count() << endl;
}


Measured memory_bytes: 384
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():

    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    sumnation = 0
    def modinv(a, mod=10 ** 9 + 7):
        return pow(a, mod - 2, mod)
    twoinv = modinv(2, mod)
    for i in A:
        sumnation += (i % mod)
        sumnation %= mod

    ans = pow(sumnation, 2, mod)
    for i in A:
        ans -= pow(i, 2, mod)
        while ans < 0:
            ans += mod
    ans *= twoinv
    ans %= mod
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 97224
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = (1 << 30) - 1;
const ll LINF = (1L << 62) - 1;
const ll MOD = 1000000007;
template <class T> inline void chmin(T& a, T& x) { a = a < x ? a : x; }
template <class T> inline void chmax(T& a, T& x) { a = a > x ? a : x; }

const int CHAR_CNT = 26;
template <class T> struct Segtree {
  T INIT = vector<int>(CHAR_CNT, 0);
  int S = 1;       // size
  vector<T> data;  // 1-indexed

  Segtree() {}
  Segtree(int n) { build(n); }
  Segtree(vector<T>& d) { build(d); }

  void build(int n) {
    while (S < n) S *= 2;
    data.assign(2 * S, INIT);
  }

  void build(vector<T>& d) {
    int n = d.size();
    build(n);
    for (int i = 0; i < n; ++i) data[S + i] = d[i];
    for (int i = S - 1; i > 0; --i) data[i] = f(data[2 * i], data[2 * i + 1]);
  }

  void update(int idx, T val) {  // 0-indexed
    idx += S;
    data[idx] = val;
    while (idx >>= 1) data[idx] = f(data[2 * idx], data[2 * idx + 1]);
  }

  T query(int a, int b) {  // 0-indexed
    return query(a, b, 1, 0, S - 1);
  }

  T query(int a, int b, int k, int l, int r) {
    if (r < a || b < l) return INIT;
    if (a <= l && r <= b) return data[k];
    T vl = query(a, b, 2 * k, l, (l + r) / 2);
    T vr = query(a, b, 2 * k + 1, (l + r) / 2 + 1, r);
    return f(vl, vr);
  }

  T f(T& a, T& b) {
    T ret = vector<int>(26, 0);
    for (int i = 0; i < CHAR_CNT; ++i) {
      ret[i] += a[i] + b[i];
    }
    return ret;
  }

  void print() {
    for (int i = 0; i < 2 * S; i++) {
      cout << data[i] << (i == 2 * S - 1 ? "\n" : " ");
    }
  }
};

int ctoi(char c) { return c - 'a'; }

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

  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<vector<int>> vs;
  for (int i = 0; i < n; ++i) {
    vector<int> tmp(CHAR_CNT, 0);
    ++tmp[ctoi(s[i])];
    vs.push_back(tmp);
  }
  auto st = Segtree<vector<int>>(vs);
  for (int i = 0; i < q; ++i) {
    int type;
    cin >> type;
    if (type == 1) {
      int x;
      char c;
      cin >> x >> c;
      --x;
      vector<int> tmp(CHAR_CNT, 0);
      ++tmp[ctoi(c)];
      st.update(x, tmp);
    } else {
      int l, r;
      cin >> l >> r;
      --l, --r;
      vector<int> q = st.query(l, r);
      int cnt = 0;
      for (auto a : q)
        if (a > 0) ++cnt;
      // dump(q);
      cout << cnt << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 207112
#include <bits/stdc++.h>
#define de(x) cout << #x << "=" << x << ", "
#define dd cout << '\n';
#define XinAi ios::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define int long long
using namespace std;
typedef pair<int,int> pii;
const int N = 2e5+10;

int cnt[N], a[N], res, n;

signed main()
{
    XinAi
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i];
    for (int i=1; i<=n; i++) cnt[a[i]]++;
    for (int i=1; i<=n; i++) res += cnt[i]*(cnt[i]-1)/2;
    for (int i=1; i<=n; i++)
    {
        int tmp = res;
        tmp -= (cnt[a[i]]*(cnt[a[i]]-1))/2;
        cnt[a[i]]--;
        tmp += (cnt[a[i]]*(cnt[a[i]]-1))/2;
        cnt[a[i]]++;
        cout << tmp << '\n';
    }
}

Measured memory_bytes: 6700
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N; // 参加者
  int K; // 持ち点数
  int Q; // 回数
  int A;
  cin >> N >> K >> Q;
  vector<int> user(N, 0);
  K -= Q;

  for (int i = 0; i < Q; i++) {
    cin >> A;
    user[A-1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << (user[i] + K > 0 ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 1024
#include <stdio.h>

int
main(void)
{
	int A, B;
	scanf("%d %d", &A, &B);

	if (A == 1)
		A = 14;
	if (B == 1)
		B = 14;

	if (A > B)
		puts("Alice");
	else if (A < B)
		puts("Bob");
	else
		puts("Draw");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	void solve() {
		try (final Scanner sc = new Scanner(System.in)) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long x = sc.nextLong();
			System.out.println(b / x - (a == 0 ? -1 : (a - 1) / x));
		}
	}

	public static void main(String[] args) {
		new Main().solve();
	}

}


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

const int MAX=1<<17;
const int INF=(1LL<<31)-1;

int n,dat[2*MAX-1];//0-indexed

void init()
{
	int n_=n;
	n=1;
	while(n<n_)n<<=1;
	for(int i=0;i<2*n-1;i++)dat[i]=INF;
	return;
}

void update(int k,int a)
{
	k+=n-1;
	dat[k]=a;
	while(k>0)
	{
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
	return;
}

int getmin(int a,int b,int k,int l,int r)//[a,b),vertex-number(0),k's range[l,r)
{
	if(r<=a||b<=l)return INF;
	
	if(a<=l&&r<=b)return dat[k];
	else
	{
		int vl=getmin(a,b,k*2+1,l,(l+r)/2);
		int vr=getmin(a,b,k*2+2,(l+r)/2,r);
		return min(vl,vr);
	}
}

int main()
{
	int q;cin>>n>>q;
	int a,b,c;
	init();
	for(int i=0;i<q;i++)
	{
		cin>>c>>a>>b;
		if(c)
		{
			cout<<getmin(a,b+1,0,0,n)<<endl;
		}
		else
		{
			update(a,b);
		}
	}
	return 0;
}

Measured memory_bytes: 4108
/**
  @file a.cpp
  @title A - B +/- A
  @url https://atcoder.jp/contests/abc118/tasks/abc118_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

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

  if (B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#include<bits/stdc++.h>
#define fr first
#define sc second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define forn(i,n) for(int i =1;i<= (n);++i)
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
const int inf = 1e9+7;
const int nmax = 500005;
const ll linf = LLONG_MAX;
const ll mod = 1000000007;

int n , m , a[200005] , b[200005] , ac , pn;
int main(){
    fast;
    cin >> n >> m;
    int p ; string s;
    forn(i,m){
        cin >> p >> s;
        if(s == "WA" && a[p] == 0){
            b[p] ++;
        }
        if(s == "AC" && a[p] == 0){
            ac ++;
            a[p] = 1;
        }
    }
    forn(i,n){
        pn += b[i]*a[i];
    }
    cout << ac << ' ' << pn << '\n';
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << "a ";
    if (a < b) {
        cout << "<";
    } else if (a > b) {
        cout << ">";
    } else {
        cout << "==";
    }
    cout << " b" << endl;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = ":(";
            if (iA <= 8 && iB <= 8) { sOut = "Yay!"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 6005;
#define pb push_back
#define pii pair<int,int>

int t;
int n,m;
pii A[MN];
int f[MN][MN],g[MN][MN];
int dp[MN];
int main()
{
	memset(f,0,sizeof f);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d%d",&A[i].first,&A[i].second);
	sort(A+1,A+1+n);
//	for(int i=1;i<=n;++i) printf("(%d,%d,%d)\n",i,A[i].first,A[i].second);
	for(int i=1;i<=n;++i)
	{
		int c = A[i].first, w = A[i].second;
		for(int j=0;j<m;++j) f[i][j] = f[i-1][j];
		for(int j=m-1;j>=c;--j)
		{
//			dp[j] = max(dp[j],dp[j-c]+w);
			f[i][j] = max(f[i-1][j],f[i-1][j-c]+w);
		}
	}
	for(int i=n;i>=1;--i)
	{
		int c = A[i].first, w = A[i].second;
		for(int j=0;j<m;++j) g[i][j] = g[i-1][j];
		for(int j=m-1;j>=c;--j)
		{
//			dp[j] = max(dp[j],dp[j-c]+w);
			g[i][j] = max(g[i-1][j],g[i-1][j-c]+w);
		}
	}
	int ans = 0;
	for(int i=1;i<=n;++i)
	{
		int w = A[i].second;
		for(int j=0;j<m;++j)
		{
			
			ans = max(ans,f[i-1][j]+w+g[i+1][m-j-1]);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 213760
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N = keyboard.nextInt();
		
		String ans = "APPROVED";
		for(int a = 0; a<N; a++) {
			int Ain = keyboard.nextInt();
			if(Ain%2 == 0) {
				if(Ain%3 != 0 && Ain%5 != 0) {
					ans = "DENIED";
				}
			}
		}
			
		System.out.println(ans);
		keyboard.close();	
	}
}


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

#define ll long long
#define T int t, q=0; cin>>t; while(q++<t)

int main()
{
    int n;
    cin>>n;
    ll sum=(n/500)*1000;
    n=n%500;
    sum+=(n/5)*5;
    cout<<sum;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
    long int n, i, k;
    long int prime[1000001] = {0};
    long int sum[1000002] = {0};
    for(i = 2; i <= 1000000; i++) {
        prime[i] = 1;
    }
    for(i = 2; i <= 1000000; i++) {
        if(prime[i]) {
            for(k = 2*i; k <= 1000000; k+=i) {
                prime[k] = 0;
            }
        }
    }
    for(i = 0; i < 1000001; i++) {
        sum[i+1] = sum[i] + prime[i];
    }
    while(scanf("%ld", &n) != EOF) {
        printf("%ld\n", sum[n+1]);
    }
    return 0;
}

Measured memory_bytes: 17316
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  int n,k; cin>>n>>k;
  int und;
  int up;
  rep(i,n){
    int a; cin>>a;
    if(a==1)
    und=i;
  }
  up=n-(und+1);
  // cout<<"und "<<und<<" up "<<up<<endl;
  int ans=1000000009;
  int U=und;
  while(up>=0&&und<U+k){
    int aa=0;
    if(und%(k-1)==0)
    aa=und/(k-1);
    else
    aa=und/(k-1)+1;
    // cout<<ans<<endl;
    if(up%(k-1)==0)
    aa+=up/(k-1);
    else
    aa+=up/(k-1)+1;

    // cout<<aa<<endl;
    ans=min(ans,aa);
    und++;
    up--;
  }

  cout<<ans<<endl;


  return 0;
}


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

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

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
using namespace std;
typedef long long ll;


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

	sort(a, a + 12);
	if (a[0] == a[3] && a[4] == a[7] && a[8] == a[11])
		cout << "yes" << endl;
	else
		cout << "no" << endl;
	return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;



int main()
{
	int N;
	cin >> N;
	
	int a[N];
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}	
	
	sort(a, a+N, greater<int>());
	int Alice = 0;
	int Bob = 0;
	
	for(int i = 0; i < N; i++){
		if(i % 2 == 0) Alice += a[i];
		else Bob += a[i];
	}
		
	
	cout << Alice - Bob << endl;
	return 0;
}

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

const int mxN=1e5+5;
int n, a[mxN], dp[mxN];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for (int i=0; i<n; ++i)
        cin >> a[i];
    memset(dp, 0x3f, sizeof(dp));
    dp[0]=0;
    for (int i=0; i<n; ++i) {
        dp[i+1]=min(dp[i+1], dp[i]+abs(a[i+1]-a[i]));
        dp[i+2]=min(dp[i+2], dp[i]+abs(a[i+2]-a[i]));
    }
    cout << dp[n-1] << '\n';
}


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

int main()
{
    int n,sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=__gcd(__gcd(i,j),k);
            }
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
using namespace std;
struct node
{
	int val;
	node* next;
};
node* tree[100001];
void insert(int a,int b)
{
		node* temp=new node;
		temp->val=b;
	
		node* fresh=tree[a];
	if(tree[a]==NULL)
	{
	
		tree[a]=temp;
		temp->next=NULL;
	}
	else
	{
		temp->next=fresh;
		tree[a]=temp;
	}
}
int bval[100001];
int aval[100001];
int visit[100001];
int visit2[100001];
void dfs(int a,int v)
{
	if(visit[a]==1)
	return;
	visit[a]=1;
	int i;
	aval[a]=v;
	node*temp=tree[a];
	while(temp!=NULL)
	{
		dfs(temp->val,v+1);
		temp=temp->next;
	}
	
}
void dfs2(int a,int v)
{
	if(visit2[a]==1)
	return;
	visit2[a]=1;
	int i;
	bval[a]=v;
	node*temp=tree[a];
	while(temp!=NULL)
	{
		dfs2(temp->val,v+1);
		temp=temp->next;
	}
	
}
int main() 
{
	int n;
	cin >> n;
	int i;
	for(i=1;i<=n-1;i++)
	{
		int a,b;cin >>a >> b;
		insert(a,b);
		insert(b,a);
	}
	dfs(1,0);
	dfs2(n,0);
	int count=0;
	for(i=1;i<=n;i++)
	{
		if(aval[i]<=bval[i])
		count++;
	}
	if(count>(n-count))
	cout << "Fennec" << endl;
	else
	cout << "Snuke" << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>
#define N 100

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int A,B;
  scanf("%d%d",&A,&B);

  char S[N][N];
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      if(i < N/2) S[i][j] = '#';
      else S[i][j] = '.';
    }
  }

  int cnt = 0;
  for(int i = 1;i < N/2;i += 2){
    for(int j = 1;j < N-1;j += 2){
      if(++cnt < A) S[i][j] = '.';
    }
  }

  cnt = 0;
  for(int i = N/2+1;i < N;i += 2){
    for(int j = 1;j < N-1;j += 2){
      if(++cnt < B) S[i][j] = '#';
    }
  }

  printf("%d %d\n",N,N);
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      printf("%c",S[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    cout.precision(15);
    double t = (double)h + m/60.0;
    double hr = ((2*M_PI)/12)*t;
    double mr = ((2*M_PI)/60)*m;
    double angle = abs(hr-mr);
    double c = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(angle));
    cout<<c<<"\n";

}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
string SS[10010];

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

    int ba = 0;
    int bs = 0;
    int sa = 0;
    for(int i = 0; i < N; i++){
        string &s = SS[i];
        for(int j = 1; j < (int)s.size(); j++){
            if(s[j-1] == 'A' && s[j] == 'B'){
                cnt++;
            }
        }
        if(s[0] == 'B' && s[(int)s.size() - 1] == 'A'){
            ba++;
        }
        else if(s[0] == 'B'){
            bs++;
        }
        else if(s[(int)s.size() - 1] == 'A'){
            sa++;
        }
    }
    
    if(bs == 0 && sa == 0){
        cnt += max(ba - 1, 0);
    }
    else{
        cnt += ba;
        cnt += min(bs, sa);
    }
    cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <algorithm>
#include <queue>

#define pq priority_queue
using ll = long long;
using namespace std;

ll N, M, a, b;

int main(void) {
    cin >> N >> M;
    vector<vector<ll>> JOBS(M);
    
    for (ll i=0; i<N; i++) {
        cin >> a >> b;
        if (a > M) continue;
        JOBS[a-1].push_back(b);
    }
    
    ll result = 0;
    pq<ll> Q;
    for (ll i=0; i<M; i++) {
        for (ll x: JOBS[i]) Q.push(x);
        if (Q.empty()) continue;
        result += Q.top();
        Q.pop();
    }
    
    cout << result << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;
int main(){
  ll n;cin>>n;
  VL a(n);REP(i,n){cin>>a[i];}
  ll sum=0;
  ll count=0;
  int key=0;
  for(int i=0;i<n;i++){
    if(a[i]<0){
      count++;
    }
  }
  ll min=10000000000000;
  for(int i=0;i<n;i++){
    if(a[i]==0){
      key=1;
    }
  }
  if(key==1||count%2==0){
    for(int i=0;i<n;i++){
      if(a[i]<0){
        a[i]=-a[i];
      }
      sum+=a[i];
    }
  }else{
    for(int i=0;i<n;i++){
      if(min>abs(a[i])){
        min=abs(a[i]);
      }
      if(a[i]<=0){
        a[i]=-a[i];
      }
      sum+=a[i];
    }
    sum-=2*min;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3536
# -*- coding: utf-8 -*-

na,nb,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=min(a)+min(b)

for i in range(m):
    x,y,c=map(int,input().split())
    tmp=a[x-1]+b[y-1]-c
    if tmp<ans:
        ans=tmp
print(ans)


Measured memory_bytes: 18612
/*input
314159265 358979323846264338
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii; 


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


ll gcd(ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
} 

ll lcm(ll fir, ll sec){
	return (fir*sec)/(gcd(fir, sec));
}


const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


int main(){
	ll x,y;
	cin>>x>>y;
	ll cur = x;
	int ans = 0;
	while(cur<=y){
		cur*=2;
		ans++;
	}
	syso(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())

int main() {
  int k,n; cin>>k>>n;
  vi a(n); rep(i,n) cin>>a.at(i);
  a.push_back(a.at(0)+k);
  int l=0;
  rep(i,n) l=max(l,a.at(i+1)-a.at(i));
  cout<<k-l<<endl;
}


  


Measured memory_bytes: 1792
n = gets.to_i
v = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)
sum = 0

(0...n).each do |number|
  sum += v[number] - c[number] if v[number] - c[number] >= 0
end
puts sum


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin>>S;
  
  if(S[2]==S[3] && S[4]==S[5])
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
int n, m;
int c[MAXN];
ll L[MAXN];
vector <int> v[MAXN];
int main() {
	while (scanf("%d%d", &n, &m) != EOF) {
		if (n == 0 && m == 0) break;
		for (int i = 1; i <= n; i++) c[i] = i, L[i] = 0, v[i].push_back(i);
		for (int i = 1; i <= m; i++) {
			char op; scanf(" %c", &op);
			if (op == '?') {
				int x, y; scanf("%d%d", &x, &y);
				if (c[x] != c[y]) puts("UNKNOWN");
				else printf("%lld\n", L[y] - L[x]);
			}
			else {
				int x, y, cx, cy, z; scanf("%d%d%d", &x, &y, &z); //y = x+z
				cx = c[x]; cy = c[y];
				if (cx == cy) continue;
				else {
					if (v[cx].size() > v[cy].size()) {
						ll Ly = L[y];
						for (auto &t : v[cy]) L[t] = -(Ly - L[t]) + L[x] + z;
						for (auto &t : v[cy]) c[t] = cx, v[cx].push_back(t);
						v[cy].clear();
					}
					else {
						ll Lx = L[x];
						for (auto &t : v[cx]) L[t] = -(Lx - L[t]) + L[y] - z;
						for (auto &t : v[cx]) c[t] = cy, v[cy].push_back(t);
						v[cx].clear();
					}
				}
			}
		}
		for (int i = 1; i <= n; i++) v[i].clear();
	}
}

Measured memory_bytes: 10124
def q3():
    Alphabet = ["dummy"] + [c for c in "abcdefghijklmnopqrstuvwxyz"]

    n = int(input())

    name = ""
    while True:
        if n <= 26:
            name = Alphabet[n] + name
            break
        n_c = n % 26
        if n_c == 0:
            name = "z" + name
            n = n // 26 - 1
        else:
            name = Alphabet[n_c] + name
            n = (n - n_c) // 26

    print(name)


q3()


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int n, total=1;
string a;
vector<string>store;

bool comparator(string a, string b){
	return a<b;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n;
	while(n--){
		cin >> a;
		store.push_back(a);
	}
	sort(store.begin(), store.end(), comparator);
	for(int i=1;i<store.size();i++){
		if(store[i]!=store[i-1]){
			total++;
		}
	}
	cout << total << '\n'; 
}

Measured memory_bytes: 11700
import heapq

n,h = map(int, input().split())
cut = 0
throw = []
heapq.heapify(throw)

for i in range(n):
	a,b = map(int, input().split())	
	cut = max(cut, a)
	heapq.heappush(throw, -(b))

ans = 0
for i in range(n):
	num = heapq.heappop(throw)*(-1)
	if num > cut:
		 h -= num
		 ans += 1
		 if h <= 0:
			 print(ans)
			 exit()
	else:
		ans += (-(-h // cut))
		print(ans)
		exit()	
		
ans += (-(-h // cut))
print(ans)	

Measured memory_bytes: 7116
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fr(a,b) for(int i=a;i<b;i++)
#define frn(a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define vpi vector<pair<int,int>>
void fast(){ 
ios_base::sync_with_stdio(false); cin.tie(NULL); 
#ifndef ONLINE_JUDGE 
	freopen("input.txt","r",stdin); 
	freopen("output.txt","w",stdout); 
#endif
}
#define test int t;cin>>t; while(t--)
#define mp make_pair
#define pb push_back
#define pu push

int32_t main(){
	fast();
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans = 0;
	if(a-k<0){
		ans +=a;
		k -= a;
		if(b-k<0){
			k -=b;
			ans = ans-k;
			cout<<ans;
		}
		else cout<<ans;
	}
	else cout<<k;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	long long T;
	cin>>N>>T;
	vector<long long> t(N,0);
	int i;
	long long s=0;
	for (i=0;i<N;i++){
		cin>>t[i];
	}
	for (i=0;i<N-1;i++){
		long long x=t[i+1]-t[i];
		if (x<=T){
			s+=x;
		}else{
			s+=T;
		}
	}
	s+=T;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1792
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
inline void Fail(){printf("0");exit(0);}

const int maxn=305;
int n,m,mod;
inline int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline int sub(int a,int b){return a-b<0?a-b+mod:a-b;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
int dp[maxn][maxn],sum[maxn][maxn],c[maxn][maxn];

int main(){
	scanf("%d%d%d",&n,&m,&mod);
	rep(i,302)c[i][0]=1;
	REP(i,301)REP(j,301)c[i][j]=add(c[i-1][j],c[i-1][j-1]);
	REP(i,n+1)rep(j,m+1){
		if(i==1)dp[i][j]=1;
		else{
			REP(k,i-1)dp[i][j]=add(dp[i][j],mul(mul(c[i-2][k-1],dp[i-k][j]),sub(sum[k][m],sum[k][j])));
		}
		sum[i][j]=add(!j?0:sum[i][j-1],dp[i][j]);
	}
	printf("%d",dp[n+1][0]);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)

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

	ll s,w;
	cin >> s >>w;
	if(w>=s){
		cout<<"unsafe";
	}else{
		cout<<"safe";
	}
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <numeric>
using namespace std;

int main(void) {
    long long n,k,ans = 0;

    cin >> n >> k;
    ans = (n % k);


    cout << min(ans, abs(ans - k)) << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
Broken = [0] * (N + 3)
for i in range(M):
    ai = int(input())
    Broken[ai] = 1


dp = [0] * (N + 1)
dp[0] = 1

for i in range(N):
    if (Broken[i + 1]) == 0 and (i + 1) <= N:
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD

    if (Broken[i + 2]) == 0 and (i + 2) <= N:
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD

print(dp[N] % MOD)


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

int main() {
  int N;
  cin >> N;
  map<string, int> m;
  rep(i, N) {
    string s;
    cin >> s;
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;

  return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int main() {
	vi h;
	int n, i, j, k;

	cin >> n;
	h.resize(n);

	rep(i, n) {
		cin >> h[i];
	}

	k = 1;
	j = h[0];
	
	repj(i, 1, n) {
		if (j <= h[i]) {
			k++;
			j = h[i];
		}
	}

	cout << k << endl;

	return 0;
}


Measured memory_bytes: 256