akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int n=cin.nextInt();
        int ans=5;
        if(n<105)ans=0;
        else if(n<135)ans=1;
        else if(n<165)ans=2;
        else if(n<189)ans=3;
        else if(n<195)ans=4;
        Console.WriteLine(ans);
      
    }


}



class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}






Measured memory_bytes: 11092
from fractions import gcd

mod = 10 ** 9 + 7

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

L = 1
for a in A:
    L *= a // gcd(L, a)

L %= mod

print(sum(L * pow(a, mod - 2, mod) % mod for a in A) % mod)

Measured memory_bytes: 6072
#include <iostream> 
#include <cstring>
#include <algorithm>
#define INF 500050
typedef long long ll;
ll a[INF];
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	double sum = a[1]+a[2];
	ll k = 2;
	for(int i=3; i<=n; i++) {
		sum += 1.0*k*a[i];
		k *= 2;
	}
	sum/=k*1.0;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

// #include "prettyprint.hpp"

using namespace std;
typedef long long ll;
// vector<vector<int>> vvi;
// vvi = vector<vector<int>>(20, vector<int>(10, 0));

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char b;
    cin >> b;
    if (b == 'A')
    {
        cout << 'T' << endl;
    }
    else if (b == 'C')
    {
        cout << 'G' << endl;
    }
    else if (b == 'G')
    {
        cout << 'C' << endl;
    }
    else if (b == 'T')
    {
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,n) for(int i=a;i<n;i++)
typedef pair<int,int> P;
typedef long long ll;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    ans+=n/(a+b)*a;
    if(n%(a+b)>a)ans+=a;
    else{ans+=n%(a+b);}
    cout<<ans;
}

Measured memory_bytes: 256
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun gcd(a: Long, b: Long): Long {
    if (b == 0L) return a
    return gcd(b, a%b)
}


fun primeFactorize(N: Long): Map<Long, Int> {
    if (N <= 1L) return mapOf()
    val fact = mutableMapOf<Long, Int>()
    var n = N
    var i = 2L
    while (i * i <= n) {
        while (n%i == 0L) {
            fact[i] = (fact[i] ?: 0) + 1
            n /= i
        }
        i++
    }
    if (n != 1L) {
        fact[n] = (fact[n] ?: 0) + 1
    }
    return fact
}


fun solve(A: Long, B: Long): Int {
    val g = gcd(A, B)
    val mp = primeFactorize(g)

    return mp.keys.size + 1
}


fun main(args: Array<String>) {
    val (A,B) = readLongArray()

    val ans = solve(A, B)

    println(ans)
}


Measured memory_bytes: 38336
#include <iostream>
using namespace std;
int main(void) {
	long long n, a, b;
	cin >> n >> a >> b;
	long long ans = 0;
	if ((b - a) % 2 == 0) ans = (b - a) / 2;
	else ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> h(n),a(m),b(m);
    vector<vector<int>> d(n);
    for(int i=0; i<n; i++) cin>>h[i];    
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        d[a[i]].push_back(b[i]);
        d[b[i]].push_back(a[i]);
    }
    int cnt=0;
    for(int i=0; i<n; i++){
        bool ok=true;
        for(auto j : d[i]){
            if(h[j]>=h[i]) ok=false;
        }
        if(ok) cnt++;
    }
    cout<<cnt<<endl;
}

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

int main(){

	int N,M;
  	int a,b,c[N+1];
  	cin >> N >> M;
  	for(int i = 1; i <= N; i++)c[i]=0;

  	for(int i = 1; i <= M; i++){
      	cin >> a >> b;
		c[a]++;
      	c[b]++;
      
    }
  	
  	
  	for(int i = 1; i <= N; i++){
   		cout <<c[i]<<endl;
  }
  	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int n;
int a[maxn];
ll qpow(ll a, ll k) {
    ll res=1;
    while(k) {
        if(k&1) res=res*a%mod;
        a=a*a%mod, k>>=1;
    }
    return res;
}

ll comb(int n, int m) {
    ll res=1;
    for(int i=0; i<m; ++i) res=res*(n-i)%mod;
    for(int i=1; i<=m; ++i) res=res*qpow(i,mod-2)%mod;
    return res;
}

int main() {
    int n=read(), a=read(), b=read();
    ll ans=(qpow(2,n)-1+mod)%mod;
    cout<<(ans-comb(n,a)-comb(n,b)+2*mod)%mod<<endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b < a) swap(a, b);
    if (c < b) swap(b, c);
    
    int res;
    if ((c - b) % 2 == 0 && (c - a) % 2 == 0) {
        res = (c - b) / 2 + (c - a) / 2 ;
    }
    else if (((c - b) % 2 == 1 && (c - a) % 2 == 0) || ((c - b) % 2 == 0 && (c - a) % 2 == 1)){
        res = (c - b) / 2 + (c - a) / 2 + 2;
    }
    else {
        res = (c - b) / 2 + (c - a) / 2 + 1;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: {},
});

hs = [];

rl.on('line', function(h) {
    hs.push(h | 0);
});

rl.on('close', function() {
    hs.sort(function(p, q) { return p - q; });
    for(var i = 0; i < 3; ++i)
        console.log(hs[hs.length - i - 1]);
});

Measured memory_bytes: 15936
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    ll n, k, h[100005];
    cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h, h + n);
    ll ans = LLINF;
    for (ll i = 0; i < n - k + 1; i++) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
  char str[100001];
  int i, joi, ioi;

  while (scanf("%s", str) != EOF){
    joi = 0;
    ioi = 0;
    for (i = 0; i < strlen(str) - 2; i++){
      if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I'){
        joi++;
      }
      else if(str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I'){
        ioi++;
      }
    }
    printf("%d\n%d\n", joi, ioi);
  }


  return (0);

}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, ans;

int main(){
  cin >> N;
  for (ll i = 1; i <= N; i++){
    ans += (i + (N / i) * i) * (N / i) / 2;
  }
  cout << ans << endl;

  return 0;
}


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

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

    if (a == b + c || b == a + c || c == a + b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
s = p[:x] + q[:y] + r
s.sort(reverse=True)
print(sum(s[: x + y]))


Measured memory_bytes: 106720
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

int main() {
  int n;
  cin >> n;
  vi v(n);
  REP(i, n) { cin >> v[i]; }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());

  int ans = v.size();
  if ((n - v.size()) % 2 == 1)
    ans--;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<String> dic = new HashSet<>();
    for(int i = 0; i < n; i++) {
      if(sc.next().equals("insert")) {
        dic.add(sc.next());
      } else {
        if(dic.contains(sc.next())) {
          System.out.println("yes");
        } else {
          System.out.println("no");
        }
      }
    }
  }
}



Measured memory_bytes: 261228
import math
a,b,h,m=map(int,input().split())
x=abs(30*h+0.5*m-6*m)
#math.cos(x*3.141592/180)
y=a**2+b**2-2*a*b*math.cos(x*3.14159265358979323846264/180)
print(math.sqrt(y))

Measured memory_bytes: 9504
use std::io::stdin;

fn main() {
    let a: i64 = 10;
    let mo:i64 = a.pow(9) +7;
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let (n, k) = {
        let mut nk:Vec<i64> = st.trim().split(" ").map(|x| x.parse().unwrap()).collect();
        (nk[0], nk[1])
    };
    let mut r:i64 = 0;
    for i in k..(n+2) {
        let s:i64 = i*(i+1)/2;
        let e:i64 = i*(n+1+(n+2-i))/2;
        r += e-s+1;
        r %= mo;
    };
    println!("{}", r);
}

Measured memory_bytes: 2128
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        char[] ch = sc.next().toCharArray();
        final int N = ch.length;
        boolean ans = true;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                if (ch[i] == ch[j]) ans = false;
            }
        }
        out.println(ans ? "yes" : "no");
        
        out.flush();
    }
}

Measured memory_bytes: 21844
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    long long sum;

    cin >> n;
    for(int i=0;i<n;i++) {
      long long in;
      cin >> in;
      sum += in;
    }

    if(sum % 2 == 0) {
      cout << "YES";
    } else {
      cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void){
	char str[101];
	char dir[20];
	while(scanf("%s",str),str[0]!='#'){
		int i=0,j=0;
		while(str[i]){
			if(str[i]=='n'){
				dir[j]='n';
				j++;
				i+=5;
			}else if(str[i]=='w'){
				dir[j]='w';
				j++;
				i+=4;
			}
		}
		int numerator=0;
		int denominator=1<<(j-1);
		for(i=0;i<j;i++){
			if(i+1==j){
				if(dir[i]=='w'){
					numerator+=90*(1<<i);
				}else{
					numerator+=0;
				}
				break;
			}
			if(dir[i]=='w'){
				numerator+=90*(1<<i);
			}else{
				numerator-=90*(1<<i);
			}
		}
		while(denominator>1){
			if(numerator%2==0&&denominator%2==0){
				numerator/=2;
				denominator/=2;
			}else{
				break;
			}
		}
		printf("%d",numerator);
		if(denominator>1){
			printf("/%d",denominator);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 540
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
static const int INFTY = (1 << 30);
int n;

int calc() {

    int res = INFTY, r1, r2, r3;
    for (int i = 0; i <= n / 500 + 1; i++) {
        r1 = i / 3 * 3 * 850 * 88/ 100 + i % 3 * 850;
        for (int j = 0; j <= n / 300 + 1; j++) {
            r2 = j / 4 * 4 * 550 * 85 / 100 + j % 4 * 550;
            if (r1 + r2 > res) break;
            for (int k = 0; k <= n / 200 + 1; k++) {
                if (i * 500 + j * 300 + k * 200 != n) continue;
                r3 = k / 5 * 5 * 380 * 80 / 100 + k % 5 * 380;
                if (res < r1+r2+r3) break;
                res = min(res, r1+r2+r3);
            }
        }
    }

    return res;
}


/*int calc2(int qA, int qB, int qC) {
    if (qA * 200 + qB * 300 + qC * 500 >= n) {
        int res = qA / 5 * 1520 + qA % 5 * 380 + qB / 4 * 1870 + qB % 4 * 550 + qC / 3 * 2244 + qC % 3 * 850;
        return res;
    }
    return min(calc2(qA+1, qB, qC), min(calc2(qA, qB+1, qC), calc2(qA, qB, qC+1)));
}*/

int main()  {
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        cout << calc() << endl;
        //cout << calc2(0, 0, 0) << endl;

    }
    return 0;
}



Measured memory_bytes: 3036
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    char :"%c",char*:"%s")


int main(void){
    unsigned n,m;
    scanf("%u %u",&n,&m);

    unsigned ans;

    for(unsigned i = m / n;i > 0;i--)if(m % i == 0){ans = i;break;}

    mprint(ans);
    return 0;
}


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

using namespace std;

int main()
{
    int n,m,sum;
    cin>>n>>m;
    sum=(n-m);
    sum+=m*19;
    int num=2;
    while(--m){
        num*=2;
    }
    cout<<num*sum*100;
    return 0;
}


Measured memory_bytes: 256
K = int(input())
A = list(map(int, input().split()))

def g(x):
    for a in A:
        x = (x // a) * a
    return x

overEq = 10**18
less = 0
while overEq - less > 1:
    mid = (overEq + less) // 2
    if g(mid) < 2:
        less = mid
    else:
        overEq = mid

over = 10**18
lessEq = 0
while over - lessEq > 1:
    mid = (over + lessEq) // 2
    if g(mid) <= 2:
        lessEq = mid
    else:
        over = mid

if g(overEq) == 2 and g(lessEq) == 2:
    print(overEq, lessEq)
else:
    print(-1)


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

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

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    if s.len() % 2 == 1 {
        println!("No");
        return;
    }
    for i in 0..s.len() {
        if i % 2 == 0 {
            if s[i] != 'h' {
                println!("No");
                return;
            }
        } else {
            if s[i] != 'i' {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}

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

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


Measured memory_bytes: 4352
test_case = int(input())
t, a = map(int, input().rstrip().split())
xs = list(map(int, input().rstrip().split()))
result = None
idx = None

for i in range(len(xs)):
    x = xs[i]
    temp = abs(t - x*0.006 - a)
    if result is None:
        result = temp
        idx = i+1
    elif temp < result:
        result = temp
        idx = i + 1
print(idx)

Measured memory_bytes: 3064
from fractions import gcd


def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())
SUM = B - A + 1
c = (B // C - (A - 1) // C)
d = (B // D - (A - 1) // D)
cd = (B // lcm(C, D) - (A - 1) // lcm(C, D))
print(B - A + 1 - (B // C - (A - 1) // C + B // D - (A - 1) // D - cd))


Measured memory_bytes: 5372
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;
using namespace std;


std::vector<int> parent;
std::vector<int> rank_;

void init(int n){
    parent.clear();
    rank_.clear();
    for(int i=0; i<n; i++){
        parent.push_back(i);
        rank_.push_back(0);
    }
}

int find(int x){
    if(x == parent[x]){
        return x;
    } else {
        return parent[x] = find(parent[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);

    if(x == y) return;

    if(rank_[x] < rank_[y]){
        parent[x] = y;
    } else {
        parent[y] = x;
        if(rank_[x] == rank_[y]) rank_[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}


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

    int n, m;
    cin >> n >> m;

    vector<int> l(m), r(m);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        l[i] = a;
        r[i] = b;
    }

    int cnt = 0;

    for (int i = 0; i < m; i++) {
        init(n);
        for(int a=0; a<m; a++){
            if(a == i) continue;
            unite(l[a], r[a]);
        }

        bool is_same = true;
        for(int a=0; a<n && is_same; a++){
            for(int b=0; b<n && is_same; b++){
                if(!same(a, b)){
                    is_same = false;
                    cnt++;
                }
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    a = list(set(s))
    if len(a) <2:
        print('No')
        exit()
    if s.count(a[0]) == s.count(a[1]) == 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;
using Matrix = vector<vector<int>>;

constexpr int MOD = 1e9 + 7;

void print(Matrix mat)
{
	for(auto& el : mat)
	{
		for(auto& it : el)
		{
			cout << it << " ";
		}
		cout << endl;
	}
	cout << nl;
}

Matrix Multiply(const Matrix& a , const Matrix& b)
{
	int n = sz(a) , m = sz(b[0]);
	
	Matrix res(n , vi(m));
	
	rep(i , n)
	{
		rep(j , m)
		{
			rep(k , sz(a[0]))
			{
				res[i][j] += 1LL * a[i][k] * b[k][j] % MOD;
				res[i][j] %= MOD;
			}
		}
	}
	
	return std::move(res);
}


Matrix pow(Matrix mat , ll k)
{
	Matrix res(sz(mat) , vi(sz(mat)));
	rep(i , sz(mat))
		res[i][i] = 1;
		
	while(k > 0)
	{
		if(k % 2 == 1)
			res = Multiply(res , mat);
		mat = Multiply(mat , mat);
		k /= 2;
	}
	
	return std::move(res);
}

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

	int n;
	ll k;
	cin >> n >> k;
	
	Matrix mat(n , vi(n));
	
	rep(i , n)
	{
		rep(j , n)
		{
			cin >> mat[i][j];
		}
	}
	
	auto res = pow(mat , k);
	
	int ans = 0;
	for(const auto& row : res)
	{
		for(int el : row)
		{
			ans += el;
			ans %= MOD;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define M1 1000000007
#define M2 998244353
#define ll long long int
#define N (int)1e5+3
#define test(t) while(t--)
#define PI acos(-1.0)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,b,a) for(ll i=b-1;i>=a;i--)
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define V(a) vector<a>
#define M(a,b) map<a,b>
#define endl '\n'
#define all(x) begin(x),end(x)
#define allr(x) rbegin(x),rend(x)
#define pr(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { -1, 0, 1, 0 };
using namespace std;

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    string s;
    cin >> s;
    ll t = s.size();
    string a;
    a.append(t,'x');
    cout << a << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

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

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

  int n;
  cin>>n;
  string s;
  cin>>s;

  vector<int> A[3];//0->R, 1->G, 2->B
  int arr[3]  = {0, 1, 2};

  for(int i=0; i<n; i++){
    if(s[i]=='R')A[0].push_back(i);
    else if(s[i]=='G')A[1].push_back(i);
    else if(s[i]=='B')A[2].push_back(i);
  }

  long long num = 0;

  do{
    for(int i=0; i<(int)A[arr[0]].size(); i++){
      vector<int>::iterator l = lower_bound(A[arr[1]].begin(), A[arr[1]].end(), A[arr[0]][i]);
      int j = l-A[arr[1]].begin();
      for(;j<(int)A[arr[1]].size(); j++){
        vector<int>::iterator z = lower_bound(A[arr[2]].begin(), A[arr[2]].end(), A[arr[1]][j]);
        int k = z-A[arr[2]].begin();

        num += A[arr[2]].size()-k;

        vector<int>::iterator it = lower_bound(A[arr[2]].begin(), A[arr[2]].end(), 2*A[arr[1]][j]-A[arr[0]][i]);
        int m = it-A[arr[2]].begin();
        if(m<(int)A[arr[2]].size() && A[arr[2]][m]==2*A[arr[1]][j]-A[arr[0]][i])num--;
      }
    }
  }while(next_permutation(arr, arr+3));

  

  cout<<num<<"\n";

  return 0;
}


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

bool check(string s) {
	bool res = true;
	int n = s.size();
	for (int i = 0; i < n/2; ++i) {
		if (s[i] != s[n - 1 - i]) res = false;
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	string ans = "No";
	if (check(s) && check(s.substr(0, n/2)) && check(s.substr((n + 3)/2 - 1))) ans = "Yes";
	cout << ans << endl;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

#define mod 1000000007

ll fac[111111];

int main(){
	cin.sync_with_stdio(false);
  fac[0]=fac[1]=1;
  repl(i,1,100010)fac[i+1]=fac[i]*(i+1)%mod;
  ll a,b;
  cin>>a>>b;
  if(abs(a-b)>1){
    cout<<0<<endl;
  }else if(abs(a-b)==1){
    cout<<fac[a]*fac[b]%mod<<endl;
  }else{
    cout<<fac[a]*fac[b]*2%mod<<endl;
  }
	return 0;
}


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

const int M = 1e9 + 7;
const int INF = 1e9 + 5;

int main() {
	int n, w;
	cin >> n >> w;
	vector<int> val(n), weight(n);
	
	for(int i = 0; i < n; i++) {
		cin >> weight[i] >> val[i];
	}
	
	vector<ll> dp(w+1);
	
	for(int i = 1; i <= n; i++) {
		//vector<ll> new_dp(w+1);
		//for(int j = 1; j <= w; j++) {
			//if(weight[i-1] <= j) {
				//new_dp[j] = max(dp[j], dp[j - weight[i-1]] + val[i-1]);
			//}
			//else {
				//new_dp[j] = dp[j];
			//}
		//}
		//dp = new_dp;
		for(int j = w; j >= weight[i-1]; j--) {
			dp[j] = max(dp[j], dp[j - weight[i-1]] + val[i-1]);
		}
	}
	
	cout << dp[w] << "\n";
}


Measured memory_bytes: 4008
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n, m,k,tmp,cnt=0;
	cin >> n >> m;
	vector<int>p(m+1,0);
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> tmp;
			p[tmp]++;
		}
	}
	for (int i = 1; i <= m; i++) {
		if (p[i] == n)cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int w,h,n,i,j,k,ans=0,gx,gy,nx,ny;
	scanf("%d %d %d",&w,&h,&n);
	scanf("%d %d",&nx,&ny);
	for(i=1;i<n;i++){
		scanf("%d %d",&gx,&gy);
		while(!(gx==nx&&gy==ny)){
			if(gx==nx&&gy<ny){
				ny--;
				ans++;
			}
			if(gx==nx&&gy>ny){
				ny++;
				ans++;
			}
			if(gx<nx&&gy==ny){
				nx--;
				ans++;
			}
			if(gx>nx&&gy==ny){
				nx++;
				ans++;
			}
			if(gx<nx&&gy<ny){
				nx--;
				ny--;
				ans++;
			}
			if(gx<nx&&gy>ny){
				nx--;
				//ny++;
				ans++;
			}
			if(gx>nx&&gy>ny){
				nx++;
				ny++;
				ans++;
			}
			if(gx>nx&&gy<ny){
				nx++;
				//ny++;
				ans++;
			}
		}
	}
	
	printf("%d\n",ans);
	return 0;
}	

Measured memory_bytes: 1860
use std::io::*;
use std::str::*;
use std::cmp::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let ks = vec_usize(2);
    let k = ks[0];
    let s = ks[1];
    let mut result = 0;
    for x in 0..k + 1 {
        let s2 = s - x;
        for y in 0..min(s2, k) + 1 {
            let z = s2 - y;
            if z <= k && x + y + z == s {
                result += 1;
            }
        }
    }
    println!("{}", result);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

// ??????2?????¢?´¢??¨??§?????¢????£??????¨?????£???(?°???????)

struct query{int q,s,t;};

int n;
int a,d;
int m;
query ql[252521];
int k;

int main(){
  scanf("%d",&n);
  scanf("%d%d",&a,&d);
  scanf("%d",&m);
  REP(i,m){
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    --y; --z;
    ql[i] = (query){x,y,z};
  }
  scanf("%d",&k);
  --k;
  // ???????????????
  int pos = k;
  REP(_i,m){
    int i = m-1-_i;
    query q = ql[i];
    if(q.q != 0)continue;
    int beg = q.s;
    int end = q.t;
    if(!(beg<=pos && pos<=end))continue;
    // ?????¢
    int len = end-beg+1;
    if(len%2==0){
      int len2 = len/2;
      pos -= beg;
      pos -= len2;
      if(pos>=0)++pos;
      pos = -pos;
      if(pos>=0)--pos;
      pos += len2;
      pos += beg;
    }else{
      int len2 = len/2;
      pos -= beg;
      pos -= len2;
      pos = -pos;
      pos += len2;
      pos += beg;
    }
  }
  int val = a+pos*d;
  REP(i,m){
    query q = ql[i];
    int beg = q.s;
    int end = q.t;
    if(!(beg<=pos && pos<=end))continue;
    if(q.q == 0){
      int len = end-beg+1;
      if(len%2==0){
        int len2 = len/2;
        pos -= beg;
        pos -= len2;
        if(pos>=0)++pos;
        pos = -pos;
        if(pos>0)--pos;
        pos += len2;
        pos += beg;
      }else{
        int len2 = len/2;
        pos -= beg;
        pos -= len2;
        pos = -pos;
        pos += len2;
        pos += beg;
      }
    }else if(q.q == 1){
      val += 1;
    }else if(q.q == 2){
      val /= 2;
    }
  }
  cout<<val<<endl;
  return 0;
}

Measured memory_bytes: 3368
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map(String::toInt)
    val ans = readLine()!!.filterIndexed { i, c -> if (i == a) c == '-' else c in '0'..'9' }.length == a + b + 1
    println(if (ans) "Yes" else "No")
}


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

A = [int(input()) for _ in range(N)]

"順方向の最大値、逆方向の最大値"

left_max = [A[0]]
right_max = [A[-1]]

for i in range(1, N):
    left_max.append(max(left_max[-1], A[i]))


for i in range(N-2, -1, -1):
    right_max.append((max(right_max[-1], A[i])))

# print(left_max)
right_max.reverse()
# print(right_max)

print(right_max[1])  # 最初の項A1を除いた最大値
for i in range(1, N-1):
    print(max(left_max[i-1], right_max[i+1]))
print(left_max[-2])


Measured memory_bytes: 15716
#include<stdio.h>

int main(){
    
    int N;
    int i,j,k,v;
    int min;
    int count=0;
    int check;
    
    scanf("%d",&N);
    
    int a[N];
    
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0;i<N;i++){
        min=i;
        check=i;
        for(j=i;j<N;j++){
            if(a[j]<a[min]){
                min=j;
            }
        }
        
        if(check!=min){
            count++;
        }
        v=a[i];
        a[i]=a[min];
        a[min]=v;
    }
    
       
    for(k=0;k<N-1;k++){
        printf("%d ",a[k]);
    }
    printf("%d\n",a[N-1]);
    
    printf("%d\n",count);
       
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;

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

    std::cin >> N >> M;

    int mx = 1;

    for(int i=1;i*i<=M;++i){
        if(M % i == 0){
            int j = M / i;

            if(j >= N){
                mx = std::max(mx, i);
            }

            if(i >= N){
                mx = std::max(mx, j);
            }
        }
    }

    std::cout << mx << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int h, w; cin >> h >> w;
    char c;
    int cnt = 0;
    for (int i = 0; i < h*w; i++) { cin >> c; if (c == '#') cnt++; }
    cout << (cnt == h + w - 1 ? "Possible\n" : "Impossible\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a,x=0;
    for(int i=1;i<=n;i++){
        cin>>a;
        while(a%2==0)a/=2,x++;
        //x+=(ll)log2(a);
    }
    cout<<x;
}


Measured memory_bytes: 3616
N = int(input())
R = []
for i in range(N):
    R.append(int(input()))
ans = -1 * (10 ** 9 + 7)
minv = R[0]
for i in range(1, N):
    ans = max(R[i] - minv, ans)
    minv = min(minv, R[i])
print(ans)



Measured memory_bytes: 13592
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<ll,ll> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{   
    int a,l;
    while(cin>>a>>l,a!=0,l!=0)
    {
        vector<int>t(0);
        t.push_back(a);
        vector<int>::iterator it;
        while(1)
        {
            string s=to_string(a);
            //cout<<s<<endl;
            //cout<<l<<" "<<s.size()<<endl;
            while(l!=s.size())s.push_back('0');
            //cout<<s<<endl;
            sort(ALL(s));
            string up=s;
            reverse(ALL(s));
            string down=s;
            int big=stoi(down);
            int small=stoi(up);
            int sum=big-small;
            it=find(ALL(t),sum);
            a=sum;
            if(it!=t.end())break;
            //if(sum==t[0])break;
            t.push_back(sum);
        }
        //cout<<t.size()<<endl;
        //for(auto g:t)cout<<g<<endl;
        int ans=0;
        for(auto x=t.begin();x!=it;++x,++ans);
        cout<<ans<<" "<<a<<" "<<t.size()-ans<<endl;
    }
}


Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int inf = 1000000000;

//#define DEBUG

int main() {
    double h, a;
    cin >> h >> a;
    cout << ceil(h / a * 1.0) << endl;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define H 400
#define W 400

using namespace std;

ll h,w;
void update(string s[],ll x,ll y,ll w,ll h, ll g[][2],ll nowg,bool updated[H][W]){
    updated[y][x]=true;
    if(s[y][x]=='.') g[nowg][0]++;
        else g[nowg][1]++;
    if(x-1>=0 and s[y][x-1]!=s[y][x] and updated[y][x-1]==false) {
        update(s,x-1,y,w,h,g,nowg,updated);
    } 
    if(x+1<w and s[y][x+1]!=s[y][x] and updated[y][x+1]==false) {
        update(s,x+1,y,w,h,g,nowg,updated);
    } 
    if(y-1>=0 and s[y-1][x]!=s[y][x] and updated[y-1][x]==false) {
        update(s,x,y-1,w,h,g,nowg,updated);
    } 
    if(y+1<h and s[y+1][x]!=s[y][x] and updated[y+1][x]==false) {
        update(s,x,y+1,w,h,g,nowg,updated);
    } 
    return;
}

int main(){
    cin>>h>>w;
    ll g[h*w][2]={};

    bool updated[H][W]={false};
    ll nowg=0;
    string s[h];

    rep(i,h) cin>>s[i];
    rep(i,h){
        rep(j,w){
            if (updated[i][j]==false){
                update(s,j,i,w,h,g,nowg,updated);
                nowg++;
            }
        }
    }
    ll ans=0;
    rep(i,nowg){
       ans+=g[i][1]*g[i][0];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 25600
n,m = map(int,input().split())
menu = [0 for _ in range(m)]
for i in range(n):
  now = list(map(int,input().split()))
  del now[0]
  for x in now:
    menu[x-1] += 1
for j in range(m):
  if menu[j] == n:
    menu[j] = 1
  else:
    menu[j] = 0
print(sum(menu))

Measured memory_bytes: 3064
from heapq import heapify, heappop, heappush

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

Q = A[:N]
heapify(Q)

R = [sum(Q)]
for k in range(N, 2 * N):
    heappush(Q, A[k])
    m = heappop(Q)
    R.append(R[-1] + A[k] - m)

Q = [-a for a in A[2 * N:]]
heapify(Q)

B = [sum(Q)]
for k in reversed(range(N, 2 * N)):
    heappush(Q, -A[k])
    m = heappop(Q)
    B.append(B[-1] - A[k] - m)

print(max(r + b for r, b in zip(R, reversed(B))))


Measured memory_bytes: 40276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,m,ans=0,v[105];
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>v[i];
    for(int i=0;i<=n;i++){
		for(int j=n-1;j>=i-1;j--){
			if(i+(n-j-1)>m)continue;
			vector<ll>s;
			for(int k=0;k<i;k++)s.PB(v[k]);
			for(int k=n-1;k>j;k--)s.PB(v[k]);
			sort(s.begin(),s.end());
			ll p=0;
			for(int k=0;k<s.size();k++)p+=s[k];
			ans=max(ans,p);
			for(int k=0;k<s.size()&&k<m-(i+(n-j-1));k++){
				p-=s[k];
				ans=max(ans,p);
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#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 n,k;
string s;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>n>>k>>s;

  int diffs = 0;
  for (int i=0; i+1<n; i++) {
    if (s[i] != s[i+1]) diffs++;
  }

  int good = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == 'L' && i > 0 && s[i-1]=='L') good++;
    if (s[i] == 'R' && i+1 < n && s[i+1]=='R') good++;
  }

  //watch(diffs);
  //watch(good);
  while (k>0 && diffs>0) {
    int dx = min(2, diffs);
    diffs -= dx;
    good += dx;
    k--;
  }
  cout<<good<<endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int func(int x, int y)
{
    int xcount = 0;
    int ycount = 0;
    while (x) {
        x /= 10;
        xcount++;
    }
    while (y) {
        y /= 10;
        ycount++;
    }
    return max(xcount, ycount);
}


int main(){
    ll n, N;
    ll min = 10000000000;
    int count1 = 0, count2;
    cin >> n;
    N = n;
    while (N) {
        N /= 10;
        count1++;
    }
    count2 = (count1 + 1) / 2;
    int b = 1;
    while(count2--) {
        b *= 10;
    } 

    for (int i = 1; i < b; i++) {
        if (n % i == 0) {
            int k = n / i;
            int a = func(i, k);
            if (min > a) {
                min = a;
            }
        }
    }
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

/*void to_unique(vector<int> &v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
}
vector<int> ans;
void solve() {
	int n, m; cin >> n >> m;
	ans.resize(n, -1);
	vector<pair<int, P>> v;
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		if (a == n - 1)continue;
		if (b == n - 1) {
			ans[a] = max(ans[a], c);
			continue;
		}
		v.push_back({ c,{b,a} });
	}
	sort(v.begin(), v.end(),greater<int>());
	rep(i, v.size()) {
		int le = i;
		while (i + 1 < (int)v.size() && v[i].first == v[i + 1].first) {
			i++;
		}
		if (i == le) {
			int id = v[i].second.first; int to = v[i].second.second;
			ans[to] = max(ans[to], ans[id]);
			continue;
		}
		vector<int> x;
		vector<P> u;
		Rep(j, le, i) {
			u.push_back(v[j].second);
			x.push_back(v[j].second.first);
			x.push_back(v[j].second.second);
		}
		to_unique(x);
		{
			map<int, int> mp;
			rep(i, x.size()) {
				mp[x[i]] = i;

			}
		}
	}
}*/

void solve2(){ 
	ll n, d;
	cin >> n >> d;
	if (d == 1) {
		cout << n * (n - 1) / 2 << endl;
	}
	else cout << 2 * (n - d) + (d - 2) + (n - d)*(n - d - 1) / 2 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve2();
	//stop
		return 0;
}



Measured memory_bytes: 3168
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       N:usize, X:Chars
    }
    let X: Vec<u64> = X.iter().map(|&c| (c as u8 - '0' as u8) as u64).collect();
    let mut ones = 0;
    for i in 0..N {
        ones += X[i];
    }
    let mut amari_m = vec![1u64; N];
    let mut amari_p = vec![1u64; N];
    let mut amari_m_total = 0;
    let mut amari_p_total = 0;
    if ones > 1 {
        amari_m[0] = 1 % (ones - 1);
        amari_m_total += X[N - 1] * amari_m[0];
        for i in 1..N {
            // べき乗のあまりは循環するので、2^i % (one+-1)== 0となるiを見つける。(高々N==10万。)
            amari_m[i] = amari_m[i - 1] * 2 % (ones - 1);
            amari_m_total += X[N - i - 1] * amari_m[i];
        }
    }
    amari_p[0] = 1 % (ones + 1);
    amari_p_total += X[N - 1] * amari_p[0];
    for i in 1..N {
        // べき乗のあまりは循環するので、2^i % (one+-1)== 0となるiを見つける。(高々N==10万。)
        amari_p[i] = amari_p[i - 1] * 2 % (ones + 1);
        amari_p_total += X[N - i - 1] * amari_p[i];
    }
    //println!("ones={}", ones);
    //println!("m {},{:?}", amari_m_total, amari_m);
    //println!("p {},{:?}", amari_p_total, amari_p);
    for i in 0..N {
        if ones == 1 && X[i] == 1 {
            println!("0");
            continue;
        }
        let mut t = if X[i] == 1 {
            //       println!("{} - {}, {}", amari_m_total, amari_m[N - i - 1], ones - 1);
            (amari_m_total - amari_m[N - i - 1]) % (ones - 1)
        } else {
            //     println!("{} + {}, {}", amari_p_total, amari_p[N - i - 1], ones + 1);
            (amari_p_total + amari_p[N - i - 1]) % (ones + 1)
        };
        let mut ans = 1;
        while t > 0 {
            ans += 1;

            let mut ones2 = 0;
            let mut t2 = t;
            while t2 > 0 {
                ones2 += t2 & 1;
                t2 = t2 >> 1;
            }
            t = t % ones2;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 7856
package main

import "fmt"

var ar = []int{0, 2, 5, 5, 4, 5, 6, 3, 7, 6}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	ur := make([]bool, 10)
	for i := 0; i < m; i++ {
		var u int
		fmt.Scan(&u)
		ur[u] = true
	}

	dp := make([]int, n+1)
	for i := range dp {
		dp[i] = -1
	}
	dp[0] = 0
	for i := 1; i <= 9; i++ {
		if !ur[i] {
			continue
		}
		for j := 0; j <= n-ar[i]; j++ {
			if dp[j] < 0 {
				continue
			}
			if dp[j+ar[i]] < dp[j]+1 {
				dp[j+ar[i]] = dp[j] + 1
			}
		}
	}
	for {
		if n == 0 {
			break
		}
		for i := 9; i >= 0; i-- {
			if !ur[i] {
				continue
			}
			if n-ar[i] < 0 {
				continue
			}
			if dp[n-ar[i]] == dp[n]-1 {
				fmt.Print(i)
				n -= ar[i]
				break
			}
		}
	}
	fmt.Println()
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int a, b;

	cin >> a;
	cin >> b;

	if (a > b) cout << "a > b" << endl;
	if (a < b) cout << "a < b" << endl;
	if (a == b) cout << "a == b" << endl;

	return 0;
}


Measured memory_bytes: 3072
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 1000000007;

bool dp[4000][16000];

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  std::string s;
  std::cin >> s;
  ll x, y,n;
  n=s.size();
  std::cin >> x >> y;
  std::vector<ll> xlen, ylen;
  ll mode = 1, temp = 0;
  rep(i, 0, n ){
    if (s[i] == 'T') {
      if (mode == 1) {
        xlen.push_back(temp);
      } else {
        ylen.push_back(temp);
      }
      mode *= -1;
      temp = 0;
    } else {
      temp++;
    }
  }

  if (mode == 1) {
    xlen.push_back(temp);
  } else {
    ylen.push_back(temp);
  }

  ylen.push_back(0);

  bool ans=true;

  rep(i,0,16000)dp[0][i]=false;
  dp[0][xlen[0]+8000]=true;
  rep(i,1,xlen.size()){
    rep(j,0,16000){
      dp[i][j]=((j-xlen[i]>=0)&&dp[i-1][j-xlen[i]])||((j+xlen[i]<16000)&&dp[i-1][j+xlen[i]]);
    }
  }
  ans= (ans&&dp[xlen.size()-1][x+8000]);


  rep(i,0,16000){
    dp[0][i]=false;
  }
  dp[0][8000+ylen[0]]=true;
  dp[0][8000-ylen[0]]=true;
  rep(i,1,ylen.size()){
    rep(j,0,16000){
      dp[i][j]=((j-ylen[i]>=0)&&dp[i-1][j-ylen[i]])||((j+ylen[i]<16000)&&dp[i-1][j+ylen[i]]);
    }
  }
  ans=(ans&&dp[ylen.size()-1][y+8000]);
  if(ans){
    std::cout<<"Yes";
  }else{
    std::cout<<"No";
  }
  return 0;
}

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

int
main(void)
{
	char s[201];
	char t[201];
	int i, h, m, l;

	for (;;) {
		scanf("%s", s);
		if (s[0] == '-')
			break;
		l = strlen(s);
		scanf("%d", &m);
		for (i = 0; i < m; i++) {
			scanf("%d", &h);
			memcpy(t, s + h, l - h);
			memcpy(t + l - h, s, h);
			memcpy(s, t, l);
		}
		printf("%s\n", s);
	}

	return 0;
}



Measured memory_bytes: 2068