akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 405
#define M 51
#define INF 500
#define MOD 924844033
#define MOD2 1000000009
#define eps 1e-7
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}

ll a[N];
ll x[N][4];
ll c[N][10];
ll dp[N][10];
int mp[4][4] = {{1,0,3,2},{0,3,2,1},{3,2,1,0},{2,1,0,3}};
map<ll,int>m;
ll get(ll x,ll y,ll z,ll h)
{
    ll ret = x;
    ret = (ret<<10)+y;
    ret = (ret<<10)+z;
    ret = (ret<<10)+h;
    return ret;
}
ll pack(ll x,ll y,ll z,ll h)
{
    return min(min(get(x,y,z,h),get(y,z,h,x)),min(get(z,h,x,y),get(h,x,y,z)));
}
ll fac(ll x)
{
    ll ret = 1;
    FOR(i,1,x)ret*=i;
    return ret;
}
ll rot(ll key)
{
    int k[4];
    FOR(i,0,3)
    {
        k[i] = key&((1<<10)-1);
        key>>=10;
    }
    if(k[0] == k[1]&&k[1] == k[2]&&k[2] == k[3])return 4;
    if(k[0] == k[2]&&k[1] == k[3])return 2;
    return 1;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        c[1][0] = c[1][1] = 1;
        FOR(i,2,n)
        {
            c[i][0] = 1;
            FOR(j,1,min(4,i-1))c[i][j] = c[i-1][j]+c[i-1][j-1];
            c[i][i] = 1;
        }
        FOR(i,1,n)
        {
            FOR(j,0,3)cin>>x[i][j];
            a[i] = pack(x[i][0],x[i][1],x[i][2],x[i][3]);
        }
        ll ans = 0;
        m.clear();
        FOR(i,1,n)
        {
            FOR(ii,1,i-1)
            {
                FOR(j,0,3)
                {
                    ll y[4];
                    y[0] = pack(x[ii][(j+1)%4],x[ii][(j+0)%4],x[i][1],x[i][0]);
                    y[1] = pack(x[ii][(j+0)%4],x[ii][(j+3)%4],x[i][2],x[i][1]);
                    y[2] = pack(x[ii][(j+3)%4],x[ii][(j+2)%4],x[i][3],x[i][2]);
                    y[3] = pack(x[ii][(j+2)%4],x[ii][(j+1)%4],x[i][0],x[i][3]);

                    sort(y,y+4);
                    ll ret = 1;
                    for(int p = 0;p<4;)
                    {
                        int cnt = 1;
                        for(int r = p+1;r<4&&y[r] == y[p];r++)cnt++;
                        int num = m.count(y[p])?m[y[p]]:0;
                        if(y[p] == a[ii])num--;
                        if(num<cnt)
                        {
                            ret = 0;
                            break;
                        }
                        ret*=c[num][cnt]*pow(rot(y[p]),cnt)*fac(cnt);
                        p+=cnt;
                    }
                    ans+=ret;
                }
            }
            if(m.count(a[i]))m[a[i]]++;
            else m[a[i]] = 1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
//  ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿>
//  ⣿         
//  ⣿ Author - midu_01
//  ⣿         
//  ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿>

import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main
{
    static Scanner cin = new Scanner(System.in);
    static PrintStream cout = new PrintStream
    (new FileOutputStream(FileDescriptor.out));
    
    public static void main(String args[])
    {
        int t,n,m,a,b,c,d,e,i,j,k,x,y,z,/*cnt=0,*/cnt1=0;
        Vector<Integer> v = new Vector<>();
        boolean flag = false;
        n=cin.nextInt();
        int[] ch=new int[n];
        for(i=0;i<n;i++)
        {
            ch[i]=cin.nextInt();
        }
        long cnt=0;
        for(i=0;i<n;i++)
        {
            a=ch[i];
            for(j=i+1;j<n;j++)
            {
                b=ch[j];
                if(a==b) continue;
                for(k=j+1;k<n;k++)
                {
                    c=ch[k];

                    if(a==c || b==c) continue;
                    if(a+b<=c || a+c<=b || b+c<=a) continue;
                    cnt++;
                }
            }
        }
        cout.println(cnt);
    }
}


Measured memory_bytes: 36640
#include<bits/stdc++.h>
using namespace std;
typedef pair <int,int> pi;
using ll = long long int;
const int size=1e6+5;
ll gcd(ll a,ll b)
{
    if(!a) return b;
    return gcd(b%a,a);
}
ll mulmod(ll a, ll b, ll c) {
  ll x = 0, y = a % c;
  while (b) {
    if (b & 1) x = (x + y) % c;
    y = (y << 1) % c;
    b >>= 1;
  }
  return x % c;
}

ll fastPow(ll x, ll n, ll MOD) {
  ll ret = 1;
  while (n) {
    if (n & 1) ret = mulmod(ret, x, MOD);
    x = mulmod(x, x, MOD);
    n >>= 1;
  }
  return ret;
}

bool isPrime(ll n) {
  ll d = n - 1;
  int s = 0;
  while (d % 2 == 0) {
    s++;
    d >>= 1;
  }
  // It's guranteed that these values will work for any number smaller than 3*10**18 (3 and 18 zeros)
  int a[9] = { 2, 3, 5, 7, 11, 13, 17, 19, 23 };
    if(n<=23)
    {
        for(int i=0;i<9;i++)
            if(n==a[i])
                return 1;
        return 0;
    }
  for(int i = 0; i < 9; i++) {
    bool comp = fastPow(a[i], d, n) != 1;
    if(comp) for(int j = 0; j < s; j++) {
      ll fp = fastPow(a[i], (1LL << (ll)j)*d, n);
      if (fp == n - 1) {
        comp = false;
        break;
      }
    }
    if(comp) return false;
  }
  return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll g = gcd(a,b);
    if(g>1 && isPrime(g))
        return cout<<"2\n",0;
    ll cnt=0;
    for(ll i=2;i*i<=g;i++)
    {
        if(g%i==0)
        {
            if(isPrime(i))
                cnt++;
            if(g/i != i && isPrime(g/i))
                cnt++;
        }
    }
    cout<<cnt+1LL<<"\n";
}


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

int main(){
    map<string,ll> mp;
    ll N,total=0;
    string str;
    cin >> N;
    for(ll i=0;i<N;i++){
        cin >> str;
        sort(str.begin(),str.end());
        mp[str]++;
    }
    for(auto p : mp){
        total += p.second*(p.second-1)/2;
    }
    
    cout << total << endl;

    return 0;
}

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

int main(){
    int N;
    cin >> N;

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

    int min=P[0];
    for(int i=0;i<N;i++){
        if(P[i]<=min){
            ans++;
            min=P[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
s = sum(a)
mina = 0
for i in range(n):
    if a[i] % 10 != 0:
        mina = a[i]
        break

if mina == 0:
    print(0)
elif s % 10 == 0:
    print(s-mina)
else:
    print(s)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, t;
    cin >> n >> t;
    vector<int> a(n + 1);
    in_arr(int, a, n);
    a[n] = INT_MAX;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += min(a[i + 1] - a[i], t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ret = 0;
            for (int i = inputs.Length - 1; i >= 1; i--)
            {
                if (inputs[i - 1] - inputs[i] == 1)
                {
                    inputs[i - 1]--;
                }
                else if (inputs[i - 1] - inputs[i] > 1)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int x,a;

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

  cin>>x>>a;
  cout << (x<a ? 0 : 10) <<endl;
  

  return 0;
}


Measured memory_bytes: 256
loop do
  l=gets.split.map(&:to_i).sort!
  break if l[0]==0
  min_rad=((l[0]*0.5)**2+(l[1]*0.5)**2)**0.5
  gets.to_i.times do
    puts gets.to_i>min_rad ? "OK" : "NA"
  end
end

Measured memory_bytes: 8804
import scala.io.StdIn.{readLine, readInt}

object Main extends App {
  val n = readInt()
  val x = readLine().split(" ").map(_.toInt)
  val y = readLine().split(" ").map(_.toInt)

  println(calcDistance(x, y, 1))
  println(calcDistance(x, y, 2))
  println(calcDistance(x, y, 3))
  println(calcDistance(x, y, 0))

  def calcDistance(x: Array[Int], y: Array[Int], p: Int): Double = {
    p match {
      case p if p >= 1 => Math.pow((x zip y).map { case(x, y) => Math.pow((x - y).abs, p) }.sum, 1d/p)
      case _ => (x zip y).map { case (x, y) => (x - y).abs }.max
    }
  }
}



Measured memory_bytes: 44280
#include <stdio.h>

int main(void)
{
  int a;
  int b;
	scanf("%d %d", &a, &b);
	if (a<b) printf("a < b\n");
	if (a>b) printf("a > b\n");
	if (a==b) printf("a == b\n");
	return 0;
}

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

int main(){
    int H, W;
    
    while(1){
        cin >> H >> W;
        
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i % 2) == 0){
                     if((j % 2) == 0) cout << "#";
                     else  cout << ".";
                }
                else{
                    if((j % 2) == 0) cout << ".";
                     else  cout << "#";
                }
            }
            cout << endl;
        }
        
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

const int MAXN = 100000;
const int MAXQ = 100000;
const int MAXD = 100;

string S;
int N;
int Q;
int D;

int dp[MAXN * 10];

int solve(ll index, int lhs, int rhs, int ql, int qr)
{
    if (rhs < ql || qr < lhs) { return 0; }
    if (ql <= lhs && rhs <= qr) { return dp[index]; }

    if (lhs == rhs) { return 0; }

    const int mid = (lhs + rhs) >> 1;

    const ll li = index * 2;
    const ll ri = index * 2 + 1;

    const int llhs = lhs;
    const int lrhs = max(lhs, mid);

    const int rlhs = min(rhs, mid + 1);
    const int rrhs = rhs;

    const int ln = solve(li, llhs, lrhs, ql, qr);
    const int rn = solve(ri, rlhs, rrhs, ql, qr);

    return ln + rn;
}

int countUp(ll index)
{
    if (index >= D) { return dp[index]; }

    const ll lhs = index * 2;
    const ll rhs = index * 2 + 1;

    const int ln = countUp(lhs);
    const int rn = countUp(rhs);

    return dp[index] = ln + rn;
}


int main()
{
    cin >> N >> Q;
    cin >> S;

    D = 1;
    while (D < N) { D = D << 1; }

    rep(i, N - 1) { if (S[i] == 'A' && S[i + 1] == 'C') { dp[D + i + 1] = 1; } }

    countUp(1);

    int ql, qr;

    rep(i, Q)
    {
        cin >> ql >> qr;
        --ql;
        --qr;

        const int ans = solve(1, 0, D - 1, ql, qr);
        const int offset = ql > 0 && S[ql - 1] == 'A' && S[ql] == 'C' ? 1 : 0;

        cout << ans - offset << endl;
    }

    return 0;
}


Measured memory_bytes: 1920
//============================================================================
// Name        : 0521.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {

	int x;
	int ans;

	while(1){

		cin >>x;
		x=(1000-x);

		ans=x/500;
		x=x%500;
		ans=ans+x/100;
		x=x%100;
		ans=ans+x/50;
		x=x%50;
		ans=ans+x/10;
		x=x%10;
		ans=ans+x/5;
		x=x%5;
		ans=ans+x/1;

		cout <<ans<<endl;
		if(x==0){
			break;
		}

	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		int i = 1, num;

		Scanner sc = new Scanner(System.in);

		num = sc.nextInt();

		while(num != 0){
			System.out.println("Case " + i + ": " + num);
			num = sc.nextInt();
			i++;
		}
	}
}


Measured memory_bytes: 44816
#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
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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

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

int main() {
    
    int N;
    cin >> N;
    
    string S;
    cin >> S;
    int cnt = 0;
    char b = '!';
    for (int i = 0; i < N; i++) {
        char c = S[i];
        if (b != c) {
            cnt += 1;
        }
        b = c;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define f first
#define s second
pair<int,int> seg[3000001];
int a[200001];
int b[200001];
#define in pair<int,int>
void build(int node,int l,int r){

if(l==r){

    seg[node].f=a[l];
    seg[node].s=a[r];

}
else{
    int mid=(l+r)/2;
    int x=2*node;
    build(x,l,mid);
    build(x+1,mid+1,r);
    seg[node].f=min(seg[x].f,seg[x+1].f);
    seg[node].s=max(seg[x].s,seg[x+1].s);


}




}
int query_min(int node,int l,int r,int p,int q){

if(r<p||q<l)
    return 1e9;
if(p<=l&&q>=r)
    return seg[node].f;

    int mid=(l+r)/2;
    int x=2*node;
  int d=query_min(x,l,mid,p,q);
  int d1=query_min(x+1,mid+1,r,p,q);
  return min(d,d1);
}

int query_max(int node,int l,int r,int p,int q){

if(r<p||q<l)
    return 0;
if(p<=l&&q>=r)
    return seg[node].s;

    int mid=(l+r)/2;
    int x=2*node;
  int d=query_max(x,l,mid,p,q);
  int d1=query_max(x+1,mid+1,r,p,q);
  return max(d,d1);
}
map<pair<int,int>,pair<int,int> > cv;
pair<int,int> solve(int x,int y,int n){

if(x%2){


    int l=query_min(1,1,n,x,y);

    int r=query_max(1,1,n,b[l]+1,y);
    r=r-n;
    r=n-r;


cv[mp(l,r)]=mp(x,y);


    return mp(l,r);


 }
 else{



    int l=query_max(1,1,n,x,y);
    l=l-n;
    l=n-l;
    int r=query_min(1,1,n,b[l]+1,y);
    cv[mp(l,r)]=mp(x,y);

return mp(l,r);
}
}
int main(){

int i,j;
int n;
cin>>n;

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

    int x;
    cin>>x;
    if(i%2==0)
    {

        a[i]=n+n-x;

    }
    else
        a[i]=x;

    b[x]=i;

}
build(1,1,n);
std::priority_queue<in, std::vector<in >, std::greater<in > > sa;
pair<int,int> x;
x=solve(1,n,n);
sa.push(x);
vector<int> ans;
while(!sa.empty()){

 pair<int,int> o=sa.top();
 sa.pop();
 ans.pb(o.f);
 ans.pb(o.s);
//cout<<o.f<<endl;
//cout<<o.s<<endl;
 pair<int,int> h=cv[o];
 int x=b[o.f];
 int y=b[o.s];
 if(h.f<x)
 {
     sa.push(solve(h.f,x-1,n));
 }
  if(x+1<y)
 {
     sa.push(solve(x+1,y-1,n));
 }
  if(y+1<h.s)
 {
     sa.push(solve(y+1,h.s,n));
 }





}

for(i=0;i<n;i++)
    cout<<ans[i]<<" ";
cout<<endl;

return 0;


}














Measured memory_bytes: 14960
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i
count = 0
A.downto(0) do |num500|
  if num500 * 500 > X
    next
  elsif num500 * 500 == X
    count += 1
    next
  else
    B.downto(0) do |num100|
      if num500 * 500 + num100 * 100 > X
        next
      elsif num500 * 500 + num100 * 100 == X
        count += 1
        next
      else
        C.downto(0) do |num50|
          if num500 * 500 + num100 * 100 + num50 * 50 > X
            next
          elsif num500 * 500 + num100 * 100 + num50 * 50 == X
            count += 1
            break
          else
            break
          end
        end
      end
    end
  end
end
puts count

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

int tripleGcd(int a,int b,int c){
	return __gcd(__gcd(a,b),c);
}

int main()
{
	long long K;
	long long sum=0;
	cin>>K;
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			for(int k=1;k<=K;k++){
				sum+=(long long)tripleGcd(i,j,k);
			}
		}
	}
	cout<<sum<<endl;

	return 0;
}



Measured memory_bytes: 3596
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=400+19;
const int M=100000+19;

bitset<N> A[N];
int alb[N];
int x[M],y[M];
int n,m,ans;

int main(){
	n=IN(),m=IN();
	For(i,1,m+1) x[i]=IN(),y[i]=IN();
	For(u,1,n+1){
		A[u][u]=1;
		for (int i=m;i;i--){
			if (A[u][x[i]]&&A[u][y[i]]){
				alb[u]=1;break;
			} lf (A[u][x[i]]){
				A[u][y[i]]=1;
			} lf (A[u][y[i]]){
				A[u][x[i]]=1;
			}
		}
	}
	For(i,1,n+1) For(j,i+1,n+1){
		if (!alb[i]&&!alb[j]&&!(A[i]&A[j]).count()) ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
def solve(s):
    S = set()
    S.add(s)
    i = 1
    a = s
    while True:
        if a % 2 == 0:
            a = a / 2
        else:
            a = 3*a + 1
        if a in S:
            return i+1
        S.add(a)
        i += 1

s = int(input())
print(solve(s))

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    int p[m];
    string s[m];
    for (int i = 0; i < m; i++) cin >> p[i] >> s[i];
    pair<bool, int> aw[n];
    for (int i = 0; i < n; i++) {
        aw[i].first = false;
        aw[i].second = 0;
    }
    int ac = 0, wa = 0;
    for (int i = 0; i < m; i++) {
        if (s[i] == "AC" && !aw[p[i] - 1].first) {
            aw[p[i] - 1].first = true;
            ac++;
            wa += aw[p[i] - 1].second;
        } else if (s[i] == "WA" && !aw[p[i] - 1].first) {
            aw[p[i] - 1].second++;
        }
    }
    cout << ac << ' ' << wa << endl;
}

Measured memory_bytes: 6912
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

int main(void) {
    string S, T; cin >> S >> T;
    bool ans = false;
    for (int i = 0; i < S.size(); ++i) {
        if (S == T) {
            ans = true;
            break;
        }
        S = S.back() + S.substr(0, S.size() - 1);
    }
    if (ans) {
        cout << " Yes " << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    
   int n;
   cin >> n;
   
   vector<int> h(n);
   for (int i = 0; i < n; i++) cin >> h[i];
   
   int ans = 0;
   int count = 0;
   
   for (int i = 0; i+1 < n; i++){
       if (h[i] >= h[i+1]) count++;
       else count = 0;
       
       ans = max(ans,count);
   }
   
   cout << ans << endl;
}

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

int main(){
    int n, i;
    vector<int> b(99);
    cin >> n;
    for(i = 0;i < n-1;i++){
        cin >> b.at(i);
    }

    int ans = 0;
    for(i = 0; i < n-1;i++){
        if(i == 0) continue;
        ans += min(b.at(i-1), b.at(i));
    }
    ans += b.at(0);
    ans += b.at(n-2);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=5e5+10;
const ll mod=1e9+7;
int main()
{
	int n,i,t,x,y,px,py,ok,pt;
	while(~scanf("%d",&n))
	{
		pt=px=py=0;
		ok=1;
		for(i=0;i<n;i++)
		{
			scanf("%d%d%d",&t,&x,&y);
			int temp=(t-pt)-(abs(x-px)+abs(y-py));
			if(temp<0) ok&=0;
			else if(temp%2==0) ok&=1;
			else ok&=0;
			px=x;
			py=y;
			pt=t;
		}
		ok?puts("Yes"):puts("No");
	}
	return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;

int main() {
    ios::sync_with_stdio (false), cin.tie (0);
    int a, b;
    cin >> a >> b;
    if(a<= 0 && b>= 0){
        cout << "Zero" << '\n';
    }
    else if(a > 0 ||  (b < 0 &&  abs( b - a + 1  ) % 2 ==0 ) ){
        cout << "Positive" << '\n';
    }
    else cout << "Negative" << '\n';

    return 0;
}













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

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)

void Main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}

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


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

int main() {
  int64_t H,W,ans;
  cin >> H >> W;
  if(H%2==1&&W%2==1){
    ans=(H*W+1)/2;
  }else{
    ans=(H*W)/2;
  }
  if(W==1||H==1){
    ans=1;
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n) {
    ll t = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll u = c.end() - upper_bound(c.begin(), c.end(), b[i]);
    ans += t * u;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int calc(int n){
  int ans = 0;
  while(true){
    if(n%2!=0){
      return ans;
    }else{
      n/=2;
      ans++;
    }
  }
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1; i<=n; i++){
    ans=max(ans,calc(i));
  }
  cout << (int)pow(2,ans) << endl;
}


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

using namespace std;

int main()
{
    string s1, s2, s3;  cin >> s1 >> s2 >> s3;
    char a = s1[0] - 0x20, b = s2[0] - 0x20, c = s3[0] - 0x20;
    cout << a << b << c << endl;
}

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

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<":"<<' '; 
   int l;
   cin>>l;
   double x=l/3.0;
  
   cout<<setprecision(16)<<x*x*x<<endl;
}


return 0;
}





Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int h, w;
    for (;;) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) {
            break;
        }
        else {
            for (int i = 1; i < h+1; i++) {
                for (int j = 1; j < w+1; j++) {
                    if ((i+j) % 2 == 0) {
                        printf("#");
                    }
                    else {
                        printf(".");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define abs(x)      ((x)>0?(x):-(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define p(x)        printf("~%lld~\n",x)
#define pp(x,y)     printf("~~%lld %lld~~\n",x,y)
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",x,y,z)
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",a,b,c,d)
#define f_in(x)     freopen(x,"r",stdin)
#define f_out(x)    freopen(x,"w",stdout)
#define open(x)     f_in(x".in"),f_out(x".out")
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#define NEG 1
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif 
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=getchar();   for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=getchar())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=getchar();   for (;!isdigit(ch);ch=getchar());    for (;isdigit(ch);ch=getchar())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=getchar();   for(;isspace(ch);ch=getchar());  return ch;  }
    inline ll readstr(char *s){ char ch=getchar();   int cur=0;  for(;isspace(ch);ch=getchar());      for(;!isspace(ch);ch=getchar())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
    inline ld getreal(){    static ld lbc;  scanf("%lf",&lbc);  return lbc; }
}using namespace SHENZHEBEI;
ll n,q[100],Q[100],top,answ;
int main(){
	n=read();
	while(n)q[++top]=n%10,n/=10,answ+=q[top];
	For(lcp,1,top-1){
		ll now=0;
		memcpy(Q,q,sizeof Q);
		For(j,1,lcp)Q[j]=9;
		Q[lcp+1]--;
		for(ll j=lcp+1;Q[j]<0;++j)
			Q[j]--,Q[j]+=10;
		For(i,1,top)now+=Q[i];
		answ=max(answ,now);
	}
	writeln(answ);
}
/*
*/

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double pi = 3.141592653589793;
	double tmp;
	double tmpH, tmpM;
	tmpH = 30.0 * H + 30.0 / 60.0 * M;
	tmpM = 6 * M;
	tmp = max(tmpH, tmpM) - min(tmpH, tmpM);
	if (tmp > 180) {
		tmp = 360 - tmp;
	}
	//cout << tmp << endl;
	//cout << cos(tmp) << endl;
	double ans = A * A + B * B - 2.0 * A*B*cos(tmp*pi/180.0);
	//cout << sqrt(ans) << endl;
	printf("%.20lf", sqrt(ans));
	return 0;
}

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

int main() {
  ll X, Y;
  cin >> X >> Y;

  ll a = X, cnt = 1;
  while (a * 2 <= Y) {
    cnt++;
    a *= 2;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int *p = new int[n+1];
	for(int i=1;i<=n;i++)
        cin>>p[i];
    int res = 0;
    int t = 0;
    int i = 1;
    vector<int> v(n+1,0);
    /*for(int i=0;i<=n;i++) {
        cout<<v[i]<<" ";
    }
    */
    while(t!=2) {
        res++;
        if(v[i]==1) {
            cout<<"-1";
            return 0;
        }
        v[i]=1;
        t = p[i];
        i = t;
    }
    cout<<res;
	return 0;
}


Measured memory_bytes: 1024
# solution

nim, mike = map(int, input().split())
array = [list(map(int, input().split())) for _ in range(nim)]
array.sort()

ans = 0
for i in range(nim):
    ans += array[i][0] * min(mike, array[i][1])
    mike -= array[i][1]
    if mike <= 0:
        break

print(ans)


Measured memory_bytes: 27760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll n,arr[10005],x,k,d;

int main()
{
    cin>>x>>k>>d;
    x=abs(x);
    ll e = x/d;
    if(e>k){
        cout<<x-(k*d)<<endl;
    }
    else{
        x%=d;
        if(e==0){
            if(k%2) cout<<min(abs(d+x),abs(x-d))<<endl;
            else cout<<x<<endl;
        }
        else{
            k-=e;
            if(k%2) cout<<min(abs(d+x),abs(x-d))<<endl;
            else cout<<x<<endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define per(i,n) for(ll i = n-1; i >= (ll)0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
const ll mod = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  if(abs(n-m)>1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  rep(i,n) {
    ans *= (i+1);
    ans %= mod;
  }
  rep(i,m) {
    ans *= (i+1);
    ans %= mod;
  }
  if(n==m) {
    ans *= (ll)2;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int a[3][3];
	rep(i, 3) rep(j, 3) cin >> a[i][j];

	int n;
	cin >> n;

	int b[10];
	rep(i, n) cin >> b[i];

	bool f[3][3];
	rep(i, 3) rep(j, 3) f[i][j] = false;
	rep(i, n) {
		rep(j, 3) rep(k, 3) {
			if(b[i] == a[j][k]) f[j][k] = true;
		}
	}

	bool ans = false;
	rep(i, 3) if(f[i][0] && f[i][1] && f[i][2]) ans = true;
	rep(i, 3) if(f[0][i] && f[1][i] && f[2][i]) ans = true;
	if(f[0][0] && f[1][1] && f[2][2]) ans = true;
	if(f[0][2] && f[1][1] && f[2][0]) ans = true;
	cout << (ans ? "Yes" : "No") << endl;
}


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

signed main(){
  int N,S;
  cin>>N>>S;
  int co=0;
  for(int i=N;i<=S;i++){
    int A=i/10000,B=i/1000%10,D=i/10%10,E=i%10;
    if(A==E&&B==D)co++;
  }
  cout<<co<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<double> mo;
	double n;
	while(cin >> n)
		mo.push_back(n);
	sort(mo.begin(), mo.end());
	cout << *mo.rbegin()-*mo.begin()  << endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> minus = new ArrayList<>();
        List<Integer> plus = new ArrayList<>();
        for(int i=0; i<n; i++){
            int num = sc.nextInt();
            if(num < 0) minus.add(num);
            else plus.add(num);
        }
        int selectMinus = k;
        if(selectMinus > minus.size()) selectMinus = minus.size();
        int selectPlus = k - selectMinus;
        int min = 2000000000;
        while(selectPlus <= plus.size()){
            int minValue = 0;
            int maxValue = 0;
            if(selectMinus > 0){
                minValue = minus.get(minus.size() - selectMinus);
            }
            if(selectPlus > 0){
                maxValue = plus.get(selectPlus -1);
            }
            int ans;
            if(Math.abs(minValue) < maxValue){
                ans = Math.abs(minValue)*2 + maxValue;
            }
            else ans = Math.abs(minValue) + maxValue*2;
            if(ans < min) min = ans;
            selectMinus--;
            selectPlus++;
        }
        System.out.println(min);
    }
}

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

int main(int argc, char *argv[]) {
  int r, d;
  std::vector<int> x(11);
  std::cin >> r >> d >> x.at(0);
  for (int i = 1; i <= 10; ++i) {
    x.at(i) = x.at(i - 1) * r - d;
  }

  for (int i = 1; i <= 10; ++i) 
    std::cout << x.at(i) << std::endl;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<algorithm>
using  namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int a1=a+b;
    int b1=a+c;
    int c1=b+c;
printf("%d\n",min(a1,min(b1,c1)));
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int cnt[9];

int main() {
  int n; cin >> n;
  rep(i, 0, n) {
    int t; cin >> t;
    if (t >= 3200) cnt[8]++;
    else cnt[t / 400]++;
  }
  int uniq = 0;
  rep(i, 0, 8) if (cnt[i]) uniq++;
  cout << max(uniq, 1) << " " << uniq + cnt[8] << endl;
}

Measured memory_bytes: 256
f :: (Num a) =>  a -> a -> a 
f a b = a * b

g :: (Num a) => a -> a -> a
g a b = 2 * (a + b)

main = do 
   x <-getLine 
   let xs = words x 
   let y = read(xs !! 0) ::Int
   let z = read(xs !! 1 )::Int
   putStrLn $ show (f y z) ++ " " ++ show (g y z)
   

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n,k; cin >> n>>k;
    string s;cin >> s;
    int same = 0;int lr = 0; int rl = 0;
    bool frag = false;
    if(s.at(0) != s.at(n-1)) frag=true;

    for(int i = 1;i<s.size();i++){
        if(s.at(i-1)==s.at(i)){
            same++;
        }else{
            if(s.at(i-1)=='L' and s.at(i)=='R'){
                lr++;
            }else{
                rl++;
            }
        }
    }
    for(int i = 0;i<k;i++){
        if(rl>0 and lr>0){
            same+=2;
            lr--;rl--;
        }else if(rl==1 or lr==1){
            same++;
            rl--;lr--;
        }
    }
    cout << same << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vector<ll>on(60),off(60);
  for(int i=0; i<n; i++){
    ll a;
    cin >> a;
    for(int j=0; j<60; j++){
      if(a >> j & 1) on[j]++;
      else off[j]++;
    }
  }
  ll ans=0;
  for(int i=0; i<60; i++){
    ll count=pow(2,i);
    count%=mod;
    count*=on[i];
    count%=mod;
    count*=off[i];
    count%=mod;
    ans+=count;
    ans%=mod;
  }
  cout << ans << endl;
}
  
  
  


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

#if 1
//whileで小さくしてく
ll gcd(ll x,ll y){
  if(x<y) swap(x,y);
  //xの方が常に大きい
  while(y>0){
    ll r=x%y;
    x=y;
    y=r;
  }
  return x;
}

#endif

#if 1

ll lcm(ll x,ll y){
  return ll(x*y/gcd(x,y));
}

#endif

int main(){
  ll x,y;cin >> x >> y;
  cout << lcm(x,y) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

template <class RandomIt>
size_t bsort(RandomIt first, RandomIt last) {
    /* Bubble sort */
    size_t times=0;
    for (RandomIt it=first; it<last; ++it)
        for (RandomIt it2=last-1; it2>it; --it2)
            if (it2[0] < it2[-1]) {
                swap(it2[0], it2[-1]);
                ++times;
            }

    return times;
}

template <class RandomIt>
size_t ssort(RandomIt first, RandomIt last) {
    /* Selection sort */
    size_t times=0;
    for (RandomIt it=first; it<last; ++it) {
        RandomIt min_=it;
        for (RandomIt it2=it+1; it2<last; ++it2)
            if (*it2 < *min_)
                min_ = it2;

        if (it != min_) {
            swap(*it, *min_);
            ++times;
        }
    }

    return times;
}

template <class Index, class T>
bool is_stable(vector<pair<Index, T>> sorted, const vector<T> table[]) {
    Index rank_=0;
    size_t j=0;
    for (size_t i=0; i<sorted.size(); ++i, ++j) {
        if (rank_ < sorted[i].first) {
            rank_ = sorted[i].first;
            j = 0;
        }

        if (table[rank_][j] != sorted[i].second)
            return false;
    }
    return true;
}

bool operator<(pair<int, char> m, pair<int, char> n) {
    return m.first < n.first;
}

int main() {
    size_t N;
    scanf("%zu\n", &N);

    vector<pair<int, char>> A(N), A_bub, A_sel;
    vector<char> rank_[10];
    for (size_t i=0; i<N; ++i) {
        scanf("%c%d ", &A[i].second, &A[i].first);
        rank_[A[i].first].push_back(A[i].second);
    }

    A_bub = A_sel = A;

    bsort(A_bub.begin(), A_bub.end());
    for (size_t i=0; i<N; ++i) {
        pair<int, char> p=A_bub[i];
        printf("%c%d%c", p.second, p.first, i<N-1? ' ':'\n');
    }

    printf("%s\n", is_stable(A_bub, rank_)? "Stable":"Not stable");

    ssort(A_sel.begin(), A_sel.end());
    for (size_t i=0; i<N; ++i) {
        pair<int, char> p=A_sel[i];
        printf("%c%d%c", p.second, p.first, i<N-1? ' ':'\n');
    }

    printf("%s\n", is_stable(A_sel, rank_)? "Stable":"Not stable");
    return 0;
}

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

ll f(ll b,ll n){
	if(n<b) return n;
	else return f(b,n/b)+n%b;
}

ll solve(ll n,ll s){
	if(n==s)return n+1;
	if(n<s)return -1;

	ll b=2;
	for(;b*b<=n;b++){
		if(f(b,n)==s)return b;
	}

	for(;b>0;b--){
		if((n-s)%b==0 && f((n-s)/b+1,n)==s){
			return (n-s)/b+1;
		}
	}

	return -1;
}

int main(void){
	ll n,s;
    cin>>n>>s;
    cout<<solve(n,s)<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N + 1];
    for(int i=0;i<N+1;i++){
        cin >> A[i];
    }

    long long tmp, kill = 0;

    for(int i=0;i<N;i++){
        cin >> tmp;
        if(tmp >= A[i]){
            tmp -= A[i];
            if(tmp >= A[i + 1]){
                kill += (A[i] + A[i+1]);
                A[i+1] = 0;
            }else{
                A[i+1] -= tmp;
                kill += A[i] + tmp;
            }
        }else{
            kill += tmp;
        }
    }
    cout << kill << "\n";
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a,b,c;
	while(~scanf("%d %d %d",&a,&b,&c))
	{
		int min;
		if(a<b) {
			min=a;
			if(min>c)
			{
				printf("%d %d %d\n",c,a,b);
			}
			else{
				if(b<c)  printf("%d %d %d\n",a,b,c);
				else printf("%d %d %d\n",a,c,b);
			}
		}
		else{
			min=b;
			if(min>c)
			{
				printf("%d %d %d\n",c,b,a);
			}
			else{
				if(a<c)  printf("%d %d %d\n",b,a,c);
				else printf("%d %d %d\n",b,c,a);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2064
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000

struct Node{
  int p;
  int l;
  int r;
};
void depth(int,int);
void print(int);

struct Node T[MAX];
int n, A[MAX];

int main(){
  int k,id,c,l,r;
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    T[i].r = -1;
    T[i].l = T[i].r;
    T[i].p = T[i].l;
  }
  for(int i = 0; i < n; i++){
    scanf("%d",&id);
    scanf("%d",&k);
    for(int j = 0; j < k; j++){
      scanf("%d",&c);
    if(j == 0){
      T[id].l = c;
    }
    else{
      T[l].r = c;
    }
    l = c;
    T[c].p = id;
    }
  }
  for(int i = 0; i < n; i++){
    if(T[i].p == -1){
      r = i;
    }
  }
  depth(r,0);
  for(int i = 0; i < n; i++){
    print(i);
  }
  return 0;
}

void depth(int u, int p){
  A[u] = p;
  if(T[u].r != -1){
    depth(T[u].r,p);
  }
  if(T[u].l != -1){
    depth(T[u].l , p+1);
  }
}

void print(int u){

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",A[u]);
  if(T[u].p == -1){
    printf("root, ");
  }
  else if(T[u].l == -1){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }
  printf("[");
  for(int i = 0, c = T[u].l; c != -1; i++, c = T[c].r){
    if(0 < i){
      printf(", ");
    }
    printf("%d",c);
  }
  printf("]\n");
}



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

typedef long long ll;
typedef pair<ll, ll> P;

int n, p[21];

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

    int ans = 0;
    for(int i=1;i<n-1;i++){
        int maxi = 0;
        int mini = 100;
        for(int j=i-1;j<=i+1;j++){
            if(maxi < p[j]) maxi = p[j];
            if(p[j] < mini) mini = p[j];
        }
        if(p[i] != mini && p[i] != maxi) ans++;
    }

    cout << ans << endl;
}

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

int	main() {
	long N;
	cin >>N;
	vector<long> A(N+1, 0);
	for (int i=1; i<=N; i++) {
		cin >>A.at(i);
		A.at(i) +=A.at(i-1);
	}
	sort(A.begin(), A.end());
	long S=1;
	long SS=0;
	for (int i=1; i<=N; i++) {
		if (A.at(i-1)==A.at(i)) {
			S++;
		} else {
			SS +=S*(S-1)/2;
			S=1;
		}
	}
	SS +=S*(S-1)/2;
	cout <<SS <<endl;
	return 0;
}


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

void Main()
{
  int K; string S;
  cin >> K;
  cin >> S;
  rep(i,min((int)S.size(),K)) {
    cout << S[i];
  }
  if (K < (int)S.size()) cout << "..." << endl;
  else cout << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 3612
// ABC167A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	if (s == t.substr(0, s.size())) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3600