akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){

    int icenum;
    int ice[10] = {0};    

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

    for( int i = 0 ; i < 10 ; i++ ){
      int I = ice[i];
      if(I){
	for( int j = 0 ; j < I ; j++ ){
	  cout << "*";
	    }
      }
      else cout << "-";
      cout << endl;
    }
  
  }
  return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long K) {
    int a = N % K;
    int b = (K - a);
    cout << min(a, b) << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C4Adjacent solver = new C4Adjacent();
        solver.solve(1, in, out);
        out.close();
    }

    static class C4Adjacent {
        private static final String YES = "Yes";
        private static final String NO = "No";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            int x = 0, y = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] % 4 == 0) {
                    x++;
                } else if (a[i] % 2 == 1) {
                    y++;
                }
            }
            if (y <= x || (y <= x + 1 && x + y == n)) {
                out.println(YES);
            } else {
                out.println(NO);
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 39172
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    int N; cin >> N;

    map<int,int> mp;
    REP(i,N){
        int a; cin >> a;
        mp[a]++;
    }

    int cnt =0;
    for(auto x:mp){
        if(x.second%2 == 1) cnt ++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll u_int64_t
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
 
int main() {
	int a, b, h, m;
	double th_a, th_b;
	cin >> a >> b >> h >> m;
	th_a = 2*PI*(double(60*h+m)/720);
	th_b = 2*PI*(double(m)/60);
	double dx, dy, d;
	dx = a*cos(th_a) - b*cos(th_b);
	dy = a*sin(th_a) - b*sin(th_b);
	d = sqrt(dx*dx+dy*dy);
	printf("%.20f\n", d);
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

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

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int x, y, z, k;

  cin >> x >> y >> z >> k;
  vi a(x);
  REP(i, x) {
    cin >> a[i];
  }
  RSORT(a);
  vi b(y);
  REP(i, y) {
    cin >> b[i];
  }
  RSORT(b);
  vi c(z);
  REP(i, z) {
    cin >> c[i];
  }
  RSORT(c);
  vi ans;
  REP(i, x) {
    REP(j, y) {
      if ((i + 1) * (j + 1) > 3000) break;
      REP(k, z) {
        if ((i + 1) * (j + 1) * (k + 1) > 3000) break;
        ans.pb(a[i] + b[j] + c[k]);
      }
    }
  }
  RSORT(ans);
  REP(i, k)cout << ans[i] << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 1656
import sys
from collections import deque

# txt = "100000"
# for i in range(99999):
#     txt += "\n" + str(i) +" " +  str(i+1)
# def i():
#     for l in txt.split("\n"):
#         yield l
# input = i().__next__
def main():
    N = int(input())
    mawari = [[] for _ in range(N)]
    e_num = [0] * N 
    for l in range(N-1):
        i, j = [int(x)-1 for x in input().split()]
        e_num[i] += 1
        e_num[j] += 1
        mawari[i].append((j, l))
        mawari[j].append((i, l))
    look = -1
    for ind, l in enumerate(e_num):
        if l == 1:
            look = ind
            break
    color = [-1]*(N-1)
    c_prev = deque([-1])
    to_visit = deque([look])
    maxc = 0
    while len(to_visit)>=1:
        look = to_visit.pop()
        c = 0
        prevc = c_prev.pop()
        for i,j in mawari[look]:
            if color[j] != -1:
                continue
            if c == prevc:
                c += 1
            color[j] = c
            c_prev.append(c)
            to_visit.append(i)
            maxc = max(maxc, c)
            c += 1
        
    # mc, c = a(N, 0, look, color, mawari, -1)
    print(maxc+1)
    for i in color:
        print(i+1)


# def a(N, maxc, look, color, mawari, prev):
#     nexts = mawari[look]
#     c = 0
#     for i,j in nexts:
#         if c == prev:
#             c += 1
#         color[j] = c
#         maxc = max(maxc, a(N, maxc, i, color, mawari, c)[0])
#         c += 1
#     return maxc, color
    

main()

Measured memory_bytes: 39932
/*      Abhijith    */
#include<bits/stdc++.h>
#include<iomanip>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
     lld n,k;
     cin>>n>>k;
     vector<lld> l(k),r(k);
     rep(i,0,k-1)
     {
         cin>>l[i]>>r[i];
     }
     lld ans=*min_element(all(r))-*max_element(all(l))+1;
     cout<<max(ans,(lld)0)<<endl;
    return 0;
}


Measured memory_bytes: 1792
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second


  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
     long long int a[n],cons=1000000000+7,s=0,ans=0;
    for(int i=0; i<n; i++){
    	cin>>a[i];
    }
    s=0;
    for(int i=n-1; i>=0; i--){
       ans+=a[i]*s;
       s+=a[i];
       ans%=cons;
       s%=cons;
    }
    cout<<ans%cons<<endl;
    return 0;
  }

Measured memory_bytes: 5184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

string s[2000];
int l[2001][2001];
int r[2001][2001];
int u[2001][2001];
int d[2001][2001];

int main(){
	int h,w;
	cin >> h >> w;
	
	for(int i=0;i<h;i++) cin >> s[i];

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				l[i][j] = 0;
			}else if(j==0){
				l[i][j] = 1;
			}else if(j>0){
				l[i][j] = l[i][j-1]+1;
			}
		}
		for(int j=w-1;j>=0;j--){
			if(s[i][j]=='#'){
				r[i][j] = 0;
			}else if(j==w-1){
				r[i][j] = 1;
			}else if(j<w-1){
				r[i][j] = r[i][j+1]+1;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				u[i][j] = 0;
			}else if(i==0){
				u[i][j] = 1;
			}else if(i>0){
				u[i][j] = u[i-1][j]+1;
			}
		}
	}
	for(int i=h-1;i>=0;i--){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				d[i][j] = 0;
			}else if(i==h-1){
				d[i][j] = 1;
			}else if(i<h-1){
				d[i][j] = d[i+1][j]+1;
			}
		}
	}
	int ans = 0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ans = max(ans, l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 66944
#include<iostream>

using namespace std;

long long gcd(long long a, long long b){
    long long r = a % b;
    if(r == 0){
        return b;
    } else {
        return gcd(b, r);
    }
}

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

long long min(long long a, long long b){
    return a < b ? a : b;
}

long long max(long long a, long long b){
    return a > b ? a : b;
}

int main() {
    long long A, B, C, D;

    cin >> A >> B >> C >> D;

    long long min_num = min(C, D);
    long long max_num = max(C, D);
    long long lcm_num = lcm(max_num, min_num);

    long long calc1 = (A - 1) / C + (A - 1) / D - (A - 1) / lcm_num;
    long long calc2 = B / C + B / D - B / lcm_num;

    long long ans = B - (A - 1) - (calc2 - calc1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define ll long long
const int mod=1e9+7;
const int mxN=2e5;
ll a[mxN+1];
int main(){
	int n;
	cin>>n;
	ll s=0;
	for(int i=0;i<n;i++){
        cin>>a[i];
        s=(s+a[i])%mod;
	}
	ll ans=0;
	for(int i=0;i<n;i++){
        s=(s-a[i]+mod)%mod;
        ans=(ans+s*a[i])%mod;
	}
	cout<<ans;
}


Measured memory_bytes: 5116
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}

map<int, ll> m;

void solve(){
    int n;
    ll k;
    cin >> n >> k;

    rep(i,n){
        int a,b;
        cin >> a >> b;
        m[a] += b;
    }

    for(auto it = m.begin(); it != m.end(); it++) {
        if ( k > it->second ) {
            k -= it->second;
        } else {
            cout << it->first << endl;
            break;
        }
    }
}

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


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define P acos(-1)
int main() {
  double x;
  scanf("%lf",&x);
  printf("%.10f",2*P*x);
 	return 0;
}

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

struct unionfindtree {
    vector<int> parent;

    unionfindtree(int size): parent(size) {
        iota(begin(parent), end(parent), 0);
    }

    void unite(int a, int b) {
        if ((a = find(a)) == (b = find(b))) return;
        parent[b] = a;
    }

    int find(int a) {
        return (parent[a] == a ? a : parent[a] = find(parent[a]));
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    for (auto& e : p) cin >> e;
    unionfindtree uft(n+1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        uft.unite(x, y);
    }

    int ans = 0;
    map<int, pair<vector<int>, vector<int>>> groups;
    for (int i = 0; i < n; i++) {
        int pp = uft.find(p[i]);
        groups[pp].first.push_back(p[i]);
        groups[pp].second.push_back(i+1);
    }
    for (auto& e : groups) {
        vector<int> tmp;
        sort(begin(e.second.first), end(e.second.first));
        set_intersection(begin(e.second.first), end(e.second.first), begin(e.second.second), end(e.second.second), back_inserter(tmp));
        ans += tmp.size();
    }

    cout << ans << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

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

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

  int dp[n];
  rep(i,n)dp[i] = INF;
  dp[0] = 0;

  for(int i = 1;i < n;i++){
    for(int j = max(0,i-k);j < i;j++){
      dp[i] = min(dp[i],dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 4408
#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(v) (v).begin(),(v).end()

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

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

const ll INF = 1ll<<61;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	
	if (*(a.end() - 1) == b[0] && *(b.end() - 1) == c[0]) puts("YES");
	else puts("NO");
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
#define int long long int
int32_t main() {
    
    int n;
    cin>>n;
    int a[n];
    int x=1000000007;
    for(int i=0;i<n;i++)
   {
       cin>>a[i];
      // s+=a[i];
   }
  // s=s*s;
    int sum[n],s=0;
    for(int i=n-1;i>=0;i--)
    {
      s=s+a[i];
      sum[i]=s;
      
      //sum=sum+(a[i]*a[i]);
        //sum[i]=s;
    }
  int ss=0,si=0;
  for(int i=0;i<=n-2;i++)
    {
      si=((a[i]%x)*(sum[i+1]%x))%x;
      ss=ss%x+si%x;
      //sum=sum+(a[i]*a[i]);
        //sum[i]=s;
    }
    ss=ss%x;
    
    cout<<ss;
    
    return 0;
}


Measured memory_bytes: 6700
N=int(input())
S=input()
T=''
a='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(len(S)):
    for j in range(26):
        if S[i]==a[j]:
            T+=a[j+N]
print(T)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    vector<int> vs(N);
    for(int i = 0; i < N; i++){
        vs[i] = In<int>();
    }
    sort(vs.begin(), vs.end());
    double ans = vs[0];
    for(auto v : vs) ans = (ans + v)/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		var s = Console.ReadLine();
		var t = Console.ReadLine();

		var d = Enumerable.Range('a', 26).ToDictionary(x => (char)x, x => new List<int>());
		for (var i = 0; i < s.Length; i++) d[s[i]].Add(i);

		int turn = 0, si = -1;
		foreach (var c in t)
		{
			if (!d[c].Any()) { Console.WriteLine(-1); return; }

			var ci = d[c].BinarySearch(si + 1);
			if (ci < 0) ci = ~ci;
			if (ci < d[c].Count)
			{
				si = d[c][ci];
			}
			else
			{
				turn++;
				si = d[c][0];
			}
		}
		Console.WriteLine((long)s.Length * turn + si + 1);
	}
}


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

int main() {
 int n,k,i; cin >> n >> k;
 string s; cin >> s;
 int a[n];
 rep(i,n) a[i]=(s[i] == 'R')?1:0;
 int cnt = 0;
 for(i=0;i<n;i++){
   if(a[i]==0){
    if(i==0) continue;
    (a[i]==a[i-1])?cnt++:0;
   }else{
     if(i==n-1) continue;
     (a[i]==a[i+1])?cnt++:0;
   }
 }
 cout << min(n-1,cnt+k*2);
}


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

#define pie 3.14159265

int main(void)
{
	int a, b, C;
	double S, L, h, c;

	scanf("%d %d %d", &a, &b, &C);

	S = ((((a * b)) * sin((C / 180.0) * pie) / 2.0));

	c = sqrt(((a * a) + (b * b)) - ((2 * a) * (b * cos((C / 180.0) * pie))));
	
	L = (a + b) + c;

	h = (2 * S) / (double)a;

	printf("%f %f %f\n", S, L, h);

	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
using namespace std;
int main() {
	int H, W;
	string Mine[50];
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		cin >> Mine[i];
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (Mine[i][j] != '#') {
				Mine[i][j] = '0';
				if (i < H - 1 && Mine[i + 1][j] == '#') {
					++Mine[i][j];
				}
				if (i != 0 && Mine[i - 1][j] == '#') {
					++Mine[i][j];
				}
				if (j < W - 1 && Mine[i][j + 1] == '#') {
					++Mine[i][j];
				}
				if (j != 0 && Mine[i][j - 1] == '#') {
					++Mine[i][j];
				}
				if (i < H - 1 && j < W - 1 && Mine[i + 1][j + 1] == '#') {
					++Mine[i][j];
				}
				if (i < H - 1 && j != 0 && Mine[i + 1][j - 1] == '#') {
					++Mine[i][j];
				}
				if (i != 0 && j < W - 1 && Mine[i - 1][j + 1] == '#') {
					++Mine[i][j];
				}
				if (i != 0 && j != 0 && Mine[i - 1][j - 1] == '#') {
					++Mine[i][j];
				}
			}
			cout << Mine[i][j];
		}
		cout << endl;
	}
}

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

typedef long long ll;
const int N = 1e5 + 10;
ll n, s[N], a[N], b[N], ans;  // a[i] 存的是 s[i] 的最简数，b[i] 是 a[i] 的补数
map<ll, int> num;
map<ll, bool> vis;
int mark[N], p[N], tot;  // 10^{10/3} 以内质数有 326 个，10^{10/3}~10^5 以内质数有 9267 个

void euler(int n) {
    rep(i, 2, n) {
        if (!mark[i]) p[++tot] = i;
        for (int j = 1; j <= tot && p[j] * i <= n; j++) {
            mark[p[j] * i] = 1;
            if (i % p[j] == 0) break;
        }
    }
}

int main() {
    euler(100000);
    cin >> n;
    rep(i, 1, n) scanf("%lld", &s[i]);

    ll k, tmp;
    rep(i, 1, n) {
        k = s[i]; a[i] = b[i] = 1;
        rep(j, 2, 2200) {  // 2200 ^ 3 约等于 1e10
            if (k == 1) break;
            if (mark[j]) continue;

            tmp = 1ll * j * j * j;
            while (k % tmp == 0) k /= tmp;  // 简化
            tmp = 1ll * j * j;
            if (k % tmp == 0) a[i] *= tmp, b[i] *= j;
            else if (k % j == 0) a[i] *= j, b[i] *= tmp;
            while (k % j == 0) k /= j;
            // printf("%d %lld %lld %lld ?\n", j, a[i], b[i], k);
        }
        if (k > 1) {
            tmp = (ll)sqrt(k);
            if (tmp * tmp == k) a[i] *= k, b[i] *= tmp;
            else a[i] *= k, b[i] *= k * k;
        }
        // printf("%lld %lld !\n", a[i], b[i]);
    }
    rep(i, 1, n) num[a[i]]++;
    rep(i, 1, n) {
        if (vis[a[i]]) continue;
        vis[a[i]] = vis[b[i]] = 1;
        ans += (a[i] == b[i] ? 1 : max(num[a[i]], num[b[i]]));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 28032
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<pair<string,int> > v(n);
    rep(i,n){
        cin>>v[i].fi>>v[i].sec;
    }    
    string x;
    cin>>x;
    int pos = n;
    ll ans = 0;
    rep(i,n){
        if(v[i].fi == x){
            pos = i;
            break;
        }
    }
    repa(i,pos+1,n){
        ans += v[i].sec;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef pair<double, double> pdd;

const double EPS = 1e-10;

const double INF = DBL_MAX / 2.0;

bool equals(double a, double b){
	return abs(a-b) < EPS;
}

int n;
vector<pdd> v;
int iter = 100;

double f(double x, double y){
	double r = 0.0;
	rep(i, n) {
		double a = v[i].fi, b = v[i].se;
		r = max(r, hypot(x - a, y - b));
	}
	return r;
}

double g(double x){
	double left = -1000.0, right = 1000.0;
	rep(i, iter){
		double m1 = (left * 2 + right) / 3;
		double m2 = (left + right * 2) / 3;
		if(f(x, m1) > f(x, m2)) left = m1;
		else right = m2;
	}

	return f(x, left);
}

double solve(){
	double left = -1000.0, right = 1000.0;
	rep(i, iter){
		double m1 = (left * 2 + right) / 3;
		double m2 = (left + right * 2) / 3;
		if(g(m1) > g(m2)) left = m1;
		else right = m2;
	}
	
	return g(left);
}

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

	cin >> n;

	v.resize(n);
	rep(i, n){
		double x, y;
		cin >> x >> y;
		v[i] = {x, y};
	}
	
	cout << fixed << setprecision(10);
	cout << solve() << endl;
}


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

inline int qr()
{
    int s=0,f=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
    return s*f;
}

int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
	long long k=n/(a+b);
	long long s=n-k*(a+b);
	long long ans=k*a+min(s,a);
	cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<ll> b(n);
  rep(i,n){
      cin >> b[i];
  }
  stack<ll> ans;
  while(b.size()){
      repr(j,b.size()-1){
          if(b[j] == j+1){
              ans.push(j+1);
              b.erase(b.begin() + j);
              break;
          }
          if(j==0){
              cout << -1 << endl;
              return 0;
          }
      }
   }
  rep(i,n){
      ll tmp = ans.top();
      ans.pop();
      cout << tmp << endl;
  }


}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse", "sse2", "avx", "avx2")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int mod = 1e9 + 7;
const int K = 120;



signed main() {
    accell();
    int n;
    cin >> n;
    int s = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (int k = 1; k <= n; ++k) {
                s += __gcd(__gcd(i, j), k);
            }
        }
    }
    cout << s;
    return 0;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll X; cin >> X;
    ll res = 0;
    res += (X / 500) * 1000;
    res += ((X % 500) / 5) * 5;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int ans=0;
  int N;
  cin>>N;
  vi A(N);
  int sum=0;
  rep(i,0,N){
    cin>>A[i];
    sum+=A[i];
  }
  int av=sum/N;
  rep(i,0,N){
    int X=A[i]-av;
    ans+=X*X;
  }
  sum=0;
  av++;
  rep(i,0,N){
    int X=A[i]-av;
    sum+=X*X;
  }
  ans=min(ans,sum);
  cout<<ans<<endl;
  }



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

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

using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> H(N);

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

  int max=0;
  int ans=0;
  for(auto h:H)
  {
    if(h>=max)
    {
      max = h;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,k; string s;
    cin>>n>>s>>k;
    char c=s[k-1];
    rep(i,n){
        if(s[i]!=c)s[i]='*';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n,x,y,b,p,planA,planB;
int main(){
  cin>>n;
  while(n--){
    cin>>x>>y>>b>>p;
    planA=(max(5,b)*x+max(2,p)*y)*4/5;
    planB=b*x+p*y;
    cout<<min(planA,planB)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    int N,A,B;
    string s;
    
    cin >> N >> A >> B;
    cin >> s;
    
    int n_a = 0;
    int n_b = 0;
    
    for(int i = 0 ; i < N ; i++ ){
        if( s[i] == 'a' ){
            if( n_a + n_b < A + B ){
                n_a++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else if( s[i] == 'b' ){
            if( n_a + n_b < A + B && n_b < B){
                n_b++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
    
    return 0;
}

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

a=list(map(int,input().split()))

l=[1]
di={}
di[1]=1

for i in a:
    b=a[l[-1]-1]
    if b in di:
        x=b
        break
    l.append(b)
    di[b]=1
aa=0
for j in l:
    if j==x:
        break
    else:
        aa+=1

bb=len(l)-aa
if k<=aa:
    print(l[k])

else:
    cc=(k-aa)%bb
    print(l[aa+cc])


Measured memory_bytes: 35424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A;
  cin >> A;
  
  if(A[0]<A[1] ||((A[0]==A[1])&&(A[0]<A[2]))){
    cout << ((atoi(A.c_str())+1)/100+1)*111 << endl;
  }
  else{
    cout << (atoi(A.c_str())/100)*111 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int union_find[2000000];
int union_check(int a){
    if(union_find[a] == a) return a;
    return union_find[a] = union_check(union_find[a]);
}
int union_merge(int a,int b){
    a = union_check(a);
    b = union_check(b);
    union_find[a] = b;
}
int main(){
    int n,query;
    cin >> n >> query;
    REP(i,n){
        union_find[i] = i;
    }
    REP(i,query){
        int a,b,c;
        cin >> a >> b >> c;
        if(a == 0) union_merge(b,c);
        else{
            if(union_check(b) != union_check(c)){
                cout << 0 << endl;
            }else cout << 1 << endl;
        }
    }
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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


	int ans[27];
	memset(ans, 0, sizeof(ans));

	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		ans[s[i]-'a']++;
	}

	for (int i = 1; i < n; i++) {
		cin >> s;

		int a[27];
		memset(a, 0, sizeof(a));

		for (int i = 0; i < s.size(); i++) {
			a[s[i]-'a']++;
		}

		for (int i = 0; i < 27; i++) {
			if (a[i]>0 && ans[i]>0) {
				ans[i] = min(ans[i], a[i]);
			} else if (a[i]==0) {
				ans[i] = 0;
			}
		}
	}

	string al = "abcdefghijklmnopqrstuvwxyz";

	string ret;
	for (int i = 0; i < 27; i++) {
		if (ans[i]>0) {
			for (int j = 0; j < ans[i]; j++) {
				ret += al[i];
			}
		}
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
from math import ceil
N = int(input())
X = list(map(int, input().split()))
# N=2
# X=[1,4]
x = (sum(X)/N)
kouho = [int(x), ceil(x)]
ans = [0,0]
for k in range(len(kouho)):
    for i in range(N):
        ans[k] += (X[i]-kouho[k])**2
print(min(ans))

Measured memory_bytes: 3064
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll x,k,d;
	cin >> x >> k >> d;
	ll a, b, index;
	if (x >= 0) {
		a = x - x / d * d;
		b = x - x / d * d - d;
		index = min(abs(a), abs(b));
		if (index == abs(a)) {
			index = a;
		}
		else {
			index = b;
		}
		
	}
	else {
		a = x + abs(x) / d * d;
		b = x + abs(x) / d * d+ d;
		index = min(abs(a), abs(b));
		if (index == abs(a)) {
			index = a;
		}
		else {
			index = b;
		}
	}
	
	ll count = (abs(x - index)) / d;
	
	
	if (count > k) {
		cout << abs(abs(x) - d * k) << endl;
	}
	else {
		if (k % 2 == count%2) {
			cout << abs(index) << endl;
		}
		else {
			cout << min(abs(index - d), abs(index + d)) << endl;
		}
	}
	return 0;
}

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

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int nums=sc.nextInt();
		int[] arr=new int[nums];
		for(int i=0;i<nums;i++) {
			arr[i]=sc.nextInt();
		}
		Arrays.sort(arr);
		
		int count=arr[nums/2]-arr[nums/2-1];
		System.out.println(count);
	}
}


//1 4 4 6 7 9
//
//1 4 4 5 5 9 14 14



Measured memory_bytes: 50216
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
 
#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double
 
#define pii   pair<int, int>
#define piii  pair<int, pair<int, int>>
#define pll   pair<ll, ll>
 
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
 
#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename T>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}
 
// add templates here

template<class T>
void println(const vector<T> &data) {
    cout << to_string<vector<T>, T>(data) <<endl;
}
 
template<class T>
void println(const T &data) {
    cout << to_string((T)data) << endl;
}
 
const int MOD = int(1e9+7);
const int oo  = int(1e9 + 20);
const ll lloo  = (ll)(1e18 + 10);

int toInt(char num) {
    return num - '0';
}

void solve() {
    string n;
    cin >> n;
    
    for(int i = 1; i < n.size(); ++i) {
        if(abs(toInt(n[i]) - toInt(n[i-1])) == 0) {
            cout << "Bad" << endl;
            return;
        }
    }
    cout << "Good" << endl;
}

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

Measured memory_bytes: 3648
/*
[abc150] F - Xor Shift
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2e5;
const int MAX_B = 30;

const int MAX_PAT = MAX_N;
const int MAX_TXT = MAX_N * 2;

typedef bitset<MAX_B> B;

int N;
B a[MAX_N], b[MAX_N];

int table[MAX_PAT + 1];
bool matched[MAX_TXT];

void kmp(const vector<B> &txt, const vector<B> &pat) {
    int n = txt.size(), m = pat.size();

    table[0] = -1;
    for (int i = 0, j = -1; i < m; i++) {
        while (j >= 0 && pat[i] != pat[j]) {
            j = table[j];
        }
        table[i + 1] = ++j;
    }

    for (int i = 0, j = 0; i < n; i++) {
        while (j >= 0 && txt[i] != pat[j]) {
            j = table[j];
        }
        if (++j >= m) {
            matched[i - m + 1] = true;
            j = table[j];
        }
    }
}

void solve() {
    vector<B> c(2 * N), d(N);
    for (int i = 0; i < 2 * N; i++) {
        c[i] = a[i % N] ^ a[(i + 1) % N];
    }
    for (int i = 0; i < N; i++) {
        d[i] = b[i % N] ^ b[(i + 1) % N];
    }

    kmp(c, d);

    for (int i = 0; i < N; i++) {
        if (!matched[i]) {
            continue;
        }
        cout << i << " " << (a[i] ^ b[0]).to_ulong() << endl;
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        a[i] = B(ai);
    }
    for (int i = 0; i < N; i++) {
        int bi;
        cin >> bi;
        b[i] = B(bi);
    }

    solve();

    return 0;
}


Measured memory_bytes: 12288
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
using namespace std;

int INF=1e9;

int main(void){
    int n,m,r;
    cin>>n>>m>>r;
    vector<int> R(r);
    for(int i=0;i<r;i++){
        cin>>R[i];
    }
    
    sort(R.begin(),R.end());
    
    int w[300][300];//コスト
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            w[i][j]=INF;
            if(i==j)w[i][j]=0;
        }
    }
    
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        w[a][b]=c;
        w[b][a]=c;
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                w[i][j]=min(w[i][j],w[i][k]+w[k][j]);
            }
        }
    }
    
    int ans=INF;
    
    do{
        int sum=0;
        
        for(int i=0;i<r-1;i++){
            sum+=w[R[i]][R[i+1]];
        }
        
        ans=min(ans,sum);
        
    }while(next_permutation(R.begin(),R.end()));
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 512
//110
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include <vector>
using namespace std;

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

    int ans = 0;
    if(A >= B && A >= C){
        ans = A*10+B+C;
    }else if(B >= A && B >= C){
        ans = B*10 + A + C;
    }else{
        ans = C*10 + A + B;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MAXN 100100
#define ll unsigned long long
ll n, m, cnt, A, B, C, D, t, ans;
map<ll, ll> dp; 
ll solve(ll u)
{
	if(u == 1) return D;
	if(u == 0) return 0;
	if(dp[u] != 0) return dp[u];
	ll Min = u*D;
	Min = min(Min, solve((u-u%2)/2) + A + u%2*D);
	if(u%3 <= 1) Min = min(Min, solve((u-u%3)/3) + B + u%3*D);
	else Min = min(Min, solve((u+3-u%3)/3) + B + (3-u%3)*D);
	if(u%5 <= 3)Min = min(Min, solve((u-u%5)/5) + C + u%5*D);
	if(u%5 >= 3) Min = min(Min, solve((u+5-u%5)/5) + C + (5-u%5)*D);
	if(u%2 != 0) Min = min(Min, solve((u+2-u%2)/2) + A + (2-u%2)*D);
	dp[u] = Min;
	return Min;
}
int main()
{
	scanf("%lld",&t);
	while(t--)
	{
		dp.clear();
//		memset(dp, 0, sizeof(dp));
		scanf("%lld",&n);
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		ans = solve(n);
		printf("%lld\n",ans);
	}
	
	
	return 0;
}

Measured memory_bytes: 4600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[] = new int[n];

		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		int point =0;
		int cnt=0;
		int check=1;
		for(int i=0;i<n;i++) {
			if(check==a[i]) {
				cnt+=i-point;
				point=i+1;
				check+=1;
			}
		}
		if(point!=n) cnt+=n-point;

		if(check==1)System.out.println("-1");
		else System.out.println(cnt);
	}
}

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

int main(){
  int N;
  cin >> N;
  int sum=0;
  for(int i = 0; i < N; i++){
    int s,e;
    cin>> s >> e;
    sum += e-s+1;
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 384
n = int(input())
l = []
for i in range(n):
    a = list(map(int,input().split()))
    l.append(a)
dpa = [l[0][0]]
dpb = [l[0][1]]
dpc = [l[0][2]]
for i in range(1,n):
    dpa.append(l[i][0]+max(dpb[i-1],dpc[i-1]))
    dpb.append(l[i][1]+max(dpa[i-1],dpc[i-1]))
    dpc.append(l[i][2]+max(dpb[i-1],dpa[i-1]))
print(max([dpa[n-1],dpb[n-1],dpc[n-1]]))

Measured memory_bytes: 42512
#include "bits/stdc++.h"
using namespace std;
#define ll long long;
// Start Time: 11:41
int main(){
	std::ios::sync_with_stdio(false);
	int N, D;
	cin >> N >> D;
	int sum = 0;
	int count = 0;
	int temp = 0;
	for(int x = 1; x<=N; x+=2*D+1){
		count++;
	}
	cout << count;
 
}

Measured memory_bytes: 256
import heapq

N,M = list(map(int, input().split()))


rinsetuList = [[] for _ in range(100001)]

for _ in range(N):
    A, B = list(map(int, input().split()))
    rinsetuList[A].append(B)

#print(rinsetuList[:M+1])

work_list = []
hpq = heapq.heapify(work_list)

ans = 0
for rinsetu in rinsetuList[:M+1]:
    for money in rinsetu:
        heapq.heappush(work_list, money * (-1))
    if(len(work_list) != 0):
        ans += heapq.heappop(work_list) * (-1)

#    print(ans)
#    print(work_list)

print(ans)

Measured memory_bytes: 25128
#include <bits/stdc++.h>
using namespace std;
long long int x,y,z,k,l,m,tx,ty,ans,tz;
int main()
{
	scanf("%lld %lld %lld",&x,&y,&z);
	if(x%2==1 || y%2==1 || z%2==1)
	{
		printf("0");
		return 0;
	}
	if(x==y || y==z || x==z)
	{
		printf("-1");
		return 0;
	}
	while(x%2==0 && y%2==0 && z%2==0)
	{
		tx=(y/2)+(z/2);
		ty=(x/2)+(z/2);
		tz=(y/2)+(x/2);
		x=tx;
		y=ty;
		z=tz;
		ans++;
	}
	printf("%lld",ans);
}


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

int C[1001][1001];

int lcs(string X,string Y){
  int m=X.length();
  int n=Y.length();
  int maxl=0;
  X=' '+X;
  Y=' '+Y;
  for (int i=0;i<=m;i++) C[i][0]=0;
  for (int j=1;j<=n;j++) C[0][j]=0;
  
  for (int i=1;i<=m;i++){
    for (int j=1;j<=n;j++){
      if(X.at(i)==Y.at(j)){
        C[i][j]=C[i-1][j-1]+1;//同じのがでてきたら足す
      }else{
        C[i][j]=max(C[i-1][j],C[i][j-1]);//同じでない場合　上と左の多い方
      }
      maxl=max(maxl,C[i][j]);
    }
  }
  
  return maxl;
}

int main(){
  string s1,s2;
  int n;cin>>n;
  for (int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }
  return 0;
 }
 



Measured memory_bytes: 7120
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n,m;
    cin>>n>>m;
    map<ll,ll>mp;
    ll now=0;
    ll ans=0;
    mp[0]++;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        now+=x;
        now%=m;
        ans+=mp[now];
        mp[now]++;
    }
    cout<<ans;
}



Measured memory_bytes: 7412
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int n, m;
int dp[100005];
vector< vi > graph(100005);
int compute(int i)
{
    if(dp[i] != -1) return dp[i];
    int j;
    int si = graph[i].size();
    int ans = 0;
    FOR0(j, si)
    {
        int v = graph[i][j];
        ans = MAX2(ans, 1+compute(v));
    }
    return dp[i] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n>>m;
    int i;
    FOR0(i, n) dp[i] = -1;
    FOR0(i, m)
    {
        int u, v;
        cin>>u>>v;
        u--;v--;
        graph[u].pb(v);
    }
    int ans = 0;
    FOR0(i, n)
    {
        ans = MAX2(ans, compute(i));
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int dp[10000010];

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

  int N;
  cin>>N;

  for(int i=1;i<=N;i++) for(int j=1;i*j<=N;j++) dp[i*j]++;

  ll ans=0;
  for(ll i=1;i<=N;i++) ans+=i*dp[i];

  cout<<ans<<endl;

  

  return 0;
}


Measured memory_bytes: 42680