akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
long long n, s=1, M=1e9+7, a[1005];
int main() {
	int i, j, k;
	cin>>n;
	for(j=1; j<=n; j++) {
		k = j;
		for(i=2; k>1; ) {
			if(k%i==0) k/=i, a[i]++;
			else i++;
		}
	}
	for(i=2; i<=n; i++) s = s*(a[i]+1)%M;
	cout<<s;
	return 0;
}

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

template <class T> struct fenwick_tree {
using  U=long long ;

  public:
    fenwick_tree() : _n(0) {}
    fenwick_tree(int n) : _n(n), data(n) {}

    void add(int p, T x) {
        assert(0 <= p && p < _n);
        p++;
        while (p <= _n) {
            data[p - 1] += U(x);
            p += p & -p;
        }
    }

    T sum(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        return sum(r) - sum(l);
    }

  private:
    int _n;
    vector<U> data;

    U sum(int r) {
        U s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
};


int main(){
long long n;
cin>>n;
string ans;
string t="ACL";
for(long long i=0;i<n;i++){
  ans+=t;
}
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3596
fn main() {
    let n = read::<usize>();
    let a = read_vec::<u64>();

    let mut left: Vec<u64> = vec![0; n + 1];
    let mut right: Vec<u64> = vec![0; n + 1];
    for i in 0..n {
        left[i + 1] = gcd(left[i], a[i]);
        right[n - 1 - i] = gcd(right[n - i], a[n - 1 - i]);
    }

    let mut ma = 0;
    for i in 0..n {
        let l = left[i];
        let r = right[i + 1];
        let tmp = gcd(l, r);
        if ma < tmp {
            ma = tmp
        }
    }
    println!("{}", ma)
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4460
import java.util.*;
public class Main  {
   public static void main(String[] args)  {
      Scanner sc = new Scanner(System.in);
      
      int x = sc.nextInt();
      int y = sc.nextInt();
      int z = sc.nextInt();
      
      int prevx = x;
      x = y; 
      y = prevx;
      
      int prevxx = x;
      x = z;
      z = prevxx;
            
      System.out.println(x + " " + y + " " + z);  
   }        
}

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

int main() {
    string s;
    cin >> s;

    string ret ="No";
    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') {
            ret = "Yes";
            break;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

int count_rightwhite(int i,int n,const char s[])
{
  int cnt=0;
  int j;
  for(j=i;j<n;j++){
    if(s[j]=='.')cnt++;
  }
  return cnt;
}


int main(void)
{
  int n;
  char s[200001];
  scanf("%d",&n);
  scanf("%s",s);
  
  int c[200001]={0};
  int i=0,j=0;
  for(i=0;i<n;i++){
    if(j%2==0){
      if(s[i]=='.'){
        c[j]++;
      }else{
        j++;
        c[j]++;
      }
    }else{
      if(s[i]=='#'){
        c[j]++;
      }else{
        j++;
        c[j]++;
      }
    }
  }
  
  int cntmin=n;
  int sum_black=0,sum_white=count_rightwhite(0,n,s);
  for(i=0;i<=j;i+=2){
    sum_white-=c[i];
    
    int tmp=sum_black+sum_white;
    if(cntmin>tmp){
      cntmin=tmp;
    }
    
    sum_black+=c[i+1];
  }
  
  printf("%d\n",cntmin);
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

void swap(int& a, int& b){
	int c;
	c=a;a=b;b=c;
}

int main(){
	int cup[3] = {1,0,0};
	char s1, s2;

	while( scanf("%c,%c\n", &s1, &s2) != EOF){
		swap( cup[s1-'A'] , cup[s2-'A'] ) ;
		
	}
	printf("%c\n", cup[0]*'A' + cup[1]*'B' + cup[2]*'C');
	

	return 0;
}

Measured memory_bytes: 0
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k = LI()
    a = LI_()
    r = 0
    if a[0] != 0:
        r += 1
    e = collections.defaultdict(set)
    for i in range(1,n):
        e[a[i]].add(i)

    def f(i, p):
        m = 0
        r = 0
        for c in e[i]:
            ct,cr = f(c, i)
            r += cr
            if ct > m:
                m = ct
        if (m == k-1 and p != 0) or (m == k and p == 0):
            r += 1
            m = -1
        return (m+1,r)

    for c in e[0]:
        m,t = f(c,0)
        r += t
    return r


print(main())




Measured memory_bytes: 151040
#include<stdio.h>
#include<algorithm>
using namespace std;
double dp[510][110][110];
int p[110];
int q[110];
int t[510];
int main(){
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	for(int i=0;i<d;i++)scanf("%d%d",p+i,q+i);
	c--;
	for(int i=0;i<a;i++)t[i]=-1;
	for(int i=0;i<d;i++){
		t[p[i]-1]=q[i]-1;
	}
	dp[a][0][c]=1;
	for(int i=a;i>0;i--){
		int z=0;
		for(int j=0;j<i;j++)if(!~t[j])z++;
		for(int j=0;j<=e;j++){
			for(int k=0;k<b;k++){
			//	printf("%d %d %d: %f\n",i,j,k,dp[i][j][k]);
				if(~t[i-1]){
					int to=k;
					if(t[i-1]==to)to++;
					else if(t[i-1]+1==to)to--;
					dp[i-1][j][to]+=dp[i][j][k];
				}else{
					double p=(double)(e-j)/(z);
					dp[i-1][j][k]+=dp[i][j][k]*(1.0-p);
					int rem=b-1;
					if(k){
						rem--;
						dp[i-1][j+1][k-1]+=dp[i][j][k]*p/(b-1);
					}
					if(k<b-1){
						rem--;
						dp[i-1][j+1][k+1]+=dp[i][j][k]*p/(b-1);
					}
					dp[i-1][j+1][k]+=dp[i][j][k]*p*rem/(b-1);
				}
			}
		}
	}
	double ret=0;
	for(int i=0;i<b;i++)ret=max(ret,dp[0][e][i]);
	printf("%.12f\n",ret);
}

Measured memory_bytes: 48260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
  cin>>n;
    vector<ll> a(n),b(n);
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }

    ll result=0;
    for(ll i=n-1;i>=0;i--){
        result+=(((a[i]+result+b[i]-1)/b[i])*b[i]-(a[i]+result));
    }

    cout<<result;
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

ll n,a,b;
ll h[100010];

int isok(ll c){
    ll num=a-b;
    ll c1=0;
    rep(i,n){
        if (c*b<h[i]){
            ll d=h[i]-b*c;
            if (d%num==0)c1+=d/num;
            else c1+=(d/num)+1;
        }
    }
    if (c1>c)return 0;
    else return 1;
}


int main() {
    cin>>n>>a>>b;
    //n=100000,a=1000000000,b=999999999;
    rep(i,n){
        cin>>h[i];
    }
    ll l=0,r=1e9;
    while (r-l>1){
        ll mid=(r+l)/2;
        if (isok(mid))r=mid;
        else l=mid;
    }
    //rep(i,10)cout<<isok(i)<<endl;
    if (isok(l))cout<<l<<endl;
    else cout<<r<<endl;
    

    return 0;
}


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

int main() {
 int W, a, b;
 cin >> W >> a >> b;

 if(a < b) {
   if(a + W > b) { cout << 0; return 0; }

   cout << b - (a + W);
 }
 else if(a == b) { cout << 0; return 0; }
 else {
   if(a < b + W) { cout << 0; return 0; }

   cout << a - (b + W);
 }
  return 0;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n, ans = 0, tmp = 0;
    cin >> n;
    if (n%2 == 0) cout << 0.5 << endl;
    else cout << (double)(n/2+1)/n << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (k, x) = (v[0], v[1]);
    if k * 500 >= x {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> mp;
    REP(i,n) {
        int x; cin >> x;
        mp[x]++;
    }
    int ans = 0;
    bool b = true;
    if (n % 2 == 0) {
        for(int i = 1;i <= n - 1; i+=2) {
            if (mp[i] != 2) {
                b = false;
                break;
            }
        }
        if (b) {
            ans += 1;
            REP(i,n/2) ans = modm(ans,2);
        }
    } else {
        if (mp[0] != 1) {
            b = false;
        } else {
            for(int i = 2;i <= n - 1; i+=2) {
                if (mp[i] != 2) {
                    b = false;
                    break;
                }
            }
        }
        if (b) {
            ans += 1;
            REP(i,n/2) ans = modm(ans,2);
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);Rev(P);
  if(N>K)rep(i,K,N)sum+=P[i];
  Out(sum);
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  

  int N, diff = 0;
  cin >> N;
  vector<int> card(N);
  for(int &ele : card) cin >> ele;

  sort(ALLR(card));
  for(int idx = 0; idx < N; ++idx){
    if(idx & 1) diff -= card[idx];
    else diff += card[idx];
  }

  cout << diff << "\n";
  return 0;
}

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

int main(){
  ll H,W,K,ans=0;
  cin >> H >> W >> K;
  vector<string> C(H);
  rep(i,H) cin >> C.at(i);
  for (int tmp = 0; tmp < (1 << H+W ); tmp++) {
    bitset<12> s(tmp);
    vector<string> c(H);
    c=C;
    rep(i,H+W){
      if(s.test(i)){
        if(i<H){
          rep(j,W){
            c.at(i).at(j)='.';
          }
        }else{
          rep(j,H){
            c.at(j).at(i-H)='.';
          }
        }
      }
    }
    ll k=0;
    rep(i,H)rep(j,W){
      if(c.at(i).at(j)=='#'){
        k++;
      }
    }
    if(k==K){
      ans++;
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	cout<<(1000-n%1000)%1000<<"\n";
	return 0;
}

Measured memory_bytes: 3684
import sys
sys.setrecursionlimit(10**7)

n, m, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]

def dfs(k, x):
    global mx
    if k == n:
        v = 0
        for line in query:
            a, b, c, d = line
            if x[b] - x[a] == c: v += d
        if mx < v: mx = v
    else:
        for i in range(x[-1], m + 1):
            dfs(k + 1, x + [i])
    
mx = 0
dfs(0, [1])

print(mx)

Measured memory_bytes: 9044
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7;
using namespace std;
ll t;
ll arr[200005];
int main()
{
    ll a,b,c,d,e,f,i,j;
    cin>>a>>b;
    c=0;
    while(b--)
    {
        cin>>d;
        c+=d;
    }
    if(c>=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int mi = 3e5;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int p; cin >> p;
		if(p <= mi) ans++;
		mi = min(mi, p);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
arr = list(map(int,input().split()))

num4=0
num2=0
num1=0
for a in arr:
    if a%4==0:
        num4 += 1
    elif a%2==0:
        num2 += 1
    else:
        num1 += 1

if num4 >= n//2:
    print("Yes")
else:
    if num4 >= num1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252
a,b,c,x,y = gets.chomp.split(" ").map(&:to_i)

a = {cost:a, require:x}
b = {cost:b, require:y}

min = [a,b].min_by{|hash| hash[:require]}
max = [a,b].max_by{|hash| hash[:require]}
other = max.clone
other[:require] -= min[:require]

cost_a = 2*c * min[:require]
cost_a += other[:cost] * other[:require]

cost_b = 2*c * max[:require]

cost_c = a[:cost] * a[:require] + b[:cost] * b[:require]

puts [cost_a,cost_b,cost_c].min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
const int N = 1e5 + 55;
int n;
int a[N];
int cnt[N] = {0};
const int M = 1e9 + 7;
void fuck() {
	cout << 0;
	exit(0);
}
void solve() {
	cin >> n;
	for (int i = 1; i <= n; i += 1)
		cin >> a[i];
	int remain = 3;
	int ans = 1;
	for (int i = 1; i <= n; i += 1) {
		if (a[i] == 0) {
			if (!remain)
				fuck();
			ans *= remain;
			ans %= M;
			--remain;
		}
		else {
			ans *= cnt[a[i] - 1];
			--cnt[a[i] - 1];
			ans %= M;
		}
		++cnt[a[i]];
	}
	cout << ans;
}     	

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int solve(string s){
	int cnt=0,ans=0;
	int n=s.length();
	for(int i=0;i<n;i++){
		cnt++;
		if(i==n-1 || s[i]!=s[i+1]){
			ans+=cnt/2;
			cnt=0;
		}
	}
	return ans;
}

int main(){
  string str;
  cin>>str;
  long long int k,n;
  cin>>k;
  n=str.length();
  bool flag=false;
  for(int i=0;i<n-1;i++){
    if(str[i]!=str[i+1]){
      flag=true;
      break;
    }
  }
  if(!flag){
    cout<<k*n/2;
    return 0;
  }
  string str2=str+str;
  long long int n1=solve(str);
  long long int n2=solve(str2);
  cout<<n1+(n2-n1)*(k-1);
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!.toCharArray()
    var ans = 0
    var cur = 'X'
    S.forEach { s ->
        if (cur == s) return@forEach
        ans++
        cur = s
    }
    println(ans)
}

Measured memory_bytes: 33732
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで

int main() {
  int64_t n, ans=2*pow(10, 10);
  cin >> n;
  for(int i=1; i<=sqrt(n); i++){
    if(n%i==0){
      int64_t tmp=max((log10(i)), log10(n/i))+1;
      if(tmp<ans) ans=tmp;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3956
/*
 * atcoder/abc114_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

string S;
int N;
int dp[11][2][2][2][2][2];

int rec(int n=0, bool l = true, bool zero = true, bool three = false, bool five = false, bool seven = false) {
  int &cc = dp[n][l][zero][three][five][seven];
  if (~cc) return cc;
  if (n==N) return cc = three and five and seven;
  int u = l ? S[n]-'0' : 9;
  int ways = 0;
  for (int i=0; i<=u; i++) {
    if (!zero and i == 0) continue;
    if (i == 0 or i == 3 or i == 5 or i == 7)
      ways += rec(n+1, l and i == u, zero and i == 0, three or i == 3, five or i == 5, seven or i == 7);
  }
  return cc = ways;
}

void solve() {
  cin >> S;
  N = S.size();
  loop(n,0,11) loop(a,0,2) loop(b,0,2) loop(c,0,2) loop(d,0,2) loop(e,0,2) {
    dp[n][a][b][c][d][e] = -1;
  }
  cout << rec() << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> list(100000, 0);
    for (int i = 0; i < N; i++) {
        int input;
        scanf("%d", &input);
        list[input]++;
    }

    int ans_max = 0;
    for (int i = 1; i < 99999; i++) {
        int sum = list[i - 1] + list[i] + list[i + 1];
        if (sum > ans_max) {
            ans_max = sum;
        }
    }
    cout << ans_max << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
long long INF = 1LL<<60;
int n;
int main(){
    cin>>n;
    vector<int> p(n),q(n);
    rep(i,n)cin>>p.at(i);
    rep(i,n)cin>>q.at(i);
    vector<int> temp(n);
    rep(i,n)temp.at(i)=p.at(i);
    sort(temp.begin(),temp.end());
    int qi=0,pi=0;
    int cnt=0;
    do{
        int comp[n];
        int i=0;
       for(int x: temp){
          comp[i]=x;
          i++;
       }
       rep(j,n){
           if(pi!=0)break;
           if(comp[j]!=p.at(j))break;
           if(j==n-1)pi=cnt;
       }
       rep(j,n){
           if(qi!=0)break;
           if(comp[j]!=q.at(j))break;
           if(j==n-1)qi=cnt;
       }
       cnt++;
    }while(next_permutation(temp.begin(),temp.end()));
    cout<<abs(pi-qi)<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int vis[9];
int fre, cnt;

int main()
{
	int n, t;
	scanf("%d", &n);
	fre = cnt = 0;
	while(n--){
		scanf("%d", &t);
		if(t >= 3200)	fre++;
		else vis[t / 400]++;
	}
	for(int i = 0; i <= 7; i++)
		if(vis[i])	cnt++;
	if(cnt == 0)	printf("%d %d\n", 1, fre);
	else	printf("%d %d\n", cnt, cnt + fre);
	return 0;
}

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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x - r < 0 || y - r < 0 || x + r > w || y + r > h) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main(){
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;cin>>n;
  string s;
cin>>s;
  int ci=0,cj=0;
  for(char ch:s){
      if(ch=='R') ci++;
       else cj++;
  }
  if(ci>cj) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
#define MAX_N 500000
#define INF 2139062143
 
int x[MAX_N][3], cnt;//num,left,right
int n, a;
string S;
 
void inorder(int u) {
    if (u == -1) { return; }
    inorder(x[u][1]);
    cout << ' ' << x[u][0];
    inorder(x[u][2]);
}
void preorder(int u) {
    if (u == -1) { return; }
    cout << ' ' << x[u][0];
    preorder(x[u][1]);
    preorder(x[u][2]);
}
 
int main() {
    int root = -INF;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> S;
        if (S == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
        if (S == "insert") {
            cin >> a;
            if (root == -INF) {
                root = cnt;
            }
            else {
                int v = root;
                while (true) {
                    if (a < x[v][0]) {
                        if (x[v][1] == -1) {
                            x[v][1] = cnt;
                            goto E;
                        }
                        v = x[v][1];
                    }
                    else {
                        if (x[v][2] == -1) {
                            x[v][2] = cnt;
                            goto E;
                        }
                        v = x[v][2];
                    }
                }
            E:;
            }
            x[cnt][0] = a; x[cnt][1] = -1; x[cnt][2] = -1;
            cnt++;
        }
    }
    return 0;
}



Measured memory_bytes: 8988
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll n,ans=INF;
    cin >> n;
    ll s[n];
    for (ll i=0;i<n;i++)cin >> s[i];
    for (ll i=0;i<n;++i){
        ll a=0;
        while(true){
            if (a>ans){
                break;
            }
            if (s[i]%2!=0){
                ans=min(a,ans);
            }
            s[i]=s[i]/2;
            a++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

double dp[301][301][301];

int main(){
    int n;
    cin>>n;
    int a[n];
    int cnt[4]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int k=0;k<=n;k++){
        for(int j=0;j<=n;j++){
            for(int i=0;i<=n;i++){
                if(i==0&&j==0&&k==0)continue;
                if(i+j+k>n)continue;
                if(i>0)dp[i][j][k]+=i*dp[i-1][j][k];
                if(j>0)dp[i][j][k]+=j*dp[i+1][j-1][k];
                if(k>0)dp[i][j][k]+=k*dp[i][j+1][k-1];
                dp[i][j][k]+=n;
                dp[i][j][k]/=i+j+k;
            }
        }
    }
    cout<<fixed<<setprecision(15)<<dp[cnt[1]][cnt[2]][cnt[3]]<<endl;
}

Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()

int main(){
    int i,j,k,n;
    vector<vector<int>> a(3,vector<int>(3));
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    cin>>n;
    vector<int> b(n);
    for(i=0;i<n;i++) cin>>b[i];
    vector<vector<int>> c(3,vector<int>(3));
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            for(k=0;k<n;k++){
                if(b[k]==a[i][j]){
                    c[i][j]=1;
                }
            }
        }
    }
    // for(i=0;i<3;i++){for(j=0;j<3;j++) cout<<c[i][j]<<endl;}
    for(i=0;i<3;i++){
        if(c[i][0]==1 and c[i][1]==1 and c[i][2]==1){
            cout<<"Yes"; return 0;
        } else if(c[0][i]==1 and c[1][i]==1 and c[2][i]==1){
            cout<<"Yes"; return 0;
        }
    }
    if(c[0][0]==1 and c[1][1]==1 and c[2][2]==1){
        cout<<"Yes"; return 0;
    }else if(c[0][2]==1 and c[1][1]==1 and c[2][0]==1){
        cout<<"Yes"; return 0;
    }
    cout<<"No"; return 0;
}



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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    ll n;
    cin>>n;
    ll a[n], b[n], c[n];
    ll a_, b_, c_;  /// value of happiness at ith day, if activity was done A, B and C resp
    fr(i, n) cin>>a[i]>>b[i]>>c[i];

    a_ = a[0], b_ = b[0], c_ = c[0];
    ll ta, tb, tc;  /// temp vars
    rep(i, 1, n-1){
        ta = a[i] + max(b_, c_);
        tb = b[i] + max(a_, c_);
        tc = c[i] + max(b_, a_);

        a_ = ta, b_ = tb, c_ = tc;
    }
    cout<<max({a_, b_, c_});
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n;

int main(){
	cin >> n;
	vector<int> a(n+1);
	for(int i = 1; i < n+1; i++)cin >> a[i];
	vector<int> b(n+1); //答えが入る配列
	for(int i = n; i >= 1; i--){
		int sum = 0; //iの倍数
		//でかい方からやって，n/2まではとりあえず実行しない
		for(int j = i+i; j<=n; j+=i){
			sum ^= b[j];	
		}
		b[i] = sum^a[i];
	}
	vector<int> ans;
	for(int i=1; i<n+1; i++){
		if(b[i]==1)ans.push_back(i);
	}
	cout << ans.size() <<endl;
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3064
function main(input) {
  const inputs = input.split('\n')
  const N = Number(inputs[0])
  const A = inputs[1].split(' ').map(Number)

  const a = A.map((e,i) => [e, i]).sort((a, b) => {
    return a[0] < b[0] ?
      1:
      -1
  })
  // console.log(a)
  const dp = Array.from(new Array(N+1)).map(e => [])
  // console.log(dp)
  dp[0][0] = 0
  for(let i = 0; i < N; i++) {
    const aind = a[i][1]
    const ai = a[i][0]
    for(let l = 0; l < i+1; l++) {
      const r = i - l
      // ここにdp...?
      // console.log(aind, i, l, r)
      const c = dp[i][l]
      // calc next
      // 右
      if (dp[i+1][l] === undefined) dp[i+1][l] = 0
      // console.log('calc:', i, l)
      // console.log('right point:', ai * ((N - r - 1) - aind))
      dp[i+1][l] = Math.max(dp[i+1][l], dp[i][l] + ai * ((N - r - 1) - aind))
      // 左
      if (dp[i+1][l+1] === undefined) dp[i+1][l+1] = 0
      // console.log('calc:', i, l+1)
      // console.log('left point:', dp[i][l] + ai * (aind - l))
      dp[i+1][l+1] = Math.max(dp[i+1][l+1], dp[i][l] + ai * (aind - l))
      // console.log(dp)
    }
  }
  console.log(Math.max.apply(null, dp[dp.length-1]))
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 79668
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 200010;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int n;
int b[MAXN], tot, p[MAXN];
ll a[555][555];

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

ll lcm(ll a)
{
	return a;
}

template<class A, class... B>
ll lcm(A a, B... b)
{
	auto c = lcm(b...);
	return c ? (a ? a/gcd(a, c)*c : c) : a;
}

int main()
{
	
	for (int i = 2; i <= 200000; ++ i)
		if (!b[i])
		{
			p[++ tot] = i;
			for (int j = i+i; j <= 200000; j += i)
				b[j] = 1;
		}
	for (int i = 1; i <= 500; ++ i)
		for (int j = 1; j <= 500; ++ j)
		{
			if ((i+j)%2 == 1) continue;
			a[i][j] = (ll)p[(i+j)/2]*p[(i-j)/2+750];
		}
	
	for (int i = 1; i <= 500; ++ i)
		for (int j = 1; j <= 500; ++ j)
		{
			if ((i+j)%2 == 0) continue;
			a[i][j] = lcm(a[i-1][j], a[i][j-1], a[i][j+1], a[i+1][j])+1;
		}
	
	cin >> n;
	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
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    string S;
    cin >> S;
    
    int ans = 0;
    FOR(i, 0, S.length()/2) {
        if (S[i] != S[S.length() - i - 1]) {
            ans++;
        }
    }
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
#a, b, t = map(int, input().split())
n=int(input())
alist = list(map(int, input().split()))

ok=[]
ok2=[]

yakusu=make_divisors(alist[-1])
for yk in yakusu:
    ok2.append(yk)

yakusu=make_divisors(alist[-2])
for yk in yakusu:
    if yk in ok2:
        ok2.remove(yk)
        ok.append(yk)
    else:
        ok2.append(yk)
ok=sorted(ok)
alist=alist[:-2]

for al in alist:
    #print(ok, ok2)
    if al%ok[-1]==0:
        ok3=[]
        for o2 in ok2:
            if al%o2==0:
                ok3.append(o2)
        ok2=ok3
    else:
        ok3=[]
        for o2 in ok2:
            if al%o2==0:
                ok3.append(o2)
        ok2=ok3
        ok3=[]
        for o in ok:
            if al%o==0:
                ok3.append(o)
            else:
                ok2.append(o)
        ok=ok3
#print(ok, ok2)
if len(ok)>0:
    koho1=max(ok)
else:
    koho1=1
if len(ok2)>0:
    koho2=max(ok2)
else:
    koho2=1
print(max(koho1, koho2))

Measured memory_bytes: 63984
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
//#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  int cnt = 0, del = 0;
  string s;
  cin >> s;
  for (auto it : s) {
    if (it == 'S') {
      cnt++;
    }
    else {
      if (cnt > 0) {
        cnt--;
        del++;
      }
    }
  }
  cout << SZ(s) - 2 * del << '\n';
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll s;
  ll count=1;
  cin >> s;
  unordered_set<ll> st;
  st.emplace(s);
  while(true){
    count++;
    if(s%2==0) s=s/2;
    else s=3*s+1;
    if(st.find(s)!=st.end()) break;
    st.emplace(s);
  }

  cout << count << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
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--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, t;
	cin >> n >> t;
	vi d(n);
	REP(i, n) cin >> d[i];
	sort(ALL(d));
	ll ans = 1;
	REP(i, n)
	{
		ll cnt = d.begin() + i - lower_bound(d.begin(), d.begin() + i, d[i] - t) + 1;
		ans *= cnt;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int A, B, C, D, a=0, b=0;
  cin>>A>>B>>C>>D;
  if(A<=B)a=A;
    else a=B;
  if(C<=D)b=C;
  else b=D;
  cout<<a+b<<endl;
  return 0;
}






Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{

    class ProgramB
    {
        static void Main(string[] args)
        {
            //入力
            string[] a = Console.ReadLine().Split(' ');
            int n = int.Parse(a[0]);
            int k = int.Parse(a[1]);
            int[] sunuke = new int[n];

            for (int i = 0; i < k; i++)
            {
                int d = int.Parse(Console.ReadLine());
                string[] s = Console.ReadLine().Split(' ');
                for(int j = 0;j <d;j++)
                {
                    sunuke[int.Parse(s[j]) - 1] = 1;
                }
            }

            int count = 0;


            for (int i = 0; i < n; i++)
            {
                if (sunuke[i] == 0)
                    count++;
                
            }

            Console.WriteLine(count);


        }
    }
}


Measured memory_bytes: 27788
N = int(input())


def query(i):
    print(i)
    s = input()
    if s == 'Vacant':
        exit()
    return s


root = query(0)


def is_ok(ind):
    # 左ならTrue
    response = query(ind)
    if ind % 2 == 1:
        return root == response
    else:
        return root != response


def bin_search_meguru():
    """
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng, okは,とり得る最小の値-1,とり得る最大の値+1
    """

    # 適当にいじる
    ng = -1  # ind=0が条件を満たすこともあるため
    ok = N  # ind=len(a)-1が条件を満たさないこともあるため

    # いじらない
    # okとngのどちらが大きいかわからないことを考慮
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return False


bin_search_meguru()


Measured memory_bytes: 3660
#include <stdio.h> 

int main() {
  int n,x;
  int b,i,j,k,a;

  while(1) {
    scanf("%d %d",&n,&x);   
    b = 0;
    if( n == 0 && x == 0){
      break;
    }
    for(k = 1; k <= n ; k++) {


      for(j = 1; j <= n ; j++) {

	for(i = 1; i <= n; i++) {
	  
	  if(i == j || j == k || i ==k) {
	    
	  }else{
	    a = i + j + k;
	    if(a == x) {
	     
	      b += 1;
 
	    }
	  }
	  
	}
	
      }

    }
    printf("%d\n",b/6);
  }


  return 0;
}  



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

using ll = long long;

ll JudgeHarmony(ll a, ll b, ll mid) {
	return abs(a - mid) - abs(b - mid);
}

int main() {
	ll a, b; cin >> a >> b;
	if (a < b) swap(a, b);

	ll l = 0L, r = 1000000001L;
	while (r - l > 1) {
		ll mid = (l + r) / 2L;
		ll j = JudgeHarmony(a, b, mid);
		if (j == 0) {
			cout << mid << endl;
			return 0;
		}
		else if (j > 0) l = mid;
		else r = mid;
	}

	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String numbers = "1";
    int sum;

    while(true) {
      numbers = scanner.nextLine();
      if (numbers.equals("0")) break;
      
      sum = 0;
      for (int i = 0; i < numbers.length(); ++i) {
        sum += Character.getNumericValue(numbers.charAt(i));
      }
      System.out.println(sum);
    }
  }
}


Measured memory_bytes: 26668
import Control.Monad
import qualified Data.IntSet as IntSet

check :: String -> String -> Bool
check [] [] = True
check (a : as) (b : bs) = if a == b || a == '?' || b == '?' then check as bs else False
check _ _ = False

findMatches :: String -> String -> [Int]
findMatches s t = filter checkOffset [-lt..ls]
  where
  ls = length s
  lt = length t
  checkOffset offset =
    let b = max 0 offset
        e = min (lt + offset) ls
        l = e - b
        ss = if offset > 0 then drop offset s else s
        tt = if offset < 0 then drop (-offset) t else t
    in check (take l ss) (take l tt)

solve :: String -> String -> String -> Int
solve a b c = 
  let [la, lb, lc] = map length [a, b, c]
      calcLength x y = maximum [la, x + lb, y + lc] - minimum [0, x, y]
      xs = findMatches a b
      ys = findMatches a c
      zs = IntSet.fromList $ findMatches b c
      checkOffset offset = offset < (-lc) || offset > lb || IntSet.member offset zs
      as = [calcLength x y | x <- xs, y <- ys, checkOffset (y - x)]
  in if null as then la + lb + lc else minimum as

main :: IO ()
main = do
  [a, b, c] <- replicateM 3 getLine
  putStrLn $ show $ minimum $ [solve a b c, solve b a c, solve c a b]

Measured memory_bytes: 2428
#include <iostream>
using  namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;

int min(int x,int y)
{
  if(x>=y) return  y;
  else return x;
}

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;

}


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

int main() {
    int k;
    cin >> k;
    vector<int> fix(8, -1);
    for (int i = 0; i < k; ++i) {
        int r, c;
        cin >> r >> c;
        fix[r] = c;
    }
    vector<int> ord(8);
    iota(ord.begin(), ord.end(), 0);
    do {
        bool ng = false;
        for (int i = 0; i < 8; ++i) {
            if (fix[i] >= 0 && fix[i] != ord[i]) ng = true;
        }

        if (ng) continue;
        for (int i = 0; i < 8; ++i) {
            for (int j = i + 1; j < 8; ++j) {
                if (j - i == ord[j] - ord[i]) ng = true;
                if (j - i == ord[i] - ord[j]) ng = true;
            }
        }
        if (ng) continue;
        for (int i = 0; i < 8; ++i) {
            for (int j = 0; j < 8; ++j) {
                if (j == ord[i]) cout << "Q";
                else cout << ".";
            }
            cout << endl;
        }
    } while (next_permutation(ord.begin(), ord.end()));
}


Measured memory_bytes: 3104
S = list(input())
N = len(S)
al=[chr(ord('a') + i) for i in range(26)]
#print(al)

if N < 26:
  for i in range(26):
    if al[i] not in S:
      S.append(al[i])
      print(*S,sep="")
      exit()
else:
  flg = False
  S = S[::-1]
  x = 0
  while x < len(S):
    id = al.index(S[x])
    if id == 25:
      S = S[x+1:]
    else:
      id += 1
      for k in range(id,26):
        if al[k] not in S:
          S[x] = al[k]
          S = S[::-1]
          print(*S,sep="")
          exit()
      S = S[x+1:]
  print(-1)



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

int main() {
  char s[26];
  int i, j;
  scanf("%s", s);
  int len = strlen(s);
  for (i = 0; i < len-1; i++) {
    for (j = len-1; j > i; j--) {
      if (s[j-1] > s[j]) {
	char temp = s[j];
	s[j] = s[j-1];
	s[j-1] = temp;
      }
    }
  }
  /*printf("%s", s);*/
  int flag = 0;
  for (i = 0; i < len-1; i++) {
    if (s[i] == s[i+1]) {
      flag = 1;
    }
  }
  if (flag == 1) {
    printf("no\n");
  } else {
    printf("yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll pi=M_PI;
    ll a,b,h,m;cin>>a>>b>>h>>m;
    double s2=(double)(a*a+b*b-2*a*b*cos(abs(M_PI*(60*h-11*m)/360)));
    cout<<fixed<<setprecision(12);
    //cout<<s2<<endl;
    cout<<pow(s2,0.5)<<endl;
}


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

int main () {
    int x;
    cin >> x;
    cout << (x / 500) * 1000 + ((x % 500)  / 5 ) * 5 << endl;
}

Measured memory_bytes: 256