akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ri register int
#define il inline
#define LL long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
template<class T>il void in(T &x)
{
	x=0; char c=getchar(); bool f=0;
	while(c<'0'||c>'9') f|=(c=='-'),c=getchar();
	while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
	f?x=-x:0;
}
template<class T>il void out(T x)
{
	static short st[30]; short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
}
template<class T,class ...Args>il void in(T &x,Args &...args)
{
	in(x); in(args...);
}
template<class T,class ...Args>il void out(const T &x,const Args &...args)
{
	out(x),space; out(args...);
}
template<class ...Args>il void outn(const Args &...args)
{
	out(args...); enter;
}
namespace i207M
{
#define N 1005
const int md=1e9+7;
int cnt(int a,int b)
{
	if(!b) return 0;
	if(a<b) return cnt(b,a);
	return cnt(b,a%b)+1;
}
LL f[100];
void prework()
{
	f[0]=1,f[1]=1;
	for(ri i=2;i<=87;++i)
		f[i]=f[i-1]+f[i-2];
}
void solve(LL a,LL b)
{
	if(a<b) swap(a,b);
	if(b==1)
	{
		outn(1,a%md);
		return;
	}
	int mx=1,ans=0;
	for(;mx<=87&&f[mx+1]<=a&&f[mx]<=b;++mx); --mx;
	out(mx),space;
	if(mx==1)
	{
		outn(a*b%md);
		return;
	}
	for(ri i=1;i<=mx;++i)
	{
		LL x=f[i+1],y=f[i];
		if(i!=mx)
		{
			x+=f[i];
			for(ri j=i+1;j<=mx;++j) swap(x,y),x+=y;
		}
		if(x>a||y>b) continue;
		ans=(ans+(a-x)/y+1+(x<=b?(b-x)/y+1-(x==y):0))%md;
	}
	outn(ans);
}
signed main()
{
	int cq; in(cq);
	prework();
	LL a,b;
	for(ri o=1;o<=cq;++o)
	{
		in(a,b);
		solve(a,b);
	}
	return 0;
}
}
int main()
{
#ifdef M207
	freopen("in.in","r",stdin);
//	freopen("ot.out","w",stdout);
#endif
	i207M::main();
	return 0;
}

Measured memory_bytes: 3968
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) h[i] = sc.nextInt();
        int p = 0;
        double dmin = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            double d = Math.abs(a - (t - h[i] * 0.006));
            if (dmin > d) {
                dmin = d;
                p = i + 1;
            }
        }
        System.out.println(p);
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<string>
#include<map>
using namespace std;
#define ans pair<int, int>
string s;
ans equation(int p);
ans factor(int p);
ans term(int p);
int main(){
  int n;
  cin >>n;
  while(n--){
    cin >>s;
    ans r = equation(0);
    cout <<r.first<<endl;
  }
  return 0;
}
ans equation(int p){
  ans r = factor(p);
  while(s[r.second] == '+' || s[r.second] == '-'){
    ans r_dash = factor(r.second+1);
    if(s[r.second] == '+'){r.first += r_dash.first;}
    if(s[r.second] == '-'){r.first -= r_dash.first;}
    r.second = r_dash.second;
  }
  return r;
}
ans factor(int p){
  ans r = term(p);
  while(s[r.second] == '*' || s[r.second] == '/'){
    ans r_dash = term(r.second+1);
    if(s[r.second] == '*'){r.first *= r_dash.first;}
    if(s[r.second] == '/'){r.first /= r_dash.first;}
    r.second = r_dash.second;
  }
  return r;
}
ans term(int p){
  if(s[p] == '('){
    ans r = equation(p+1);
    r.second++;
    return r;
  }
  else{
    int v = 0;
    while(isdigit(s[p])){
      v = v*10+s[p++]-'0';
    }
    return ans(v,p);
  }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

struct modint
{
    ll a;
    modint():a(0){}
    modint(ll t){
        a=t%MOD;
        if(a<0) a+=MOD;
    }
    //operator long long() const{return a;}
    bool operator==(const modint & x)const{return a==x.a;}
    bool operator!=(const modint & x)const{return a!=x.a;}
    modint operator-() const {return modint(a?(MOD-a):0);}
    modint operator~() const {return modint(MOD -2);}
    modint operator+(const modint &x) const{return modint(*this)+=x;}
    modint operator-(const modint &x) const{return modint(*this)-=x;}
    modint operator*(const modint &x) const{return modint(*this)*=x;}
    modint operator/(const modint &x) const{return modint(*this)/=x;}
    modint &operator+=(const modint &x){
        a+= x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-= x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    
    modint &operator*=(const modint &x){
        a=a*x.a %MOD;
        return *this;
    }
    modint &operator/=(const modint &x){
        a=a*(~x).a %MOD;
        return *this;
    }

    friend ostream &operator<<(ostream &os,const modint &x){
        return os << x.a;
    }

    friend istream &operator>>(istream &is,modint &x){
        ll t;
        x=modint(t);
        return is;
    }

    modint pow(ll x)const{
        modint ret = 1,tmp=a;
        for(;x;tmp*=tmp,x>>=1){
            if(x&1) ret*=tmp;
        }
        return ret;
    }

};

modint nCr(int n,int r){
    modint ans=1;
    for(int i=1;i<=r;i++) ans*=modint(n-i+1)/modint(i);
    return ans;
}


int main(){
    ll n,p; cin >> n >> p;
    auto y = map<ll,ll>();
    auto so = v<>();
  
  	while(p%2==0){
        y[2]++;
        p/=2;
    }
  
    for(ll i=3;i*i<=p;i+=2){
        while(p%i==0){
            y[i]++;
            p/=i;
        }
    }
  	if(p!=1) y[p]++;
  
  	ll ans=1;
  	for(auto i:y){
    	ans*=pow(i.first,i.second/n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int index = 0;
		int count = 0;
		while(true) {
		    index = s.indexOf("o", index) + 1;
		    if (index == 0) break;
		    count++;
		}
        System.out.println(700+count*100);
     }
}	

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

int main() {
  int N,A,j,opr;

  cin >> N;
  for(int i=0;i<N;i++) {
    cin >> A;
    j=0;
    while(1) {
      if(A%2==0) {
        A/=2;
        j++;
      } else {
        break;
      }
    }
    if(i!=0) {
      if(opr > j) opr=j;
    } else {
      opr=j;
    }
  }
  cout << opr << endl;
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

int main() {
  int X;
  cin >> X;
  if(X == 7 || X == 5 || X == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
typedef long long ll;
using namespace std;
int main(void){
    // Your code here!
    ll N,K;
    cin>>N>>K;
    static ll h[100000],dp[100000];
    rep(0,i,N)cin>>h[i];
    rep(1,i,N){
        rep(1,j,K+1){
            if(j==1){
                dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
            }else if(K<=i ||i>=j){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
            }
        }
        //cout<<dp[i]<<endl;
    }
    cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n;
char s[N];
int a[N];

inline void out()
{
	for (int i = 1; i <= n; i+=1) if (a[i] == 1) cout << 'S'; else cout << 'W';
	puts("");
}

int main()
{
	//File("in");
	n = gi <int> ();
	scanf("%s", s + 1);
	for (int i = 1; i <= 2; i+=1)
		for (int j = 1; j <= 2; j+=1)
		{
			a[1] = i, a[2] = j;
			for (int k = 3; k <= n; k+=1)
				if (s[k - 1] == 'o')
				{
					if (a[k - 1] == 1) a[k] = a[k - 2];
					else a[k] = 3 - a[k - 2];
				}
				else
				{
					if (a[k - 1] == 1) a[k] = 3 - a[k - 2];
					else a[k] = a[k - 2];
				}
			bool fl1 = false, fl2 = false;
			if (s[n] == 'o')
			{
				if (a[n] == 1 && a[n - 1] == a[1]) fl1 = true;
				if (a[n] == 2 && a[n - 1] != a[1]) fl1 = true;
			}
			else
			{
				if (a[n] == 1 && a[n - 1] != a[1]) fl1 = true;
				if (a[n] == 2 && a[n - 1] == a[1]) fl1 = true;
			}
			if (s[1] == 'o')
			{
				if (a[1] == 1 && a[n] == a[2]) fl2 = true;
				if (a[1] == 2 && a[n] != a[2]) fl2 = true;
			}
			else
			{
				if (a[1] == 1 && a[n] != a[2]) fl2 = true;
				if (a[1] == 2 && a[n] == a[2]) fl2 = true;
			}
			if (fl1 && fl2) {out(); return 0;}
		}
	puts("-1");
	return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<long>> AB(N, vector<long>(2));
    long long ans = 0;
    int num = 0;

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

    sort(AB.begin(), AB.end());
    for (int j = 0; num!=M ; ++j) {
        if(num+AB[j][1]>M){
            ans += AB[j][0]*(M-num);
            num += M-num;
        } else {
            num += AB[j][1];
            ans += AB[j][0]*AB[j][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
main :: IO ()
main = do
  [_, p] <- map read.words <$> getLine :: IO [Integer]
  as <- map read.words <$> getLine :: IO [Integer]
  let odds = length $ filter odd as
      evens = length $ filter even as
      comb _ 0=1
      comb n r=div((n-r+1)*comb n(r-1))r
  print $ case p of
    0 -> sum [comb odds x| x<-[0,2..odds]] * sum [comb evens x| x<-[0..evens]]
    _ -> sum [comb odds x| x<-[1,3..odds]] * sum [comb evens x| x<-[0..evens]]


Measured memory_bytes: 764
main = do
  [q, h, s, d] <- map read . words <$> getLine
  n <- readLn
  let md = minimum [8 * q, 4 * h, 2 * s, d]
  let ms = minimum [4 * q, 2 * h, s]
  print $ solve md ms n

solve md ms 0 = 0
solve md ms 1 = ms
solve md ms n = p * md + solve md ms r
  where (p, r) = n `divMod` 2

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  long long M=0,A=0,R=0,C=0,H=0;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    
    if(S.at(0)=='M')
      M++;
    if(S.at(0)=='A')
      A++;
    if(S.at(0)=='R')
      R++;
    if(S.at(0)=='C')
      C++;
    if(S.at(0)=='H')
      H++;
   
  }
  
  cout<<M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H ;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 10000000), 10000000)
	var N int
	fmt.Scan(&N)
	n3 := N * 3
	a := make([]int, n3)
	scanner.Scan()
	inputs := strings.Split(scanner.Text(), " ")
	for i := 0; i < n3; i++ {
		n, _ := strconv.ParseInt(inputs[i], 10, 64)
		a[i] = int(n)
	}
	sort.Ints(a)
	var ans int
	for i := N; i < n3; i += 2 {
		ans += a[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 17152
#include <iostream>
#include <algorithm>
#include <stdio.h>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+50;
int a[N];
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    while(cin>>n)
    {
      cout<<n*n*n<<endl;
    }
  return 0;
}


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

int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int answ=0,anss=0;
    double t=-5;
    for(int i=0;a*100*i<=f;i++){
        for(int j=0;j*b*100+a*100*i<=f;j++){
            int water=j*b*100+i*a*100;
            for(int k=0;c*k<=e*water/100 && c*k+water<=f;k++){
                int suger=c*k;
                for(int l=0;suger+d<=e*water/100 && suger+water+d<=f;l++) {
                    suger+=d;
                }
                if(water != 0 ){
                double res=1000000*suger/(suger+water);
                if(res>t){
                    t=res;
                    answ=water+suger;
                    anss=suger;
                }
             }


            }
        }
    }

    cout<<answ<<" "<<anss<<endl;

}


Measured memory_bytes: 256
from bisect import bisect_left
from collections import defaultdict

N, T, *A = map(int, open(0).read().split())

inf = 10 ** 9 + 7
dp = [inf] * (N + 1)
ctr = defaultdict(int)
for i in range(N):
    idx = bisect_left(dp, A[i])
    dp[idx] = A[i]
    if idx != 0:
        ctr[A[i] - dp[0]] += 1

print(ctr[max(ctr)])


Measured memory_bytes: 69916
let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main({ input, load, yesno, math_sum, math_max, math_min, log_json }) {
    const [A] = load(1,1,BigInt)
    let [B] = load(1,1,String)
    B = BigInt(B.split('.').join(''))
    return (A*B/100n).toString()
}



let inputs = input.split(/[\s\n]/)
let result = main({
    input,
    yesno: value => value ? 'Yes' : 'No',
    math_sum: numbers => numbers.reduce((acc, cur) => acc + cur, 0),
    load(rows = 1, cols = 1, type = Number) {
        const length = rows * cols
        let result = inputs.splice(0, length)
        if(type !== String) result = result.map(type)
        if(cols > 1) {
            const arrays = new Array(cols)
            for(let col = 0; col < cols; col++) {
                arrays[col] = new Array()
                for(let row = 0; row < rows; row++) {
                    arrays[col].push(result[row * cols + col])
                }
            }
            result = arrays
        }
        return result
    },
    inifinite_loop_preventer() {
        throw new Error("Infinite loop")
    },
    math_max,
    math_min,
    log_json(value) {
        console.log(JSON.stringify(value))
    },
})

if(result === undefined) {
    console.warn("result is undefined")
} else {
    console.log(result)
}

function math_max(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n > result) result = n
    return result
}

function math_min(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n < result) result = n
    return result
}


Measured memory_bytes: 29532
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int k, x;
    cin >> k >> x;

    // max: min(x ~ x+k-1, 1000000)
    // min: max(x-k+1 ~ x, -1000000)
    for (int i=max(x-k+1, -1000000); i<=min(x+k-1, 1000000); i++) {
        cout << i << " ";
    }
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Const C As Long = 1000000007
    Dim nab As Long() = Cin.LngArr()
    Dim n As Long = nab(0)
    Dim a As Long = nab(1)
    Dim b As Long = nab(2)
    Dim m As Modulo = New Modulo(b, C)
    Dim ans As Long = m.Pow(2, n)
    ans = (ans - 1) Mod C
    ans = ans + C - m.Ncr(n, a) + C - m.Ncr(n, b) + C
    ans = ans Mod C
    Console.WriteLine(ans.ToString())
  End Sub

  Class Modulo
    Private Factorial As Long()
    Private Inverse As Long()
    Private M As Long

    Public Sub New(size As Long, Optional m As Long = 1)
      Me.M = m
      ReDim Factorial(0 To size)
      Factorial(0) = 1
      For i As Integer = 1 To size
        Factorial(i) = Factorial(i - 1) * i Mod m
      Next
      ReDim Inverse(0 To size)
      Inverse(size) = Pow(Factorial(size), m - 2) Mod m
      For i As Integer = size To 1 Step -1
        Inverse(i - 1) = Inverse(i) * i Mod m
      Next
    End Sub

    Public Function Pow(x As Long, y As Long) As Long
      If y = 0 Then Return 1
      If y Mod 2 = 0 Then
        Dim d As Long = Pow(x, y / 2)
        Return (d * d) Mod Me.M
      Else
        Return (x * Pow(x, y - 1)) Mod Me.M
      End If
    End Function

    Public Function Ncr(n As Long, r As Long) As Long
      ' nCr = (n - r + 1) * … * n * r!^-1 '
      Dim ans As Long = 1
      For i As Long = n - r + 1 To n 
        ans = (ans * i) Mod Me.M
      Next 
      Return (ans * Inverse(r)) Mod Me.M
    End Function
  End Class
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 14048
#include<stdio.h>
#include<math.h>

int main()
{
	int n=0, e=1;/*スライムの最初と最後の数*/
	char c[100000];/*スライムの色*/
	
	scanf("%d", &n);
	scanf("%s", c);
  
	for(int i=1; i<n; i++)
    {
    	if(c[i-1] == c[i])
        {
        	/*nothing*/
        }else{
        	e++;
        }
    }
  
    printf("%d", e);
 	return 0;
}

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

int n;
long double dp[400][400][400];
int arr[3];

long double rec(int one, int two, int three)
{
    if (dp[one][two][three] > -1) return dp[one][two][three];
    
    int den = one + two + three;
    long double ret = n;
    if (one) ret += one * rec(one - 1, two, three);
    if (two) ret += two * rec(one + 1, two - 1, three);
    if (three) ret += three * rec(one, two + 1, three - 1);
    
    return dp[one][two][three] = ret / den;
}

int main()
{
    cin >> n;
    for (int i = 0; i != n; ++i)
    {   
        int x;
        cin >> x;
        ++arr[--x];
    }
    for (int i = 0; i <= n; ++i) for (int j = 0; j <= n; ++j) for (int k = 0; k <= n; ++k) dp[i][j][k] = -2;
    dp[0][0][0] = 0;
    cout << setprecision(20) << rec(arr[0], arr[1], arr[2]);
    return 0;
}

Measured memory_bytes: 753792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    string result = "APPROVED";
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 == 0 || a[i] % 5 == 0){
                result;
            }
            else{
                result = "DENIED";
            }
        }
    }
    cout << result << endl;
}

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

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}


/*
長さ4以上のアンバランスあったとすると
その中には必ずaba あるいはaab bba なる区間がある
*/

int main() {
    string S; 
    cin >> S;
    int N = S.length();

    if (S[0] == S[1]) {
        cout << "1 2\n"; return 0;
    }
    for (int i = 2; i < N; i++) {
        if (S[i] == S[i-1]) {
            cout << i << " " << i+1 << endl; return 0;
        } else if (S[i] == S[i-2]) {
            cout << i-1 << " " << i+1 << endl; return 0;
        }
    }
    cout << "-1 -1\n";


}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int e = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        System.out.println((e - a) <= k ? "Yay!" : ":(");
    }
}


Measured memory_bytes: 23764
#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()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//
int main(){
    int n,d; cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d,0));
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    int count=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            double dist2=0;
            rep(k,d){
                dist2+=((x[i][k]-x[j][k])*(x[i][k]-x[j][k]));
            }
            double dist=sqrt(dist2);
            if(floor(dist)==dist) count++;
            
        }
    }
    cout<<count<<endl;
}

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

int main() {
	int A[4][3][10];
	for(int i=0;i<4;++i){
	    for(int j=0;j<3;++j){
	        for(int k=0;k<10;++k){
	        A[i][j][k]=0;
	    }
	}}
	
	int n;
	cin>>n;
	
	int b[n];
	int f[n];
	int r[n];
	int v[n];
	
	for(int i=0;i<n;++i){
	    cin>>b[i]>>f[i]>>r[i]>>v[i];
	    A[b[i]-1][f[i]-1][r[i]-1] +=v[i];
	}
	

	    for (int i=0; i<4; i++) {
        for (int j=0; j<3; j++) {
        for (int k=0; k<10; k++) {
            printf("%2d", A[i][j][k]);
        }
        printf("\n");
    }
    if(i!=3){
    printf("####################\n");
	}
	}
	return 0;
}


Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;


typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int m;
double ans;
string str;

int main(){
    cin>>n;
    double x;
    forn(i){
        cin>>x;
        cin>>str;
        if(str=="JPY"){
            ans+=x;
        }else{
            ans+=380000.0*x;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
t = 0
p = N
tmp = int(math.sqrt(N)) + 1
for num in range(2,tmp):
    d = 1
    while N % num**d ==0:
        N //= num**d
        t += 1
        d += 1
    if(N % num == 0):
        while N % num == 0:
            N //= num
if (N != 1):
    t+=1
if(t==0 and p != 1):
    t = 1
print(t)

Measured memory_bytes: 63928
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;

  auto calc=
    [&](vector<Int> vs){
      Int n=vs.size();
      Int res=0,cnt=0;
      for(Int i=0;i<n;i++){
        if(vs[i]==1) cnt++;
        else res+=cnt;
      }
      return res;
    };
  
  Int n=s.size();
  Int ans=0;
  vector<Int> vs;  
  for(Int i=0;i<n;i++){
    if(s[i]=='A'){
      vs.emplace_back(1);
      continue;
    }    
    if(s[i]=='C'){
      ans+=calc(vs);
      vs.clear();
      continue;
    }
    assert(s[i]=='B');
    if(i+1<n&&s[i+1]=='C'){
      vs.emplace_back(0);
      i++;
      continue;
    }
    ans+=calc(vs);
    vs.clear();
  }  
  ans+=calc(vs);
  vs.clear();
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3720
def Search(o):
    global name
    i=0
    while i<len(o):
        if o[i]==name[0]:
            j=1
            while i+j*(len(name)-1)+1<=len(o):
                if o[i+j]==name[1]:
                    flag=True
                    for k in range(2,len(name)):
                        if o[i+j*k]!=name[k]:
                            flag=False
                            break
                    if flag:
                        return 1
                j+=1
        i+=1
    return 0
n=int(input())
name=input()
old=[input()for i in range(n)]
cnt=0
for o in old:cnt+=Search(o)
print(cnt)

Measured memory_bytes: 7756
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
//#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class CumulativeSum{
public:
  vector<double> sum;
  CumulativeSum(){}
  CumulativeSum(vector<double> A){
    int n = A.size();
    sum.resize(n+1,0);
    for(int i=1;i<=n;i++) sum[i] += sum[i-1] + A[i-1];
  }
  double get(int l,int r){assert(l>=0 && r<=(int)sum.size());return sum[r] - sum[l];} //[l,r)
};


int n;
int m;
vector<double> A;
CumulativeSum sum;

double mem[510][510];
int used[510][510];

double dfs(int pos,int cnt){
  
  if(pos == n) return cnt == m? 0:-INF;;
  if(used[pos][cnt]++) return mem[pos][cnt];

  double res = -INF;
  for(int i=pos;i<n;i++){
    double a = sum.get(pos,i+1) / (i+1-pos);
    Max(res,a + dfs(i+1,cnt+1));
  }
  return mem[pos][cnt] = res;
}

signed main(){

  cin>>n;
  cin>>m;
  A.resize(n);
  cin>>A;
  sum = CumulativeSum(A);
  
  double ans = dfs(0,0);
  printf("%.10lf\n",ans);
  return 0;
}



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

map< string, vector<string> > dic;

const int d[] = {2,2,2, 3,3,3, 4,4,4, 5,5,5, 6,6,6, 7,7,7,7, 8,8,8, 9,9,9,9};

inline string toD(string s){
  string res;
  rep(i,s.size())res += (char)('0'+d[s[i]-'a']);
  return res;
}

vector<int> flag;
vector< vector<string> > memo;

vector<string> rec(int p, const string &s){
  vector<string> res;
  if(p == (int)s.size()){
    res.push_back("");
    return res;
  }
  if(flag[p])return memo[p];

  string suf;
  rep(i,50){
    if(p+i>=(int)s.size())break;
    suf += s[p+i];
    if(dic[suf].size()){
      vector<string> tmp = rec(p+i+1,s);
      for(string x : dic[suf]){
	for(string y : tmp){
	  if(y!="")res.push_back(x + " " + y);
	  else res.push_back(x);
	}
      }
    }
  }

  flag[p] = 1;
  return memo[p] = res;
}

int main(){
  int n;
  while(cin >> n, n){
    dic.clear();
    rep(i,n){
      string s;
      cin >> s;
      dic[toD(s)].push_back(s);
    }

    string seq;
    cin >> seq;
    memo.clear(); memo.resize(seq.size());
    flag.clear(); flag.resize(seq.size());
    vector<string> ans = rec(0,seq);

    rep(i,ans.size()){
      cout << ans[i] << ".\n";
    }
    cout << "--\n";
  }
}

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

typedef struct {
    int ID;
    int penalty;
    int solved;
} set;

set team[51];
int i, j;
int wrong[51][11];
int tID, pID, time;
int T, P, R;
char mes[10];
int count;

int max_solved, min_penalty, winner;

void findfirst(void);

int main(void)
{
    while(1) {
	scanf("%d %d %d", &T, &P, &R);
	if (T == 0) break;
	for (i = 1; i <= T; i++) {
	    team[i].ID = i;
	    team[i].penalty = 0;
	    team[i].solved = 0;
	    for (j = 1; j <= P; j++) {
		wrong[i][j] = 0;
	    }
	}
	for (i = 0; i < R; i++) {
	    scanf("%d %d %d %s", &tID, &pID, &time, mes);
	    if (mes[0] == 'W') {
		wrong[tID][pID]++;
	    } else {
		team[tID].solved++;
		team[tID].penalty += 1200 * wrong[tID][pID] + time;
	    }
	}
	max_solved = T + 1;
	min_penalty = - 1;
	winner = 0;
	for (count = 0; count < T; count++) {
	    findfirst();
	    printf("%d %d %d\n", winner, team[winner].solved, team[winner].penalty);
	    max_solved = team[winner].solved;
	    min_penalty = team[winner].penalty;
	}
    }
    return 0;
}

void findfirst(void)
{
    int winner_solved = -1;
    int winner_penalty = 1200 * 500 + 10800 * 500;
    int winner_team;
    int winner_candidate[51];

    for (i = 1; i <= T; i++) {
	if (team[i].solved > winner_solved && (team[i].solved < max_solved || (team[i].solved == max_solved && team[i].penalty > min_penalty) || (team[i].solved == max_solved && team[i].penalty == min_penalty && i > winner))) {
	    winner_solved = team[i].solved;
	    winner_team = i;
	}
    }
    j = 0;
    for (i = winner_team; i <= T; i++) {
	if (team[i].solved == team[winner_team].solved) {
	    if (team[i].solved < max_solved || (team[i].solved == max_solved && team[i].penalty > min_penalty) || (team[i].solved == max_solved && team[i].penalty == min_penalty && i > winner)) {
	        winner_candidate[j] = i;
	        j++;
	    }
	}
    }
    for (i = 0; i < j; i++) {
	if (team[winner_candidate[i]].penalty < winner_penalty) {
	    winner_penalty = team[winner_candidate[i]].penalty;
    	    winner = winner_candidate[i];
	}
    }
}
    	

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

int main() {
  int num = 5;
  int input[num], k;
  for (int i=0; i<num; i++) {
    cin >> input[i];
  }
  cin >> k;

  for (int i=0; i<num; i++) {
    for (int j=i+1; j<num; j++) {
      if (input[j] - input[i] > k) {
        cout << ":(" << endl;
        exit(0);
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    c = [input() for i in range(H)]
    seen = [[0]*W for i in range(H)]

    def bfs(sy, sx):
        que = deque()

        seen[sy][sx] = 1
        que.append((sy, sx))
        d = ((1, 0), (0, 1))
        while que:
            uy, ux = que.popleft()
            for dy, dx in d:
                next_y = uy + dy
                next_x = ux + dx
                if not(0 <= next_y < H and 0 <= next_x < W):
                    continue
                if seen[next_y][next_x] != 0:
                    continue
                if c[next_y][next_x] == '.':
                    continue
                seen[next_y][next_x] = 1
                que.append((next_y, next_x))
                break
    bfs(0, 0)
    num = 0
    cnt = 0
    for h in range(H):
        for w in range(W):
            if c[h][w] == "#":
                num += 1
            if seen[h][w] == 1:
                cnt += 1
    # print(*seen, sep="\n")
    if seen[-1][-1] == 1 and num == cnt:
        print("Possible")
    else:
        print("Impossible")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38508
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


N, K = read_ints()
p = read_ints()
p.sort()

print(sum(p[:K]))


Measured memory_bytes: 67396
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

string s;


int main() {
	ll x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1)cout << "Brown" << endl;
	else cout << "Alice" << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int h[] = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    int max = 0;
    for (int i = 0; i < n; i++) {
      int Rcount = 0;
      int j = i+1;
      while (j < n && h[j] <= h[j-1]) {
        Rcount++;
        j++;
      }
      max = Math.max(max, Rcount);
      //System.out.println(max);
      if (Rcount > 0) i = j - 1;
    }
    System.out.println(max);
  }
}


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


def count(base, total):
    count = 0
    exp = 1
    while exp * base <= total:
        exp *= base
    remain = total
    while exp != 1:
        count += remain // exp
        remain %= exp
        exp //= base
    count += remain
    return count


Min = float("inf")
for i in range(N + 1):
    c = 0
    c += count(6, i)
    c += count(9, N - i)
    Min = min(Min, c)
print(Min)


Measured memory_bytes: 3064
N, M = map(int, input().split())
X = [list(input().split()) for _ in range(M)]

acs = [False] * (N + 1)
was = [0] * (N + 1)

for p, s in X:
    if s == "AC":
        acs[int(p)] = True
    elif not acs[int(p)]:
        was[int(p)] += 1

was_cnt = 0
for a, w in zip(acs, was):
    if a:
        was_cnt += w

print(sum(acs), was_cnt)


Measured memory_bytes: 67416
def gi() gets.to_i end
def gs() gets.chomp end
def gim() gets.split.map(&:to_i) end
def gsm() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end
def sqrt(i) i ** (1.0/2) end
#####

# a,b,c = gim
# YesNo1(Math.sqrt(a) + Math.sqrt(b) + 0.000001 < Math.sqrt(c))

h,w = gim
if h == 1 || w == 1
  puts 1
else
  puts ((h*w)/2.0).ceil
end

# n = gi
# alp = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
# stds = [0,1].repeated_permutation(n-1).to_a
# stds.each do |std|
#   newstd = [0] + std
#   #print newstd
#   count = 0
#   res = ""
#   newstd.each do |gonext|
#     if gonext == 1
#       count += 1
#     end
#     res += alp[count]
#   end
#   puts res
# end


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 100000 + 10;
vector<int> g[MAX_N];

int d1[MAX_N];
int d2[MAX_N];
int color[MAX_N];

void dfs(int pos, int prev, int dist, int* out) {
  out[pos] = dist;
  for (int x : g[pos]) {
    if (x == prev) continue;
    dfs(x, pos, dist + 1, out);
  }
}

void dfs2(int pos, int prev, int c) {
  if (color[pos] == 3 - c) return;
  color[pos] = c;
  for (int x : g[pos]) {
    if (x == prev) continue;
    dfs2(x, pos, c);
  }
}

int main2() {
  int N = nextInt();
  REP(i, N) g[i].clear();
  REP(_, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0, -1, 0, d1);
  dfs(N-1, -1, 0, d2);

  memset(color, 0, sizeof(color));

  // pv(d1, d1 + N);
  // pv(d2, d2 + N);

  color[0] = 1;
  color[N-1] = 2;
  
  REP(i, N) if (color[i] == 0) {
    if (d1[i] + d2[i] == d1[N-1]) {
      if (d1[i] <= d2[i]) color[i] = 1; else color[i] = 2;
    }
  }

  dfs2(0,   -1, 1);
  dfs2(N-1, -1, 2);
  // pv(color, color + N);

  int c1 = 0, c2 = 0;
  REP(i, N) if (color[i] == 1) c1++; else c2++;


  if (c1 > c2) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 13184
import sys
import math
import collections
#n = int(input())
n, m = map(int, input().split())
#s = input()
#x = list(map(int, input().split()))
l = []
for i in range(m):
    l.append(list(map(int, input().split())))

if n == 1:
    s = str(0)
    p = 1
    for k in range(m):
        if int(s[l[k][0]-1]) != l[k][1]:
            p = 0
            break

    if p == 1:
        print("0")
        sys.exit()

j = 10 ** (n-1)
while(j < 10 ** n):
    s = str(j)
    p = 1
    for k in range(m):
        if int(s[l[k][0]-1]) != l[k][1]:
            p = 0
            break

    if p == 1:
        print(j)
        sys.exit()

    j += 1

print("-1")
            


Measured memory_bytes: 3316
a, b, k = gets.split().map{|n| n.to_i}

a_list = []
a.times do |n|
    n += 1

    if a % n == 0
        a_list.push(n)
    end
end

b_list = []
b.times do |n|
    n += 1

    if b % n == 0
        b_list.push(n)
    end
end

ans_list = a_list & b_list

puts ans_list[-k]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678];
signed main() {
	ll n = 0, m, q, k, a = 0, b = 0, c = 0, d = 0, cnt = 0; string s, t;
	vector<ll> v(n);
	cin >> n >> a >> b >> c >> d;
	if (n == 0) { cout << 1 << endl; }
	if (a == 0) { cout << 2 << endl; }
	if (b == 0) { cout << 3 << endl; }
	if (c == 0) { cout << 4 << endl; }
	if (d == 0) { cout << 5 << endl; }
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int f[100][10];
    int p[100][11];
    int c, s, ans = INT_MIN;
    
    rep(i, n) {
        rep(ii, 10) {
            cin >> f[i][ii];
        }
    }
    
    rep(i, n) {
        rep(ii, 11) {
            cin >> p[i][ii];
        }
    }
    
    for (int i = 1; i < (1 << 10); i++) {
        s = 0;
        bitset<10> b(i);
        
        rep(ii, n) {
            c = 0;
            
            rep(iii, 10) {
                if (f[ii][iii] && b[iii]) {
                    c++;
                }
            }
            
            s += p[ii][c];
        }
        
        ans = max(ans, s);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    string s;   cin >> s;
    string tmp="", bef="";
    ll res=0;
    repd(i, s.size()){
        tmp += s[i];
        if(bef==tmp) continue;
        bef = tmp;  tmp="";
        res += 1;
    }
    cout << res << endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int x;
	cin >> x;
	cout << ((x >= 30) ? "Yes\n" : "No\n");

}


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

#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int dp[100001] = {0} ;
vector <int> v ;

int rec (int n) {
  if (n == 1) return dp[1] = abs(v[1] - v[0]) ;
  if (n <= 0)return 0 ;

  if (dp[n] != -1)return dp[n] ;
  int a = abs(v[n] - v[n - 1]) + rec(n - 1) ;
  int b = abs(v[n] - v[n - 2]) + rec(n - 2) ;
  return dp[n] = min(a, b);
}

int main () {
  int n ;
  cin >> n ;
  v.resize(n) ;
  // vector <int> v(n) ;
  memset(dp, -1, sizeof dp) ;
  for (auto &it : v) cin >> it ;
  cout << rec(n - 1) ;
  return 0 ;
}

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

#define rep(i, k) for (int i = 0; i < k; i++)
#define pair(x, y) make_pair((x), (y))

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

void deb() { cout << 0 << endl; };

int main() {
    int n, k;
    ll ans = 0;
    cin >> n >> k;
    int MAX = max(n, k);

    vector<int> H(MAX, 0);
    rep(i, n) { cin >> H[i]; }

    sort(H.begin(), H.end(), std::greater<int>());

    rep(i, k) { H[i] = 0; }
    rep(i, MAX) ans += H[i];

    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
using namespace std;
typedef long long ll;
int main(){
    ll h;
    cin>>h;
    int i=0;
    while(h>1){
    i++;
    h/=2;
    }
    cout<<ll(pow(2,i+1)-1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC98();
}

void ABC98(){
    int a,b,n[3],i,max;
    cin>>a>>b;
    n[0]=a+b;
    n[1]=a-b;
    n[2]=a*b;
    max=n[0];
    for(i=1;i<=2;++i){
        if(n[i]>max)max=n[i];
    }
    cout<<max;
}

Measured memory_bytes: 256
n,t = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort(key = lambda x: x[0])

dp = [[0]*(t+3001) for _ in range(n+1)]

for i in range(n):
    a,b = ab[i]
    for j in range(t):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    for j in range(t+ab[i][0]):
        if j + a <= t+3000:
            dp[i+1][j+a] = max(dp[i+1][j+a], dp[i][j] + b)

ans = 0

for i in range(n):
    ans = max(ans, max(dp[i+1][:t+ab[i][0]]))

print(ans)


Measured memory_bytes: 216632
n, m, q = map(int, input().split())
a = [0 for _ in range(q)]
b = [0 for _ in range(q)]
c = [0 for _ in range(q)]
d = [0 for _ in range(q)]

for i in range(q):
	a[i], b[i], c[i], d[i] = map(int, input().split())
	a[i] -= 1
	b[i] -= 1

def get_next(l):
	i = n-1
	while i > -1 and l[i] == m:
		i -= 1

	if i < 0:
		return -1
	else:
		l[i] += 1
		for j in range(i+1, n):
			l[j] = l[i]
	return l

max_score = 0
cur_seq = [1 for _ in range(n)]
while cur_seq != -1:
	cur_score = 0
	for i in range(q):
		if cur_seq[b[i]] - cur_seq[a[i]] == c[i]:
			cur_score += d[i]
	if cur_score > max_score:
		max_score = cur_score
	cur_seq = get_next(cur_seq)

print(max_score)


Measured memory_bytes: 68680
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    rep(i, n+1) {
        rep(j, m+1) {
            int kuro = m*i + (n-2*i)*j;
            if(kuro == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::process;

fn main() {
    let stdin = io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let num: usize = buf.trim().parse().unwrap();
    let mut buf2 = String::new();
    stdin.read_line(&mut buf2).ok();

    if (num == 1) {
        println!("Yes");
        process::exit(0);
    }

    let mut previous: usize = 0;
    let mut result = "Yes";

    for (i, num_s) in buf2.split_whitespace().enumerate() {
        let num = usize::from_str(num_s).unwrap();

        if (i == 0) {
            previous = num;

            continue;
        } else {
            if (previous > num) {
                result = "No";
                break;
            } else {
                if (previous == num) {
                    previous = num;
                    continue;
                }

                if (previous <= (num - 1)) {
                    previous = num - 1;
                    continue;
                }

                result = "No";
                break;
            }
        }
    }

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


Measured memory_bytes: 6396
import bisect
s = str(input())
t = str(input())

alpha2num = lambda c: ord(c) - ord('a')

S2 = [[] for i in range(26)]
for i in range(len(s)):
  S2[alpha2num(s[i])].append(i)
  
#print(S2)
time = 0
place = -1
for i in range(len(t)):
  now = alpha2num(t[i])
  if S2[now] == []:
    print(-1)
    quit()
  else:
    index = bisect.bisect_left(S2[now], place)
    #if index == place:
    #  index += 1
    #print(index, S2[now])  

    
    if index == len(S2[now]):
      place = S2[now][0]
      time += 1
    else:  
      if S2[now][index] == place:
        index += 1
        if index == len(S2[now]):
          place = S2[now][0]
          time += 1
        else:
          place = S2[now][index]
      else:  
        place = S2[now][index]
  #print(place, time)  
    
    
ans = len(s) * time + place + 1
print(ans)
    
    
  
  

Measured memory_bytes: 79872