akhauriyash/Code-Regression huggingface dataset:
def read_i
  gets.chomp.split(' ').map(&:to_i)
end

class Solver
  attr_reader :n

  def initialize(n, q, s, spells)
    @n = n
    @q = q
    @s = s
    @spells = spells
    @memo = {}
  end

  def search(dir)
    l = 1
    r = @n + 1
    loop do
      break if r - l == 1
      n = (r + l) / 2
      if shrink_r?(dir, solve(n))
        r = n
      else
        l = n
      end
    end
    l
  end

  def shrink_r?(dir, ans)
    return true if ans == :r_out
    return false if ans == :l_out
    dir == :L
  end

  def solve(n)
    @memo[n] ||=
      begin
        cur = n
        @spells.each do |target, d|
          next if target != @s[cur - 1]
          if d == 'L'
            cur -= 1
          else
            cur += 1
          end
          return :l_out if cur == 0
          return :r_out if cur == @n + 1
        end

        :alive
      end
  end
end


n, q = read_i
s = gets.chomp.chars
spells = q.times.map { gets.chomp.split(' ') }
solver = Solver.new(n, q, s, spells)

l = solver.search(:L)
r = solver.search(:R)

puts r - l

__END__
3 4
ABC
A L
B L
B R
A R


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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll N;
ll x[100000 + 100];

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

	ll ans = 1, cnt = 1;
	ll used = 0;
	for (int i = 1; i < N; i++) {
		ll need;
		need = (i - 1) * 2 + 1;
		if (x[i - 1] + used * 2 - need < 0) {
			//左へ行けるリストのうち、1つを必ずリリースしないと今の場所より向こうは、ゴールできない
			ans *= cnt;
			used++;
		}
		else {
			cnt++;
		}
		ans %= MOD;
	}
	for (ll i = 1; i <= cnt; i++) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[100010][2];
bool f[410][410],ok[410];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d%d",&a[i][0],&a[i][1]);
	for (int i=1;i<=n;i++)
	{
		f[i][i]=1;ok[i]=1;
		for (int j=m;j;j--)
		{
			if (f[i][a[j][0]]&&f[i][a[j][1]]) {ok[i]=0;break;}
			if (f[i][a[j][0]]) f[i][a[j][1]]=1; else if (f[i][a[j][1]]) f[i][a[j][0]]=1;
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		if (ok[i])
			for (int j=i+1;j<=n;j++)
				if (ok[j])
				{
					bool t=1;
					for (int k=1;k<=n;k++) if (f[i][k]&&f[j][k]) t=0;
					ans+=t;
				}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		sc.close();
	}
}

Measured memory_bytes: 35736
#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>;
//vector<> vec(n);

int main(){
  int n=0;

  cin >> n;
  if(n==0){
  	cout << "1" << endl;
  }
  else{
  cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
vector<bool>dp(k+5,false);
    for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<=k)
    dp[a[i]]=true;
    }
    sort(a,a+n);

    for(int i=1;i<=k;i++){
    if(dp[i])
    continue;
for(int j=0;j<n;j++){
if(a[j]>i)
break;
if(!dp[i-a[j]]){
dp[i]=true;
break;}


}

    }
    if(dp[k])
cout<<"First";
else
cout<<"Second";
    return 0;}


Measured memory_bytes: 3640
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a == b + c || b == a + c || c == a + b){
System.out.println("Yes");
}else{
System.out.println("No");
}

}
}

Measured memory_bytes: 21588
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日  3/25 20:02:43 2018
 * Ended  Time*  : 日  3/25 20:09:25 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 1e5;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int a[MAXN+5];
int presum[MAXN+5], sufsum[MAXN+5];
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++)
		presum[i] = abs(a[i] - a[i-1]) + presum[i-1];
	for(int i = n; i >= 1; i--)
		sufsum[i] = abs(a[i] - a[i+1]) + sufsum[i+1];
	for(int i = 1; i <= n; i++){
		int ans = presum[i-1] + sufsum[i+1] + abs(a[i-1] - a[i+1]);
		printf("%d\n", ans);
	}
    return 0;
}


Measured memory_bytes: 2432
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long[] res;
    ArrayList<Integer>[] tree;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        out.println(main.solve());
        out.flush();
    }
    String solve(){
        int k = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        for(int i=a;i<=b;i++){
            if(i%k==0) return "OK";
        }
        return "NG";
    }
}



Measured memory_bytes: 35844
#include <stdio.h>

int main()
{
  int h, w;
  int i;
  char a[102][102] = {};
  scanf("%d %d",&h ,&w);
  for(i=0; i<h; i++)
  {
    scanf("%s",&a[i][0]);
  }

  for(i=0; i<w+2; i++)
  {
    printf("#");
  }
  printf("\n");

  for(i=0; i<h; i++)
  {
    printf("#%s#\n",a[i]);
  }
  for(i=0; i<w+2; i++)
  {
    printf("#");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(){

    int n;
    cin >> n;

    int p[n],q[n];
    for(int i=0;i<n;i++)cin >> p[i];
    for(int i=0;i<n;i++)cin >> q[i];

    int a=0;
    int b=0;

    int o[n];
    for(int i=0;i<n;i++)o[i]=i+1;

    int c=1;
    do{
        int d=0,e=0;
        for(int i=0;i<n;i++){
            if(p[i]==o[i])d++;
        }
        if(d==n)a=c;
        for(int i=0;i<n;i++){
            if(q[i]==o[i])e++;
        }
        if(e==n)b=c;
        c++;
    }while(next_permutation(o,o+n));

    cout << abs(a-b) << endl;

}

Measured memory_bytes: 256
// ORZ YJZ
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int X; 
int main() {
	X=readint();
	int cur=0;
	int i=0;
	while (cur<X) {
		cur+=(++i);
	}
	int ans=i;
	int diff=cur-X;
	while (diff&&i) {
		if (diff>=i) diff-=i;
		i=min(i-1,diff);
	}
	if (diff) ans+=2;
	printint(ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 1000010
#define db double
int main(){
    int n,k;
    cin>>n>>k;
    db d[n];
    for (int i = 0; i <n ; ++i) {
        cin>>d[i];
        d[i]=(1+d[i])/2;
    }
    int last=0;
    db sum=0,ma=0;
    for (int j = 0; j <k ; ++j) {
        sum+=d[j];
    }
    if(sum>ma)ma=sum;
    for (int l = k; l <n ; ++l) {
        sum-=d[last];
        sum+=d[l];
        last++;
        if(sum>ma)ma=sum;
    }
    printf("%.12f",ma);
    return 0;

}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  int count=0;
  for(int i=a;i<=b;i++){
    int a,b,c,d,e;
    a=i/10000; b=i/1000-a*10;
    c=i/100-a*100-b*10; e=i%10;
    d=(i-10000*a-1000*b-100*c-e)/10;
    if(a==e&&b==d) count++;
  }
  cout<<count<<endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int countMin = 0;
    
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        int count = 0;
        while (a%2 == 0)
        {
            count += 1;
            a /= 2; 
        }
        
        if(i == 0){
            countMin = count;
        }else{
            if(count < countMin){
                countMin = count;
            }
        }
    }
    cout << countMin << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll n, c; cin >> n >> c;
	vector<vector<int>> d(c, vector<int>(c));
	rep(i,c) rep(j,c) cin >> d[i][j];
	vector<vector<int>> cc(n, vector<int>(n));
	rep(i,n) rep(j,n) {cin >> cc[i][j]; cc[i][j]--;}

	vector<vector<ll>> cost (c, vector<ll>(3,0));
	rep(k,c) rep(i,n) rep(j,n){
	  cost[k][(i+j)%3] += d[cc[i][j]][k];
	}
  
	vector<vector<pair<ll, int>>> ord(3);
  rep(i, 3) {
	  rep(k, c) {
		  ord[i].push_back({cost[k][i], k});
	  }
	}

	rep(i,3) sort(all(ord[i]));

	ll ans = INF;
	rep(i, 3) rep(j, 3) rep(k, 3) {
		if (ord[0][i].second == ord[1][j].second 
		 || ord[2][k].second == ord[1][j].second
		 || ord[0][i].second == ord[2][k].second) continue;

		 chmin(ans, ord[0][i].first + ord[1][j].first + ord[2][k].first);
	}

	cout << ans << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
using namespace std;

const ll N = 1e5+5;
const ll MOD = 1e9+7;
ll pre[N];
int main()
{


    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,q;
    cin>>n>>q;
    string s;
    cin >> s;
    

    for(int i = 1;i<n;i++){
        pre[i] = pre[i-1];
        if(s[i] == 'C' && s[i-1] == 'A'){
            pre[i]++;
        }

    }

    while(q--){
        ll l,r;
        cin >> l >> r;
        --l,--r;
        cout << pre[r] - pre[l] << endl;
    }


    return 0;
}

Measured memory_bytes: 1872
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int n,a;
  cin>>n>>a;
  if(n%500<=a)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int K = scan.nextInt();
    int A = scan.nextInt();
    int B = scan.nextInt();
    scan.close();

    System.out.println(A%K == 0 || A/K != B/K ? "OK" : "NG");
  }
}

Measured memory_bytes: 27048
import java.util.*;
class Main{
  public static void main(String[] arg){
    Scanner stdIn=new Scanner(System.in);
    int N=stdIn.nextInt();
    int total=0;
    for(int i=1;i<=N;i++){
      total+=i;
    }
    System.out.println(total);
  }
}
      
    
    

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

int main()
{
  int n, res[10001];
  cin >> n;
  for (int i = 0; i < n * 2; i++){
    cin >> res[i];
  }
  sort(res, res + n * 2);
  int ct = 0;
  for (int i = 0; i < n; i++){
    ct += min(res[i * 2], res[i * 2 + 1]);
  }
  cout << ct << endl;
}


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


int n, k;
int d;
bool s[1000];
int a;

int main(){

    cin >> n >> k;

    for(int i = 0; i < k; i++){
        cin >> d;

        for(int j = 1; j <= d; j++){
            cin >> a;
            s[a] = true;
        }
    }

    int ans = 0;

    for(int i = 1; i <= n; i++){
        if(!s[i]){
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

int main() {
  int a;
  int b;
  int i;
  int ans;
 
  cin >> a >> b;
  i = -1;
  ans = 1;
  while (++i < a)
  {
    if (ans * 2 - ans > b)
      ans += b;
    else
      ans *= 2;
  }
  cout << ans << endl;
}

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

const int N = 1010;
 
int n,cnt;
int mark[N * 10];
long long pri[N], a[N][N];
 
void getpri() {
  for (int i=2;i<=10000;i++) {
    if (!mark[i]) pri[++cnt]=i;
    if (cnt==1000) break;
    for (int j=1;j<=cnt && i*pri[j]<=10000;j++) {
      mark[i*pri[j]]=1;
      if (i%pri[j]==0) break;
    }
  }
}
 
long long lcm(long long x,long long y) {
  if (!x || !y) return x+y;
  return x/__gcd(x,y)*y;
}
 
int main()
{
  getpri();
  scanf("%d",&n);
  if (n==2) {
    puts("4 7");
    puts("23 10");
    return 0;
  }
  for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
      if ((i+j)%2==0)
	a[i][j]=pri[(i+j)/2]*pri[n+(i-j)/2+(n+1)/2];
  for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
      if (!a[i][j])
	a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
  for (int i=1;i<=n;i++) {
    for (int j=1;j<=n;j++)
      printf("%lld ",a[i][j]);
    puts("");
  }
  return 0;
}


Measured memory_bytes: 7296
import itertools as it
N=int(input())
llist=list(map(int, input().split()))
#llist.sort()
ans=0
ijk=it.combinations(range(N),3)
for ls in ijk:
    [i,j,k]=list(ls)
    li=llist[i]
    lj=llist[j]
    lk=llist[k]
    lll=[li,lj,lk]
    #print(lll)
    if li==lj or li==lk or lj==lk:
        pass
    elif max(lll)<sum(lll)-max(lll):
        ans+=1
    #    print(i+1,j+1,k+1)
    #    print(li,lj,lk)
print(ans)


Measured memory_bytes: 8856
#include <iostream>

using namespace std;

int main() {
  int a, b;
  char op;

  for ( ; ; ) {
    cin >> a >> op >> b;
    int result;
    if      (op == '+') result = a + b;
    else if (op == '-') result = a - b;
    else if (op == '*') result = a * b;
    else if (op == '/') result = a / b;
    else break;
    cout << result << endl;
  }

  return 0;
} 



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

int main(){

  int n;
  cin >> n;
  
  rep(i,3){
    
    if(n%10 == 7){
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n,arr1[25], arr2[25], arr3[25];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> arr1[i];
    }
    for(int i=0;i<n;i++){
        cin >> arr2[i];
    }
    for(int i=0;i<n;i++){
        arr3[i]=arr1[i]-arr2[i];
    }
    sort(arr3,arr3+n);
    int fmax=0;
    for(int i=n-1;i>=0;i--){
        if(arr3[i] <= 0){
            break;
        } else {
            fmax += arr3[i];
        }
    }
    cout << fmax << el;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
d=sum(B)
for i in range(n-1):
  if A[i+1]-A[i]==1:
    d+=C[A[i]-1]
print(d)

Measured memory_bytes: 9188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String reg = "\\d+";

        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        boolean atrue = true;
        boolean btrue = true;
        boolean hi = true;

        for(int i=0; i<s.length(); i++){
            if(i < a && !Character.isDigit(s.charAt(i))){
                atrue = false;
            }

            if (i == a && !(s.charAt(i) == '-')){
                hi = false;
            }

            if(!Character.isDigit(s.charAt(i)) && i > a){
                btrue = false;
            }
        }

        if(atrue && btrue && hi){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void printListOneLine(List list){
        for(int i=0; i<list.size(); i++){
            System.out.println(list.get(i));
        }
    }

    public static void printList(List list){
        for(int i=0; i<list.size(); i++){
            if(i == list.size()){
                System.out.println(list.get(i));
            } else {
                System.out.print(String.format("%d ", list.get(i)));
            }
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	Int temp = INF;
	Int cnt;
	for (Int i = -100; i < 101; i++) {
		cnt = 0;
		for (Int j = 0; j < N; j++) {
			cnt += (i - a[j]) * (i - a[j]);
		}
		if (temp > cnt) {
			temp = cnt;
		}
	}

	cout << temp << "\n";
}

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

using ll = long long;
constexpr ll MOD = 1e9+7;

int na, nt, ng, nc;
ll memo[64][64][64][64];
vector<int> terminal;
map<string, vector<string>> nonterminal;

ll rec(int a, int t, int g, int c) {
    ll& res = memo[a][t][g][c];
    if(res != -1) {
        return res;
    }
    if(a == na && t == nt && g == ng && c == nc) {
        return res = 1;
    }
    if(a > na || t > nt || g > ng || c > nc) {
        return res = 0;
    }
    res = 0;
    int term = terminal[a + t + g + c];
    if(na > a && (term >> 3) & 1) {
        res = (res + rec(a+1, t, g, c)) % MOD;
    }
    if(nt > t && (term >> 2) & 1) {
        res = (res + rec(a, t+1, g, c)) % MOD;
    }
    if(ng > g && (term >> 1) & 1) {
        res = (res + rec(a, t, g+1, c)) % MOD;
    }
    if(nc > c && (term & 1)) {
        res = (res + rec(a, t, g, c+1)) % MOD;
    }
    return res;
}

bool parse(string const& name) {
    auto terms = nonterminal[name];
    for(auto& t : terms) {
        if(t[0] == '[') {
            int symbol = 0;
            for(int i=1; i<t.size()-1; ++i) {
                if(t[i] == 'A') {
                    symbol |= (1 << 3);
                } else if(t[i] == 'T') {
                    symbol |= (1 << 2);
                } else if(t[i] == 'G') {
                    symbol |= (1 << 1);
                } else if(t[i] == 'C') {
                    symbol |= 1;
                }
            }
            terminal.push_back(symbol);
            if(terminal.size() > na + nt + ng + nc) {
                return false;
            }
        } else {
            if(!parse(t)) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    fill(memo[0][0][0], memo[64][0][0], -1);
    cin >> na >> nt >> ng >> nc;
    int m;
    cin >> m;
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    string dna;
    for(int i=0; i<m; ++i) {
        string rule;
        getline(cin, rule);
        stringstream ss(rule);
        string nonterm;
        ss >> nonterm;
        nonterm.pop_back();
        if(i == 0) {
            dna = nonterm;
        }
        string t;
        while(ss >> t) {
            nonterminal[nonterm].push_back(t);
        }
    }
    if(!parse(dna)) {
        cout << 0 << endl;
    } else {
        cout << rec(0, 0, 0, 0) << endl;
    }
}


Measured memory_bytes: 134284
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
struct UFS{
	int par[100005],s[100005];
	ll ans;
	void init(int n){
		ans=(ll)n*(n-1)/2;
		for(int i=0;i<100005;i++)par[i]=i,s[i]=1;
	}
	int find(int x){return x==par[x]?x:par[x]=find(par[x]);}
	bool same(int x,int y){return find(x)==find(y);}
	void unite(int x,int y){
		if(!same(x,y)){
			int nx=find(x),ny=find(y);
			par[nx]=ny;
			ans-=(ll)s[ny]*s[nx];
			s[ny]+=s[nx];
		}
	}
	ll get(){
		return ans;
	}
}uf;
vector<pair<int,int> >edge;
int n,m;
ll ans[100005];
int main(){
	cin>>n>>m;
	uf.init(n);
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		edge.push_back(make_pair(x,y));
	}
	for(int i=edge.size()-1;i>=0;i--){
		ans[i]=uf.get();
		uf.unite(edge[i].first,edge[i].second);
	}
	for(int i=0;i<m;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=2e5+100;

LL gi() {
	LL w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

pair<LL,LL>p[N];
int main()
{
	int n=gi(),i;LL mx=-OO,pre=0,ans=0;
	for (i=1;i<=n;i++) p[i].first=gi(),p[i].second=gi();
	sort(p+1,p+1+n);
	for (i=1;i<=n;i++) {
		mx=max(mx,p[i].first-pre);
		pre+=p[i].second;
		ans=max(ans,pre-p[i].first+mx);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
using point = pair<long double, long double>;

int main() {
    int n;
    cin >> n;
    vector<point> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].second >> p[i].first;
    }
    
    sort(p.begin(), p.end(), [](const point &l, const point &r) {
        return atan2l(l.first, l.second) < atan2l(r.first, r.second);
    });
    
    for (int i = 0; i < n; i++) p.emplace_back(p[i]);
    
    long double ans = 0.0;
    for (int i = 0; i < n; i++) {
        long double y = p[i].first, x = p[i].second;
        long double res = sqrtl(y * y + x * x);
        for (int j = i+1; j < i+n; j++) {
            y += p[j].first; x += p[j].second;
            chmax(res, sqrtl(y * y + x * x));
        }
        chmax(ans, res);
    }
    
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n;

int a[72];
int it = 0;

deque<int> s, t;
vi ans;

int main(){

  n = in() + 1;

  while( n > 0 ){
    a[it++] = n % 2;
    n /= 2;
  }

  // SHOWA( a , it );

  int x = 1;
  for( int i = it-2; i >= 0; i-- ){
    s.push_back( x );
    t.push_back( x );
    x++;
    if( a[i] == 1 ){
      s.push_front( x );
      t.push_back( x );
      x++;
    }
  }

  while( not s.empty() ){
    ans.pb( s.front() );
    s.pop_front();
  }

  while( not t.empty() ){
    ans.pb( t.front() );
    t.pop_front();
  }

  printf( "%lld\n" , SZ(ans) );
  REP( i , SZ(ans) ){
    if( i != 0 ){
      printf( " " );
    }
    printf( "%d" , ans[i] );
  }
  printf( "\n" );

  /*
  int cnt = 0;
  REP( i , PW(SZ(ans)) ){
    if( i == 0 or __builtin_popcount(i) % 2 == 1 ){
      continue;
    }
    vi c(0);
    REP( j , SZ(ans) ){
      if( i & PW(j) ){
        c.pb( ans[j] );
      }
    }
    bool ok = true;
    REP( j , SZ(c)/2 ){
      if( c[j] != c[SZ(c)/2+j] ){
        ok = false;
        break;
      }
    }
    if( ok ){
      cnt++;
    }
  }
  cout << cnt << endl;
  */
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"Yay!"<<endl;
    else cout <<":("<<endl;
    return;
}
int main(){
    ll a,b;
    cin>>a>>b;
    YN(a<=8 && b<= 8);
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<algorithm> 
#include<cassert> 
#include<vector> 
#include<fstream> 
#include<string> 
#include<stdio.h> 
#include<stdlib.h> 
#include<time.h> 
#include<queue> 
#include<map> 
#include<set> 
#include<bitset> 
#include<cmath> 

using namespace std; 
#define REP(i,m,n) for(int i=m;i<n;++i) 
#define REPll(i,m,n) for(long long i=m;i<n;++i) 
#define INF 10000000000000000 
#define MOD 1000000007 
#define ll long long 
#define mp make_pair 
#define all(v) v.begin(),v.end() 

int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll hoge=max(max(a,b),c);
    REP(i,0,k){
        hoge*=2;
    }
    ll ans=a+b+c+hoge-max(max(a,b),c);
    cout<<ans<<endl;
    return 0; 
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $a);

$datas = str_split($a);

if($datas[0] == 1) {
  echo 9;
} else {
  echo 1;
}
if($datas[1] == 1) {
  echo 9;
} else {
  echo 1;
}
if($datas[2] == 1) {
  echo 9;
} else {
  echo 1;
}

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long m, n;
        cin >> n >> m;

        vector<long> a(n);
        long total = 0;
        for (auto &x : a) {
            cin >> x;
            total += x;
            x *= 4*m;
        }
        long count = 0;
        for (auto &x : a) {
            if (x >= total) count++;
        }
        if (count >= m) puts("Yes");
        else puts("No");
    }
}


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

long long N, K;
vector<long double> A(200001);

bool nibun(int x){
  long long sum = 0;
  for(int i = 0; i < N; i++){
    sum += ceil(A[i] / x) - 1;
  }
  if(sum <= K){
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> N >> K;
  long double maxx = 0;
  for(int i = 0; i < N; i++){
     cin >> A[i];
     maxx = max(maxx, A[i]);
  }
  int l = 0, r = maxx;
  int m;
  while(r - l > 1){
    m = (r + l) / 2;
    //cout << l << " " << r << " " << m <<endl;
    if(nibun(m)){
      //cout << m << " ok" <<endl;
      r = m;
    } else{
      //cout << m << " bad" <<endl;
      l = m;
    }
  }
  cout << r <<endl;
}


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

int main(){
    int N;
    cin >> N;
    char mark;
    int num;
    int S[14], H[14], C[14], D[14];
    
    for(int i = 0; i < 14; i++){
        S[i] = 0;
        H[i] = 0;
        C[i] = 0;
        D[i] = 0;
    }
    
    for(int i = 0; i < N; i++){
        cin >> mark >> num;
        if(mark == 'S'){
            S[num] = 1;
        } else if(mark == 'H'){
            H[num] = 1;
        } else if(mark == 'C'){
            C[num] = 1;
        } else {
            D[num] = 1;
        }
    }
    
    for(int i = 1; i<14; i++){
        if(S[i] == 0) cout << "S " << i << endl;
    }
    for(int i = 1; i<14; i++){
        if(H[i] == 0) cout << "H " << i << endl;
    }
    for(int i = 1; i<14; i++){
        if(C[i] == 0) cout << "C " << i << endl;
    }
    for(int i = 1; i<14; i++){
        if(D[i] == 0) cout << "D " << i << endl;
    }
    
    return 0;
}


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

int main()
{
	string s, t; cin >> s >> t;
	
	int a, b; cin >> a >> b;

	string u; cin >> u;

	string ans = "Yes";

	if (s == u) {
		a--;
	}
	else if (t == u) {
		b--;
	}
	else {

	}

	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
//
// Created by Geoffrey West on 12/22/18.
//

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    int count = 0;
    for(int i = 0; i < 4; i++){
        if ((n - 2) % 10 == 0)
            count++;
        n /= 10;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
const int N=100005;
int n,a[N<<1],b[N<<1];
int check(int x) {
	for(RI i=1;i<=2*n-1;++i) b[i]=(a[i]>=x);
	for(RI i=0;i<n;++i) {
		if(b[n-i]==b[n-i-1]) return b[n-i];
		if(b[n+i]==b[n+i+1]) return b[n+i];
	}
	return b[1];
}
int main()
{
	n=read();
	for(RI i=1;i<=2*n-1;++i) a[i]=read();
	int l=1,r=2*n-1,ans;
	while(l<=r) {
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#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>;
using vv = vector<vector<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;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main() {
    cout.precision(15);
    int n;cin >> n;
    vector<vector<int>> a(n,vector<int>(2)); 
    rep(i,n) cin >> a[i][0] >> a[i][1];
    vector<int> x(n);
    rep(i,n) x[i] = i;
    double ans = 0;
    int t = 0;
    do{
	t++;
	for(int i=0;i<n-1;i++){
	   int p = a[x[i]][0]-a[x[i+1]][0];
	   int q = a[x[i]][1]-a[x[i+1]][1];
	    ans += sqrt(p*p+q*q);
	}
    }while(next_permutation(x.begin(),x.end()));
    cout << ans/t << endl;
    return 0;
}


Measured memory_bytes: 256
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
 	use_fast;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
		a[i] *= -1;
    sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++)
		a[i] *= -1;
//  hesh cmp nabod 
	for (int i = 1; i <= n; i++) {
        if(i + 1 > a[i + 1]) {
        	int ans = 0;
            for(int j = i + 1; a[j] == i; j++)
                ans ^= 1;
            ans |= (a[i] - i) & 1;
            if (ans) 
				cout << "First" << endl;
            else
				cout << "Second" << endl;
			return 0;
		}
	}
	assert(0);
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/


Measured memory_bytes: 4452
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x = cin.nextLong();

            double now = x;
            var ans = 0;
            while (true)
            {
                now = Math.Ceiling((now * 100 / 101.0));
                ans++;
                if(now == 100)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }
            
            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var a = inputLongArray[0];
            var b = inputLongArray[1];
            var c = inputLongArray[2];
            var d = inputLongArray[3];

            if(Math.Abs(a - c) <= d) {
                Console.WriteLine("Yes");
                return;
            }

            if (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d) {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
import copy
N, M, Q = map(int, input().split())
Qj = [list(map(int, input().split())) for i in range(Q)]

ans = 0

def dfs(Aj):
	global ans
	if len(Aj) == N:
		now = 0
		for Q in Qj:
			if Aj[Q[1]-1] - Aj[Q[0]-1] == Q[2]:
				now += Q[3]
		ans = max(ans, now)
		return;
	if len(Aj) == 0:
		Aj.append(1)
	else:
		Aj.append(Aj[-1])
	while Aj[-1] <= M:
		dfs(copy.deepcopy(Aj))
		Aj[-1] += 1
Aj = []
dfs(Aj)
print(ans)

Measured memory_bytes: 9280
var i,j,n,m:longint;
    b1,b2:boolean;
    s:string;
begin
read(s);
for i:=length(s) downto 1 do
  if s[i]='F' then
  begin
    m:=i;
    b1:=true;
    break;
  end;
if b1 then
  for i:=1 to m do
    if s[i]='C' then
    begin
      write('Yes');
      exit;
     end;
write('No');
end.


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
    int ar[n];
	for(int i = 0; i < n; i++) cin>>ar[i];
	int res = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			int sum = ar[i] + ar[j];
			int diff = abs(ar[i] - ar[j]);
			for(int k = j+1; k < n; k++) res += ar[k] < sum && ar[k] > diff && ar[i] != ar[j] && ar[i] != ar[k] && ar[j] != ar[k];
		}
	}
	cout<<res;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char prev = 'x';
		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != prev) {
				count++;
				prev = s.charAt(i);
			}
		}
		System.out.println(count - 1);
	}
}


Measured memory_bytes: 24484
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_L 1010
typedef pair<char,int> P;
 
int L,limit[52],v;
string line[MAX_L];
map<P,int> val;
 
int change(char x){
    if(islower(x)){
	return x-'a';
    }
    return x-'A'+26;
}
 
int getDigit(int *l,int *cur){
    int res = 0;
    while(isdigit(line[*l][*cur])){
	res *= 10;
	res += line[*l][*cur]-'0';
	(*cur)++;
    }
    return res;
}
 
int getArray(int *l,int *cur){
    char x = line[*l][*cur];
    int idx = change(x);
    (*cur) += 2;
    int num;
    if(islower(line[*l][*cur]) || isupper(line[*l][*cur])){
	num = v = getArray(l,cur);
	if(num == -1){ return -1; }
	if(limit[idx] <= num){
	    return -1;
	}
	(*cur)++;
	P p = P(x,num);
	if(val.find(p) == val.end()){
	    return -1;
	}else{
	    return val[P(x,num)];
	}
    }
    num = v = getDigit(l,cur);
    (*cur)++;
    if(limit[idx] <= num){ return -1; }
    else{
	P p = P(x,num);
	if(val.find(p) == val.end()){
	    return -1;
	}else{
	    return val[P(x,num)];
	}
    }
}
 
int solve(int l,int cur){
    if(l == L){ return 0; }
    char now = line[l][cur];
    if(islower(now) || isupper(now)){
	char x = line[l][cur];
	int num;
	getArray(&l,&cur);
	int v2 = v;
	if(line[l][cur] == '='){
	    cur++;
	    if(isdigit(line[l][cur])){
		num = getDigit(&l,&cur);
	    }else{
		num = getArray(&l,&cur);
		if(num == -1){ return l+1; }
	    }
	    if(limit[change(x)] <= v2){ return l+1; }
	    val[P(x,v2)] = num;
	    return solve(l+1,0);
	}else if(line[l][cur] == '$'){
	    limit[change(x)] = v;
	    return solve(l+1,0);
	}
    }
    return l+1;
}
 
void init(){
    val.clear();
    memset(limit,-1,sizeof(limit));
}
 
int main(){
    while(cin >> line[0],line[0] != "."){
	init();
	line[0] += '$';
	L = 1;
	while(true){
	    cin >> line[L];
	    if(line[L] == "."){ break; }
	    line[L] += '$';
	    L++;
	}
	cout << solve(0,0) << endl;
    }
    return 0;
}

Measured memory_bytes: 3476