akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    map<int, int> counts;
    FOR(i, 0, N) {
        int a;
        cin >> a;
        counts[a]++;
    }

    int ret = 0;
    for (auto& pr : counts) {
        int x = pr.FIR, y = pr.SEC;
        if (y < x)
            ret += y;
        else if (y > x)
            ret += y - x;
    }

    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 4736
import std.stdio, std.string, std.conv, std.algorithm, std.range, std.array, std.typecons, std.math, std.numeric;

long lcm(long a, long b) {
    return a * b / gcd(a, b);
}

void main() {
    long a,b,c,d;
    readf("%d %d %d %d\n", &a, &b, &c, &d);
    long e = lcm(c, d);

    long a1 = a + (c - a % c) % c;
    long b1 = b - b % c;
    // writefln("(%d, %d) -> %d", a1, b1, (b1 - a1) / c + 1);

    long a2 = a + (d - a % d) % d;
    long b2 = b - b % d;
    // writefln("(%d, %d) -> %d", a2, b2, (b2 - a2) / d + 1);

    long a3 = a + (e - a % e) % e;
    long b3 = b - b % e;
    // writefln("(%d, %d) -> %d", a3, b3, (b3 - a3) / e + 1);

    long ans = (b - a) + 1;
    ans -= (b1 - a1) / c + 1;
    ans -= (b2 - a2) / d + 1;
    ans += (b3 < a3) ? 0 : ((b3 - a3) / e + 1 );

    writeln(ans);


}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

const int64_t MOD = 998244353;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	vector<pair<int,int>> v;
	int b, w;
	b = w = 0;
	v.push_back(make_pair(0, 0));
	for (int i = 0; i < n; ++i) {
		if (s[i] == '#') {
			b++;
		}
		else {
			w++;
		}
		v.push_back(make_pair(b, w));
	}
	int min_cost = n;
	for (int i = 0; i < v.size(); ++i) {
		auto item = v[i];
		int left_b = item.first;
		int left_w = item.second;
		int right_b = b - item.first;
		int right_w = w - item.second;
		int cost = left_b + right_w;
		min_cost = min(cost, min_cost);
	}
	cout << min_cost << endl;
	return 0;
}

Measured memory_bytes: 2680
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

uf = UnionFind(n)
#print(uf.parents)

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1, b-1)
    #print(uf.parents)

print(abs(min(uf.parents)))

Measured memory_bytes: 14360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<int> ans(n,0);
    rep(i,n-1){
        int x;cin >> x;x--;
        ans[x]++;
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}
// ll n;cin >> n;
// vector<int> a(n);
// rep(i,n) cin >> a[i];

// cout << (res?"Yes":"No") << endl;
// cout << ans << endl;

Measured memory_bytes: 3996
# https://atcoder.jp/contests/abc126/tasks/abc126_d
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())

    ans = [-1] * (N + 1)
    vec = defaultdict(list)
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        vec[u].append((v, w))
        vec[v].append((u, w))

    que = [1]
    ans[1] = 0  # 1 を白にする

    while que:
        cursor = que.pop(0)
        for next, weight in vec[cursor]:
            if ans[next] == -1:
                if weight % 2 == 0:
                    ans[next] = ans[cursor]
                else:
                    ans[next] = 1 if ans[cursor] == 0 else 0
                que.append(next)
    for i in ans[1:]:
        print(i)


if __name__ == '__main__':
    main()


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  string S;
  cin >> S;
  string ans;
  if(S == "ABC"){
    ans = "ARC";
  } else {
    ans = "ABC";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <deque>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main()
{
    int r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++)
    {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
using namespace std;
long long n,s,w[1005],v[1005],f[1005][100005],i,j;
int main()
    {
        cin>>n>>s;
        for (i=1;i<=n;i++) cin>>w[i]>>v[i];
        for (i=1;i<=n;i++)
            for (j=1;j<=s;j++)
        {
            if (j-w[i]>=0) f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
            else f[i][j]=f[i-1][j];
        }
        cout<<f[n][s];
        return 0;
    }


Measured memory_bytes: 79360
#include <stdio.h>
#include <stdlib.h>
#define l 200000
#define L 1000000000
#define s 2
#define S 1

int main(){

  int C[l],i,big=0,n,oum;

  scanf("%d",&n);

  if(s<=n&&n<=l){
    i=0;
    while(i<n){
      scanf("%d",&C[i]);
      if(S>C[i]||C[i]>L){
	exit(1);
      }
      i++;
    }
    big=C[i-1];
    oum=C[i-1]-C[i-2];

    i=n-2;
    while(i>=0){
      if(big<C[i]&&i!=0){
	big=C[i];
      }
      if(oum<big-C[i]&&C[i]!=big){
	oum=big-C[i];
      }
      i--;
    }
  }
  else{
    exit(1);
  }

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



Measured memory_bytes: 2588
def solve():
    N = int(input())
    As = list(map(int, input().split())) + [0]

    pow2 = 2**N

    anss = []
    ans = 0
    max2s = [[0, -1]]
    for S in range(1, pow2):
        m1, m2 = S, -1
        for i in range(N):
            if (S>>i)&1:
                S0 = S^(1<<i)
                i1, i2 = max2s[S0]
                if m1 == i1:
                    m2 = m2 if As[m2] >= As[i2] else i2
                elif As[m1] >= As[i1]:
                    m2 = m2 if As[m2] >= As[i1] else i1
                else:
                    m2 = m1 if As[m1] >= As[i2] else i2
                    m1 = i1
        ans2 = As[m1]+As[m2]
        if ans2 > ans:
            ans = ans2
        anss.append(ans)
        max2s.append([m1, m2])

    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 80568
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll width[30]={1};
ll cal(ll x1,ll y1,ll x2,ll y2,int level) {
    if(level==0) return abs(y1-y2);
    ll w=width[level-1];
    if(x1/w!=x2/w) return abs(x1-x2)+abs(y1-y2);//不同层
    if(x1/w==1&&abs(y1/w-y2/w)>=2) {//同层且在456这层
        return min(x1%w+x2%w+2,w*2-x1%w-x2%w)+abs(y1-y2);
    }
    return cal(x1%w,y1,x2%w,y2,level-1);
}
int main() {
    for(int i=1;i<30;i++) width[i]=width[i-1]*3;
    int T;
    scanf("%d",&T);
    while(T--) {
        ll a,b,c,d;
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d),a--,b--,c--,d--;
        if(abs(a-c)>abs(b-d)) swap(a,b),swap(c,d);//避免（2，8）
        printf("%lld\n",cal(a,b,c,d,30));
    }
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int n,c[1000],w[1000];
bool done[1000][1000],p[1000][1000];
int s[1001],dp[1000];

bool memo(int i,int j){
    if(done[i][j]) return p[i][j];
    done[i][j]=true;
    if(memo(i+1,j) and c[i]>=s[j+1]-s[i+1]) return p[i][j]=true;
    if(memo(i,j-1) and c[j]>=s[j]-s[i]) return p[i][j]=true;
    return false;
}

void solve(){
    cin >> n;
    rep(i,0,n) cin >> c[i] >> w[i];

    rep(i,1,n+1) s[i]=s[i-1]+w[i-1];

    rep(i,0,n) p[i][i]=done[i][i]=true;
    rep(i,0,n) rep(j,i+1,n) memo(i,j);

    fill_n((int*)dp,1000,inf);
    rep(i,0,n) rep(j,i,n){
        if(!p[i][j]) continue;
        if(i==0){
            dp[j]=1;
            continue;
        }
        dp[j]=min(dp[j],dp[i-1]+1);
    }

    cout << dp[n-1] << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define vec vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define vsort(vec) sort(vec.begin(),vec.end())
using namespace std;
signed main() {
	int a, b, c, ans = 0;
	cin >> a >> b >> c;
	if (a + b + 1 >= c) {
		ans = b + c;
	}
	else {
		ans = b + a + b + 1;
	}
	cout << ans << endl;
	system("PAUSE");
	return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n, r;
  cin >> n >> r;
  
  if(n >= 10)
    cout << r << endl;
  else
    cout << r+ 100*(10-n) << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};
int H, W;
string s[50];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  int sum = 0;
  for (int i = 0; i < H; i++) {
    cin >> s[i];
    for (int j = 0; j < W; j++) {
      sum += s[i][j] == '#';
    }
  }  
  using P = pii;
  queue<P> que;
  que.emplace(0, 0);
  int dist[50][50];
  const int INF = 1 << 20;
  fill_n((int*)dist, 50 * 50, INF);
  dist[0][0] = 0;
  while (!que.empty()) {
    int y, x;
    tie(y, x) = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if (ny >= 0 && ny < H && nx >= 0 && nx < W && s[ny][nx] != '#' && dist[ny][nx] == INF) {
        dist[ny][nx] = dist[y][x] + 1;
        que.emplace(ny, nx);
      }
    }
  }
  if (dist[H - 1][W - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << H * W - sum - dist[H - 1][W - 1] - 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	ll a,b,c,k; cin>>a>>b>>c>>k;
	if(k <= a+b)
		cout<<min(k,a);
	else
		cout<<(2*a+b-k);		
	return 0;
}

Measured memory_bytes: 3696
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int N, T;
    cin >> N >> T;

    vector<int> paths;
    for (int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            paths.push_back(c);
        }
    }
    sort(paths.begin(), paths.end());

    if (paths.empty()) {
        cout << "TLE" << endl;
    } else {
        cout << paths[0] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin >> s;
	string t = "";
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') t.push_back('0');
		else if (s[i] == '1') t.push_back('1');
		else if (t.size() > 0) t.pop_back();
	}
	cout << t << endl;
}

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

int main() {
  // 科目の数Nを受け取る
  int N,a,b,c=0;
  //char a;
  cin >> N;

  for(int i=0;i<N;i++)
  {
    cin >> a>>b;
    c += b-a+1;
  }
  cout << c <<endl;

  return 0;
}


  

Measured memory_bytes: 256
import sys

def fi(li):
    for i in range(1,len(li)):
        if li[i-1] > li[i]:
            return False
    return True

def main():
    n=int(input())
    ps=list(map(int,input().split()))
    if fi(ps):
        print("YES")
        return 0
    for i in range(len(ps)):
        for j in range(i,len(ps)):
            if ps[i]>ps[j]:
                ps[i],ps[j]=ps[j],ps[i]
                if fi(ps):
                    print("YES")
                    return 0
                ps[i],ps[j]=ps[j],ps[i]
    print("NO")
    return 0

if __name__ == "__main__":
    sys.exit(main())


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
using namespace std;
typedef long long unsigned int llui_t;
typedef long long int lli_t;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

/* inputs */
long long unsigned int N, M;

int main() {
    cin >> N >> M;
    if(N==1 && M==1) {
        cout << 1 << endl;
    } else if(N==1 || M==1) {
        cout << N*M - 2 << endl;
    } else {
        cout << (N-2) * (M-2) << endl;
    }
}


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

using namespace std;

#define MAX 100010
const int MAX_N = 1<<17;
typedef long long ll;

class RMQ{
public:
  ll n,dat[2*MAX_N-1];
  
  void init(int n_){
    n = 1;
    while(n < n_){ n *= 2; }
    for(int i = 0 ; i < 2*n-1 ; i++){
      dat[i] = 0LL;
    }
  }

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

  ll query(ll a,ll b,ll k,ll l,ll r){
    if(r <= a || b <= l){ return 0LL; }
    if(a <= l && r <= b){
      return dat[k];
    }else{
      ll vl = query(a,b,k*2+1,l,(l+r)/2);
      ll vr = query(a,b,k*2+2,(l+r)/2,r);
      return max(vl,vr);
    }
  }
};

int main(){
  ll N,x[MAX],sum = 0LL;
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> x[i];
    sum += x[i];
  }
  RMQ rmq;
  rmq.init(N);
  for(int i = 0 ; i < N ; i++){
    ll c = rmq.query(1,x[i]+1,0,0,rmq.n);
    rmq.update(x[i],c+x[i]);
  }
  cout << sum-rmq.query(1,N+1,0,0,rmq.n) << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

int main() {
    ios::sync_with_stdio(false);
    int a[3][3];
    int n;
    rep(y, 3) {
        rep(x, 3) { cin >> a[y][x]; }
    }
    cin >> n;

    vector<int> b(n);
    rep(i, n) {
        int t;
        cin >> t;

        rep(y, 3) {
            rep(x, 3) {
                if (a[y][x] == t) {
                    a[y][x] = -1;
                }
            }
        }
    }

    rep(y, 3) {
        if (a[y][0] + a[y][1] + a[y][2] == -3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(x, 3) {
        if (a[0][x] + a[1][x] + a[2][x] == -3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (a[0][0] + a[1][1] + a[2][2] == -3 ||
        a[0][2] + a[1][1] + a[2][0] == -3) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
int main(){
 int w,h,x,y,r,f;
 scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
 f=0;
 if(w<x+r)f=1;
 if(h<y+r)f=1;
 if(x<r)f=1;
 if(y<r)f=1;
 if(f==0)printf("Yes\n");
 else printf("No\n");
 return 0;
}

Measured memory_bytes: 1816
n = int(input())

def func(n):
    if n % 2 != 0:
        return 0

    n_half = n//2
    count = 0

    i = 1
    while 5**i <= n_half:
        count += n_half // 5**i
        i += 1

    return count


print(func(n))


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
	long ans = 0;
	int N;
	scanf("%d",&N);
	long A[N];
	int i = 0;
	for(i=0 ; i<N ; i++){
		scanf("%ld",&A[i]);
	}
	ans += A[0]-1 ;
	long r = 2;
	for(i = 1; i<N ; i++)
	{
		if(A[i] != r){
			ans += (A[i]-1)/r ;
		}
		else
			r++;
	}
	printf("%ld\n",ans);
	return 0;
}

Measured memory_bytes: 896
n = int(input())
w_dic =	{}
for i in range(n):
    w = input()
    if w_dic.get(w, False):
        print('No')
        break
    if i != 0:
        if last_word != w[0]:
            print('No')
            break
    last_word = w[-1]
    w_dic[w] = True
    if i == n-1:
        print('Yes')

Measured memory_bytes: 3060
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
num = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |z|
      if 500 * i + 100 * j + 50 * z == x
        num += 1
      end
    end
  end
end
puts num

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  vector<int> Q(N);
  for (int i = 0; i < N; i++) {
    cin >> Q.at(i);
  }
  vector<int> PP(N);
  vector<int> QQ(N);
  int p=0;
  
  for (int i =0; i <N; i++) {
    int d=0;
     for (int j = i+1; j <N; j++) {
       if(P.at(i)>P.at(j)){
         d++;
         
       }
       PP.at(i)=d; 
       int c=N-i-1;
       while(c>0){
        PP.at(i)*=c;
         c--;
       }
     }
  }
  
  for (int i =0; i <N; i++) {
    int d=0;
     for (int j = i+1; j <N; j++) {
       if(Q.at(i)>Q.at(j)){
         d++;
         
       }
       QQ.at(i)=d; 
       int c=N-i-1;
       while(c>0){
        QQ.at(i)*=c;
         c--;
       }
     }
  }
  for (int i = 0; i < N; i++) {
    p=p+PP.at(i)-QQ.at(i);
  }
  if(p>0){
    
    cout<<p<<endl;
  }
  else{
    cout<<-p<<endl;
  }
}

Measured memory_bytes: 256
'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  inp[0] = inp[0].split(' ')
  const N = Number(inp[0][0]) // 全長
  const K = Number(inp[0][1]) // 最大操作数
  inp = inp[1]

  let b = 1 // 分割数
  for (let i = 0; i < N - 1; i++) {
    if (inp[i] !== inp[i+1]) b++
  }

  console.log(Math.min(N - b + (2 * K), N - 1))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

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

    vector<int> v;

    for(int i=0; i<m; i++){
        int input;
        cin>>input;
        v.push_back(input);
    }

    int result = n-accumulate(v.begin(), v.end(), 0);

    if(result>=0)
        cout<<result;
    else
        cout<<"-1";
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
const int P=1e9+7;
const int N=1<<20|11111;
int n,m,k,mx;
int lim[25][2];
int F[23][N],D[23][N];
inline int fix(int x){
	return x+(x>>31&P);
}
int main(){
	scanf("%d%d%d",&n,&m,&k);//m lines 
	for(int i=1,a,b,c;i<=k;++i){
		scanf("%d%d%d",&a,&b,&c);
		lim[a][c]|=1<<n-1-b;
	}
	--n;
	if(!n)return puts("1"),0;
	mx=1<<n;
	for(int i=0;i<n;++i){
		for(int j=0;j<mx;++j)if(j>>i&1){
			int x=j,y=i;
			x^=1<<i;
			for(--y;y>=0&&(x>>y&1);--y);
			if(y>=0)x^=1<<y;
			D[i][j]=x;
//			printf("%d,%d %d\n",i,j,x);
		}
	}
	for(int i=0;i<mx;++i)F[n][i]=1;
	for(int i=1;i<=m;++i){
//		printf("(%d %d)\n",lim[i][0],lim[i][1]);
		for(int j=0;j<mx;++j){
			F[0][j]=(j&lim[i][0]|~j&lim[i][1])?0:F[n][j];
//			printf("%d,%d %d\n",i,j,F[0][j]);
		}
		for(int j=0;j<n;++j){
			int*F1=F[j+1],*F0=F[j],*D1=D[j];
			for(int k=0;k<mx;++k){
				F1[k]=F0[k];
				if(k>>j&1)F1[k]=fix(F1[k]+F0[D1[k]]-P);
			}
		}
	}
	printf("%d\n",F[n][mx-1]);
	return 0;
}

Measured memory_bytes: 160000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string A, B, ans;

	cin >> A >> B;

	if (A.length() > B.length()) ans = "GREATER";
	else if (A.length() < B.length()) ans = "LESS";
	else {
		ans = "EQUAL";
		rep(i, (int)A.length()) {
			if (A[i] > B[i]) {
				ans = "GREATER";
				break;
			}
			else if (A[i] < B[i]) {
				ans = "LESS";
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N;
string S;

signed main() {
  cin >> N >> S;

  vi w(N), e(N); 
  int W = 0, E = 0;
  rep(i, 0, N) {
    if(S[i] == 'W') {
      W++;
      w[i] = W;
      e[i] = E;
    }else{
      E++;
      w[i] = W;
      e[i] = E;
    }
  }

  
  vi ans(N);
  rep(i, 0, N) {
    ans[i] = w[i] + e[N-1] - e[i];
    if(S[i] == 'W') ans[i]--;
  }
  SORT(ans);
  cout << ans[0] << endl;
  return 0;
}



Measured memory_bytes: 7684
#include <math.h>
#include <bits/stdc++.h>//一括で読み込み
typedef long long ll;
using namespace std;

int p, q, a, n;
int answer;

void dfs(int pp, int qq, int x, int count)//今の分子、分母（約分なし）と、分母の積、分数の個数
{
	if(p*qq == q*pp)//目標値と等しい
  {
		answer++;
		return;
	}
	if(count == n) return;//分数の個数の上限
	//if(p*qq < q*pp) return;//目標値を超えた
  
	for(int i = x; i*qq <= a; i++)//分母の許容積の範囲全ての(1/i)を足す
  {
		int np = pp*i + qq;//(1/i)を足して約分しない時の分子
		int nq = i*qq;//(1/i)を足して約分しない時の分母
		dfs(np, nq, i, count+1);
	}
}

int main()
{
	while(true)
  {
		cin >> p >> q >> a >> n;
		if(p == 0) break;
    
		answer = 0;
		dfs(0,1,1,0);//初期値は分数0/1
		cout << answer << endl;
	}
  return 0;
}



Measured memory_bytes: 3060
def f1():
    s = input()
    while s:
        if s[-5:] in ['dream', 'erase']:
            s = s[:-5]
        elif s[-6:] == 'eraser':
            s = s[:-6]
        elif s[-7:] == 'dreamer':
            s = s[:-7]
        else:
            print('NO')
            return
    print('YES')

if __name__ == "__main__":
    f1()

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] nm = RIntAr();

            int[] food = new int[nm[1]];
            for (int i = 0 ; i < nm[0] ; i++)
            {
                int[] items = RIntAr().Skip(1).ToArray();
                for (int j = 0 ; j < items.Count() ; j++)
                {
                    food[items[j] - 1]++;
                }
            }

            int cnt = 0;
            foreach (var item in food)
            {
                if (item == nm[0]) cnt++;
            }

            Console.WriteLine(cnt);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll N;

    cin >> N;

    cout << ((N - N / 1000 * 1000) % 111 && (N / 10) % 111 ? "No" : "Yes") << endl;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int a[100010];

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> a[i];

	int ans = 1, sgn = 0;
	rep(i,n-1){
		if(a[i]==a[i+1]) continue;

		if(a[i] < a[i+1]){
			if(sgn == -1)
				sgn = 0,ans++;
			else
				sgn = 1;
		}else{
			if(sgn == 1)
				sgn = 0,ans++;
			else
				sgn = -1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i <= max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int W,H,x,y;
  cin >> W >> H >> x >> y;
  double ans = (double)W*H/2;
  int num = (W==x*2 && H==y*2) ? 1 : 0;
  printf("%.10f %d\n", ans, num);
  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);

		while (sc.hasNext()) {
			final char[] str = sc.next().toCharArray();
			
			
			int j_count = 0;
			int i_count = 0;
			for(int i = 0; i < str.length - 2; i++){
				if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] =='I'){
					j_count++;
				}
				
				if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] =='I'){
					i_count++;
				}
			}
			
			System.out.println(j_count);
			System.out.println(i_count);
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    int N;
    int cnt;
    int i;
    int x, y, z;

    cin >> N;
    vector<int> array(10000);

    i = 1;

    for(x = 1; x <= 100; x++)
    {
        for(y = 1; y <= 100; y++)
        {
            for(z = 1; z <= 100; z++)
            {
                int func = x*x + y*y + z*z + x*y + y*z + z*x - i;
                if( func < 10000 )
                {
                    array[func] += 1;
                }
            }
        }
    }

    for(i = 0; i < N; i++)
    {
        cout << array[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3508
import heapq
N,M=map(int,input().split())
X=[tuple(map(int,input().split())) for i in range(N)]
X.sort(key=lambda x:x[0])
ans=0
index=0
#print(X)
q=[]
for k in range(M):
    while(1):
        if not(index<N):
            break
        if X[index][0]<=k+1:
            heapq.heappush(q,-X[index][1])
            index+=1
        else:
            break
    
    if len(q)>0:
        ans-=heapq.heappop(q)
    #print(k,index,q,ans)
print(ans)


Measured memory_bytes: 80984
import math
N=int(input())
k=math.sqrt(N)
t_c=int(k)
t_c=t_c+1
t_r=0
for i in range(t_c):
  if N % (t_c-i)==0:
    t_r=N//(t_c-i)
    t_c=t_c-i
    break
print(t_c-1+t_r-1)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace IPT1_6D
{
    class Program
    {
        static void Main(string[] args)
        {
            //n,m ?????????????????????
            string[] in_NM = Console.ReadLine().Split(' ');
            int n = int.Parse(in_NM[0]);
            int m = int.Parse(in_NM[1]);
            //A???????????\???
            int[,] A = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                String[] in_A = Console.ReadLine().Split(' ');
                for (int j = 0; j < m; j++)
                {
                    A[i, j] = int.Parse(in_A[j]);
                }
            }
            //B???????????\???
            int[] B = new int[m];
            //String[] in_B = Console.ReadLine().Split(' ');
            for (int i = 0; i < m; i++)
            {
                B[i] = int.Parse(Console.ReadLine());
            }
            //????????????????¨????
            for (int i = 0; i < n; i++)
            {
                int c = 0;
                for (int j = 0; j < m; j++)
                {
                    c += A[i, j] * B[j];
                }
                Console.WriteLine(c);
            }
        }
    }
}

Measured memory_bytes: 9400
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll N, K;
ll calc(ll l, ll r, vector<ll>& V)
{
  ll res = 0;
  vector<ll> hand;
  for (ll i = 0; i < l; ++i)
  {
    hand.push_back(V.at(i));
    res += V.at(i);
  }
  // if (r < N)
  // {
  //   cout << "vr" << V.at(r) << endl;
  // }
  for (ll i = r; i < N; ++i)
  {
    hand.push_back(V.at(i));
    res += V.at(i);
  }
  // for (ll i = 0; i < hand.size(); ++i)
  // {
  //   cout << hand.at(i) << ' ';
  // }
  // cout << endl;
  sort(hand.begin(), hand.end());
  ll hand_size = hand.size();
  // for (ll i = 0; i < hand_size; ++i)
  // {
  //   cout << hand.at(i) << ' ';
  // }
  // cout << endl;
  ll range = min(K - (N - (r - l)), hand_size);
  for (ll i = 0; i < range; ++i)
  {
    if (hand.at(i) >= 0)
    {
      break;
    }
    res -= hand.at(i);
  }
  // cout << "l" << l << "r" << r << "res" << res << endl;
  return res;
}

int main()
{
  cin >> N >> K;
  vector<ll> V(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> V.at(i);
  }
  ll ans = -INF;
  ll zero = 0;
  ll min_span = max(N - K, zero);
  for (ll width = min_span; width < N + 1; ++width)
  {
    for (ll l = 0; l < N - width + 1; ++l)
    {
      ll r = l + width;
      ans = max(ans, calc(l, r, V));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007


lli D[40][40];
lli c[510][510];

signed main(){

	lli N,C;
	cin>>N>>C;
	REP(i,0,C)REP(j,0,C)cin>>D[i][j];
	REP(i,0,N)REP(j,0,N){
		cin>>c[i][j];
		c[i][j]--;
	}

	lli sum[3][40];
	REP(i,0,3)REP(j,0,40)sum[i][j]=0;


	/*色は30種類*/
	/*そのうち3色しか使わない*/
	/*つまり、使う色3色決めてその時の違和感を計算すればよい*/
	/*最悪計算量は*/
	/*500*500*30*29*28 = 6*10^9*/
	/*ギリ間に合いそう*/

	/*こうじゃなくて*/
	/*(i+j)%3==0のところと、(i+j)%3==1とのところと(i+j)%3について*/
	/*最小値をたたき出しておく*/
	lli ans=INF;

	for(lli y=0;y<N;y++){
		for(lli x=0;x<N;x++){
			lli nowColor = c[y][x];
			for(lli color=0;color<C;color++){
				sum[(x+y)%3][color] += D[nowColor][color];
			}
		}
	}

	REP(i,0,C)REP(j,0,C)REP(k,0,C){
		if(i==j || j==k || k== i)continue;
		ans = min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
	}

	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rrep(i, n) for(int i = (int)(n) - 1; i >= 0; i --)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define mod2 998244353
#define inf 1000000000000000000
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rsort(a) sort(a.rbegin(), a.rend())
#define print(x) for(auto i : (x)) cout << i << " "; cout << endl
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

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

    ll n; cin >> n;
    string s; cin >> s;
    ll ans = 0;
    vector<vector<ll>> index(10);
    for (int i = 0; i < n; i++) {
        ll m = s[i] - '0';
        index[m].pb(i);
    }
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                if (index[i].size() == 0 || index[j].size() == 0 || index[k].size() == 0) continue;
                ll index_1 = index[i][0], index_3 = index[k].back();
                for (auto l : index[j]) {
                    if (index_1 < l && l < index_3) {
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3832
#include <iostream>
using namespace std;
int _move[8][2] = {-1,-1,0,-1,1,-1,-1,0,1,0,-1,1,0,1,1,1,};
int main( ){
    int h,w;
    cin>>h>>w;
    char _map[55][55];
    for(int i = 0;i<52;i++){
        _map[0][i]='.';
        _map[i][0]='.';
    }
    for(int i = 1;i<=h;i++){
        for(int j = 1;j<=w;j++){
            cin>>_map[i][j];
        }
    }
    for(int i = 1;i<=h;i++){
        for(int j = 1;j<=w;j++){
            if(_map[i][j]=='.'){
                _map[i][j]='0';
                for(int x=0;x<8;x++){
                    if(_map[i+_move[x][0]][j+_move[x][1]]=='#'){
                        _map[i][j]++;
                    }
                }
            }
        }
    }
    for(int i = 1;i<=h;i++){
        for(int j = 1;j<=w;j++){
            cout<<_map[i][j];
        }
        cout<<endl;
    }
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

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

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  int x;
  cin >> x;
  if(x < 1200) { 
    cout << "ABC" << endl;
  }
  else {
    cout << "ARC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/

const ll MOD = 1e18 + 7;
ll poww(ll b, ll p)
{
    if (p == 0)
        return 1;

    ll sq = poww(b, p / 2);

    sq = (sq * sq) % MOD;

    if (p % 2 == 1)
    {
        sq = (sq * b) % MOD;
    }

    return sq;
}

void solve()
{
    ll n;
    cin >> n;
    ll sz = 1;
    ll lol = 26;

    while (lol < n)
    {
        n -= lol;
        lol *= 26;
        sz++;
    }   

    string ans(sz, 'a');
    n--;
    ll i = sz - 1;
    while (n)
    {
        ans[i] += (n % 26);
        n /= 26;
        i--;
    }

    cout << ans << endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3628
N = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

t = Hash.new(0)
a.each do |ai|
  t[ai] += 1
end

ans = 0
t.each do |k, v|
  together = t[k-1] + v + t[k+1]
  ans = together if ans < together
end

print ans

Measured memory_bytes: 12676
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 3000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

std::set<int> set[26];
int n, q;
char s[500000 + 5];
 
int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    scanf("%d", &q);
    for (int i = 1; i <= n; i++) {
        set[s[i] - 'a'].insert(i);
    }
    while (q--) {
        int type;
        int l, r;
        int i; char ch[5];
        scanf("%d", &type);
        if (type == 1) {
            scanf("%d %s", &i, ch);
            set[s[i] - 'a'].erase(i);
            s[i] = ch[0];
            set[s[i] - 'a'].insert(i);
        } else {
            scanf("%d %d", &l, &r);
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                int p = *set[i].lower_bound(l);
                if (p >= l && p <= r) ans++;
            }
            printf("%d\n", ans);
        }
    }
    return 0;
}

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

int main() {
  int R, L, A, B, C, D;
  string op;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


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

  if (a == b && b == c) pr("1");
  else if (a == b || b == c || c == a) pr("2");
  else pr("3");


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >> a>>b;
int ans =0;
for(int i=a;i<=b;i++){
    string che = to_string(i);
    if(che.at(0)==che.at(4)&&che.at(1)==che.at(3)){
        ans++;
    }
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	ll n;
	int ans=0;
	cin>>n;
	if(n==1){cout<<0<<endl;return 0;}
	ll q=n;
	for(ll i=2;i*i<=q;i++)
	{
		int sum=0;
		while(n%i==0)	
		{
			n/=i;
			sum++;
		}
	//	if(sum!=0)
	//	cout<<i<<" "<<sum<<endl;
	//	cout<<sum<<endl;
		int now=0;
		while(sum>0)
		{
			now++;
			sum-=now;
		}
		if(sum<0)
		now--;
		ans+=now;
	}
	if(n!=1)ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3656
#include<stdio.h>
#define mod 1000000007
int main(){
	int n;
	scanf("%d",&n);
	int i;
	long long a=1,b=1,c=1;
	for (i=1;i<=n;i++)
	  a=a*10 % mod;
	for (i=1;i<=n;i++)
	  b=b*9 % mod;
	b=b*2 % mod;
	for (i=1;i<=n;i++)
	  c=c*8 % mod;
	long long ans=(a-b)%mod;
	ans=(ans+c)% mod;
	if (ans<0) ans=ans+mod;
	printf("%lld",ans);
}

Measured memory_bytes: 1732
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;
#define Abs(x) ((x>=0)?x:-x)


#define FOR(i,init,n) for(int i = init; i < n ;i++)
#define REP(i,n)  FOR(i,0,n)

int prime_judge(int candidate){
	int i,limit;
	if (candidate >= 2){
		limit = (int)sqrt((double)candidate);

		for (i = limit; i > 1; i--){
			if (candidate%i == 0){
				break;
			}
		}

		if (i == 1){
			return(1);
		}
		else{
			return(0);
		}
	}
	else{
		return(0);
	}
}

int main()
{
	
	while (1){
		int a, d, n;
		scanf("%d", &a);
		scanf("%d", &d);
		scanf("%d", &n);
		if (a == 0 && d == 0 && n == 0){
			break;
		}
		int candidate, prime,count;
		count = 0;
		candidate = a;
		while (count < n){
			prime = 0;
			prime = prime_judge(candidate);
			if (prime == 1){
				count++;
			}
			if (count == n){
				break;
			}
			candidate += d;
		}

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

Measured memory_bytes: 1028