akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  string a;
  cin>>a;
  int s=a.length();
  for(int i=0;i<a.length()-1;i+=1){
    if(a[i]!=a[i+1]){
      a.erase(i,2);
      if(a.length()==0)
        break;
      if(i==0)
        i-=1;
      else
        i-=2;
    }
  }
  cout<<s-a.length()<<endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int x=sc.nextInt();
    if(x<=599){
      System.out.println(8);
    }else if(x<=799){
      System.out.println(7);
    }else if(x<=999){
      System.out.println(6);
    }else if(x<=1199){
      System.out.println(5);
    }else if(x<=1399){
      System.out.println(4);
    }else if(x<=1599){
      System.out.println(3);
    }else if(x<=1799){
      System.out.println(2);
    }else{
      System.out.println(1);
    }
  }
}


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

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

    int n, m;
    long long k;
    while (cin >> n >> m >> k) {
        vector<long long> A(n + 1), B(m + 1);

        for (int i = 1; i <= n; i++) {
            cin >> A[i];
            A[i] += A[i - 1];
        }
        for (int i = 1; i <= m; i++) {
            cin >> B[i];
            B[i] += B[i - 1];
        }

        int j = m, ans = 0;
        for (int i = 0; i <= n; i++) {
            while (j >= 0 && A[i] + B[j] > k)
                --j;

            if (j < 0)
                break;

            ans = max(ans, i + j);
        }
        cout << ans << '\n';
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    int sum = 0;
    rep(i, n-1) sum += l[i];
    if (sum > l[n-1]) puts("Yes");
    else puts("No");
    return 0;
}

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

double sumhalf(vector<double> v, double p) {
  if (p == 1)
    return (v[0] + v[1]) / 2;
  else
    return (sumhalf(v, p - 1) + v[p]) / 2;
}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll cntw = 0, ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'B') {
      ans += cntw;
    } else
      cntw++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
w = []
for i in range(N):
    w.append(input())

l = []
c = False
o = ""
for a in w:
    if a in l:
        print("No")
        exit()
    if c == False or o == a[0]:
        l.append(a)
        o = a[-1]
        c = True
    else:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 3060
from math import sin, cos, radians

cl = [0, 0]
cd = 0

while True:
    o = input()
    if o == (0, 0):
        break

    cl[0] += o[0] * sin(radians(cd))
    cl[1] += o[0] * cos(radians(cd))
    cd += o[1]
    if 180 <= cd:
        cd -= 360
    elif cd <= -180:
        cd += 360

for x in cl:
    print(int(x))

Measured memory_bytes: 4424
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val S = ns()
    val N = S.length
    val C = Array.ofDim[Int](26)
    REP(N) { i =>
      C(S(i) - 'a') += 1
    }

    var ans = 1L
    REP(25) { i =>
      REP(25 - i, i + 1) { j =>
        if (i != j) ans += C(i).toLong * C(j)
      }
    }
    out.println(ans)
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


Measured memory_bytes: 29276
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        Long N = nextLong();

        if(N == 1){
            println("1");
            return;
        }

        Long min = N;
        for(Long i=1L; i<=Math.sqrt(N); i++){
            if(N%i == 0){
                Long j = N/i;
                min = min > i+j-2 ? i+j-2 : min;
            }
        }

        println(min);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 38356
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    fmt = '{:5d}'.format

    while 1:
        n = int(readline())
        if not n:
            exit()

        total = [0] * (n+1)

        for _ in range(n):
            s = 0
            for i, val in enumerate(int(d) for d in readline().split()):
                total[i] += val
                s += val
                print(fmt(val), end='')
            total[-1] += s
            print(fmt(s))

        print(''.join(fmt(i) for i in total))


if __name__ == '__main__':
    main()

Measured memory_bytes: 4244
#include <stdio.h>
#include <string.h>

int main()
{
    char inputS[101];
    scanf("%s", inputS);
    long len = strlen(inputS);

    for (int i = 0; i < len; i++)
    {
        inputS[i] = 'x';
    }

    printf("%s \n", inputS);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int a[100000],b[100000];
int cnt=0;
int c,i,j;
int main(void){
	while(1){
		scanf("%d %d",&a[cnt],&b[cnt]);
		if((a[cnt]==0)&&(b[cnt]==0)) break;
		cnt++;
	}//cnt1大きい

	for(c=0;c<cnt;c++){
		for(i=0;i<a[c];i++){
			for(j=0;j<b[c];j++){
				if((i>0)&(i<a[c]-1)&(j>0)&(j<b[c]-1)) printf(".");
				else printf("#");
			}
			printf("\n");//次の行
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		String T = sc.next();
		String[] TSplit = T.split("");
		boolean[] dup = new boolean[N];
		long res = 0;
		for (int i = 0; i < TSplit.length; i++) {
			if (i >= K && TSplit[i].equals(TSplit[i - K]) && !dup[i - K]) {
				dup[i] = true;
			}
			if (i < K || !dup[i]) {
				if ("r".equals(TSplit[i])) {
					res += P;
				} else if ("p".equals(TSplit[i])) {
					res += S;
				} else {
					res += R;
				}
			}
		}
		System.out.print(res);
	}
}

Measured memory_bytes: 33248
#include<bits/stdc++.h>
#define int long long
#define mod 100000000000000000
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, a[234567], dp[234567][5][5];//i,num,last
signed main() {
	cin >> n;
	dp[0][0][0] = 0;
	dp[0][0][1] = -mod;
	dp[0][1][0] = -mod;
	dp[0][1][1] = -mod;
	dp[0][2][0] = -mod;
	dp[0][2][1] = -mod;
	for1(i, n) {
		cin >> a[i];
		dp[i][0][0] = dp[i - 1][0][1];
		dp[i][0][1] = dp[i - 1][0][0] + a[i];
		dp[i][1][0] = max(dp[i - 1][0][0], dp[i - 1][1][1]);
		dp[i][1][1] = dp[i - 1][1][0] + a[i];
		dp[i][2][0] = max(dp[i - 1][1][0], dp[i - 1][2][1]);
		dp[i][2][1] = dp[i - 1][2][0] + a[i];
	}
	if (n % 2)cout << max({ dp[n - 2][0][1],dp[n - 1][1][1],dp[n][2][1] }) << endl;
	else cout << max({ dp[n - 1][0][1], dp[n][1][1] }) << endl;
}

Measured memory_bytes: 44244
#include<stdio.h>
int main(void){
	int H,W,a,b;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(a=0;a<H;a++){
			for(b=0;b<W;b++){
				if(a%2==0 && b%2==0){
					printf("#");
				}else if(a%2!=0 && b%2!=0){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#countはループを含むためO(N**2)となる、O(N)ならOK
N = gets.to_i
ary = gets.strip.split.map(&:to_i)
rec = Array.new(N,0)
i = 0
while i < N-1 do
  rec[ary[i]-1] += 1
  i += 1
end
puts rec

Measured memory_bytes: 35732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
static const long long INF = 100000000;
int main(){
    int a,b;
    cin >> a >> b;
    if (a % b == 0){
        cout << a/b << endl;
    }
    else {
        cout << a/b + 1 << endl;
    }
    return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
intvec L;
int ans;

void input() {
	cin>>N;
	init(L,N);
}

void solve() {
	sort(all(L));
	for(int i=0; i<N; i++) for(int j=i+1; j<N; j++) for(int k=j+1; k<N; k++) {
		if(L[i]==L[j] || L[j]==L[k] || L[i]==L[k]) continue;
		if(L[i]+L[j]>L[k]) ans++;
	}
	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	string S, T; cin >> S >> T;
	//dp[i+1][j+1]	//Sのi文字目までと、Tのj文字目までの最長共通部分(LCS)の長さ
	vector<vector<int>> dp(S.size() + 1, vector<int>(T.size() + 1, 0));

	for (int si = 1; si <= S.size(); ++si) {
		for (int ti = 1; ti <= T.size(); ++ti) {
			if (S[si - 1] == T[ti - 1]) {
				dp.at(si).at(ti) = max(dp.at(si - 1).at(ti - 1) + 1, dp[si][ti]);
			}
			dp[si][ti] = max(dp[si - 1][ti], dp[si][ti]);
			dp[si][ti] = max(dp[si][ti - 1], dp[si][ti]);
		}
	}
	
	//復元
	int si = S.size(), ti = T.size();
	string str = "";
	while (si > 0 && ti > 0) {
		if (dp[si][ti] == dp[si - 1][ti]) {
			--si;
		}
		else if (dp[si][ti] == dp[si][ti - 1]) {
			--ti;
		}
		else {
			str = S[si - 1] + str;
			--si;--ti;
		}
	}
	cout << str << endl;

}


Measured memory_bytes: 38172
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, u, v = map(int, readline().split())
m = map(int,read().split())
data = list(zip(m,m))

graph = [[] for _ in range(n+1)]
for a,b in data:
    graph[a].append(b)
    graph[b].append(a)

def dfs(v):
    dist = [None] * (n + 1)
    dist[v] = 0
    stack = deque([v])
    while stack:
        x = stack.popleft()
        for y in graph[x]:
            if dist[y] is None:
                dist[y] = dist[x] + 1
                stack.append(y)
    return dist


res = 0
for i, j in zip(dfs(u), dfs(v)):
    if i is None:
      continue
    if i <= j:
        if j > res:
            res = j
print(res - 1)

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

using namespace std;
#define int long long
#define inf 999999999999999999
#define N 666666
int arr[N];
int n,m,x;
int c[N];
int mp[666][666];
int t[N];
signed main(){
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++) cin>>mp[i][j];
	}
	int ans=inf;
	for(int i=0;i<(1<<n);i++){
		int s=0;
		for(int j=0;j<=400;j++) t[j]=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				s+=c[j];
				for(int k=1;k<=m;k++) t[k]+=mp[j][k];
			}
		}
		int f=1;
		for(int j=1;j<=m;j++){
			if(t[j]<x){
				 f=0;
				break;
			}
		}
		if(f) ans=min(ans,s);
	}
	if(ans==inf) cout<<"-1";else cout<<ans;
	return 0;
}

Measured memory_bytes: 3656
class alphabet():
    def __init__(self, capitalize):
        self.num = dict()
        self.index = dict()
        self.abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"\
            ,"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        if capitalize: 
            for i in range(26): self.abc[i] = self.abc[i].upper()
        for i, a in enumerate(self.abc):
            self.num[a] = i
            self.index[i] = a

def solve():
    N = input()
    i = 0
    if len(N) % 2 == 1: print("No")
    else:
        S = "hi" * (len(N) // 2)
        if S == N: print("Yes")
        else: print("No")


    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    int now[3];
    int prev[3];
    memset(prev, -1, sizeof prev);
    cin>>now[0]>>now[1]>>now[2];
    int ans = 0;
    while(1){
        sort(now, now+3);
        sort(prev, prev+3);
        if((now[0]&1) || (now[1]&1) || (now[2]&1)){
            break;
        }
        if(now[0] == prev[0] && now[1] == prev[1] && now[2] == prev[2]){
            ans = -1;
            break;
        }

        ans++;
        FOR(i,3)prev[i] = now[i];
        FOR(i,3){
            now[i] = 0;
            FOR(j,3){
                if(i==j)continue;
                now[i] += prev[j]/2;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
	int a, b, cnt=0;
	cin >> a >>b;

	for(int i=a;i<=b;i++){
		if(i/10000==i%10 && (i/1000)%10==(i%100)/10)cnt++;
	}

	cout << cnt << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 100000000;
    for (int i = 0; i < (1 << n); i++) {
        int res = 1;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) res *= 2;
            else res += k;
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
ans = 0
f = 0
b = 0

for i in range(N):
    if 'A' == S[i]:
        break
    else:
        f += 1
for i in range(1,N + 1):
    if 'Z' == S[-i]:
        break
    else:
        b += 1
b = N - b

ans = b - f
print(ans)

Measured memory_bytes: 9004
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		int result = 0;
		int[] cnt = new int[100001];
		for(int i = 0; i < n; i++){
		    if(a[i] > 100000 || cnt[a[i]] >= a[i]){
		        result++;
		    }else{
		        cnt[a[i]]++;
		    }
		}
		for(int i = 1; i < cnt.length; i++){
		    if(cnt[i] != 0 && cnt[i] != i){
		        result += cnt[i];
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}



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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();
    int n, d;   cin >> n >> d;
    cout << (int)ceil(1.0 * n / (2 * d + 1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int m, k; cin >> m >> k;
    if (m == 1 && k == 0) {
        cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        return 0;
    }
    int sum = 0;
    rep(i,1<<m) {
        if (i == k) continue;
        sum ^= i;
    }
    if (sum != k) cout << -1 << endl;
    else {
        deque<int> q;
        q.push_back(k);
        rep(i,1<<m) {
            if (i == k) continue;
            q.push_front(i);
            q.push_back(i);
        }
        q.push_back(k);
        while (!q.empty()) {
            int v = q.front(); q.pop_front();
            cout << v << " ";
        }
    }
}

Measured memory_bytes: 4712
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;

int n, x, cnt;

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> x;
        if (x % 2 == 1)
            ++cnt;
    }

    cout << (cnt % 2 == 0? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N):
    for k in range(N):
        if k != N - 1:
            print(A[k], end=" ")
        else:
            print(A[N-1], end="")
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print()
for k in range(N):
    if k != N - 1:
        print(A[k], end=" ")
    else:
        print(A[N-1])



Measured memory_bytes: 5980
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const memo = (func) => {
    const cache = [];
    const innerFunc = (x, y) => {
          if (!cache[[x, y]]) cache[[x, y]] = func(x, y);
          return cache[[x, y]]
    };
    return innerFunc;
  }

  const solve = (i, m) => {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  };

  arr2.map(m => memo(solve)(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();



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

int main() {
  
  int n;
  cin >> n;
  
  if ( n % 2 == 0 ){
    cout << (n / 2) * (n / 2) << endl;
  }else{
    cout << (n / 2) * ((n / 2) +1) << endl;
  }
  
}



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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

namespace mp = boost::multiprecision;

int main(){

	ll n;
	cin >> n;

	mp::cpp_int ans = 1;
	REP(i, 2, n+2) ans *= i;

	cout << ans + 2 << endl;

	rep(i, n) cout << i + 2 << endl;

	return 0;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 12, M = 1e3 + 5;
const ll LINF = 1e18 + 5;
int n, m;
int dp[M][1<<N], a[M], b[M], c[M];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m;
 	for(int i=1; i<=m; i++)
 	{
 		cin >> a[i] >> b[i];
 		for(int j=0, x; j<b[i]; j++)
 		{
 			cin >> x;
 			c[i] |= (1<<(x-1));
 		}
 	}
 	for(int i=0; i<=m; i++)
 		for(int j=0; j<(1<<n); j++)
 			dp[i][j] = INF;
 	dp[0][0] = 0;
 	for(int i=1; i<=m; i++)
 	{
 		for(int j=0; j<(1<<n); j++)
 		{
 			dp[i][j] = min(dp[i][j], dp[i-1][j]);
 			dp[i][j|c[i]] = min(dp[i][j|c[i]], dp[i-1][j]+a[i]);
		}
	}
	int ans = dp[m][(1<<n)-1];
	if(ans==INF) ans = -1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 16256
// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)...}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__) << '\n'
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin { 
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }	
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on





auto Main() {
	string s;
	cin>>s;
	s[1] ^= 'B'^'R';
	cout <<s;
	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


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


using namespace std;


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

    int cur = h.at(0);
    for (int i=1; i<n; ++i) {
        if (cur > h.at(i)) h.at(i)++;
        if (cur > h.at(i)) {
            cout << "No" << endl;
            return 0;
        }
        cur = h.at(i);
    }

    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;   
const int inf = (int) 1e9+7;
int main(){
	fastIO;        
	long long int n,v=11,ans=0;
	cin>>n;
	if(n%v==0 || n%v>6){
		if(n%v==0)ans=n/v*2;
		else ans=n/v*2+2;
	}		
	else ans=n/v*2+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
S = list(input())
N = len(S)
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1
MOD = 10**9 +7

for i in range(1,N+1):
    R = [0]*13
    if S[i-1] == "?":
        for j in range(10):
            r = j * pow(10,N-i,13) %13 
            R[r] += 1 
        for k in range(13):
            for l in range(13):
                    dp[i][k] += dp[i-1][l] * R[(k-l)%13]
                    dp[i][k] %= MOD

    else:
        r = int(S[i-1]) * pow(10,N-i,13) %13
        R[r] += 1
        for k in range(13):
                for l in range(13):
                    dp[i][k] += dp[i-1][l] * R[(k-l)%13]
                    dp[i][k] %= MOD

print(dp[N][5])

Measured memory_bytes: 66876
#include<stdio.h>

int main(void){
int a=100000,i,n;

scanf("%d",&n);
for(i=0;i<n;i++){
a=a+(int)((float)a*0.05);
a=(int)((float)(a+999)/1000)*1000;
}
printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int[] a = new int[10000];
		int[] b = new int[10000];
		while(true){
			String[] tmp = stdIn.nextLine().split(",");
			if(tmp.length!=2){
				break;
			}
			else{
				a[Integer.parseInt(tmp[0])]++;
			}
		}
		while(stdIn.hasNext()){
			String[] tmp = stdIn.nextLine().split(",");
			if(tmp.length!=2){
				break;
			}
			else{
				b[Integer.parseInt(tmp[0])]++;
			}
		}
		for(int i=0;i<a.length;i++){
			if(a[i]>0&&b[i]>0){
				System.out.println(i+" "+(a[i]+b[i]));
			}
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main(void){
  char buf[32] = { 0 };
  int N;
  long power = 1;
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d", &N);
  int i = 1;
  while(i <= N){
    power *= i;
    power = power % (1000000007);
    i++;
  }
  printf("%ld\n", power);
  return 0;
}


Measured memory_bytes: 1704
import java.awt.Point;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long INF = Long.MAX_VALUE/10;
		Scanner sc = new Scanner(System.in);
		long ans = INF;
		int N = sc.nextInt();
		List<Point> U = new ArrayList<>();
		List<Point> R = new ArrayList<>();
		List<Point> L = new ArrayList<>();
		Map<Point, TreeSet<Integer>> Um = new HashMap<>(), Dm = new HashMap<>();
		Map<Point, TreeSet<Integer>> Um2 = new HashMap<>(), Dm2 = new HashMap<>();
		Map<Integer, TreeSet<Integer>> D2 = new HashMap<>(), L2 = new HashMap<>();
		for(int i = 0; i < N; i++) {
			int X = sc.nextInt();
			int Y = sc.nextInt();
			String S = sc.next();
			if(S.equals("U")) {
				U.add(new Point(X, Y));
				Point p = new Point(X-Y, 0);
				if(!Um.containsKey(p))
					Um.put(p, new TreeSet<>());
				Um.get(p).add(Y);
				p = new Point(X+Y, 0);
				if(!Um2.containsKey(p))
					Um2.put(p, new TreeSet<>());
				Um2.get(p).add(Y);
			}
			else if(S.equals("R"))
				R.add(new Point(X, Y));
			else if(S.equals("D")) {
				Point p = new Point(X-Y, 0);
				if(!Dm.containsKey(p))
					Dm.put(p, new TreeSet<>());
				Dm.get(p).add(Y);
				p = new Point(X+Y, 0);
				if(!Dm2.containsKey(p))
					Dm2.put(p, new TreeSet<>());
				Dm2.get(p).add(Y);
				if(!D2.containsKey(X))
					D2.put(X, new TreeSet<>());
				D2.get(X).add(Y);
			}
			else {
				L.add(new Point(X, Y));
				if(!L2.containsKey(Y))
					L2.put(Y, new TreeSet<>());
				L2.get(Y).add(X);
			}
		}
		for(Point p : U)
			if(D2.containsKey(p.x) && D2.get(p.x).last() > p.y)
				ans = Math.min(ans, Math.abs(p.y - D2.get(p.x).ceiling(p.y)) * 10 / 2);
		for(Point p : R) {
			if(L2.containsKey(p.y) && L2.get(p.y).last() > p.x)
				ans = Math.min(ans, Math.abs(p.x - L2.get(p.y).ceiling(p.x)) * 10 / 2);
			Point q = new Point(p.x - p.y, 0);
			if(Dm.containsKey(q) && Dm.get(q).last() > p.y)
				ans = Math.min(ans, Math.abs(p.y - Dm.get(q).ceiling(p.y)) * 10);
			q = new Point(p.x + p.y, 0);
			if(Um2.containsKey(q) && Um2.get(q).first() < p.y)
				ans = Math.min(ans, Math.abs(p.y - Um2.get(q).floor(p.y)) * 10);
		}
		for(Point p : L) {
			Point q = new Point(p.x - p.y, 0);
			if(Um.containsKey(q) && Um.get(q).first() < p.y)
				ans = Math.min(ans, Math.abs(p.y - Um.get(q).floor(p.y)) * 10);
			q = new Point(p.x + p.y, 0);
			if(Dm2.containsKey(q) && Dm2.get(q).last() > p.y)
				ans = Math.min(ans, Math.abs(p.y - Dm2.get(q).ceiling(p.y)) * 10);
		}
		System.out.println(ans == INF ? "SAFE" : ans);
	}

}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  B -= A;
  N--;
  rep(i,N){
    if(B >= C * i - D * (N-i) && B <= D * i - C * (N-i) ){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int l=s.length();
  ll res=0;
  rep(i,l)
  {
    int d=s[i]-'0';
    res+=(ll)((pow(10,l-1-i)-pow(2,l-1-i))/8+pow(10,l-i-1))*pow(2,i)*d;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int N, M;
long long val[1010][3];
long long res;
long long v2[1010][3];
long long v3[1010];

void solve()
{
	int i, j;
	int i1[3];
	for(i1[0]=-1; i1[0]<=1; i1[0]+=2){
		for(i1[1]=-1; i1[1]<=1; i1[1]+=2){
			for(i1[2]=-1; i1[2]<=1; i1[2]+=2){
				long long tmp = 0;
				for(i=0; i<N; i++){
					v3[i] = 0;
					for(j=0; j<3; j++){
						if(i1[j] * val[i][j] >= 0){
							v2[i][j] = abs(val[i][j]);
						}
						else
							v2[i][j] = -abs(val[i][j]);
						v3[i] += v2[i][j];
					}
				}
				sort(v3, v3+N);
				for(i=N-1; i>N-1-M; i--){
					tmp += v3[i];
				}
				if(tmp > res)
					res = tmp;
			}
		}
	}
	printf("%lld\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &N, &M);
	for(i=0; i<N; i++){
		scanf("%lld %lld %lld", &val[i][0], &val[i][1], &val[i][2]);
	}
	solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll ans = 0;
    ll count = 1;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    rep(i,23){
        count--;
        count+=a;
        ans ++;
        if(count>=b){
            cout<<ans<<endl;
            return 0;
        }
    }
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

signed main(){
  char c;
  cin>>c;
  cout<<(char)(c+1)<<endl;
  return 0;
}


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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(is,1<<h)rep(js,1<<w) {
      int cnt = 0;
      rep(i,h)rep(j,w) {
        if (is>>i&1) continue;
        if (js>>j&1) continue;
        if (s[i][j] == '#') cnt++;
      }
      if (cnt == k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
long long a[51], b[51];
long long layer(long long x)
{
	if(!a[x])
	{
		a[x] = 1 + layer(x - 1) + 1 + layer(x - 1) + 1;
	}
	return a[x];
}
long long patty(long long x)
{
	if(!b[x])
	{
		b[x] = patty(x - 1) + 1 + patty(x - 1);
	}
	return b[x];
}
int main()
{
	a[0] = 1;
	b[0] = 1;
	long long n, x, total = 0;
	scanf("%lld%lld", &n, &x);
	for(long long i = 0, j = n; i < x && j >= 0; )
	{
		if(i + layer(j) <= x)
		{
			if(i + layer(j) + 1 <= x)
			{
				total += 1;
				++i;
			}
			total += patty(j);
			i += layer(j);
		}
		else
		{
			++i;
			--j;
		}
	}
	printf("%lld\n", total);
}

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

struct Node{
	int cost;
	std::vector<Node*>child;
};

int n;
int maxlong;

void calc(Node *nod, int far){
	int memo = 0;
	for (int i = 0; i < nod->child.size(); i++)memo += nod->child[i]->child.size();

	if (memo == 0){
		maxlong = std::max(maxlong, far);
		return;
	}

	for (int i = 0; i < nod->child.size(); i++){
		if (nod->child[i]->child.size() != 0)calc(nod->child[i], far + nod->child[i]->cost);
	}
}

int main(){
	while (std::cin >> n, n){
		int sum = 0;
		maxlong = 0;

		Node node[21];

		for (int i = 0; i < n - 1; i++){
			int a, b, t;
			std::cin >> a >> b >> t;
			node[a - 1].child.push_back(&node[b - 1]);
			node[b - 1].cost = t;
			sum += t * 2;
		}

		for (int i = 0; i < n; i++){
			if (node[i].child.size() == 0)sum -= node[i].cost * 2;
		}

		calc(&node[0], 0);

		std::cout << sum - maxlong << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
const int N=505;
char s[N][N];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		if(i&1){
			for(int j=1;j<m;j++)
				putchar('#');
			printf(".\n");
		}
		else{
			putchar('#');
			for(int j=2;j<=m;j++)
				printf("%c",s[i][j]);
			putchar('\n');
		}
	putchar('\n');
	for(int i=1;i<=n;i++)
		if(i&1){
			for(int j=1;j<m;j++)
				printf("%c",s[i][j]);
			printf("#\n");
		}
		else{
			putchar('.');
			for(int i=1;i<m;i++)
				putchar('#');
			putchar('\n');
		}
	return 0;
}


Measured memory_bytes: 1024
n, x = map(int, input().split())

plist = [1]
bplist = [1]

for i in range(n):
    p = plist[i] + 2 ** (i+1)
    plist.append(p)

    bp = bplist[i] + 2 ** (i+2)
    bplist.append(bp)

ans = 0
index = n

while True:
    if index == 0:
        ans += 1
        break
    elif x > bplist[index-1] + 2:
        ans += plist[index - 1] + 1
        x -= bplist[index - 1] + 2
        index -= 1
    elif x == 1:
        break
    elif x == bplist[index-1] + 2:
        ans += plist[index-1] + 1
        break
    else:
        x -= 1
        index -= 1

print(ans)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n);
    rep(i, n) v[i] = k - q;
    rep(i, q)
    {
        int a;
        cin >> a;
        a--;
        v[a]++;
    }
    rep(i, n) cout << (v[i] > 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1408
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.Graph as G

bfs :: [G.Tree Int] -> [[Int]]
bfs [] = []
bfs ts = fmap root ts : bfs (concatMap sub ts)
  where
    root (G.Node r _)  = r
    sub  (G.Node _ sf) = sf

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]
    as <- replicateM m $ do
        [a, b] <- fmap read. words <$> getLine :: IO [Int]
        return (a, b)

    let g = G.buildG (1, n) as
    let tree = G.dfs g [1]
    let bss = take 3 $ bfs tree

    if length bss < 3
        then putStrLn "IMPOSSIBLE"
        else do
            if any (== n) (bss !! 2)
                then putStrLn "POSSIBLE"
                else putStrLn "IMPOSSIBLE"

Measured memory_bytes: 149372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
ll mod = 1000000007;


void solve(){
    int r,d,x;
    cin >> r >> d >> x;
    rep(i,10){
        x = r*x - d;
        cout << x << endl; 
    }
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;int main(){int a[4],n,m,s,c;cin>>n>>m;rep(i,4)a[i]=10;rep(i,m){cin>>s>>c;if((a[s]!=10&&a[s]!=c)||(n!=1&&s==1&&c==0)){cout<<-1;return 0;}else a[s]=c;}rep(i,n)if(a[i]==10)a[i]=0;if(n!=1&&a[1]==0)a[1]++;rep(i,n)cout<<a[i];}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<50);
const int mod=1000000007;
inline int gcd(int a,int b) { return b ? gcd(b, a % b) : a; }
int main(void){
	llint N,i,j,ans,q,w,D,Q;
	vector<llint> in;
	vector<llint> bas;
	vector<llint> ran;
	scanf("%lld %lld",&N,&D);
	in.resize(N);
	bas.resize(N+1);
	ran.resize(N+1);
	bas[0]=D;
	for(i=0;i<N;i++){
		scanf("%lld",&q);
		in[i]=q;
		if(bas[i]>0){bas[i+1]=bas[i]-q;}
		else{bas[i+1]=bas[i]+q;}
		if(abs(bas[i])<=abs(bas[i+1])){bas[i+1]=bas[i];}
	}
	ran[N]=0;
	for(i=N-1;i>=0;i--){
		ran[i]=ran[i+1]+in[i];
		if(in[i]>2*ran[i+1]+1){ran[i]=ran[i+1];}
	}
	scanf("%lld",&Q);
	for(;Q>0;Q--){
		scanf("%lld",&w);
		if(abs(bas[w-1])>ran[w]){printf("YES\n");}
		else{printf("NO\n");}
	}
	return 0;
}


Measured memory_bytes: 13696
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;

typedef pair<double, double> P;


void koch(int n, P a, P b) {
  if (n == 0) {
    cout << a.first << " " << a.second << endl;
    return;
  }
  double dx = (b.first - a.first) / 3.0;
  double dy = (b.second - a.second) / 3.0;
  double k = sqrt(3) * 0.5;
  P c(a.first + dx, a.second + dy);
  P d(c.first + dx * 0.5 - dy * k, c.second + dx * k + dy * 0.5);
  P e(c.first + dx, c.second + dy);
  koch(n - 1, a, c);
  koch(n - 1, c, d);
  koch(n - 1, d, e);
  koch(n - 1, e, b);
}

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

  cout << setprecision(10);

  int n;
  cin >> n;
  P a(0.0, 0.0);
  P b(100.0, 0.0);
  koch(n, a, b);
  cout << b.first << " " << b.second << endl;

  return 0;
}



Measured memory_bytes: 3300
# 配列を大きめにとって配った方がすっきりかけるのかも

n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(max(x), a)
dp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]

#if j == 0 and k == 0 and s == 0:
dp[0][0][0] = 1
for j in range(n):
    for k in range(n):
        for s in range(n*X):

            if dp[j][k][s]:
                dp[j+1][k][s] += dp[j][k][s]
                dp[j+1][k+1][s+x[j]] += dp[j][k][s]
ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]

print(ans)

Measured memory_bytes: 62960