akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;

int main(){
    int n, k;
    ll ans = 0;
    cin >> n >> k;
    for(int i=1; i<=n; i++){
        ll a = 1000000000000000/n;
        int score = i;
        while(score <= k-1){
            score *= 2;
            a /= 2;
        }
        ans += a;
    }
    cout << setprecision(15) << (double)ans/1000000000000000 << endl;
}

Measured memory_bytes: 256
N = int(input())
List = [int(i) for i in input().split()]

def gcd(x,y):
    while y!=0:
        tmp = x
        x = y
        y = tmp%y
    return x

M = []
L = [0]*(N+1)
R = [0]*(N+1)
for i in range(1,N):
    L[i]=gcd(L[i-1],List[i])
    R[-i-1]=gcd(R[-i],List[-i+1])
for i in range(N):
    M.append(gcd(L[i],R[i+1]))
print(max(M))

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

int main(){
    int H, W, D;
    std::cin >> H >> W >> D;
    int total = H * W;
    std::vector< std::vector< int > > A_pos_H(D, std::vector< int >(total / D + (total % D != 0), 0));
    std::vector< std::vector< int > > A_pos_W(D, std::vector< int >(total / D + (total % D != 0), 0));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int tmp;
            std::cin >> tmp;
            tmp--;
            A_pos_H[tmp % D][tmp / D] = i;
            A_pos_W[tmp % D][tmp / D] = j;
        }
    }
    std::vector< std::vector< int > > A_Csum(D, std::vector< int >(total / D + (total % D != 0), 0));
    for(int i=D; i<total; i++){
        A_Csum[i % D][i / D] = abs(A_pos_H[i % D][i / D] - A_pos_H[i % D][i / D - 1])
                             + abs(A_pos_W[i % D][i / D] - A_pos_W[i % D][i / D - 1])
                             + A_Csum[i % D][i / D - 1];
    }
    
    int Q;
    std::cin >> Q;
    std::vector< int > L(Q);
    std::vector< int > R(Q);
    for(int i=0; i<Q; i++){
        std::cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }
    for(int i=0; i<Q; i++){
        int ans = A_Csum[R[i] % D][R[i] / D] - A_Csum[L[i] % D][L[i] / D];
        std::cout << ans << std::endl;
    }
    
    
    
    return 0;
    
}


Measured memory_bytes: 18740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i=1;
    int n;
    while(true)
    {
        cin>>n;
        if(n==0)
            break;
        cout<<"Case "<<i<<": "<<n<<"\n";
        i++;
    }
    return 0;
}


Measured memory_bytes: 3004
use std::io::stdin;


fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let n: usize = ws.next().unwrap().parse().unwrap();
    let k: usize = ws.next().unwrap().parse().unwrap();

    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let r: i32 = ws.next().unwrap().parse().unwrap();
    let s: i32 = ws.next().unwrap().parse().unwrap();
    let p: i32 = ws.next().unwrap().parse().unwrap();

    let p = Points { r: r, p: p, s: s, z: 0};

    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut t: Vec<_> = s.trim_right().chars().collect();

    for i in (0_usize..n).rev() {
        if i >= k {
            if t[i] == t[i-k] {
                t[i-k] = 'x';
            }
        }
    }

    let mut point = 0;
    let it = t.iter();
    for c in it {
        point =  point + *p.win_for(c);
    }

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

struct Points {
    r: i32,
    p: i32,
    s: i32,
    z: i32,
}

impl Points {
    fn win_for(self: &Points, c: &char) -> &i32 {
        match c {
            &'r' => &self.p,
            &'p' => &self.s,
            &'s' => &self.r,
            _    => &self.z,
        }
    }
}


Measured memory_bytes: 4352
N,M = map(int, input().split())
Key = [0 for i in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    L -= 1
    R -= 1
    Key[L] += 1
    Key[R+1] -= 1
count = 0
sum = 0
for i in range(len(Key)):
    sum += Key[i]
    if sum == M:
        count += 1
print(count)

Measured memory_bytes: 9932
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,c;
int L[10];
double dp[310][32][310];
double ans;
int p[10];
void solve()
{
	for(int j=0;j<=c*n;j++)
		for(int i=0;i<(1<<(n-1));i++)
			for(int k=0;k<=c*n;k++)
				dp[j][i][k]=0.0;
	dp[0][0][L[0]*n]=1.0;
	for(int i=0;i<c*n;i++)
		for(int s=0;s<(1<<(n-1));s++)
			for(int j=i+1;j<=c*n;j++)
			{
				int o=i%n;
				if(o&&!(s&(1<<(o-1))))
					dp[i+1][s|(1<<(o-1))][min(c*n,max(j,i+L[p[o]]*n))]+=dp[i][s][j]/c;
				dp[i+1][s][j]+=dp[i][s][j];
			}
	ans+=dp[c*n][(1<<(n-1))-1][c*n];
	return ;
}
bool book[10];
int cnt;
void dfs(int x)
{
	if(x>=n){
		solve();
		cnt++;
		return ;
	}
	for(int i=1;i<n;i++)
		if(!book[i])
		{
			book[i]=true;
			p[x]=i;
			dfs(x+1);
			book[i]=false;
		}
	return ;
}
int main()
{
	scanf("%d %d",&n,&c);
	for(int i=0;i<n;i++)
		scanf("%d",&L[i]);
	sort(L,L+n);reverse(L,L+n);
	dfs(1);
	double tans=ans/cnt;
	printf("%.20lf\n",tans);
	return 0;
}

Measured memory_bytes: 23552
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec fac, finv;

ll PowMod(ll a, ll n){
	if(n == 1) return a;
	if(n%2 == 0) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
	return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

void init(ll n = 2e6){
	fac.resize(n+1);
	fac[0] = 1;
	repn(i, n) fac[i] = (fac[i-1]*i)%MOD;
	finv.resize(n+1);
	finv[n] = PowMod(fac[n], MOD-2);
	repr(i, n) finv[i] = (finv[i+1]*(i+1))%MOD;
	finv[0] = 1;
}

int main(void){
	ll n, k;
	cin >> n >> k;
	init();
	if(k >= n-1){
		co(combi(2*n-1, n));
		return 0;
	}

	ll ans = 1;
	repn(i, k){
		ans += combi(n, i)*combi(n-1, i);
		ans %= MOD;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 31488
#include<stdio.h>

int main(void){
    char str[5];
    int i, j;
    int a=0;

    scanf("%s",str);
    for(i=0;i<4;i++){
        for(j=i+1;j<4;j++){
            if(str[i] == str[j]){
                a = a + 1;
            }
        }
    }
    if(a==2){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;

    
}


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

def quickSort(A, p, r):
    if p<r:
        q = partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)

def checker(A,start,end):
    for i in range(start,end-1):
        if A[i][1]==A[i+1][1]:
            if A[i][2]>A[i+1][2]:
                return "Not stable"
    return "Stable"

n = int(input())
l = []
for i in range(n):
    card = input().split()
    l.append((card[0],int(card[1]),i))
quickSort(l,0,n-1)
print(checker(l,0,n))
for s,n,c in l:
    print("{} {}".format(s,n))

Measured memory_bytes: 22152
fn main() {
    let (h, w): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut a: Vec<Vec<usize>> = Vec::with_capacity(h);

    for _ in 0..h {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        a.push(iter.map(|x| x.parse().unwrap()).collect());
    }

    for i in 0..h {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        for (j, x) in iter.map(|x| x.parse::<i32>().unwrap()).enumerate() {
            a[i][j] = (a[i][j] as i32 - x).abs() as usize;
        }
    }

    let m: usize = (h + w) * 80;

    let mut dp = vec![vec![vec![false; m]; w]; h];
    dp[0][0][a[0][0]] = true;

    for i in 0..h {
        for j in 0..w {
            for k in 0..m {
                if dp[i][j][k] == false { continue; }

                if i + 1 < h {
                    dp[i + 1][j][k + a[i + 1][j]] = true;
                    dp[i + 1][j][(k as i32 - a[i + 1][j] as i32).abs() as usize] = true;
                    dp[i + 1][j][(a[i + 1][j] as i32 - k as i32).abs() as usize] = true;
                }

                if j + 1 < w {
                    dp[i][j + 1][k + a[i][j + 1]] = true;
                    dp[i][j + 1][(k as i32 - a[i][j + 1] as i32).abs() as usize] = true;
                    dp[i][j + 1][(a[i][j + 1] as i32 - k as i32).abs() as usize] = true;
                }
            }
        }
    }

    let mut ans = std::usize::MAX;
    for (i, &x) in dp[h - 1][w - 1].iter().enumerate() {
        if x == true {
            ans = std::cmp::min(ans, i);
        }
    }

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

Measured memory_bytes: 96508
#include <iostream>

int main()
{
    int w, h, x, y, r;

    std::cin >> w >> h >> x >> y >> r;

    if(x - r < 0 || y - r < 0) std::cout << "No" << std::endl;
    else if(x + r > w || y + r > h) std::cout << "No" << std::endl;
    else std::cout << "Yes" << std::endl;

    return 0;
}


Measured memory_bytes: 3088
from itertools import accumulate

n, m, q = map(int, input().split())
rails = [[0] * n for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(s)) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*rails)]

buf = []
for _ in range(q):
    p, q = map(int, input().split())
    buf.append(rails[q-1][p-1])
print('\n'.join(map(str,buf)))


Measured memory_bytes: 82008
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>

using namespace std;

int main() {
	string s, t;

	cin >> s >> t;

	int result = s.compare(0, s.size(), t, 0, s.size());

	if (result == 0 && t.size() == s.size() + 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	N := ScanInt(scanner)
	X := ScanInt(scanner)
	
	sum := 0
	min := 1000
	for i := 0; i < N; i++ {
	    m := ScanInt(scanner)
	    sum += m
	    min = Min(min, m)
	}
	
	ans := N + (X - sum) / min
	fmt.Println(ans)
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
  
// 262144 = 2^18
int tree[262144]; 
  
int dfs(int a,int b,int k,int l,int r){
  if(r<a || b<l)return 0;
  if(a<=l && r<=b)return tree[k];
  int m=(l+r)/2;
  return dfs(a,b,k*2+1,l,m)+dfs(a,b,k*2+2,m+1,r);
}
  
int getSum(int a,int b){
  // 131072 = 2^17
  return dfs(a,b,0,0,131071);
}
  
void update(int i,int x){
  // 131072 = 2^17
  i+=(131072-1);
  tree[i]+=x;
  while(i){
    i=(i-1)/2;
    tree[i]+=x;
  }
}

int n,q;
  
int main(){
  scanf("%d %d",&n,&q);
  while(q--){
    int type;
    scanf("%d",&type);
    if(type==0){
      int l,r,x;
      scanf("%d %d %d",&l,&r,&x);
      update(l,x);
      update(r+1,-x);
      
    }else{
      int target;
      scanf("%d",&target);
      int ans=getSum(0,target);
      printf("%d\n", ans);
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

//Union-Find木（ランクなし）
//0-index
class union_find {
public:
	union_find(int n)
		: par_(n, -1)
	{}
	void init(int n) {
		par_.assign(n, -1);
	}

	int root(int x) {
		return par_[x] < 0 ? x : par_[x] = root(par_[x]);
	}

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) {
			return false;
		}
		else {
			if (par_[x] < par_[y]) {
				par_[x] += par_[y];
				par_[y] = x;
			}
			else {
				par_[y] += par_[x];
				par_[x] = y;
			}
			return true;
		}
	}

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

	int size(int x) {
		return -par_[root(x)];
	}

private:
	std::vector<int> par_;
};

signed main() {
	ll n, m, x, y, z;

	cin >> n >> m;

	union_find uf(n);
	ll ans = n;

	REP(i, m) {
		cin >> x >> y >> z;
		if (!uf.same(x - 1, y - 1)) {
			uf.unite(x - 1, y - 1);
			ans--;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
bool x;
int main(void){
	string s,t;
	cin>>s>>t;
	x=true;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			x=false;
		}
	}
	if(x){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
}


Measured memory_bytes: 3568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>
#include <complex>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

typedef complex<double> P;
const double EPS = 1e-9;
inline bool EQ(double a, double b){return abs(a-b)<EPS;}
inline double dot(P a, P b){return a.real()*b.real()+a.imag()*b.imag();}
inline double cross(P a, P b){return a.real()*b.imag()-a.imag()*b.real();}

int main(){
  int i,j,k,n;
  double xA,yA,xB,yB,xC,yC,xD,yD;

  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xA,&yA,&xB,&yB,&xC,&yC,&xD,&yD) != EOF){
    P ab((xB-xA),(yB-yA)), cd((xD-xC),(yD-yC));
    if(EQ(0,dot(ab,cd))) printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int sort(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

typedef struct edge {int s, g; ll d;} E;
typedef struct graph {
  int vcnt, ecnt;
  E e[200010];
  int id[100005];
} G;

int esort(const void *a, const void *b){
  E *x, *y;
  x = (E *)a; y = (E *)b;
  if(x->s < y->s) return -1;
  if(x->s > y->s) return  1;
  if(x->g < y->g) return -1;
  return 1;
}

void MakeGraph(G *g, int n, int m){
  g->vcnt = n; g->ecnt = 2 * m;
  int a, b; ll c;
  rep(i, g->ecnt / 2){
    scanf("%d %d %lld", &a, &b, &c);
    a--; b--;
    g->e[2 * i].s = a;
    g->e[2 * i].g = b;
    g->e[2 * i].d = c;
    g->e[2 * i + 1].s = b;
    g->e[2 * i + 1].g = a;
    g->e[2 * i + 1].d = c;
  }

  qsort(g->e, g->ecnt, sizeof(E), esort);

  int p = 0;
  rep(i, g->vcnt){
    while(p < g->ecnt && g->e[p].s < i) p++;
    g->id[i] = p;
  }
  g->id[g->vcnt] = g->ecnt;
 }




void dfs(G *g, int i, int *visited, ll *distance){
  visited[i] = 1;
  for(int j = g->id[i]; j < g->id[i + 1]; j++){
    int p = g->e[j].g;
    if(visited[p] == 0){
      distance[p] = g->e[j].d + distance[i];
      dfs(g, p, visited, distance);
    }
  }
  return;
}

int
main(int argc, char *argv[])
{
  int n;
  scanf("%d", &n);
  
  G g;
  MakeGraph(&g, n, n - 1);
  
  int q, k;
  scanf("%d %d", &q, &k);

  int visited[100005] = {}; ll distance[100005] = {};
  dfs(&g, k - 1, visited, distance);

  int x, y;
  rep(i, q){
    scanf("%d %d", &x, &y);
    printf("%lld\n", distance[x - 1] + distance[y - 1]);
  }

  return 0;
}

  
  
  





Measured memory_bytes: 12720
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long            ll;
typedef long double          ld;
typedef string               str;
typedef pair < ll , ll >     pll;

#define X               first
#define Y               second
#define pb              push_back
#define sep             ' '
#define endl            '\n'
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbl_io(x)       cout << fixed << setprecision(x);
#define int long long

const int N = 5e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e18 + 10;

struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n = N) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

FenwickTree A[30];

int32_t main(){
    fast_io
    //dbl_io(10);
    ll n, q;
    string s;
    cin >> n >> s >> q;
    for (ll i = 0; i < n; i ++)
        A[s[i] - 'a'].add(i, 1);
    while (q --){
        ll t;
        cin >> t;
        if (t == 1){
            ll ind;
            char x;
            cin >> ind >> x;
            ind --;
            A[s[ind] - 'a'].add(ind, -1);
            s[ind] = x;
            A[s[ind] - 'a'].add(ind, 1);
        }
        else{
            ll l, r;
            cin >> l >> r;
            l --; r --;
            ll ans = 0;
            for (ll i = 0; i < 26; i ++){
                ll res = A[i].sum(l, r);
                if (0 < res)
                    ans ++;
            }
            cout << ans << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 120220
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	ll X, K, D;
	cin >> X >> K >> D;
	ll n = abs(X) / D;
	if (n > K)
	{
		ll y = abs(X) - K * D;
		cout << y << endl;
		return 0;
	}
	ll m = K - n;
	if (m % 2 != 0)
		++n;
	ll y = abs(abs(X) - n * D);
	cout << y << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using T = tuple<int,int,int>;
int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());
    ll lp = 0, rp = 0;
    for(int i=0;i<n;i++)
        rp = max(rp, a[i] * f[i]);
    ll ans = -1;
    while(lp <= rp){
        if(lp == rp) {ans = lp;break;}
        ll mid = (lp+rp)/2;
        ll cnt = 0;
        for(int i=0;i<n;i++){
            if(a[i] * f[i] > mid){
                cnt += a[i] - mid/f[i];
            }
        }
        if(cnt > k)lp = mid+1;
        else rp = mid;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  ll u[n],a[m];
  memset(u,0,sizeof(u));
  for(ll i=0;i<m;i++) scanf("%lld",a+i);
  for(ll i=m-1;i>=0;i--){
    if(u[a[i]-1]) continue;
    printf("%lld\n",a[i]);
    u[a[i]-1]=1;
  }
  for(ll i=0;i<n;i++){
    if(!u[i]) printf("%lld\n",i+1);
  }
  return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    string s;
    cin>>s;
    int ans=0;
    int tmp=0;
    rep(i,3){

        if(s[i]=='R'){
            tmp++;
        }
        else{
            tmp=0;
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n,m;
    cin>>n>>m;
    int sum=0;
    int a[n];
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    int cnt=0;
    rep(i,n){
        if(a[i]*4*m>=sum)++cnt;
    }
    if(cnt>=m){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N = I(); A = LI(); judge=True
    for i in A:
        if i%2==0:
            if i%3!=0 and i%5!=0:
                judge=False
    if judge:
        print('APPROVED')
    else:
        print('DENIED')
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;

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

  ll a[n], b[n];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];

  ll ans=0;

  //各ビットについて調査
  for(ll bit=0; bit<30; bit++){
    ll cnt=0;
    ll t = 1ll << bit;

    //tmpa, tmpbを用意
    vector<ll> tmpa(n), tmpb(n);
    for(int i=0; i<n; i++){
      tmpa[i] = a[i] % (2*t);
      tmpb[i] = b[i] % (2*t);
    }

    sort(tmpb.begin(), tmpb.end());

    //a_jを固定して考える
    for(int j=0; j<n; j++){
      cnt += lower_bound(tmpb.begin(), tmpb.end(), 4*t-tmpa[j])-lower_bound(tmpb.begin(), tmpb.end(), 3*t-tmpa[j]);
      cnt += lower_bound(tmpb.begin(), tmpb.end(), 2*t-tmpa[j])-lower_bound(tmpb.begin(), tmpb.end(), t-tmpa[j]);
    }
    if(cnt%2==1) ans += t;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8492
var S = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0]
var ans = 0
var status =0
while(status == 0){
  	//console.log(S,status)
  	if(S != ""){
		var seven = S.slice(-7);
      	var six = S.slice(-6)
		var five = S.slice(-5);
      	//console.log(six)
		if(seven =="dreamer"){
	      S = S.slice(0,-7)
    	}
      	else if(six =="eraser"){
	      S = S.slice(0,-6)
    	}
		else if(five == "dream" || five == "erase"){
          //console.log(five)
	      S = S.slice(0,-5)
	    } 
  		else{
      		status = 1
      		console.log("NO")
    	}
    }else{
      status =1;
      console.log("YES")
    }
}


Measured memory_bytes: 11340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string s;
  cin>>s;
  int a=0,z=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      a=i;
      for(int j=s.size()-1;j>i;j--){
        if(s[j]=='Z'){
          z=j;
          cout<<z-a+1<<endl;
          return 0;
        }
      }
    }
  }
}


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

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

    bool have[34];
    for(int i = 0; i < 29; i++)
        have[i] = false;

    string s;
    cin >> s;
    for(char c : s) {
        have[c - 'a'] = true;
    }

    for(int i = 0; i < 26; i++) {
        if(have[i] == false) {
            cout << (char)('a' + i);
            return 0;
        }
    }

    cout << "None";
    return 0;
}

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

using namespace std;

int main(){
int n;
cin>>n;
n=n%10;
if (n==3)
{
    cout<<"bon"<<endl;
}
else if(n==2||n==4||n==5||n==7||n==9)
{
    cout<<"hon"<<endl;
}
else if (n==0||n==1||n==6||n==8)
{
    cout<<"pon"<<endl;
}


return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(){
  int n , y;
  cin >> n >> y;
  for(int i = 0; i <= n; i++){
    for(int j = 0; i+j <= n; j++){
      if(i * 10000 + j * 5000 + (n-i-j) * 1000 == y){
        cout << i << " " << j << " " << (n-i-j) << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
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();
    String winner = "";
    if(A == B){
      winner = "Draw";
    }else if (A == 1){
      winner = "Alice";
    }else if(B == 1){
      winner = "Bob";
    }else if(A > B){
      winner = "Alice";
    }else{
      winner = "Bob";
    }
    System.out.println(winner);
  }
}


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

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

	while( cin >> a >> b >> n ){
		int sum = 0;
		a %= b;
		for(int i=0 ; i<n ; ++i ){
			a *= 10;
			sum += (a/b) % 10;
			a %= b;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

int main(){
    int N; string s, t; cin >> N >> s >> t;
    int num = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == t[0]){
            if(s.substr(i) == t.substr(0, s.size()-i)){
                num = s.substr(i).size();
                break;
            }
        }
    }
    cout << s.size() + t.size() - num << endl;
}

Measured memory_bytes: 256
def solve():
  n, k = map(int,input().split())
  group_num = 10
  
  book_map = [[] for i in range(group_num)]
  acc_map = [[0] for i in range(group_num)]

  for i in range(n):
    c,g = map(int,input().split())
    book_map[g - 1].append(c)

  for i in range(group_num):
    book_map[i].sort(reverse=True)
    acc = 0
    bmi = book_map[i]
    append = acc_map[i].append
    for j in range(len(bmi)):
      acc += (bmi[j] + j * 2)
      append(acc)
  
  dp = [[0] * (k + 1) for i in range(group_num + 1)]
  for y in range(1,k + 1):
    for x in range(1,group_num + 1):
      mp = acc_map[x - 1]
      be = dp[x - 1]
      for z in range(min(y + 1, len(mp))):
        v1 = be[y - z]
        v2 = mp[z]
        if dp[x][y] < v1 + v2:
          dp[x][y] = v1 + v2
  
  print(dp[group_num][k])
solve()



Measured memory_bytes: 6312
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <stack>

using namespace std;




int main(void)
{
    string s;
    
    while(getline(cin, s)){
        stack<double> st;
        string p[80];
        int num=0;
        for(int i=0; i<s.length(); i++){
            if(s[i]==' '){
                num++;
            }else{
                p[num]+=s[i];
            }
        }
        /*
        for(int i=0; i<=num; i++){
            cout<<i<<":"<<p[i]<<endl;
        }
        */
        for(int i=0; i<=num; i++){
            if(p[i]=="+"){
                //cout<<"35TTT"<<endl;
                double n1=st.top();
                st.pop();
                double n2=st.top();
                st.pop();
                st.push(n1+n2);
            }
            else if(p[i]=="-"){
                double n1=st.top();
                st.pop();
                double n2=st.top();
                st.pop();
                st.push(n2-n1);
            }
            else if(p[i]=="*"){
                double n1=st.top();
                st.pop();
                double n2=st.top();
                st.pop();
                st.push(n1*n2);
            }
            else if(p[i]=="/"){
                double n1=st.top();
                st.pop();
                double n2=st.top();
                st.pop();
                st.push(n2/n1);
            }else {
                st.push(atof(p[i].c_str()));
            }
            //cout<<p[i]<<endl;
            
        }
        cout<<fixed<<setprecision(6)<<st.top()<<endl;
    }
    
    
}

Measured memory_bytes: 1276
import java.util.*;

public class Main {

    public static void main(String[] args) {
        String[] tStringArr = new String[]{
                "dream",
                "dreamer",
                "erase",
                "eraser",
        };

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String sReverse = new StringBuilder(s).reverse().toString();
        for (int i = 0; i < tStringArr.length; i++) {
            tStringArr[i] = new StringBuilder(tStringArr[i]).reverse().toString();
        }

        boolean ans = true;
        for (int i = 0; i < sReverse.length();) {

            boolean flg = false;// 文字列が部分一致するか

            for (int j = 0; j < tStringArr.length; j++) {
                String tmpSubString = "";
                if (i + tStringArr[j].length() > sReverse.length()) {
                    tmpSubString = sReverse.substring(i);
                } else {
                    tmpSubString = sReverse.substring(i, i + tStringArr[j].length());
                }

                if (tmpSubString.equals(tStringArr[j])) {
                    // 一致したので次の文字列比較へ進む
                    i += tmpSubString.length();
                    flg = true;
                    break;
                }
            }

            if (!flg) {
                ans = false;
                break;
            }
        }

        System.out.println(ans ? "YES" : "NO");
    }
}


Measured memory_bytes: 28652
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

ll cnt = 0, n;

void count(ll x, bool t, bool f, bool s){
    if(x > n) return;
    else {
        if(t && f && s) cnt++;
        count(x*10+3,1,f,s);
        count(x*10+5,t,1,s);
        count(x*10+7,t,f,1);
    }
}

int main(){
    cin >> n;
    count(0,0,0,0);
    cout << cnt << endl;
    return 0;
}


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

int main() {
  vector<int> vec(2);
  for(int i=0; i<2; i++) cin>>vec.at(i);
  sort(vec.begin(),vec.end());
  if(vec.at(1)-vec.at(0)>=1) cout<<vec.at(1)*2-1<<endl;
  else if(vec.at(1)-vec.at(0)==0) cout<<vec.at(1)*2<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, m, x, y;
    bool check = false;
    sc(n) sc(m)
    vector<int> from;
    set<int> s;
    for (int i = 0; i < m; i++){
        sc(x) sc(y)
        if (y == n) s.insert(x);
        else if (x == 1) from.push_back(y);
    }
    for (int i = 0; i < from.size(); i++){
        if (s.find(from[i]) == s.end()) continue;
        check = true; 
    }
    if (check) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;

int main() {
  
  int Tc; cin >> Tc;
  int ans = 0;
  while(Tc --) {
    int K; cin >> K;
    bool ok = 0;
    for(int x=1; 2*x*x+2*x <= K; x++)
      if((K-x)%(2*x+1) == 0) { ok = 1; break; }
    if(!ok) { ans ++; }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//体積出す
//容積の半分以上だった場合と、そうでない場合に分ける
int main(){
  ll a,b,x; cin>>a>>b>>x;
  long double vol=a*a*b, in, PI=acos(-1), DEF=0.0000000000000001;
  long double low=0, high=PI/2, theta=(low+high)/2;
  //かならずしも45°が容積の半分とはかぎらないな
  if(a*tan(theta)<b) in=vol-a*a*tan(theta)/2*a;
  else in=b*b*tan(PI/2-theta)/2*a;
  while(low+DEF<high || high-DEF>low){
    if(x<in) low=theta;
    else high=theta;
    theta=(low+high)/2;
    if(a*tan(theta)<b) in=vol-a*a*tan(theta)/2*a;
    else in=b*b*tan(PI/2-theta)/2*a;
  }
  cout << fixed << setprecision(10) << theta*180/PI << endl;
}

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

long long inf = 1e18;

int main() {
  ios_base::sync_with_stdio(0);
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  long long wyn;
  if (k % 2 == 0) wyn = a - b;
  else wyn = b - a;
  
  if (abs(wyn) > inf) cout << "Unfair" << endl;
  else cout << wyn << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll,ll>;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}
const long long MOD = 1000000007;
vector<int> places[210000];
long long dp[210000];
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
int main() {
    // 入力
    int N; cin >> N;
    vector<int> c(N);
    for (int i = 0; i < N; ++i) cin >> c[i];
    // places[i] := (c[j] = i となるような j の集まり)
    for (int i = 0; i < 210000; ++i) places[i].clear();
    for (int i = 0; i < N; ++i) places[c[i]].push_back(i);
    // DP
    dp[0] = 1;
    for (int i = 1; i <= N; ++i) {
        // 特に操作しない場合
        add(dp[i], dp[i-1]);
        // 操作する場合
        int color = c[i-1];
        int it = lower_bound(places[color].begin(), places[color].end(), i-1)
            - places[color].begin(); // c[i] が color 色の何番目の要素か
        if (it > 0) {
            int j = places[color][it - 1]; // c[j] = c[i] となる j
            if ((i-1) - j > 1) add(dp[i], dp[j+1]);
        }
    }
    std::cout << dp[N] << std::endl;
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,high,ind,H,f;
  cin>>n;
  int x[n],y[n],h[n];
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]>0){ind=i;}
  }
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      f=1;
      H=max(h[ind]+abs(i-x[ind])+abs(j-y[ind]),0);
      for(int k=0;k<n;k++){
        if(max(H-abs(i-x[k])-abs(j-y[k]),0)!=h[k]){f=0;break;}
      }
      if(f){cout<<i<<' '<<j<<' '<<H<<endl;return 0;}
    }
  }
}

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

using namespace std;
int main(void){
	int n, m;
	int max = 0;
	int temp = 0;
	string s[100];
	string t[100];
	
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> s[i];
	cin >> m;
	for(int i=0; i<m; i++)
		cin >> t[i];
	
	for(int i=0; i<n; i++){
		temp = 0;
		for(int j=0; j<n; j++){
			if(s[i] == s[j])
				temp++;
		}
		for(int j=0; j<m; j++){
			if(s[i] == t[j])
				temp--;
		}
		if(temp >= max){
			max = temp;
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

std::uint64_t gcd(std::uint64_t x, std::uint64_t y)
{
    if (x < y) std::swap(x, y);
    auto z = x % y;
    if (z == 0) return y;
    return gcd(y, x % y);
}

std::size_t prime_factor_count(std::uint64_t x)
{
    std::size_t res = 0;
    for (std::uint64_t i = 2; i * i <= x; ++i) {
        bool f = false;
        while (x % i == 0) {
            x /= i;
            f = true;
        }
        if (f) ++res;
    }
    if (x != 1) ++res;
    return res;
}

int main()
{
    input in;
    output out;

    std::uint64_t A, B;
    in >> A, B;
    out << prime_factor_count(gcd(A, B)) + 1;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] list = sc.next().split("");

        String x = list[list.length - 1];
        if (x.equals("3"))  System.out.println("bon");
        else if (x.equals("0") || x.equals("1") || x.equals("6") || x.equals("8")) System.out.println("pon");
        else System.out.println("hon");
    }
}

Measured memory_bytes: 26972
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N, a[2020], dp[2][2020];

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

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

  for(int i=N-1;i>=0;i--) {
    dp[0][i]=dp[1][i]=abs(a[N]-a[i]);
    for(int j=i+1;j<=N-1;j++) {
      dp[0][i]=max(dp[0][i],dp[1][j]);
      dp[1][i]=min(dp[1][i],dp[0][j]);
    }
  }

  cout << dp[0][0] << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
list=[]

i=0
while N>0:
    a=(N//(26**i))%26
    if a>0:
       list.append(chr(a+96))
       N=N-a*(26**i)
    else:
       list.append("z")
       N=N-26*(26**i)
    i+=1

list2=list[::-1]
ret=''.join(list2)
print(ret)

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

int main()
{
	FASTIO;
	ll k,a,b,x,y;
	cin>>k;
	cin>>a>>b;

	x=a%k;
	y=a+k-x;

	if(y<=b || x==0)
        cout<<"OK"<<"\n";
    else
        cout<<"NG"<<"\n";


}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    string S;
    cin >> S;
    string t = S;
    int size_ = t.size();
    bool is_keyence = false;
    for (int i=0; i<size_; i++) {
        string f = S.substr(0, i+1);
        for (int j=i+1; j<size_; j++) {
            string e = S.substr(j, size_-j);
            if (f + e == "keyence") {
                is_keyence = true;
                break;
            }
        }
    }

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

Measured memory_bytes: 3636
import numpy as np

# 入力
N = int(input())
a = np.array([[int(i) for i in input().split()] for j in range(N)]).T

# a(0行), b(1行), c(2行)の添え字付きDPテーブルを生成
dp = np.zeros(3*(N+1), dtype=int).reshape(3, (N+1))

# 0日目(0)からN-1日目(N-1)までループ処理
for i in range(N):    # 参照する前日(i)
    for j in [0, 1, 2]:    # 前日(i)のアクティビティ
        for k in [0, 1, 2]:    # 当日(i+1)のアクティビティ
            if j != k:    # 前日のアクティビティではいけない
                dp[k, i+1] = max(dp[k, i+1], dp[j, i] + a[j, i])
                
# N日目の処理
ans = 0
for j in [0, 1, 2]:
    ans = max(ans, dp[j, N])
print(ans)

Measured memory_bytes: 35568
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let AS = reads int
    if Array.sum AS >= 22 then
        printfn "bust"
    else
        printfn "win"
    0

Measured memory_bytes: 13532
import math


while True:
    line = input()
    element = line.split(' ')
    a = int(element[0])
    b = int(element[2])
    op = element[1]
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(math.floor(a / b))




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep0c(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep1c(i, n) for (int i = 1; i <= (int)(n); i++)
#define repc0(n, i) for (int i = (int)(n); i >= 0; i--)

using namespace std;
typedef long long ll;

int N, K;
string S;

void solve() {
  char past = '1';
  int past_count = 0;
  vector<int> zeros, ones;
  rep(i, N) {
    char current = S[i];
    if(past != current) {
      if(past == '1') ones.push_back(past_count);
      else zeros.push_back(past_count);
      past = current;
      past_count = 0;
    }
    past_count++;
  }
  if(past == '1') ones.push_back(past_count);
  else {
    zeros.push_back(past_count);
    ones.push_back(0);
  }
  K = min((int)zeros.size(), K);
  if(K==0) {
    cout << ones[0] << endl;
    return;
  }
  int pastv = ones[K];
  for(int j=0; j<K; j++) pastv += ones[j] + zeros[j];
  int maxv = pastv;
  int ends = ((int)zeros.size())-K+1;
  rep1(i, ends) {
    pastv += ones[i+K] + zeros[i+K-1] - ones[i-1] - zeros[i-1];
    maxv = max(maxv, pastv);
  }
  cout << maxv << endl;
}

int main() {
  cin >> N >> K >> S;
  solve();
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void) {

	int a, b;
	cin >> a >> b;

	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)

int main(void) {
  int n, i, j, t, r, k;
  scanf("%d%d%d", &n, &r, &t);
  int p[n], dr[r], now[n], drn[r];
  rep(i, r) dr[i] = 0;
  rep(i, n) now[i] = 0;
  rep(i, n) scanf("%d", &p[i]);
  rep(i, t) {
    rep(j, r) drn[j] = 0;
    rep(j, n) {
      now[j] += p[j];
      now[j] %= r;
      if(i) {
        if(dr[now[j]]) --dr[now[j]];
        drn[now[j]]++;
      }
    }
    rep(j, r) dr[j] += drn[j];
  }
  int ans = 0;
  /*rep(i, r) printf("%d ", dr[i]);
  printf("\n");*/
  rep(i, r) ans += dr[i];
  printf("%d\n", ans + n);
  return 0;
}


Measured memory_bytes: 2740