akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int N;
    int a[10001];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];

    int res = 0;
    for(int i = 0; i < N; i++){
        while(a[i] > 0){
            if(a[i]%2 == 0){
                a[i] /= 2;
                res++;
            }else{
                break;
            }
        }
    }

    cout << res << '\n';
    return 0;
}

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

typedef long long ll;

main()
{
    int n, c = 1, a;
    cin >> n;
    int arr[n];
    cin >> arr[0];
    a = arr[0];
    for(int i = 1; i < n; i++){
        cin >> arr[i];
        if(a <= arr[i]){
            a = arr[i];
            c++;
        }
    }
    cout << c;


}





///promy_pompom
//hello world


Measured memory_bytes: 3524
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll a[N],b[N],c[N];
ll sum1[N],sum2[N];
priority_queue<ll, vector<ll>, greater<ll>> q;
int main()
{
    int x,y,A,B,C;
    cin>>x>>y>>A>>B>>C;
    for(int i=1;i<=A;i++)cin>>a[i];
    for(int i=1;i<=B;i++)cin>>b[i];
    for(int i=1;i<=C;i++)cin>>c[i];
    sort(a+1,a+A+1);
    reverse(a+1,a+A+1);
    sort(b+1,b+B+1);
    reverse(b+1,b+B+1);
    sort(c+1,c+C+1);
    reverse(c+1,c+C+1);
    // for(int i=1;i<=A;i++)cout<<a[i]<<' ';
    // cout<<endl;
    // cout<<x<<' '<<y<<endl;
    for(int i=1;i<=A;i++)sum1[i]=sum1[i-1]+a[i];
    for(int i=1;i<=B;i++)sum2[i]=sum2[i-1]+b[i];
    // for(int i=1;i<=A;i++)cout<<sum1[i]<<' ';
    // cout<<endl;
    ll t1=x,t2=y;
    q.push(a[t1]),q.push(b[t2]);
    ll ans=sum1[t1]+sum2[t2];
    ll sum=0;
    // cout<<ans<<endl;
    for(int i=1;i<=C;i++)
    {
        sum+=c[i];
        if(c[i]>(int)q.top()){
            int p=q.top();
            if(p==a[t1]&&t1){
                t1--;
                if(t1)q.push(a[t1]);
            }else if(p==b[t2]&&t2){
                // if(t2==0)break;
                t2--;
                if(t2)q.push(b[t2]);
            }else {
                break;
            }
            ans=max(ans,sum1[t1]+sum2[t2]+sum);
            q.pop();
        }else{
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4096
N = int(input())
A = list(map(int,input().split()))

  
Flag = True
t = A[0]
i = 1
while Flag == True and i < N:
  t = t*A[i]
  if t > 10**18:
    Flag = False
  i += 1
if 0 in A:
  print(0)
elif Flag == True:
  print(t)
  
else:
  print(-1)

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

using namespace std;

int main()
{
    long long n1, n2;
    map<string, long long> arr;
    cin >> n1;
    for(long long i = 0; i < n1; i++)
    {
        string str;
        cin >> str;
        arr[str]++;
    }
    cin >> n2;
    for(long long i = 0; i < n2; i++)
    {
        string str;
        cin >> str;
        arr[str]--;
    }
    long long minimum = arr.begin()->second;
    for(auto it : arr)
    {
        if(minimum < it.second)
        {
            minimum = it.second;
        }
    }
    if(minimum < 0)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << minimum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>

using namespace std;

int main() {
   int N;
   cin >> N;
   double x;
   string u;
   double ans = 0;
   for (int i = 0; i < N; i++) {
      cin >> x >> u;
      if (u == "JPY") ans += x;
      else ans += 380000.0 * x;
   }
   cout << fixed << setprecision(10) << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n ; 
	cin >> n ; 
	if ( n % 2 == 0 ){
		cout << fixed << setprecision(12) << 0.5 << endl;
	}
	else{
		double ans = (n / 2 + 1) / (double) n ; 
		cout << fixed << setprecision(12) << 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,X,Y;cin>>N>>K>>X>>Y;
  if(N<=K) cout << X*N << endl;
  else cout << X*K+(N-K)*Y << endl;
}


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

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

    map<char,int>cc,ic;

    for(int i=0;i<s.size();i++){
        if(isdigit(s[i]))ic[s[i]]++;
        else cc[s[i]]++;
    }

    int ans=s.size();

    for(char c='a';c<'z';c++){
        while(cc[c]){
            char next=c+1;
            while(next<='z'&&cc[next])next++;

            if(next-c<=3)break;
            ans-=next-c-3;
            for(char d=c;d<next;d++)cc[d]--;
        }
    }


    for(char c='0';c<'9';c++){
        while(ic[c]){
            char next=c+1;
            while(next<='9'&&ic[next])next++;

            if(next-c<=3)break;
            ans-=next-c-3;
            for(char d=c;d<next;d++)ic[d]--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vs>		vvs;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int ma = B / A;
	cout << min(ma, C) << endl;

	return 0;
}

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

using namespace std;

int main(){
    string S;
    int ans=0;
    cin >> S;
    for(int i=0;i<S.size()/2;i++){
        if(S[i]!=S[S.size()-i-1]){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
  H, W = map(int, input().split())
  
  if H == 0 and W == 0:
    break

  for i in range(H):
    for j in range(W):
      if (i == 0) or (i == H-1) or (j == 0) or (j == W-1):
        print("#", end="")
      else:
        print(".", end="")
    print()
  
  print()



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

int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < w + 2; i++) cout << '#';
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << '#';
    string s;
    cin >> s;
    cout << s;
    cout << '#';
    cout << endl;
  }
  for (int i = 0; i < w + 2; i++) cout << '#';
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int i=0;
	while(true){
		if(s[i]=='A')break;
		i++;
	}
	int j=s.size()-1;
	while(true){
		if(s[j]=='Z')break;
		j--;
	}
	int ans=j-i+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import Data.List

main = print . solve . take 2 . filter ((2<=) . length) . group . sortBy (flip compare) . drop 1 . map (read :: String -> Int) . words =<< getContents

solve [] = 0
solve [x]
    | length x >= 4 = head x * head x
    | otherwise = 0
solve (x:y:xs)
    | length x >= 4 = head x * head x
    | otherwise = head x * head y


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x,y,ans;cin>>x>>y;
  bool b=(abs(x)>abs(y));
  if(x<=0&&y<=0) {
    if(x!=0&&y!=0)ans=abs(abs(x)-abs(y))+2*(!b);
    if(x==0&&y!=0)ans=abs(y)+1;
    if(x!=0&&y==0)ans=abs(x);
  }
  if (x<=0&&y>=0) {
    ans=abs(abs(x)-abs(y))+1;if(x==0||y==0) ans-=1;
  }
  if (x>=0&&y<=0) ans=1+abs(abs(x)-abs(y));
  if (x>=0&&y>=0) {
    ans=abs(abs(x)-abs(y))+2*b;
    if(y==0) ans-=1;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
using namespace std;

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

struct Type
{
  int value, start, end;
  Type(int value = 0, int start = 0, int end = 0) : value(value), start(start), end(end) {}
};

int H, W, N;
Type types[8];
map<char, int> table;
char board[20][20];
int memo[20][20][101][1 << 8];

int rec(int x, int y, int t, int used)
{
	if(t == 101) return 0;
	if(used + 1 == 1 << N) return 0;
	if(memo[x][y][t][used] != -1) return memo[x][y][t][used];
	
	int res = 0;
	for(int i = 0; i < 5; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		
		if(0 <= nx && nx < W && 0 <= ny && ny <H)
		{
			char data = board[nx][ny];
			
			if('0' <= data && data <= '9')
			{
				int idx = table[data];
				int s = types[idx].start;
				int e = types[idx].end;
				
				if(s <= t && t < e && (used & 1 << idx) == 0)
					res = max(res, rec(x, y, t, used | 1 << idx) + types[idx].value);
			}
			else res = max(res, rec(nx, ny, t + 1, used));
		}
	}
	
	return memo[x][y][t][used] = res;
}	

int solve()
{
	memset(memo, -1, sizeof memo);
	
	int X, Y;
	
	for(int y = 0; y < H; y++)
	{
		for(int x = 0; x < W; x++)
		{
			char k;
			cin >> k;
			
			board[x][y] = k;
			
			if(board[x][y] == 'P')
			{
				X = x;
				Y = y;
			}
		}
	}
	
	cin >> N;
	
	for(int i = 0; i < N; i++)
	{
		char c;
		cin >> c >> types[i].value >> types[i].start >> types[i].end;
		
		table[c] = i;
	}
	
	return rec(X, Y, 0, 0);
}

int main()
{
  for(; cin >> W >> H && W;)
  	cout << solve() << endl;
}

Measured memory_bytes: 40000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

vector<int> cnt(N, 0);
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int ans = cnt[0] + cnt[1];
    for(int i = 0; i < n; i++) {
        if(a[i] != 0) {
            ans = max(ans, 
                cnt[a[i] - 1] + cnt[a[i]] + cnt[a[i] + 1]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
import sys
from itertools import accumulate
N = int(input())
S = input()
if S[0]=='W' or S[-1]=='W':
  print(0)
  sys.exit()
MOD = 10**9+7
p = 1
ls = [p]
for i in range(1,2*N):
  if S[i]==S[i-1]:
    p = (p+1)%2
    ls.append(p)
  else:
    ls.append(p)
if p!=0:
  print(0)
  sys.exit()
if ls.count(1)!=N:
  print(0)
  sys.exit()
A = list(accumulate(ls))
m = 0
ans = 1
for i in range(1,N+1):
  ans *= i
  ans %= MOD
for i in range(2*N):
  if ls[i]==0:
    ans *= A[i]-m
    ans %= MOD
    m += 1
print(ans)

Measured memory_bytes: 13056
#include<stdio.h>
#include<bitset>
#include<math.h>
#include<iostream>
#include<set>
#include<string.h>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
//~#include<algorithm>
#include<iomanip>
#include<limits>
#include<string.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
 
#define pb push_back
#define ii pair<int, int>
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int MOD = 1000000007;
const int maxn = 1e4 +10; 


//~ output :5 4 4 8
bitset<10*maxn>bs;
vi prime;

vi arr[maxn];

void sivo(){
	bs.set();
	bs[0] = bs[1] = 0;
	for(int i = 2; i <= maxn;i++){
		for(int j = i*i; j <= maxn;j+=i){
			bs[j] = 0;
		}
		if(bs[i])prime.pb(i);
	}
}
 
int n;
signed main (){
	//~ freopen("myfile.txt","w",stdout);
	//~ ios_base::sync_with_stdio(0); cin.tie(nullptr);
	sivo();
	cin >> n;
	vi ans ;
	for(auto p : prime){
		if ( p%5 ==1  ){
			n--;
			ans.pb(p);
		}
		if ( n == 0)break;
	}
	
	for(auto x: ans)cout << x << ' ';
	
	cout << '\n'; return 0;
	
	
 
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,e;
  cin >> a;
  vector<int>vec;
  for(int b = 0;b<a;b++){
    cin >> e;
  	vec.push_back(e);
  }
  int c = 1;
  int f = vec.at(0);
  for(int d =1;d<a;d++){
  if(vec.at(d)>=f){
  c++;
  f =vec.at(d);
  }
  
  
  }
  
  cout << c << endl;

}

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

using namespace std;

struct Combination {
	vector<int64_t> _fact, _rfact, _inv;
	int64_t MOD;

	Combination(size_t sz, int64_t mod) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1), MOD(mod) {
		_fact[0] = _rfact[sz] = _inv[0] = 1;
		for (int i = 1; i <= sz; ++i) {
			_fact[i] = _fact[i - 1] * i % MOD;
		}
		_rfact[sz] = inverse(_fact[sz]);
		for (int i = sz - 1; i >= 0; --i) {
			_rfact[i] = _rfact[i + 1] * (i + 1) % MOD;
		}
		for (int i = 1; i <= sz; ++i) {
			_inv[i] = _rfact[i] * _fact[i - 1] % MOD;
		}
	}

	inline int64_t fact(int k) const { return _fact[k]; }
	inline int64_t rfact(int k) const { return _rfact[k]; }
	inline int64_t inv(int k) const { return _inv[k]; }

	int64_t inverse(int64_t x) const { return pow(x, MOD - 2); }
	int64_t pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) { (ret *= x) %= MOD; }
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	}

	int64_t P(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(n - r) % MOD;
	}
	int64_t C(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(r) % MOD * rfact(n - r) % MOD;
	}
	int64_t H(int n, int r) const {
		if (n < 0 || r < 0) { return 0; }
		return r == 0 ? 1 : C(n + r - 1, r);
	}
};

constexpr Int MOD = 1e9 + 7;
Combination cb(200010, MOD);
vector<vector<int>> g(200010);
vector<pair<Int, Int>> d(200010);
vector<Int> ans(200010, 0);

void tapu(int now, int par) {
	Int a = 0, b = 1, cnt = 1;
	for (int u : g[now]) {
		if (u == par) { continue; }
		tapu(u, now);
		Int n = d[u].first;
		a += n;
		(b *= cb.rfact(n)) %= MOD;
		(cnt *= d[u].second) %= MOD;
	}
	Int x = cb.fact(a) * b % MOD * cnt % MOD;
	d[now] = { a + 1, x };
}

void tapi(int now, int par, Int n_par, Int c_par) {
	Int a = 0, b = 1, cnt = 1;
	for (int u : g[now]) {
		if (u == par) {
			a += n_par;
			(b *= cb.rfact(n_par)) %= MOD;
			(cnt *= c_par) %= MOD;
			continue;
		}
		Int n = d[u].first;
		a += n;
		(b *= cb.rfact(n)) %= MOD;
		(cnt *= d[u].second) %= MOD;
	}
	ans[now] = cb.fact(a) * b % MOD * cnt % MOD;

	for (int u : g[now]) {
		if (u == par) { continue; }
		Int n = d[u].first;
		Int u_a = a - n;
		Int u_b = b * cb.fact(n) % MOD;
		Int u_c = cnt * cb.inverse(d[u].second) % MOD;
		Int x = cb.fact(u_a) * u_b % MOD * u_c % MOD;
		tapi(u, now, u_a + 1, x);
	}
}

int main() {
	const Int MOD = 1e9 + 7;
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	tapu(0, -1);
	tapi(0, -1, 0, 1);
	for (int i = 0; i < N; ++i) { cout << ans[i] << endl; }

	return 0;
}


Measured memory_bytes: 23284
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;


int main() {
  int A,B,C,K;
  cin >> A >> B >> C;
  cin >>K;
  int x = max(A,max(B,C));
  int p = 1;
  for (int i=0;i<K;i++) p *= 2 ;
  cout << x*p + A+B+C-x << endl;
}
		  

Measured memory_bytes: 256
use std::io::*;
use std::cmp;
use std::collections::HashMap;
use std::process::exit;


fn main() {
    let (n, s, w, e) = (0, 1, 2, 3);
    let mut buf: String = String::new();
    match stdin().read_line(&mut buf) {
        Ok(_) => (),
        Err(_) => exit(1)
    };
    buf = buf.trim().to_string();

    let mut coll: HashMap<char, i32> = HashMap::new();

    for c in buf.chars() {
        *coll.entry(c).or_insert(0) += 1
    }
   
    let v = vec!['N', 'S', 'W', 'E'];
    let mut res = vec![0; 4];
    
    for (i, c) in v.iter().enumerate() {
        res[i] = match coll.get(c) {
            Some(n) => *n,
            None => 0
        };
    }

    let cond = cmp::min(res[n], res[s]) == 0 && cmp::max(res[n], res[s]) != 0 || cmp::min(res[w], res[e]) == 0 && cmp::max(res[w], res[e]) != 0;

    if cond {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

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

  int n,q;
  int count = 0;
  cin >> n;
  int *S = new int[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  int x;
  for (int i = 0; i < q; i++) {
    cin >> x;
    S[n] = x;
    int j = 0;
    while (S[j] != x) j++;
    if (j != n) count++;
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()

ll pow(ll x,ll n,ll p,ll res)
{
    if(n==0)
        return res%p;
    if(n&1)
    {
        res=((res%p)*(x%p))%p;
        n--;
    }
    x=((x%p)*(x%p))%p;
    n>>=1;
    return pow(x,n,p,res);
}





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

//ll t;
//cin>>t;
//while(t--)
{

  string s;
  cin>>s;
  if(s[1]=='B')
    cout<<"ARC";
  else
    cout<<"ABC";


    cout<<endl;

}
    return 0;
}





Measured memory_bytes: 3612
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int k = Integer.parseInt(s[1]);
    char[] seq = br.readLine().toCharArray();
    ArrayList<Integer> vals = new ArrayList<>();
    char c = '?';
    int count = 0;
    for (int i=0; i<n; i++) {
      if (c=='?') {
        c = seq[i];
        count = 1;
        continue;
      } else {
        if (seq[i]==c) {
          count++;
        } else {
          c = seq[i];
          vals.add(count);
          count = 1;
        }
      }
    }
    vals.add(count);
    int sum = vals.get(0);
    int index = 1;
    for (int i=0; i<k && index<vals.size(); i++) {
      sum += vals.get(index);
      if (index+1<vals.size())
        sum += vals.get(index+1);
      index += 2;
    }
    int total = sum - 1;
    for (int i=index; i<vals.size(); i++) {
      total += vals.get(i)-1;
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 25172
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 55
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
int solve(vector <PLL>& v, int64 p, int64 q) {
	int N = v.size();
	vector <vector <int>> G(N, vector <int>());
	vector <int> indeg(N, 0);

	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
		if (v[i].X - v[j].X == p and v[i].Y - v[j].Y == q) {
			G[j].push_back(i);
			indeg[i]++;
		}
	}

	int res = 0;
	for (int i = 0; i < N; i++) if (indeg[i] == 0) res++;
	return res;
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");
	
	int N;
	scanf("%d", &N);
	vector <PLL> v(N);
	for (int i = 0; i < N; i++) scanf("%lld %lld", &v[i].X, &v[i].Y);
	int res = INT_MAX;
	if (N == 1) return puts("1"), 0;
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if(i != j){
		int64 p = v[i].X - v[j].X;
		int64 q = v[i].Y - v[j].Y;
		res = min(res, solve(v, p, q));
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 値を取得
		int n = sc.nextInt();
		int m = sc.nextInt();
		TreeMap<Long, Long> x = new TreeMap<Long, Long>();
		long ans = 0;

		for (int i = 0; i < n; i++) {
			Long a = sc.nextLong();
			Long b = sc.nextLong();
			if (x.get(a) != null) {
				x.put(a, x.get(a) + b);
			} else {
				x.put(a, b);
			}
		}
		
		for (Long key:x.keySet()) {
			if (x.get(key) <= m) {
				ans += key * x.get(key);
				m -= x.get(key);
			} else {
				ans += key * m;
				break;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 100128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
		{
			for(int j=i+1;j<a.size();j++)
			{
				if(a[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	} 
	cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    A = [[0 if j == '.' else 1 for j in input()] for i in range(N)]
    ans = 0
    min_r = float('inf')
    num_f = 0

    check = 0
    for i in range(N):
        check += sum(A[i])
    if check == 0:
        print(-1)
        return None

    for j in range(N):
        for i in range(N):
            if not A[i][j]:
                break
        else:
            num_f += 1

    if num_f == N:
        print(0)
        return None

    exits = [False] * N
    for j in range(N):
        for i in range(N):
            if A[i][j]:
                exits[j] = True
                break

    # min_r search
    for i in range(N):
        tmp = 0
        tmp += (not exits[i])

        for j in range(N):
            if A[i][j] == 0:
                tmp += 1

        min_r = min(tmp, min_r)

    ans = (N - num_f) + min_r
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 5236
//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	//入力
	long A[100001], B[100001], x[100001] = {};
	string S = {};
	char W[101] = {};
	bool f[101] = {};
	stack<pair<int, int>> dfs;
	long N = 0, K = 0, T = 0, M = 1000000000, ans = 0, l = 0, r = 0, sum = 0, a = 0, b = 0, c = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	//処理
	for (int i = 2; i < N; i++) {
		if (x[i - 2] > x[i - 1] && x[i - 1] > x[i])ans++;
		else if (x[i - 2] < x[i - 1] && x[i - 1] < x[i])ans++;
	}
	//出力
	cout << ans << endl;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
   	cin>>n>>m;
   	unordered_map<int,int> ma;

   	for (int i = 0; i < n; ++i)
   	{
   		/* code */
   		cin>>k;
   		for (int j = 0; j < k; ++j)
   		{
   			/* code */
   			cin>>sum;
   			ma[sum]++;
   		}
   	}


   	int ans=0;
   	for(auto I : ma){
   		if(I.S==n)
   			ans++;



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



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

int main() {
  int x;
  cin >> x;
  int f = 0;
 for (int p=x;p>=1;p=(p-p%10)/10){
   f += p%10;
 }
  if (x%f==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(A[i] == A[i+1]){
      continue;
    }
    ans++;
    if(A[i] < A[i+1]){
      while(A[i] <= A[i+1]){
        i++;
      }
    }else{
      while(A[i] >= A[i+1]){
        i++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=sum(a)/(4*m)
b=[]
for i in range(n):
  if a[i]>= x:
    b.append(a[i])
if len(b)>=m:
  print('Yes')
else:print('No')

Measured memory_bytes: 3060
A, B, C = gets.split.map(&:strip).map(&:to_i)
K = gets.to_i

a, b, c = A, B, C

K.times do
  if a >= b
    b *= 2
    next
  elsif b >= c
    c *= 2
    next
  else
    break
  end
end

if a < b && b < c
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14364
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,sum;
int n,a,b,c,x,y,cnt;
struct node{
	int pos,dis;
}num[300001];
bool cmp(node x,node y)
{
	return x.dis>y.dis;
}
int main()
{
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	n=a+b+c;
	for(int i=1;i<=a;i++){
		scanf("%d",&num[i].dis);
		num[i].pos=1;
	}
	for(int i=a+1;i<=a+b;i++){
		scanf("%d",&num[i].dis);
		num[i].pos=2;
	}
	for(int i=a+b+1;i<=a+b+c;i++){
		scanf("%d",&num[i].dis);
		num[i].pos=0;
	}
	sort(num+1,num+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(num[i].pos==1&&x)
			x--,ans+=num[i].dis;
		if(num[i].pos==2&&y)
			y--,ans+=num[i].dis;
		if(num[i].pos==0)
			sum+=num[i].dis,cnt++;
		if(cnt==x+y) break;
	}
	printf("%lld",ans+sum);
	return 0;
}

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

int main() {
    char b;
    cin >> b;
    char ans;

    if(b == 'A')
      ans = 'T';
    else if(b == 'T')
      ans = 'A';
    else if(b == 'G')
      ans = 'C';
    else if(b == 'C')
      ans = 'G';

    cout << ans << endl;

    return 0;  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  ll a,b,c;
  cin >> a >> b >> c;
  cout << min(b/a,c) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int n,m;
char s[100][105];
int d[102][102];
int go(int N,int M)
{
	if(N==n-1 && M==m-1)return 0;
	int &ret=d[N][M];
	if(~ret)return ret;
	ret=INF;
	if(N+1<n)
	{
		if(s[N+1][M]=='.')ret=min(ret,go(N+1,M));
		if(s[N+1][M]==s[N][M])ret=min(ret,go(N+1,M));
		if(s[N][M]=='.' && s[N+1][M]=='#')ret=min(ret,1+go(N+1,M));
	}
	if(M+1<m)
	{
		if(s[N][M+1]=='.')ret=min(ret,go(N,M+1));
		if(s[N][M]==s[N][M+1])ret=min(ret,go(N,M+1));
		if(s[N][M]=='.' && s[N][M+1]=='#')ret=min(ret,1+go(N,M+1));
	}
	return ret;
}
int main(){
	MEM_1(d);
	scanf("%d%d",&n,&m);
	fup(i,0,n-1,1)scanf("%s",s[i]);
	int ans=go(0,0);
	if(s[0][0]=='#')ans++;
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include <stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll =  long long int;
#define mod 1000000007
/*bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}*/
int main() {
string s;
    cin>>s;
    int ans=0;
    if(s[0]=='R'){
        ans++;
    }
    if(s[1]=='R'){
        ans++;
    }
    if(s[2]=='R'){
            if(s[1]=='R'){
    ans++;
            }else{
            ans=1;
            }
    }
    cout<<ans;
        return 0;
}



Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double angle=(30*h)-(5.5)*(m);
    double ans=(a*a)+(b*b)-(2*a*b)*cos(angle*acos(-1)/180);
    cout<<fixed<<setprecision(15)<<sqrt(ans)<<endl;
    
    
    
}

Measured memory_bytes: 4140
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, m;
    cin >> n >> m;
    int ans = 0;

    ans += 1900 * m + 100.0 * (n - m);

    REP(i, m)
    {
        ans *= 2;
    }
    /*
    REP(i, m)
    {
        x /= 2.0;
    }
    for (double i = 1; i <= 50.0; i++)
    {
        ans += (double)(1900.0 * m * x * i);
        x /= 2.0;
    }
    */
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = 0;
		long y = 0;
		long count = 0;
		for (int i=0;i<n;i++) {
			y = x;
			x = sc.nextInt();
			if (i>0) {
				count += Math.min((x-y)*a, b);
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 47976
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	if (n>=13) cout <<m;
	else if (n<=5) cout <<"0";
	else cout <<m/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int a,b,c,d;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for (int i=1;i<=10000;i++)
	if (i&1)
	{
		c-=b;
		if (c<=0) {printf("Yes\n"); break;}
	}
	else 
	{
		a-=d;
		if (a<=0) {printf("No"); break;}
	}
return 0;	
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  int n,a;
  cin >> n >> a;
  cout << n * n - a << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t a,b,k;
  cin >> a >> b >> k;
  int64_t cnt = 0;
  for(int64_t i=100000;i >= 1;i--){
    if(a % i == 0 && b % i == 0){
      cnt++;
      if(cnt == k){
        cout << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = list(stdin.readline().rstrip().split()[0])

ABC = list("ABC")
abc = list("abc")
idx = ABC.index(S[K-1])
S[K-1] = abc[idx]
print("".join(S))
  

Measured memory_bytes: 20528
# coding: utf-8

"""
def makeSet(x, p, rank):
    p[x] = x
    rank[x] = 0
"""

def union(x, y, p, rank):
    link( findSet(x, p, rank), findSet(y, p, rank), p, rank)
    
def findSet(x, p, rank):
    if  x != p[x] :
        p[x] = findSet(p[x], p, rank)
    return p[x]
    
def isSameSet(x, y, p, rank): # Union Find
    if findSet(x, p, rank) == findSet(y, p, rank): print 1
    else: print 0   
    
def link(x, y, p, rank):
    if  rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if  rank[x] == rank[y]  :
            rank[y] += 1

n,q = map(int,raw_input().split())
p = [i for i in range(n)] # pointer
rank = [0 for i in range(n)]
for i in range(q):
    com, x, y = map(int,raw_input().split())
    if com: # same
        isSameSet(x, y, p, rank)
    else: # unite
        union(x, y ,p , rank)

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

using namespace std;

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

typedef long long ll;
ll mod=998244353;

int main()
{
	int n;
	cin >> n;
	cout << (n-2)*180 << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class Smass_Large_Equal
{
    public static void Main()
    {
        String[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        if (a > b)
        {
            Console.WriteLine("a > b");
        }
        else if (a < b)
        {
            Console.WriteLine("a < b");
        }
        else
        {
            Console.WriteLine("a == b");
        }
    }
}


Measured memory_bytes: 8896
from collections import Counter
from itertools import accumulate
import sys
input = sys.stdin.readline
n,p = map(int,input().split())
s = input().rstrip()
if p == 2:
  ans = 0
  for i in range(n):
    if int(s[i])%2 == 0:
      ans += i+1
  print(ans)
elif p == 5:
  ans = 0
  for i in range(n):
    if int(s[i])%5 == 0:
      ans += i+1
  print(ans)
else:
  ls = [0]
  prev = 0
  for i in range(n):
    x = int(s[n-i-1])
    y = (prev+x*pow(10,i,p))%p
    ls.append(y)
    prev = y
  c = Counter(ls)
  ans = 0
  for x in c.values():
    ans += x*(x-1)//2
  print(ans)

Measured memory_bytes: 50764
N = int(input())
S = input()
wl, er = 0, S.count("E")
ans = 10**10
for i in range(N):
    if S[i] == "E":
        er -= 1
    ans = min(ans, er+wl)
    if S[i] == "W":
        wl += 1
print(ans)

Measured memory_bytes: 41944
# -*- coding: utf-8 -*-

import sys

u"""
1023回全て check
"""

def ones(n):
    o = 0
    for i in xrange(0, 10):
        b = 1 << i
        if n & b:
            o += 1
    return o

n = int(raw_input().split()[0])
# print n

openL = []
for _ in xrange(0, n):
    fs = ''.join( [e for e in raw_input().split()] )
    openL.append( int(fs, base=2) )
    
profL = []
for _ in xrange(0, n):
    profL.append( [int(e) for e in raw_input().split()] )

# print n
# print [hex(e) for e in openL]
# print profL, len(profL[0])

# print ones(0), ones(0x3ff)

maxP = -sys.maxint - 1
for i in xrange(1, 1024):
    p = 0
    for x in xrange(0, len(openL)):
        ox = openL[x]
        px = profL[x]
        p += px[ ones(ox & i) ]

    if p > maxP:
        maxP = p
    
sys.stdout.write('%d\n' % maxP)
sys.stdout.flush()


Measured memory_bytes: 2696
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin>>N>>K;
	int pos = -1;
	for(int i=0;i<N;++i){
		int ter;
		cin>> ter;
		if(ter==1){
			pos = i+1;
			break;
		}
	}
	LL ans = 0;
	N--;
	int ter = K-1;
	ans = (N+ter-1)/ter;
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
//Graph
#include <iostream>

using namespace std;

int main() {
    int n, u, k, v;
    cin >> n;
    int A[n + 1][n + 1];
    for(int i = 0; i < n + 1; i++) {
        for(int j = 0; j < n + 1; j++) A[i][j] = 0;
    }

    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v;
            A[u][v] = 1;
        }
    }
    for(int i = 1; i < n + 1; i++) {
        for(int j = 1; j < n + 1; j++) {
            if(j != 1) cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3144
#include<cstdio>
using namespace std;
int main(){

  int n,m,h,w,a,b,c,d;
 
  scanf("%d",&n);
  for(int i=0;i<n;i++){
   
    int mp[16][16]={};
    mp[0][0] = 1;
    bool mata[16][16][16][16]={false};
    
    scanf("%d %d %d",&h,&w,&m);
    for(int j=0;j<m;j++){
      scanf("%d %d %d %d",&a,&b,&c,&d);
      mata[a][b][c][d] = true;
      mata[c][d][a][b] = true;
    }

    for(int j=0;j<=h;j++){
      for(int k=0;k<=w;k++){
	if(mata[j][k][j+1][k] != true && j != h) mp[j+1][k] += mp[j][k];
	if(mata[j][k][j][k+1] != true && k != w) mp[j][k+1] += mp[j][k];
      }
    }

    if(mp[h][w] == 0) printf("Miserable Hokusai!\n");
    else printf("%d\n",mp[h][w]);

  }
  return (0);
}

Measured memory_bytes: 2740
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        string wd = Reader.ReadLine();
        int queryCount = int.Parse(Reader.ReadLine());
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        for (int i = 0; i < queryCount; i++) {
            string[] inpt = Reader.ReadLine().Split(' ');

            string cmd = inpt[0];
            int fromIdx = int.Parse(inpt[1]);
            int toIdx = int.Parse(inpt[2]);
            if(cmd.Equals("print")) {
                ans.AppendLine(wd.Substring(fromIdx, toIdx - fromIdx + 1));
            } else if(cmd.Equals("reverse")) {
                string tmp = wd.Substring(0, fromIdx);
                string tmp2 = string.Join("", wd.Substring(fromIdx, toIdx - fromIdx + 1).Reverse().Select(a => a.ToString()).ToArray());
                string tmp3 = wd.Substring(toIdx + 1);
                wd = tmp + tmp2 + tmp3;
            } else {
				string tmp = wd.Substring(0, fromIdx);
				string tmp3 = wd.Substring(toIdx + 1);
                wd = tmp + inpt[3] + tmp3;
			}
        }
        Console.Write(ans.ToString());
	}


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"






abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

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

int main() {
	int n, M = -10000, m = 10000;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		M = max(M, a);
		m = min(m, a);
	}
	cout << M - m << endl;
}

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

int main() {
    int n;
    int a;
    cin >> n;
    
    vector<int> array;
    
    for (int i = 0; i < n; ++i) {
        cin >> a;
        array.push_back(a);
    }
    
    for (int i = n-1; i >= 0; --i) {
        if (i != 0) {
            cout << array[i] << " " << flush;
        } else {
            cout << array[i] << endl;
        }
    }
}

Measured memory_bytes: 3140