akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll gcd(ll a, ll b)
{
    return (b ? gcd(b, a % b) : a);
}
int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n - 1)
    {
        ans += i + 1;
    }
    c(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    int N,W;
    cin>>N>>W;

    vector<int> w(N);
    vector<int> val(N);

    for ( int i = 0 ; i < w.size() ; i++ )
    {
        cin>>w[i]>>val[i];
    } 

    int dp[N+1][W+1];

    for ( int i = 0 ; i <= N ; i++ )
    {
        for ( int j = 0 ; j <= W ; j++ )
        {
            if ( i == 0 || j == 0 )
            {
                dp[i][j] = 0;
            }
            else if ( j >= w[i-1] )
            {
                dp[i][j] = max(val[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    } 

    cout<<dp[N][W]<<endl;
    return 0;
}

Measured memory_bytes: 79232
#include<stdio.h>
#include<stdlib.h>
#define N 500000
#define SENTINEL 1000000001
void merge(int[],int,int,int);
void mergeSort(int[],int,int);
void printArray(int[],int);
int count=0;//the number of comparisons in the merge function
int main(void)
{
  int i;//counter
  int n;//the number of integers
  int arr[N];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&arr[i]);
  mergeSort(arr,0,n);
  printArray(arr,n);
  printf("%d\n",count);
  return 0;
}
void merge(int arr[],int left,int mid,int right)
{
  int i,j,k;//counter
  int n1=mid-left;//the number of elements in array l
  int n2=right-mid;//the number of elements in array r
  int *l=(int*)malloc(sizeof(int)*(n1+1));
  int *r=(int*)malloc(sizeof(int)*(n2+1));
  for(i=0;i<n1;i++) l[i]=arr[left+i];
  for(i=0;i<n2;i++) r[i]=arr[mid+i];
  l[n1]=SENTINEL;
  r[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++)
    {
      if(l[i]<=r[j])
	{
	  arr[k]=l[i];
	  i++;
	}
      else
	{
	  arr[k]=r[j];
	  j++;
	}
      count++;
    }
  free(l);
  free(r);
}
void mergeSort(int arr[],int left,int right)
{
  int mid;//separate point of array
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergeSort(arr,left,mid);
      mergeSort(arr,mid,right);
      merge(arr,left,mid,right);
    }
}
void printArray(int arr[],int n)
{
  int i;//counter
  for(i=0;i<n;i++)
    {
      if(i>0) printf(" ");
      printf("%d",arr[i]);
    }
  printf("\n");
}



Measured memory_bytes: 5476
#include <stdio.h>
//#include <string.h>

int main(void){
  
  long int n,d;
  long int x,y;
  int count = 0;
  scanf("%ld %ld", &n, &d);
  
  for(int i=0;i<n;i++){
  scanf("%ld %ld", &x, &y);
  if(x*x+y*y <= d*d){
  count=count+1;
  }
  }
  
  printf("%d", count);
    
    
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for (int i = 0; i < W + 2; i++) cout << "#";
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
    cout << endl << "#" << vec.at(i) << "#";
  }
  cout << endl;
  for (int i = 0; i < W + 2; i++) cout << "#";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define MAX 100000

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[MAX];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  int currCount = 1;
  for (int i = 1; i < n; ++i)
    if (a[i] == a[i - 1])
      ++currCount;
    else {
      if (currCount % 2 == 1)
        ++ans;
      currCount = 1;
    }
  if (currCount % 2 == 1)
    ++ans;
  cout << ans;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		
		if (a <= c && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String q = "Odd";
    if(a%2==0||b%2==0){
      q="Even";
    }
    System.out.println(q);
  }
  

  
}

Measured memory_bytes: 25300
n=1<<18;N,m;L[1<<18],p;F[1<<18],X[1<<18];i;
long D[1<<20],Z[1<<20],A[1<<18],x,z;
long f(a,b,k,l,r){
	D[k]+=z=Z[k];
	Z[2*k+1]+=z;
	Z[2*k+2]+=z;
	Z[k]=0;
	return a<=l&r<=b?D[k]+(Z[k]=x):l<b&a<r?D[k]=fmax(
		f(a,b,2*k+1,l,(l+r)/2),
		f(a,b,2*k+2,(l+r)/2,r)
	):D[k];
}
main(j){
	for(scanf("%d%d",&N,&m);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];
	for(;i++<N;){
		x=f(x=0,i,0,0,n);
		f(i,i+1,0,0,n);
		for(p=F[i];p!=0;p=X[p])x=A[p],f(L[p],i+1,0,0,n);
	}
	printf("%ld",f(x=0,i,0,0,n));
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/


Measured memory_bytes: 16640
import math
import itertools

def imagine_time(order):
    time = 0
    for o in order[:-1]:
        time += math.ceil(dishes[o] / 10 ) * 10
    time += dishes[order[-1]]
    return time

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
dishes = [A, B, C, D, E]

ans = 99999
orders = list(itertools.permutations([0, 1, 2, 3, 4]))
for order in orders:
    ans = min(ans, imagine_time(order))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
const int mod=1e9+7;
const int N=2e6+5;
int n,ans,zero,add1[N],add2[N],a[N],sum[N],f[N];
vector<int>v[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=a[i-1]^read();
		v[a[i]].push_back(i);
	}
    for(int i=1;i<(1<<20);i++)
		if(v[i].size())add2[v[i][0]]++;
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(a[i]==0);
	for(int i=1;i<=n;i++)
        if(a[i]==0)zero++;
        else{
            f[i]=(zero*add1[i]%mod+add2[i])%mod;
            int ind=upper_bound(v[a[i]].begin(),v[a[i]].end(),i)-v[a[i]].begin();
            if(ind<v[a[i]].size())
			{
                int nxt=v[a[i]][ind];
                add1[nxt]=(add1[nxt]+add1[i]+f[i])%mod;
                add2[nxt]=(add2[nxt]+add2[i]-f[i]*zero%mod+mod)%mod;
            }
        }
	if(a[n]==0)
	{
		ans=0;
		int res=1;
		for(int i=1;i<n;i++)
			if(a[i]==0)res=res*2%mod;
			else ans=(ans+f[i])%mod;
		cout<<(ans+res)%mod;
	}
	else cout<<f[n];
}

Measured memory_bytes: 86384
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
	int n,k; cin>>n>>k;
	int h=0;
	cin>>a;

	for(int i=0;i<n;i++){
		if(a[i]=='L' and i!=0) {if(a[i-1]=='L') h++;}
		if(a[i]=='R' and i!=n-1){if(a[i+1]=='R') h++;}
	}

	cout<<min(n-1,h+2*k);
}

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


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

  x -= a;

  cout << x % b << endl;
  
  return 0;
}

Measured memory_bytes: 3576
#include<cstdio>

const int MAX_N = 100000;
int a[MAX_N];

int f(int x, int y) {
	return y <= x/2 ? x/2 - y : y - (x+1)/2;
}

int main() {
	int n;
	int max = 0;
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		if(max < a[i]) max = a[i];
	}
	int mid = max != a[0] ? a[0] : a[1];
	for(int i=1;i<n;i++) {
		if(f(max, a[i]) < f(max, mid)) mid = a[i];
	}
	printf("%d %d\n", max, mid);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;

	return 0;
}



Measured memory_bytes: 3612
def odd(a):
    return a/2

def even(b):
    return 3*b+1

num = int(input())
box = [num]
cnt = 0
answer = 0
while(True):
    if(num%2 == 0):
        num = odd(num)
    else:
        num = even(num)
    for i in range(len(box)-1):
        if(box[i] == num):
            answer = 1
    box.append(num)
    if(answer == 1):
        print(len(box))
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    while(scanf(" %d", &n),n)
    {
        vector<int> p(n),j(n-1);
        rep(i,n) scanf(" %d", &p[i]);
        rep(i,n-1) scanf(" %d", &j[i]);

        sort(all(j),greater<int>());

        ll P=0;
        rep(i,n) P+=p[i];

        ll ans=P*n;
        rep(i,n-1)
        {
            P+=j[i];
            ans = max(ans, P*(n-i-1));
        }

        printf("%lld\n", ans);
    }
    return 0;
}

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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int d,g; cin >> d >> g;
    int p[10],c[10];
    for(int i=0;i<d;++i) cin >> p[i] >> c[i];

    int ans = 1e9;
    for(int bit = 0; bit < (1<<d); ++bit) {
        // search complete bonus
        int cnt = 0, pnt = 0;
        for(int i=0; i < d; ++i) {
            if(bit & (1<<i)) {
                pnt += p[i]*(i+1)*100 + c[i];
                cnt += p[i];
            }
        }
        if(pnt < g) {
            for(int i=d-1; i >= 0; --i) {
                if(!(bit & (1<<i))) {
                    int tmp = 0;
                    while(pnt < g && tmp < p[i] ) {
                        cnt += 1;
                        tmp += 1;
                        pnt += (i+1)*100;
                    }
                }
            }
        }
        ans = min(ans, cnt);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char red[11];
  char blue[11];
  char ans[11];
  int A,B;
  scanf("%s%s%d%d%s",red,blue,&A,&B,ans);
  if(strcmp(red,ans)==0){
    A=A-1;
  }else if(strcmp(blue,ans)==0){
    B=B-1;
  }
  printf("%d %d",A,B);
  return 0;
}
  
  


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

int main(){
    int n, m;
    cin >> n;
    int ans[n]={0};
    rep(i,n-1){
        cin >> m;
        ans[m-1] += 1;
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}

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

#define fi freopen("i.txt", "r", stdin)
#define fo freopen("o.txt", "w", stdout)
#define SIO ios_base :: sync_with_stdio(false); cin.tie(0)
#define fs first
#define sc second
#define cn(a) cin >> a
#define cn2(a, b) cin >> a >> b
#define cn3(a, b, c) cin >> a >> b >> c
#define cn4(a, b, c, d) cin >> a >> b >> c >> d
#define sf(a) scanf("%d", &a)
#define sf2(a, b) scanf("%d %d", &a, &b)
#define sf3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define sf4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define sfl(a) scanf("%lld", &a)
#define sfl2(a, b) scanf("%lld %lld", &a, &b)
#define sfl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define sfl4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define pnl() putchar('\n')
#define fli(i, a, b, c) for(int i = a; i < b; i += c)
#define flie(i, a, b, c) for(int i = a; i <= b; i += c)
#define fls(i, a, b) for(int i = a; i < b; i++)
#define flse(i, a, b) for(int i = a; i <= b; i++)
#define fl(i, n) fls(i, 0, n)
#define fle(i, n) flse(i, 1, n)
#define ll long long
#define ld long double
#define vi vector <int>
#define vll vector <ll>
#define ii pair <int, int>
#define pll pair <ll, ll>
#define iii pair <int, pair <int, int> >
#define lll pair <ll, pair <ll, ll> >
#define vii vector <ii>
#define vpll vector <pll>
#define vlll vector <lll>
#define pb push_back
#define ins insert
#define fr front
#define mp make_pair
#define PI acos(-1.0)
#define INF 10000000
#define LINF 1000000000000
#define piiii pair <ii, ii>
#define sq(a) a * a
#define MOD 1000000007
#define all(x) x.begin(), x.end()
#define gc() getchar()
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define matrixCh vector <vector <char> >
#define matrixInt vector <vector <int> >

int main()
{
    ll arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];

//    if(arr[0] == arr[1] && arr[1] == arr[2])
//    {
//        cout << -1 << endl;
//        return 0;
//    }

    if((arr[0] & 1) || (arr[1] & 1) || (arr[2] & 1))
    {
        cout << 0 << endl;
        return 0;
    }

//    sort(arr, arr + 3);
    ll p = arr[2], s = 0;

    while(true)
    {
        ll x = (arr[1] + arr[2]) / 2LL;
        ll y = (arr[0] + arr[2]) / 2LL;
        ll z = (arr[0] + arr[1]) / 2LL;
        arr[0] = x, arr[1] = y, arr[2] = z;
        ++s;

//        if(arr[0] == arr[1] && arr[1] == arr[2])
//        {
//            cout << -1 << endl;
//            return 0;
//        }

        if((arr[0] & 1) || (arr[1] & 1) || (arr[2] & 1))
        {
            cout << s << endl;
            return 0;
        }

        if(s == 100000)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    return 0;
}

//int main()
//{
//    int a, b, c, i = 0;
//    cin >> a >> b >> c;
//
//    while(!(a & 1) && !(b & 1) && !(c & 1))
//    {
//        int x = (b + c) >> 1;
//        int y = (a + c) >> 1;
//        int z = (a + b) >> 1;
//        a = x, b = y, c = z, i++;
//
//        if(i == 100000)
//        {
//            cout << -1 << endl;
//            return 0;
//        }
//    }
//
//    cout << i << endl;
//    return 0;
//}


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

typedef long long int ll;
#define INF 10000000000000
using namespace std;


int main()
{
	string S, sf, ss;
	

	cin >> S;

	S.pop_back();

	while (true)
	{
		if (S.size() % 2 != 0)
			S.pop_back();
		else
		{
			sf = S.substr(0, S.size() / 2);
			ss = S.substr(S.size() / 2, S.size() / 2);
			if (sf == ss)
			{
				cout << S.size() << endl;
				break;
			}
			else
				S.pop_back();
		}
	}


	return 0;
}

Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int read(){
    register int x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 

string s, t;
int main() {
	cin >> s;
	cin >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
		return  0;
}


Measured memory_bytes: 3820
def m():
    n, k = map(int, input().split())
    ans = 0
    for b in range(1, n+1):
        p = n // b
        r = n % b
        ans += max(b-k, 0) * p
        ans += max(r-k+1, 0)
    if k == 0:
        ans -= n
    return ans

print(m())

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

int main(){
    int r, g, b;  cin >> r >> g >> b;
    if((100*r + 10*g + b)%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
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;}

int main() {
  int N; cin >> N;
  vector<char> A(N);
  rep(i,N) cin >> A[i];

  vector<int> mem(4, 0);
  rep(i,N) {
    if(A[i] == 'G') ++mem[0];
    else if(A[i] == 'W') ++mem[1];
    else if(A[i] == 'Y') ++mem[2];
    else if(A[i] == 'P') ++mem[3];
  }
  int ans = 0;
  rep(i,4){
    if(mem[i]) ++ans;
  }
  printf(ans==4?"Four\n":"Three\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int X,N;
    cin>>X>>N;
    vector<int>p(N);
    for(int j=0;j<N;j++)
    {
    	cin>>p[j];
    }
    sort(p.begin(),p.end());
    auto it=find(p.begin(),p.end(),X);
    auto it2=it;
    int Y=X;
    int Z=X;
    if(it==p.end())
    {
    	cout<<X;
    }
    else
    {
     while((*(it))==X)
     {
     	X--;
     	if((*it)==p[0])
     		break;
     	it=it-1;
     	
     }
    
   while((*(it2))==Y)
   {
   	Y++;
   	if(*(it2)==p[N-1])
   		break;
   	it2=it2+1;
   }
   if(abs(Z-Y)<abs(Z-X))
   {
   	cout<<Y;
   }
   if(abs(Z-Y)>abs(Z-X))
   {
   	cout<<X;
   }
   if(abs(Z-Y)==abs(Z-X))
   {
   	cout<<X;
   }
      	
      }


      }

Measured memory_bytes: 3652
n=int(input())
a=[0]*(10**5)
A=list(map(int,input().split()))
su=0
for i in range(n):
  su+=A[i]
  a[A[i]-1]+=1
q=int(input())
sus=[su]
for i in range(q):
  
  b,c=map(lambda x:int(x)-1,input().split())
  sus.append(sus[-1]+(c-b)*a[b])
  a[c]+=a[b]
  a[b]-=a[b]
  print(sus[-1])
  

Measured memory_bytes: 88052
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((ll)(1e15))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(998244353))
#define xx first
#define yy second
#define NN ((int)(305))
#define N ((int)(1e5 + 5))
#define pq priority_queue
///#define Q queue
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long lu;


typedef tree < pair < int,int >,  null_type,  less < pair < int,int > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;

int x[N], y[N];

int main()
{
    int n, m;
    scanf("%d %d",&n,&m);
    for(int i = 0; i<m; i++) scanf("%d",&x[i]);
    sort(x,x+m);
    if(n>=m) printf("0\n");
    else{
        int ans = x[m-1]-x[0];
        for(int i = 1; i<m; i++){
            y[i] = x[i]-x[i-1];
        }
        sort(y+1,y+m);
        for(int i = m-1; i>=0 && n>1; i--){
            n--;
            ans -= y[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1024
H, W = map(int, input().split())
N = int(input())
A = [int(x) for x in input().split()]
board = [[0] * W for _ in range(H)]
colors = [i + 1 for i in range(N) for _ in range(A[i])]

for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            board[i][j] = colors[i * W + j]
    else:
        for j in range(W):
            board[i][W-j-1] = colors[i * W + j]
for row in board:
    print(*row)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d;
  cin >> a >> b >>c;
  d=c-b;
  if(a<d)cout << "dangerous" << endl;
  else if(0>=d) cout << "delicious" << endl;
  else cout << "safe" << endl;
}
  

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

int main(){
  int N,K,S;
  cin >> N >> K >> S;
  for(int i=0;i<K;i++){
    cout << S;
    if(i!=N-1) cout << " ";
  }
  int A;
  if(S!=1){
    A = S/2+1;
  }
  else{
    A=2;
  }
  for(int i=K;i<N;i++){
    cout << A;
    if(i != N-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int x = Integer.parseInt(in.readLine());
    boolean judge = true;
    
    while(judge) {
      if(judgeNum(x)) {
        judge = false;
        System.out.println(x);
      }
      x++;
    }
  }
  
  private static boolean judgeNum(int x) {
    for(int i=2; i<x/2; i++) {
      if(x%i==0)
        return false;
    }
    return true;
  }
}

Measured memory_bytes: 32704
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(d);

        int cnt = 0;
        if (d[n/2 - 1] == d[n/2]) {
            cnt = 0;
        } else {
            cnt = d[n/2] - d[n/2 - 1];
        }

        System.out.println(cnt);
    }
}

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

using namespace std;

int
main(void){
	int n; cin >> n;
	vector<long long> vec(n);
	for(int i = 0; i < n; i++) cin >> vec[i];
	int ans = 0;
	for(int i = 0; i < n; i++){
		while(vec[i]%2 == 0){
			ans++;
			vec[i] /= 2;
		}
	}
	cout << ans;
}

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


long long int gcd(long long int m,long long int n){
	m=abs(m);
	n=abs(n);
	if(m*n==0){
		return max(m,n);
	}else {
		return gcd(min(m,n),max(m,n)%min(m,n));
	}
}

vector<long long int> pf(long long int n) {
		vector<long long int> res;
		for (long long int i = 2; i*i <= n; i++) if (n%i==0) {
			res.push_back(i);
			while (n%i==0) n /= i;
		}
		if (n!=1) res.push_back(n);
		return res;
}

int main(){
	long long int a,b;
	cin>>a>>b;
	long long int d=gcd(a,b);
	vector<long long int> f=pf(d);
	cout<<f.size()+1<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  h := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&h[i])
  }
  count := 0
  max := h[0]
  for _, v := range h {
    if v >= max {
      max = v
      count++
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)ß
#define pi (acos(-1))
//#define pii pair<int,int>
//#define pll pair<ll,ll>
//#define vec vector
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;
}
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
const int INF = 1001001001;
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(void) {
	int n;
	cin >> n;
	if (n%1000==0){
		cout << 0 << endl;
	}
	else if (n%1000 > 0) {
		cout << 1000 - n%1000 << endl;
	}
	return 0;
}









  






  



Measured memory_bytes: 3628
from collections import deque
import sys

def func(s, array, i, x, y):
  if x < 0 or y < 0 or x >= len(array) or y >= len(array[x]):
    return
  
  if s[x][y] == '#' or array[x][y] != 0:
    return
  
  array[x][y] = i
  func(s, array, index, x+1, y)
  func(s, array, index, x, y+1)
  func(s, array, index, x-1, y)
  func(s, array, index, x, y-1)
  

h,w = map(int,input().split())
c1,c2 = map(int,input().split())
d1,d2 = map(int,input().split())

s = []

for i in range(h):
  s.append(input())
  
array = [[0 for i in range(w)] for i in range(h)]
index = 1
for i in range(len(array)):
  for j in range(len(array[i])):
    if s[i][j] == '.' and array[i][j] == 0:
      func(s, array, index, i, j)
      index += 1

setArray = [set() for i in range(index)]
for i in range(len(array)):
  for j in range(len(array[i])):
    for k in range(max(i-2, 0), min(i+3, len(array))):
      for l in range(max(j-2, 0), min(j+3, len(array[0]))):
        if array[k][l] != 0:
          setArray[array[i][j]].add(array[k][l])

start = array[c1-1][c2-1]
end = array[d1-1][d2-1]

if start == end:
  print(0)
  sys.exit()

deq = deque()
array2 = [True] * index
for v in setArray[start]:
  if array2[v]:
    deq.append((1, v))
    array2[v] = False

while len(deq) != 0:
  tap = deq.popleft()
  if tap[1] == end:
    print(tap[0])
    sys.exit()
    
  for v in setArray[tap[1]]:
    if array2[v]:
      deq.append((tap[0]+1, v))
      array2[v] = False
      
print(-1)

Measured memory_bytes: 153440
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int s=0,h=0;

struct node
{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;



void insert(int);
void inorder(Node );
void preorder(Node);
Node find(Node,int);





#define NIL NULL

Node root;





void insert(int k)
{
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL)
    {
      y=x;
      if(z->key<x->key)x=x->left;
      else  x=x->right;
    }

  z->parent=y;
  if(y==NIL)root=z;
  else
    {
      if(z->key < y->key)y->left=z;
      else y->right =z;
    }
}

void inorder(Node u)
{
  if(u==NIL)return;
  inorder(u->left);

  printf(" %d",u->key);
  inorder(u->right);

}

void preorder(Node u)
{
  if(u==NIL)return;

    
   
 printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
 
}

Node find(Node u,int k)
{
  while(u!=NIL && k!=u->key)
    {
      if(k<u->key)u=u->left;
      else u=u->right;
    }
  return u;
}


int main()
{
  int n,i,x;
  char com[10];

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      scanf("%s",com);
     
      if(strcmp(com,"insert")==0)
	{
	  scanf("%d",&x);
	  insert(x);
	}
      else if(strcmp(com,"print")==0)
	{
	 
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	  
	}
      else if(strcmp(com,"find")==0)
	{
	  scanf("%d",&x);
	  
	  Node w=find(root,x);

	  
	  if(w!=NIL)printf("yes\n");
	  else printf("no\n");
	}
    }

  return 0;
  
}



Measured memory_bytes: 20456
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++){ ;
int main() {
   int a,b,c;
   cin>>a>>b>>c;
   if((a+b+c)%2==0){
   int d=(a+b+c)/2;
   if(a==d||b==d||c==d){
       cout<<"Yes"<<endl;
   }
   else
   cout<<"No"<<endl;
   }
   else
   cout<<"No"<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
const int N = 1e6 + 1,M = 998244353;
int n,sum[N],ans,freq[N];
void add(int &a,int b){
	a+=b;
	if(a >= M)a-=M;
	if(a < 0)a+=M;
}
int power(int base,int to){
	int ret = 1;
	while(to){
		if(to&1)ret = ret*1LL*base%M;
		to>>=1;
		base = base*1LL*base%M;
	}
	return ret;
}
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d",&n);
	for(int i = 0,a;i < n;i++){
		scanf("%d",&a);
		add(freq[a],a);
		add(ans,-a);
	}
	for(int j = N - 1;j;j--){
		for(int k = j;k < N;k+=j)
			add(sum[j],freq[k]);
		sum[j] = sum[j]*1LL*sum[j]%M;
		for(int k = j + j;k < N;k+=j)
			add(sum[j],-sum[k]);
		add(ans,sum[j]*1LL*power(j,M - 2)%M);
	}
	cout << ans*1LL*power(2,M - 2)%M << endl;
}

Measured memory_bytes: 8064
import Text.Printf (printf)
import Data.Complex

format :: Double -> String
format = printf "%.3f"

type Triangle = (Complex Double, Complex Double)

solve :: [Double] -> [Double]
solve [x0,y0,x1,y1,x2,y2] = [px,py,r]
    where
        rv = csc ((x1-x0) :+ (y1-y0),(x2-x0) :+ (y2-y0))
        r = realPart $ abs rv
        (px :+ py) = (x0:+y0) + rv

csc :: Triangle -> Complex Double
csc (x0:+y0,b@(x1:+y1)) = b/2 + l * (y1 :+ (-x1)) where
    s0 = x0^2 + y0^2 - x0*x1 - y0*y1
    s1 = x0*y1 - x1*y0
    l = (s0/(2*s1)) :+ 0


main = getContents >>=
    mapM_ (putStrLn . unwords . map format . solve . map read . words)
        . tail . lines

Measured memory_bytes: 4484
#include <iostream>
#include <cmath>

using namespace std;

int isPrime(int a) {
    int sqrt = sqrtl(a);
    for (int i = 2; i <= sqrt; ++i) {
        if (a % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {
    int n;
    cin >> n;
    int count = 0;

    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (isPrime(a)) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	string a;

	cin >> a;
	int k = 0;
	k = a.size();

	for (int i = k; i > 0; i--)
	{
		cout << a.substr(i - 1,1);
	}
	cout << endl;
}


Measured memory_bytes: 3032
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
int n; cin>>n;
int a[n];
set<int> trash;
rep(i,n){
    cin>>a[i];
    trash.insert(a[i]);
}
if(trash.size()==n)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <string>
using namespace std;
bool bOk(string);
bool bLower(char);

int main()
{
	string s;
	cin>>s;
	if(bOk(s))
		cout<<"AC"<<endl;
	else
		cout<<"WA"<<endl;
	return 0;
}

bool bLower(char c)
{
	if (c>='a' && c<='z')
		return true;
	return false;
}

bool bOk(string s)
{
	int n=s.length(),m=0,x=0;
	if(s[0]!='A' || !bLower(s[1]) || !bLower(s[n-1]))
		return false;
	for(int i=2;i<n-1;i++){
		if(s[i]=='C')
			m++;
		if(bLower(s[i]))
			x++;
	}
	if(m!=1)	return false;
	if(m+x!=n-3)return false;
	return true;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long k;
    cin>>n;
    cin>>k;
    int arr[200005];
    for(int i=0;i<n;i++)cin>>arr[i];
    int des=0;
    unordered_map<int,int>m;
    int cnt=0;
    while(m.count(des)==0){
        if(k==0){
            cout<<des+1;
            return 0;
        }
        m[des]=cnt;
        k--;cnt++;
        des=arr[des]-1;
    }
    int p=cnt-m[des];
    k%=p;
    while(k!=0){
        des=arr[des]-1;
        k--;
    }
    cout<<des+1;
    return 0;
}



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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

string s[555];

int main() {
	li w, h;
	cin >> h >> w;
	rep(i, h)cin >> s[i];

	// red
	rep(i, w)cout << "#"; cout << endl;
	repp(i, 1, h - 1) {
		rep(j, w) {
			cout << ((s[i][j] == '#' || j % 2 == 0) ? '#' : '.');
		} cout << endl;
	}
	rep(i, w)cout << "."; cout << endl;
	puts("");

	// blue
	rep(i, w)cout << "."; cout << endl;
	repp(i, 1, h - 1) {
		rep(j, w) {
			cout << ((s[i][j] == '#' || j % 2 == 1) ? '#' : '.');
		} cout << endl;
	}
	rep(i, w)cout << "#"; cout << endl;


	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll len = accumulate(a, a + n, (ll) 0);
    ll pre = 0;
    ll ans = LONG_LONG_MAX;
    for (int i = 0; i < n; i++) {
        len -= a[i];
        ll dif = abs(pre - len);
        if (a[i] >= dif) ans = min(ans, a[i] - dif);
        pre += a[i];
    }

    cout << ans;


}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <iomanip>
using namespace std;
const long mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<long> sum(26, 0);
    for(int i = 0; i < N; i++){
        sum[S[i] - 'a']++;
    }
    long ans = 1;
    for(int i = 0; i < 26; i++){
        ans = (ans * (sum[i] + 1)) % mod;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
}

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

int n, k;
string s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k >> s;
	s[k-1] = s[k-1] - 'A' + 'a';
	cout << s << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9){
        cout << "hon";
    }else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        cout << "pon";
    }else if (n % 10 == 3){
        cout << "bon";
    }
    return 0;
}


Measured memory_bytes: 3548
n,k = map(int,input().split())
S = input()

C = []

count = 0
dotti = S[0]
ans = 0

for i in range(n):
    if dotti != S[i]:
        count += 1
        dotti = S[i]
    if S[i] == "R" and i < n-1: 
        if S[i+1] == "R":
            ans += 1
    elif S[i] == "L" and i > 0: 
        if S[i-1] == "L":
            ans += 1

while k > 0:
    if count >= 2:
        ans += 2
        count -= 2
    elif count == 1:
        ans += 1
        count -= 1
        break
    else:
        break
    k -= 1

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	ll k = N,s=0;
	rep(i, 11) {
		s += k % 10;
		k /= 10;
	}
	if (N % s == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    ll a; cin >> a;
    ll res = a + a*a + a*a*a;
    out(res);
}

Measured memory_bytes: 3644
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] s = new int[n];
    for(int i = 0; i < n; i++){s[i] = sc.nextInt();}
    int q = sc.nextInt();
    int[] t = new int[q];
    int cnt = 0;
    for(int i = 0; i < q; i++){
      t[i] = sc.nextInt();
      if(binary(s, t[i], n)){cnt++;}
    }
    System.out.println(cnt);
  }

  public static boolean binary(int[] s, int target, int n){
    int left = 0;
    int right = n;
    int mid = 0;

    while(left < right){
      mid = (left + right) / 2;
      if(target == s[mid]){return true;}
      if(target > s[mid]){left = mid + 1;}
      else if(target < s[mid]){right = mid;}
    }

    return false;
  }
}



Measured memory_bytes: 68356
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)


int main() {
  string s;
  ll k;
  cin >> s >> k;
  int n = (int)s.size();
  int i = 0;
  while (i < n && s[i] == '1') ++i;
  int last = s[i] - '0';

  if (i < k)
    cout << last << endl;
  else
    cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
typedef unsigned long long ullong;

ullong gcm(ullong a,ullong b){
    ullong m = a%b;
    while(m){
        a = b;
        b = m;
        m = a%b;
    }
    return b;
}

int main(){
  ullong a,b,g;
  while(scanf("%lld %lld",&a,&b)!=EOF){
    g = gcm(a,b);
    printf("%lld %lld\n",g,(a*(b/g)));
  }
}

Measured memory_bytes: 1024
object Main extends App {
val n = scala.io.StdIn.readInt
val s = scala.io.StdIn.readLine

var max_cnt = 0
for (i<-0 to n) {
  val mae = s.take(i).distinct.toList
  val ato = s.drop(i)
    
  var cnt = 0
  for (m <- mae) {
      if (ato.indexOf(m)>=0) cnt += 1
  }
  if (cnt > max_cnt) max_cnt = cnt
}
    println(max_cnt)
}

Measured memory_bytes: 27452
import math

# 半分より少ない場合

a,b,x = map(int, input().split(" "))



if x < a**2 * b * 0.5:

    rad = math.atan2(b, (2*x)/(a*b))

    dig = rad / math.pi * 180

    print(dig)

#半分より多い場合
else:
    
    rad = math.atan2(a, (2*(a*a*b - x))/(a*a))

    dig = 90 - rad / math.pi * 180

    print(dig)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sm = 0;
  int n;
  int a;
  cin >> n;
  REP(i,n){
      cin >> a;
      sm += a;
      sm = sm % 2;
  }
  if (sm==0)cout << "YES" << endl;
  else cout << "NO" << endl;
}


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


int32_t main()
{

	
	int n;cin>>n;
	string str; cin>>str;
	int cnt=1;
	for (int i = 1; i < n; ++i)
	{
		if(str[i]!=str[i-1]) cnt++;
	}
	cout<<cnt<<endl;
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
const ll MOD = 1e9+7;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    FOR(i, h)
        cin >> s[i];

    vector<vector<int>> a(h, vector<int>(w, 0)), b(h, vector<int>(w, 0)),
            c(h, vector<int>(w, 0)), d(h, vector<int>(w, 0));

    FOR(i, h){
        int x = -1;
        FOR(j, w){
            if (s[i][j]=='#'){
                x = j;
            }
            else{
                a[i][j] = j-x;
            }
        }
        x = w;
        FORI(j, w){
            if (s[i][j]=='#'){
                x = j;
            }
            else{
                b[i][j] = x-j;
            }
        }
    }
    FOR(j, w){
        int x = -1;
        FOR(i, h){
            if (s[i][j]=='#'){
                x = i;
            }
            else{
                c[i][j] = i-x;
            }
        }
        x = h;
        FORI(i, h){
            if (s[i][j]=='#'){
                x = i;
            }
            else{
                d[i][j] = x-i;
            }
        }
    }

    int sol = 0;
    FOR(i, h){
        FOR(j, w){
            sol = max(sol, a[i][j]+b[i][j]+c[i][j]+d[i][j]);
        }
    }
    cout << sol-3 << '\n';

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 69376