akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum,d, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> n >> a >> b;

	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2 << endl;

	}

	else {
		A[0] = min(max(a - 1, b - 1), n - min(a, b));
		ll MIN = min(a - 1, b - 1);
		ll MAX = n - max(a, b);

		B[0] = (b - MIN) / 2 + MIN;
		B[1] = (n - (a + MAX)) / 2 + MAX + 1;

		cout << min({ B[0], B[1],A[0]}) << endl;

	}

	return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

unsigned short task_A (unsigned short radius)
{
	return (unsigned short)(3) * radius * radius;
}

int main (void)
{
	// variables for main process
	unsigned short r;
	int            rtvl_scanf;

	// STEP.01
	// read out the given data
	rtvl_scanf = scanf("%d", &r);

	// STEP.02
	// output the answer of this task
	printf("%d\n", task_A(r));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n,m , M, K,a;

vector<ll> v,w;
int main(){
    cin >> N;
    ll det = 1;
    ll ans = 0;
    while(N > 0){
        ans += det;
        N =N/2;
        det *=2;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		int[] d = new int[N];
		// 初期化
		for (int i = 0; i < N; i++) {
			d[i] = Integer.parseInt(br.readLine());
		}

		// バケット( 100 < bで)
		int[] b = new int[110];
		int count = 0;
		for (int i = 0; i < N; i++) {
			// バケットを１で埋める
			b[d[i]]++;
		}

		for (int i = 1; i <= 100;i++) {
			if (b[i] != 0) {
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 20692
N, W = map(int, input().split())

DP = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
# DP[2][3] ... i番目までをナップサックに入れることが可能なとき（成約３）
for n in range(N):
    w_i, v_i = map(int, input().split())
    for w in range(W+1):
        tmp = 0
        if w - w_i >= 0:  # i番目のやつが入れる余地があるときここがkey
            DP[n + 1][w] = max(DP[n][w - w_i] + v_i, DP[n][w])
        else:
            DP[n + 1][w] = DP[n][w]

print(max(DP[N]))

Measured memory_bytes: 171400
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int SZ = 300000;
class UF {
public:
	int P[SZ + 1];
	UF() : P() {
		rep1(i, SZ) P[i] = -1;
	}
	int find(int A) {
		if (P[A] < 0) return A;
		return P[A] = find(P[A]);
	}
	bool unite(int A, int B) {
		int a = find(A);
		int b = find(B);
		if (a == b) return false;
		if (P[a] > P[b]) swap(a, b);
		P[a] += P[b];
		P[b] = a;
		return true;
	}
} uf;

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


	int N, M;
	cin >> N >> M;

	rep(i, M) {
		int a, b;
		cin >> a >> b;

		uf.unite(a, b);
	}

	int saidai = 0;
	rep1(i, N) {
		chmax(saidai, -uf.P[uf.find(i)]);
	}

	co(saidai);


	Would you please return 0;
}

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

int main() {
  int A,B; 
  string S;
  cin>>A>>B>>S;
  bool flag=1;
  
  rep(i,S.size()){
    if(i!=A&&S[i]=='-')flag=0;
    else if(S[A]!='-')flag=0;
  }
  if(flag)puts("Yes");
  else puts("No");
  return 0;
}

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

#define _USE_MATH_DEFINES
#include<math.h>


using namespace std;
typedef long long ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef tuple<int, int, int> ti3;

const ll MOD_CONST = 1000000007;
//const ll MOD_CONST = 998244353;


const int BIG_NUM = 1000000005;
const ll INF = 1000000000000000000;

//const vector<vector<int>> DIR{ {1,0},{0,1},{-1,0},{0,-1} };

//const double EPS = 1e-10;


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

	vector<vector<int>> g(n);
	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	priority_queue<int> c;
	for (int i = 0; i < n; i++) {
		int ci;
		cin >> ci;
		c.push(ci);
	}

	vector<pii> deg(n);
	for (int i = 0; i < n; i++) {
		deg[i] = make_pair(g[i].size(), i);
	}

	

	vector<int> d(n);
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	pq.push(deg[0]);
	

	ll sum = 0;
	vector<bool> isChecked(n);
	
	while(!pq.empty()){
		int v = pq.top().second;
		pq.pop();
		d[v] = c.top();
		c.pop();
		for (int u : g[v]) {
			if (isChecked[u]) {

				sum += d[v];
				continue;
			}
			

			
			
			pq.push(deg[u]);
		}

		
		
		isChecked[v] = true;

	}

	std::cout << sum << endl;
	for (int di : d) {
		std::cout << di << " ";
 	}
}



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

namespace ABC146_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = 0;
            switch (s)
            {
                case "SUN": ans = 7; break;
                case "MON": ans = 6; break;
                case "TUE": ans = 5; break;
                case "WED": ans = 4; break;
                case "THU": ans = 3; break;
                case "FRI": ans = 2; break;
                case "SAT": ans = 1; break;
                default:
                    break;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	cin>>n;
	if(n/100==n-(n/10)*10) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

using namespace std;

const int maxn = 110;
const int maxk = 100010;
const long long int mod = 1000000007;

long long int dp[maxn][maxk];
long long int sums[maxn][maxk];

long long int abso(long long int i){
	return ((i % mod) + mod) % mod;
}

int main(){
	long long int n, k;
	cin >> n >> k;
	long long int a[n];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	dp[0][0] = 1;
	sums[0][0] = 1;
	for (long long int i = 1; i <= k; i++){
		if (i <= a[0]){
			dp[0][i] = 1;
			sums[0][i] = sums[0][i-1] + 1;
		}
		else {
			dp[0][i] = 0;
			sums[0][i] = sums[0][i-1];
		}
	}

	for (long long int i = 0; i <= n; i++){
		dp[i][0] = 1;
		sums[i][0] = 1;
	}

	for (long long int i = 1; i < n; i++){
		for (long long int j = 1; j <= k; j++){
			if (j > a[i]){
				dp[i][j] = abso(sums[i-1][j] - sums[i-1][j-a[i]-1]);
			}
			else {
				dp[i][j] = sums[i-1][j];
			}
			sums[i][j] = (sums[i][j-1] + dp[i][j]) % mod;
		}
	}

	cout << dp[n-1][k] << endl;
	return 0;
}


Measured memory_bytes: 162048
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    string ans = (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)? "Possible" : "Impossible";
    cout << ans << endl;
    return 0;
}

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

#define MAX_N 100000

int N;
int arr[MAX_N + 1];

void solve() {
  int ma = arr[0];
  for (int i = 1; i < N; i++) {
    if (ma - 2 >= arr[i]) {
      printf("No");
      return;
    }
    ma = max(ma, arr[i]);
  }
  printf("Yes");
  return;
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
  }
  solve();
  return 0;
}

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

typedef signed long long ll;
const int MX = 1e5 + 5;
const int INF = 1e9 + 5;
int n, A[MX], dp[MX];

int solve(int pos) {
    if(pos > n) return INF;
    if(pos == (n - 1)) return 0;
    if(dp[pos] != -1) return dp[pos];
    int ans = INF;
    if(pos + 1 < n) ans = min(ans, abs(A[pos] - A[pos + 1]) + solve(pos + 1));
    if(pos + 2 < n) ans = min(ans, abs(A[pos] - A[pos + 2]) + solve(pos + 2));
    return dp[pos] = ans;
}

int main() {
    scanf("%d", &n);

    for(int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    memset(dp, -1, sizeof(dp));
    printf("%d\n", solve(0));
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

struct ModA{
	static uint32_t mod; 
	uint32_t a;
	ModA& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModA(int64_t x=0){s(x%mod+mod);}

	ModA& operator+=(const ModA &x){return s(a+x.a);}
	ModA& operator-=(const ModA &x){return s(a+mod-x.a);}
	ModA& operator*=(const ModA &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModA& operator/=(const ModA &x){
		*this*=x.inv();
		return *this;
	}

	ModA operator+(const ModA &x)const{return ModA(*this)+=x;}
	ModA operator-(const ModA &x)const{return ModA(*this)-=x;}
	ModA operator*(const ModA &x)const{return ModA(*this)*=x;}
	ModA operator/(const ModA &x)const{return ModA(*this)/=x;}
	bool operator==(const ModA &x)const{return a==x.a;}
	bool operator!=(const ModA &x)const{return a!=x.a;}
	bool operator<(const ModA &x)const{return a<x.a;}

	ModA operator-()const{return ModA()-*this;}
	ModA pow(int64_t n)const{
		ModA res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	int64_t extgcd(int64_t p,int64_t q,int64_t &x,int64_t &y)const{
		if(q==0){
			x=1;
			y=0;
			return p;
		}
		int64_t g=extgcd(q,p%q,y,x);
		y-=(p/q)*x;
		return g;
	}

	ModA inv()const{
		int64_t x,y;
		assert(extgcd(a,mod,x,y)==1);
		return ModA(x);
	}
};
using aint=ModA;
uint32_t aint::mod=1000000007;
istream& operator>>(istream& in,const ModA& a){
	return (in>>a.a);
}
ostream& operator<<(ostream& out,const ModA& a){
	return (out<<a.a);
}

signed main(){
	int P;
	cin>>P;
	vint A(P);rep(i,P)cin>>A[i];

	aint::mod=P;

	aint g;
	for(int i=1;i<P;i++){
		aint po=1;
		for(int j=1;;j++){
			po*=i;
			if(po==1){
				if(j==P-1){
					g=i;
				}
				break;
			}
		}
	}


	vector<aint>a(P-1);
	aint po=1;
	rep(i,P-1){
		a[i]=A[po.a];
		po*=g;
	}

	vector<aint>b(P-1);
	aint ig=g.inv();
	po=1;
	rep(i,P-1){
		aint x=1;
		rep(j,P-1){
			b[i]+=a[j]*x;
			x*=po;
		}
		po*=ig;
	}
	rep(i,P-1)b[i]/=P-1;

	vint B(P);
	rep(i,P-1)B[i]=b[i].a;
	B[P-1]=(B[0]-A[0]+P)%P;
	B[0]=A[0];

	rep(i,P){
		if(i)cout<<" ";
		cout<<B[i];
	}cout<<endl;
	return 0;
}

Measured memory_bytes: 512
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    fast();


    LL t,n,i,j,k,x,y,c,m;
    string str;
    cin >> str;
    n = str.size();
    LL prefr[n];
    LL suffl[n];


    prefr[0] = 0;
    suffl[n - 1] = n - 1;
    REP(i, n){
        if(str[i] == 'R'){
            prefr[i] = i;
        }
        else{
            prefr[i] = prefr[i - 1];
        }
    }
    for(LL i = n - 1; i >= 0; --i){
        if(str[i] == 'L'){
            suffl[i] = i;
        }
        else{
            suffl[i] = suffl[i + 1];
        }
    }
    
    LL res[n];
    MEM(res, 0);
    REP(i, n){
        LL dest;
        LL steps;
        if(str[i] == 'R'){
            dest = suffl[i + 1];
            steps = abs(dest - i - 1);
            if(steps & 1){
                res[dest]++;
            }
            else{
                res[dest - 1]++;
            }
        }
        else{
            dest = prefr[i - 1];
            steps = abs(dest - i - 1);
            if(steps & 1){
                res[dest]++;
            }
            else{
                res[dest + 1]++;
            }
        }
    }
    pall(res);
}

Measured memory_bytes: 3024
n=int(input())
XY=[]
for i in range(n):
  XY.append(tuple(map(int,input().split())))
def d(x1,y1,x2,y2):
  return ((x2-x1)**2+(y2-y1)**2)**0.5
ans=0
for i in range(n):
  for j in range(i+1,n):
    ans+=d(XY[i][0],XY[i][1],XY[j][0],XY[j][1])*2/n
print(ans)




Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  char b;
  
  scanf("%c", &b);
  if(b == 'A')printf("T\n");
  else if(b == 'T')printf("A\n");
  else if(b == 'C')printf("G\n");
  else if(b == 'G')printf("C\n");
  return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
        var o, e string
        fmt.Scan(&o, &e)

        var a, b int
        for i := 0; i < len(o)+len(e); i++ {
                if i%2 == 0 {
                        fmt.Printf("%c", o[a])
                        a++
                } else {
                        fmt.Printf("%c", e[b])
                        b++
                }
        }
        fmt.Println()
}

Measured memory_bytes: 512
g[21][21],*p;x,X,y,Y;m,i,j,c;main(n){for(memset(g,scanf("%d%d",&n,&m),1764);scanf("%d,%d,%d,%d",&x,&X,&y,&Y),m--;g[X][x]=Y)g[x][X]=y;for(m=++n;--m;)for(i=n;--i;)for(j=n,p=g[i];--j;p[j]=p[j]<c?p[j]:c)c=p[m]+g[m][j];exit(!printf("%d\n",y-Y-g[x][X]-g[X][x]));}

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

int main() {
  int n, l;
  cin >> n >> l;
  int ans = 0, eat = l;
  for(int i = 2; i <= n; i++) {
    if(abs(l+i-1)<abs(eat)) eat = l+i-1;
  }
  ans = n*(l-1)+n*(n+1)/2 - eat;
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;

llint ans = 0;

void dfs(llint x,llint N){
	if (x > N)return;
	else{
		int thcou = 0;
		int ficou = 0;
		int sevcou = 0;
		string X = to_string(x);
		int leng = X.length();
		for (int i = 0; i < leng; i++){
			if (X[i] == '3')thcou++;
			if (X[i] == '5')ficou++;
			if (X[i] == '7')sevcou++;
		}
		if (thcou>0 && ficou > 0 && sevcou > 0)ans++;
	}
	dfs(10 * x + 3, N);
	dfs(10 * x + 5, N);
	dfs(10 * x + 7, N);
}


int main(void) {
	llint N;
	cin >> N;
	dfs(0, N);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[]d = new int[k];
    int[]a = new int[k];
    int[]s = new int[n];
    		
    for(int i=0; i<k; i++) {
    	d[i] = sc.nextInt();
    		for(int j=0; j<d[i]; j++) {
    			 a[i] = sc.nextInt();
    			 	s[a[i]-1]++;
    		}
    }
    int cou = 0;
    for(int i=0; i<n; i++) {
    	if(s[i] == 0){
    		cou++;
    	}
    }
    		System.out.println(cou);
    		}
}


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

int ans = 100000000;
vector<int> c;
int n, m, x;
vector<vector<int>> a;
void dfs(string flag, int sum){
    if(flag.size() == n){
        vector<int> rikai(m);
        rep(i, n){
            if(flag[i] == '1'){
                rep(j, m) rikai[j] += a[i][j];
            }
        }
        rep(i, m){
            if(rikai[i] < x) return;
        }
        ans = min(ans, sum);
        return;
    }
    dfs(flag + '1', sum + c[flag.size()]);
    dfs(flag + '0', sum);
    return;
}

int main(){
    cin >> n >> m >> x;
    c.resize(n);
    a.resize(n, vector<int>(m));
    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    dfs("", 0);
    if(ans == 100000000) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>

int main() {
    unsigned long long int X;

    scanf("%lld", &X);

    int count = 0;
    unsigned long long int start = 100;

    while(start < X) {
        start *= 1.01;
        count++;
        //printf("Now Money: %lld\n", start);
        //printf("After %d years.\n", count);
    }

    printf("%d\n", count);

    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int32 gcd(int32 a, int32 b){
    if(a < b)swap(a,b);
    if(b == 0)return a;
    return gcd(b, a % b);
}

int32 lcm(int32 a, int32 b){
    return (int64)a * b / gcd(a, b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 a,b,c,d;
    cin >> a >> b >> c >> d;
    int64 ans = b - a + 1;
    ans -= b / c - (a-1) / c;
    ans -= b / d - (a-1) / d;
    ans += b / lcm(c, d) - (a-1) / lcm(c, d);
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
s = input(); a = []; b = [0]*27; t = ""
for i in range(len(s)): a.append(ord(s[i])); b[a[i]-97] = 1
if s == "zyxwvutsrqponmlkjihgfedcba": print(-1)
else:
    for i in range(27):
        if b[i] == 0: c = i; break
    if c != 26:
        a.append(c+97)
        for i in range(len(a)): t += chr(a[i])
        print(t)
    else:
        d = []
        for _ in range(24):
            if a[-2] > a[-1]: d.append(a.pop())
            else:
                d.append(a.pop()); d.sort()
                break
        else: d.append(a.pop()); d.sort()
        for i in range(len(d)):
            if a[-1] < d[i]: a.pop(); a.append(d[i]); break
        for i in range(len(a)): t += chr(a[i])
        print(t)

Measured memory_bytes: 9120
#include <iostream>
#include <string>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int X; cin >> X;
	for (int i = 1; i <= 50000; i++) {
		int pro = i * 108 / 100;
		if (pro == X) { cout << i << endl; return 0; }
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io;

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_to_string(&mut buf).unwrap();

    let mut lines = buf.split_whitespace();

    let (a, b, c) = {
        let a: i32 = lines.next().unwrap().parse().unwrap();
        let b: i32 = lines.next().unwrap().parse().unwrap();
        let c: i32 = lines.next().unwrap().parse().unwrap();
        (a, b, c)
    };
    if b-a == c-b {
        println!("YES");
    } else {
        println!("NO");
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
constexpr int INF = 1001001001;
using ll = long long;
using namespace std;
int main() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i] ;
    
    vector<vector<ll>> dp(N+10, vector<ll>(W+10, 0));
    
    rep(i, N+1) {
        rep(j, W+1) {
            if (w[i] > j)
                dp[i+1][j] = dp[i][j];
            else
                dp[i+1][j] = max(dp[i][j], dp[i][max(0, j-w[i])] + v[i]);
        }
    }        
    
    cout << dp[N][W] << endl;
    
    return 0;
}

Measured memory_bytes: 87296
#include<bits/stdc++.h>
#define inf 1e9
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> h(n+1,0),dp(n+1,0);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[0] = 0;
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        int opt1 = abs(h[i]-h[i-1]) + dp[i-1];
        int opt2 = i==2? inf : abs(h[i]-h[i-2]) + dp[i-2];
        dp[i] = min(opt1, opt2);
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 3988
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  string s;
  cin >> s;
  ll N;
  cin >> N;
  rep (i, N) {
    string op;
    cin >> op;
    if (op == "print") {
      ll a, b;
      cin >> a >> b;
      cout << s.substr(a, b-a+1) << endl;
    }
    if (op == "reverse") {
      ll a, b;
      cin >> a >> b;
      reverse(s.begin() + a, s.begin() + b+1);
    }
    if (op == "replace") {
      ll a, b;
      cin >> a >> b;
      string tmp;
      cin >> tmp;
      for (ll i = 0; i < (b-a+1); i++) s[a+i] = tmp[i];
    }
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int r;
	cin >> r;
	
	cout << r * r << endl;
}


Measured memory_bytes: 256
import Data.List
import Data.Array

--for 1 prior

--change 0 to 1
preproc::String->[Int]
preproc str = let grpd =  (group str) in case (head str, last str) of
                                        ('1','1') ->map length grpd
                                        ('0','1') ->0:(map length grpd)
                                        ('1','0') ->(map length grpd)++[0]
                                        ('0','0') ->0:(map length grpd)++[0]



foldl_trace::(b->a->b)->b->[a]->[b]
foldl_trace _ _ []     = []
foldl_trace f y (x:xs) = (f y x):foldl_trace f (f y x) xs

sum_nth::[Int]->Array Int Int
sum_nth ls = listArray (0,length ls) (0:(foldl_trace (+) 0 ls))

sum_nth_1::Array Int Int->Int->Int
sum_nth_1  ar n = ar!(2*n)

sum_nth_1_and_0::Array Int Int->Int->Int
sum_nth_1_and_0 ar n = ar!((2*n)+1)

solver::String->Int->Int
solver str k = let num_1 = length (filter (\l-> head l == '0') (group str)) in
               if  num_1 <= k
                then length str
                else let ar = sum_nth (preproc str) in
                     let (s,e) = bounds ar in
                     let idx = takeWhile (\ (_,r) -> (2*r+1) <= e ) [(i,i+k)|i<-[0..]] in
                     maximum [(sum_nth_1_and_0 ar r)-(sum_nth_1 ar l) |(l,r)<-idx]

main::IO()
main=do
  (_:k:[])<-return.map read.words=<<getLine
  str<-getLine
  print (solver str k) 


Measured memory_bytes: 23932
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

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

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint k,sum=0;
	int gcds[200][200];
	cin>>k;
	rep(i,k)rep(j,k)gcds[i][j]=gcd(i+1,j+1);
	rep(i,k)rep(j,k)rep(l,k)sum+=gcds[gcds[i][j]-1][l];
	cout<<sum<<endl;
}

Measured memory_bytes: 3808
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {

	ll N;
	cin >> N;
	vll a(N);
	rep(i, N) cin >> a[i];

	cout << 2 * N - 2 << endl;
	auto imax = max_element(all(a)), imin = min_element(all(a));
	if (abs(*imin) < abs(*imax)) {
		ll t = imax - a.begin();
		rep(i, N) if (i != t) {
			cout << t + 1 << " " << i + 1 << endl;
		}
		rep(i, N - 1) cout << i + 1 << " " << i + 2 << endl;
	}
	else {
		ll t = imin - a.begin();
		rep(i, N) if (i != t) {
			cout << t + 1 << " " << i + 1 << endl;
		}
		ford(i, 0, N - 1) cout << i + 2 << " " << i + 1 << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> dp(1 << 26), a(202020);
  for (int i = 0; i < (1 << 26); i++)
    dp[i] = n + 1;
  for (int i = 0; i < n; i++)
    a[i] ^= (1 << (s[i] - 'a'));
  for (int i = 1; i < n; i++)
    a[i] ^= a[i - 1];
  vector<int> opt(202020);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    opt[i + 1] = dp[a[i]] + 1;
    for (int j = 0; j < 26; j++) {
      opt[i + 1] = min(opt[i + 1], dp[a[i] ^ (1 << j)] + 1);
    }
    dp[a[i]] = min(dp[a[i]], opt[i + 1]);
  }
  cout << opt[n] << endl;
  return 0;
}


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

ll log(ll number, ll base){
   return (ll)log2(number)/(ll)log2(base); 
}

ll power(ll x, ll y){
    return (ll)(pow(x, y) + EPS);
}
void max_self(ll& a, ll b) {
    a = max(a, b);
}
void min_self(ll& a, ll b) {
    a = min(a, b);
}
int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int n, w;
    cin >> n >> w;

    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        cin >> weight[i] >> value[i];
    }
    ll sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INFLL); 
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= w) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    cout << answer << endl;
}

    


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        // 入力
        long n = long.Parse(Console.ReadLine());
        long[] h = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long ans = 0;
        for (int i = 1; i <= 100; i++)
        {
            long count = 0;
            for (int k = 0; k < h.Length; k++)
            {
                if (h[k] < i)
                {
                    //何もしない
                }
                else
                {
                    count++;
                    while (k < h.Length && h[k] >= i)
                    {
                        ++k; // 区間の終わりまで一気に
                    }
                }
            }
            ans += count;
        }

        Console.WriteLine(ans);
    }
}


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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

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

    int p = w[0], q=accumulate(w.begin(), w.end(), 0)-w[0];
    int ans = abs(p-q);
    for (int i = 1; i < n-1; ++i) {
        p+=w[i];
        q-=w[i];
        ans=min(ans, abs(p-q));
    }
    cout<<ans<<endl;

    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

	string s;
	cin>>s;
	int n = size(s);
	ll p = 2019;

	reverse(s.begin(),s.end());
	map<ll,ll> cnt;
	vector<ll> a(n);
	rep(i,n)a[i]=s[i]-'0';
	cnt[0]++;
	ll ten = 1;
	ll val = 0;
	rep(i,n){
		val = (val+a[i]*ten)%p;
		(ten *= 10) %= p;
		cnt[val]++;
	}
	ll ans = 0;
	auto f = [](ll v){return v*(v-1)/2;};
	for(auto [k,v]:cnt)ans+=f(v);
	cout<<(ans)<<endl;

}

Measured memory_bytes: 5144
package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Code for B - Some Sums
	var N, A, B int
	fmt.Scanf("%d %d %d", &N, &A, &B)

	var sum int = 0
	var temp2 int = 0
	for i := 1; i <= N; i++ {
		temp1 := strconv.Itoa(i)
		temp2 = 0
		for j := 0; j < len(temp1); j++ {
			temp2 += int(temp1[j] - '0')
		}

		if A <= temp2 && temp2 <= B {
			sum += i
		}

	}

	fmt.Println(sum)
}


Measured memory_bytes: 1872
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    int cnt=0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            for(int k=j+1;k<n;++k){
                if(a[i]<a[j]&&a[j]<a[k]&&a[i]+a[j]>a[k]){
                    ++cnt;
                }
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3636
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc163/tasks/abc163_d

//ポイント：
//和としてあり得るものの個数とか言われたら
//小さいものからK個取ったものが最小値で、大きいものからK個取ったものが最大値
//であることを意識する

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;

LL ans = 0;

void solve(){
	//0~iまでの和をaccum_from_0[i]とおく
	vector<LL> accum_from_0(N+1,0);
	for(int i=1;i<=N;i++) accum_from_0[i] = accum_from_0[i-1] + i;
	//i~Nまでの和をaccum_from_N[i]とおく
	vector<LL> accum_from_N(N+1,N);
	for(int i=N-1;i>=0;i--) accum_from_N[i] = accum_from_N[i+1] + i;

	//数列からi個の数を選ぶとき、その和としてあり得るものの個数をnum[i]とする
	vector<LL> num(N+1,N);
	for(int i=1;i<=N+1;i++){
		//cout << i << ":" << accum_from_0[i-1] << "~" << accum_from_N[N-(i-1)] << endl;
		num[i] = accum_from_N[N-(i-1)] - accum_from_0[i-1] + 1;
	}

	for(int i=K;i<=N+1;i++){
		//cout << "num[" << i << "]=" << num[i] << endl;
		ans += num[i];
		ans %= mod;
	}
}
 
int main(){
    cin >> N >> K;
 
    solve();

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

Measured memory_bytes: 7536
#include<stdio.h>
int main(void){

  int S,h,m,s;

  scanf("%d",&S);

  h=S/3600;
  m=(S-h*3600)/60;
  s=S-h*3600-m*60;

  printf("%d:%d:%d\n",h,m,s);

  return 0;
}



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

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

int main(){
  int a, b, c, x, y;cin>>a>>b>>c>>x>>y;
  cout<<min(
    (min(x, y)*2*c+abs(x-y)*(x>y?a:b)),
    min(a*x+b*y,max(x, y)*2*c)
  )<<endl;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)

if N == 1 && M == 1
  ans = 1
elsif N == 1 && M != 1
  ans = M - 2
elsif N != 1 && M == 1
  ans = N - 2
else
  remaining = N * M

  remaining -= 4

  if remaining <= 0
    ans = 0
  else
    remaining -= 2 * (N - 1 - 1) + 2 * (M - 1 - 1)
    if remaining <= 0
      ans = 0
    else
      ans = remaining
    end
  end
end

puts ans


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

using namespace std;

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

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

    int diff = 999999;
    for(int i=0; i<n; i++){
        int s1 = 0, s2 = 0;
        for(int j=0; j<n; j++){
            if(j <= i){
                s1 += w[j];
            }else{
                s2 += w[j];
            }
        }
        diff = min(diff, abs(s1-s2));
    }

    cout << diff << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin>>n;
	long int t;
	unordered_map<long int, long int>V;
	for(int i=0;i<n;i++){
	    cin>>t;
	    V[t]+=1;
	}
    long int count = 0;
	for(auto i=V.begin();i!=V.end();i++){
	    if(i->second >= i->first) count = count + i->second - i->first;
	    else count = count + i->second;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    long long n;
    cin >> n;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    vector<long long> b(n);
    rep(i, n) cin >> b[i];
    vector<long long> c(n);
    rep(i, n) cin >> c[i];

    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;

    rep(i,n){
        auto itr_a = lower_bound(all(a), b[i]);
        auto itr_c = upper_bound(all(c), b[i]);
        ans += (itr_a - a.begin()) * (n - (itr_c - c.begin()));
    }

    cout << ans << endl;

}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    string output;
    int num;
    
    cin >> s;
    
    num = s.size()-2;
    
    output = s[0] + num + s[s.size()-1];
    
    cout << s[0] << num << s[s.size()-1];
    
    
   
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

happy = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        happy += 1

m = 0
for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        m += 1

if K <= m:
    happy += 2*K
else:
    if m > 1:
        happy += 2*m
    if S[0] != S[N-1]:
        happy += 1
print(happy)


Measured memory_bytes: 39664
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char c11 = sc.next().charAt(0);
      	char c22 = sc.next().charAt(1);
      	char c33 = sc.next().charAt(2);
      	System.out.println(c11 +""+ c22 +""+ c33);
    }
}

Measured memory_bytes: 39144
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i32,
        m: i32,
        a: [i32; n],
    }
    let sum = a.iter().fold(0, |sum, &x| sum + x);
    let mut cnt = 0;
    for i in a {
        if 4 * m * i >= sum { cnt += 1; }
    }
    println!("{}", if cnt >= m { "Yes" } else { "No" });
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

vector<int> G[100001];
vector<int> color;
int N, M, black = 0, white = 0;

bool dfs( int v, int c ){
    color[v] = c;
    if( c ) black++;
    else white++;
    for( auto nv : G[v] ){
        if( color[nv] != -1 ){
            if( color[v] == color[nv] ) return false;
            continue;
        }

        if( !dfs( nv, c ^ 1 ) ) return false;
    }
    return true;
}

signed main(){
    cin >> N >> M;
    REP( i, M ){
        int from, to; cin >> from >> to;
        from--, to--;
        G[from].push_back( to );
        G[to].push_back( from );
    }

    color.assign( N, -1 );

    if( dfs( 0, 0 ) ){
        cout << black * white - M << endl;
    }else{
        cout << N * ( N - 1 ) / 2 - M << endl;
    }
}


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


int main() {
  int A ,B , C , K ; 
  cin >> A >> B >> C >> K ; 


  for(int N = 0 ; N <= K ; N++){
    if(B*pow(2, N) > A && C*pow(2 , K-N) > B*pow(2, N)){
      cout << "Yes" << endl;

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

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

using namespace std;

int main (void)
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long LL;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int K=0;
  if(a>b){
    int t=a;
    a=b;
    b=t;
  }
  int A=a,s;
  while(1){
    if(a%A==0 && b%A==0){
      s=A;
      K+=1;
    }
    if(K==k){
      cout<<s<<endl;
      break;
    }
    A--;
  }
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void call(int n)
{
 for (int i = 1; i <= n; i++) {
     int x = i;
   if (0 == x % 3) {
     cout << ' ' << i;
     continue;
 } else {
     while(x) {
         if (3 == x % 10) {
             cout << ' ' << i;
             break;
         }
         x /= 10;
     }
 }
}
cout << endl;
return;
}

int main(void)
{
    int n;
    cin >> n;
    call(n);
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int A, B, m, a[100010], b[100010];
int ans;
int mi1 = INF, mi2 = INF;

signed main() {
	cin >> A >> B >> m;
	for (int i = 0; i < A; i++) {
		cin >> a[i];
		mi1 = min(mi1, a[i]);
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
		mi2 = min(mi2, b[i]);
	}
	ans = mi1 + mi2;
	for (int i = 0; i < m; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		ans = min(ans, a[x - 1] + b[y - 1] - c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int res=n;
    for(int i=0;i<=n;i++){
        int cc=0;
        int t=i;
        while(t>0) cc+=t%6,t/=6;
        t=n-i;
        while(t>0) cc+=t%9,t/=9;
        if(res>cc) res=cc;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256