akhauriyash/Code-Regression huggingface dataset:
target_a, target_b = list(map(str, input().split()))
a, b = map(int, input().split())
target = input('')
list_target_a = list(target_a)
list_target_b = list(target_b)
list_target = list(target)
a_ans = 0
b_ans = 0
if len(list_target) == len(list_target_a):
    for i in range(len(list_target_a)):
        if list_target[i] == list_target_a[i]:
            a_ans += 1

if a_ans == len(list_target_a):
    a -= 1

if len(list_target) == len(list_target_b):
    for i in range(len(list_target_b)):
        if list_target[i] == list_target_b[i]:
            b_ans += 1

if b_ans == len(list_target_b):
    b -= 1

print(a, b)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 256;
ll f1 = (1 << 0) + (1 << 1) + (1 << 4) + (1 << 5);
ll f2 = (1 << 1) + (1 << 2) + (1 << 5) + (1 << 6);
ll f3 = (1 << 2) + (1 << 3) + (1 << 6) + (1 << 7);
int main() {
	int h, n;
	cin >> h >> n;
	VE<VE<bool>> ban(h, VE<bool>(4, false));
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		ban[y][x] = true;
	}
	// 先頭8個のみ持っておけばよいはず
	/*
	5 6 7 8
	1 2 3 4
	とする
	*/
	VVL dp(h + 1, VL(N, 0)); // i行目までで、i行目+i+1行目までの荷物の置き方を2進数で表したものの最大値
	rep(i, h - 1){
		rep(j, N) {
			// 取りうる選択の数が2*3通りしかない
			bool v1 = true, v2 = true, v3 = true;
			if (ban[i][0] || ban[i][1] || ban[i + 1][0] || ban[i + 1][1]) v1 = false;
			if (ban[i][1] || ban[i][2] || ban[i + 1][1] || ban[i + 1][2]) v2 = false;
			if (ban[i][2] || ban[i][3] || ban[i + 1][2] || ban[i + 1][3]) v3 = false;
			if (j & (1 << 0) || j & (1 << 1) || j & (1 << 4) || j & (1 << 5)) v1 = false;
			if (j & (1 << 1) || j & (1 << 2) || j & (1 << 5) || j & (1 << 6)) v2 = false;
			if (j & (1 << 2) || j & (1 << 3) || j & (1 << 6) || j & (1 << 7)) v3 = false;
			if (v1) chmax(dp[i][j + f1], dp[i][j] + 1);
			if (v2) chmax(dp[i][j + f2], dp[i][j] + 1);
			if (v3) chmax(dp[i][j + f3], dp[i][j] + 1);
			int nj = 0;
			rep(i, 4) if (j & (1 << (4 + i))) nj += (1 << i);
			chmax(dp[i + 1][nj], dp[i][j]);
		}
	}
	ll ans = 0;
	rep(i, N) chmax(ans, dp[h - 1][i]);
	rep(i, N) chmax(ans, dp[h][i]);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

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

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
int r;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    double ans = 0;
    cin>>r;
const double PI = acos(-1);
    ans = 2.0*r*PI;

    cout << std::setprecision(10) << ans << endl;
    return 0;
}

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

int n;
vector<int> x, y, h;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int a, b, c;
		cin >> a >> b >> c;
		x.push_back(a);
		y.push_back(b);
		h.push_back(c);
	}
	for(int i=0; i<=100; ++i)
		for(int j=0; j<=100; ++j){
			int ah;
			for(int k=0; k<n; ++k){
				if(h[k] != 0){
					ah = h[k] + abs(x[k] - i) + abs(y[k] - j);
					break;
				}
			}
			bool f = true;
			for(int k=0; k<n; ++k)
				if(h[k] != max(0, ah - abs(x[k] - i) - abs(y[k] - j)))
					f = false;
			if(f){
				cout << i << " " << j << " " << ah << "\n";
			}
		}
}

Measured memory_bytes: 256
#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 n,m;cin >> n >> m;
  if(m>n){printf("No");return 0;}
  vector<int> v;
  double ki=0.0;
  rep(i,n){
    int a; cin >> a; v.push_back(a);
    ki+=a;
  }
  ki/=(double)(4*m);
  int sum=0;
  for(auto e:v){
    if(e<ki){continue;}
    sum++;
    if(sum>=m){
      printf("Yes");
      return 0;
    }

  }
  printf("No");
  return 0;
}


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

using namespace std;

int T, A, B, C, D, k;

bool check(int x) {
	int a = A - x, b = B - (x - 1) / k;
	return b <= (long long)(a + 1) * k;
}

int main() {
	scanf("%d", &T);
	while (T--) {
		scanf("%d %d %d %d", &A, &B, &C, &D), k = ceil(1.0 * max(A, B) / (min(A, B) + 1));
		int l = 0, r = A;
		while (l + 1 < r) {
			int mid = (l + r) / 2;
			if (check(mid)) l = mid; else r = mid - 1;
		}
		
		if (check(r)) l = r; 
		
		int a = A - l, b = B - (l - 1) / k;
		l = l + (l - 1) / k, r = l + b - (long long)a * k + 1;
		
		for (int i = C; i <= min(l, D); i++) 
			if (i % (k + 1) == 0) printf("B"); else printf("A");
		for (int i = max(C, l + 1); i <= D; i++)
			if ((i - r) % (k + 1) == 0) printf("A"); else printf("B");
			
		puts("");
	}
}

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

using namespace std;

int A[1000000],cnt;

void insertionsort(int *A,int n,int g){
	int j,v;
	for(int i=g;i<n;i++){
		v=A[i];
		j=i-g;
		while(j>=0&&A[j]>v){
			A[j+g]=A[j];
			j=j-g;
			cnt++;
		}
		A[j+g]=v;
	}
}

void shellsort(int *A, int n){
	int G[100],m,temp=0,i=1;
	m = 1;
	G[0]=1;
	while(1){
		temp=3*G[i-1]+1;
		if(temp>n)
		break;
		G[i]=temp;
		i++;
		m++;
	}
	printf("%d\n",m);
	for(i=m-1;i>0;i--){
		printf("%d ",G[i]);
	}
	printf("%d\n",G[0]);
	for(i=m-1;i>=0;i--){
		insertionsort(A,n,G[i]);
	}
	printf("%d\n",cnt);
	for(i=0;i<n;i++){
		printf("%d\n",A[i]);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	shellsort(A,n);
}

Measured memory_bytes: 7056
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向
const int MAX_N = 100010;
int n;
int dp[MAX_N];

void input(){
    cin >> n;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<MAX_N;i++) dp[i] = INF;
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int pow6=1;i+pow6<=n;pow6*=6){
            chmin(dp[i+pow6], dp[i]+1);
        }
        for(int pow9=1;i+pow9<=n;pow9*=9){
            chmin(dp[i+pow9], dp[i]+1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int n,a,b,c,i,k,r,s=0,sum=0,ct=0;

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

    for(i=a;i<=n;i++)
    {
        s=0;
        k=i;
        while(k!=0)
        {
            r=k%10;
            k=k/10;
            s=s+r;

        }

        if(s>=a && s<=b )
            {

                s=0;
                sum=sum+i;

            }


    }

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








    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

int N;
string S;
int Q;
const int INF = 1000000000;

int main() {
  cin >> N >> S >> Q;
  multiset<int> s[26];

  rep(i, N) {
    s[S[i]-'a'].insert(i);
  }
  rep(j, 26) {
    s[j].insert(INF);
  }
  vector<int> ans;
  rep(i, Q) {
    int temp;
    cin >> temp;
    if(temp == 1) {
      int j;
      char c;
      cin >> j >> c;
      j--;
      s[S[j]-'a'].erase(j);
      S[j] = c;
      s[S[j]-'a'].insert(j);
    } else {
      int l, r;
      cin >> l >> r;
      l--;r--;
      int t = 0;
      rep(j, 26) {
        if(s[j].empty()) continue;
        int p = *s[j].lower_bound(l);
        if(p <= r) {
          t++;
        }
      }
      ans.push_back(t);
    }
  }
  rep(i, ans.size()) {
      cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 27504
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
		ld n;
        cin >> n;
        cout.precision(12);
        cout << (2*n*M_PI) << endl;
}     



Measured memory_bytes: 3264
#define L long long
m[31][50];main(n,p,d,x){L a[50],b;for(;scanf("%d",&n),n;){memset(m,0,6200);for(p=0;p<n;a[p]=1LL<<p,p++)for(scanf("%d",&x);x;x--)scanf("%d",&d),m[d][p]=1;for(d=1;d<31;d++){for(b=p=0;p<n;p++)if(m[d][p])b|=a[p];for(p=0;p<n;p++)if(m[d][p]&&(a[p]=b)==((L)1<<n)-1){printf("%d\n",d);goto s;}}puts("-1");s:;}exit(0);}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c){
    cout<<1<<endl;
  }else if(a==b || b==c || a==c){
    cout<<2<<endl;
  }else{
    cout<<3<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  int A;
  
  for (int i=111; i <=999; i+=111) {
    if (i-N >= 0) {
      A = i;
      break;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

if A > B:
    ans = 0
elif N==1:
    ans = 1 if A==B else 0
else:
    sum_min = (N-2) * A
    sum_max = (N-2) * B
    ans = sum_max - sum_min + 1

print(ans)

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

int main(){
 
  int R;
  cin >> R;
  
  if(R < 1200){
    cout << "ABC" << endl;
  }
  else if(R >= 1200 && R < 2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
  
}


Measured memory_bytes: 256
/**
 *      ABC 101 A
 *      author  : kyomukyomupurin
 *      created : 2018/08/21
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    string S;
    cin >> S;
    int n = 0;

    for (int i = 0; i < S.size(); ++i) {
        S.at(i) == '+' ? ++n : --n;
    }
    
    cout << n << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>

intmax_t f(intmax_t a, intmax_t b) {
  a = -a+1;
  return (b-a) / 2;
}

int main() {
  intmax_t n, a, b;
  scanf("%jd %jd %jd", &n, &a, &b);

  if ((b-a) % 2 == 0)
    return !printf("%jd\n", (b-a)/2);

  // . a . .|. . a . . . . b
  // . . a .|. a . . . . b .
  // . . . a|a . . . . b . .
  // . . . .|a . . . b . . .
  // . . . .|. a . b . . . .
  // . . . .|. . ! . . . . .

  intmax_t res = std::min(f(a, b), f(n+1-b, n+1-a));
  printf("%jd\n", res);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows: g++ p1.cpp -op1
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)

vector<ll> graph[250000];
vector<bool> sta(250000,false);
stack<ll> st;
ll tot=0;
void dfs(int n)
{
    //cout<<n<<" ";
    tot++;
    st.push(n);
    sta[n]=true;
    while(!st.empty()){
        st.pop();
    for(ll i=0;i<graph[n].size();i++)
    {
        if(sta[graph[n][i]]==false)
        {
            sta[graph[n][i]]=true;
            dfs(graph[n][i]);
        }
    }
}
}
int main()
{
   #ifndef ONLINE_JUDGE
        ifstream cin("in.in");
        ofstream cout("out.out");
    #endif
    
        io;
        //////////////////////////////////
        cs1{
             ll i,j,k,l,s=0,p=INT_MAX,n,m,q=0,e;
        
             cin>>n>>e;
             for(i=1;i<=e;i++){
                ll x,y;
                cin>>x>>y;
                graph[x].push_back(y);
                graph[y].push_back(x);
             }
             for(i=1;i<=n;i++){
                tot=0;
                if(sta[i]==false){
                    dfs(i);
                }
                s=max(s,tot);
             }
             s=max(s,tot);
             cout<<s nl;
        }
        //////////////////////////////////
        cer;
}

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

using namespace std;

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

// 45106 - 111

// 77 - 16 41


void oneCase() {
    int n;
    cin >> n;
    cout << int(sqrt(n)) * int(sqrt(n) ) << "\n";




}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    rep(i,3){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
 
int main(){
    double a,b,c,d,e,f;
    double ans,ans2;
 
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
 
            ans2=(c*d-a*f)/(b*d-a*e);
            ans=(c-b*ans2)/(a);
 
        printf("%.3f %.3f\n",ans,ans2);
    }
    return 0;
}



Measured memory_bytes: 1992
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
p = [int(i) for i in input().split()]

kitai = []
for i in range(n):
    kitai.append((1 + p[i]) / 2)

ans = 0
tmp = 0
for i in range(k):
    tmp += kitai[i]
ans = tmp
for i in range(n - k):
    tmp = tmp - kitai[i] + kitai[i + k]
    if ans < tmp:
        ans = tmp
print(ans)


Measured memory_bytes: 76040
local mod = 1000000007
local mfl = math.floor
local function badd(x, y) return (x + y) % mod end
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end
local function lltonumber(str)
  local ret = 0LL
  for i = 1, #str do
    ret = ret * 10LL
    ret = ret + str:sub(i, i):byte() - 48
  end
  return ret
end

local n = io.read("*n", "*l")
local lim = 60
local box = {}
for i = 1, lim do
  box[i] = 0
end
local s = io.read()
local llnum = {}
for z in s:gmatch("%d+") do
  table.insert(llnum, lltonumber(z))
end
local mulcnt = {}
for i = 1, lim do
  mulcnt[i] = 0
end
for i = 1, n do
  local a = llnum[i]
  for j = 1, lim do
    local p = a % 2LL
    if p == 1LL then
      mulcnt[j] = mulcnt[j] + i - 1 - box[j]
      box[j] = box[j] + 1
    else
      mulcnt[j] = mulcnt[j] + box[j]
    end
    a = a / 2LL
  end
end
local ret = 0
local mul = 1
for i = 1, lim do
  ret = badd(ret, bmul(mul, mulcnt[i]))
  mul = (mul * 2) % mod
end
print(ret)


Measured memory_bytes: 72300
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll GCD(ll a, ll b){
  ll c = max(a,b);
  ll d = min(a,b);
  if(c % d == 0)return d;
  else return gcd(d,c % d);
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  ll a,b;
  cin >> a >> b;
  cout << (a * b) / GCD(a,b) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = list(input())
T = list(input())
L = len(S)

ans = 0
for i in range(L):
    if S[i] == T[i]:
        continue
    ans += 1

print(ans)


Measured memory_bytes: 12504
#include <stdio.h>

long long int max(long long int a, long long int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

long long int min(long long int a, long long int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

long long int max3(long long int a, long long int b, long long int c){
	return max(max(a, b), c);
}

long long int min3(long long int a, long long int b, long long int c){
	return min(min(a, b), c);
}

long long int min4(long long int a, long long int b, long long int c, long long int d){
	return min(min3(a, b, c), d);
}

long long int main(){
	long long int H, W;
	scanf("%lld%lld", &H, &W);
	if(H % 3 == 0 || W % 3 == 0){
		printf("0\n");
		return 0;
	}
	long long int ans;
	long long int W1 = W / 3, W2 = 1 + (W - 1) / 3, H1 = H / 2, H2 = 1 + (H - 1) / 2;
	long long int h1 = H / 3, h2 = 1 + (H - 1) / 3, w1 = W / 2, w2 = 1 + (W - 1) / 2;
	ans = min3(min4(
		  max3(H * W1, (W - W1) * H1, (W - W1) * H2) - min3(H * W1, (W - W1) * H1, (W - W1) * H2)
		, max3(H * W2, (W - W2) * H1, (W - W2) * H2) - min3(H * W2, (W - W2) * H1, (W - W2) * H2)
		, max3(W * h1, (H - h1) * w1, (H - h1) * w2) - min3(W * h1, (H - h1) * w1, (H - h1) * w2)
		, max3(W * h2, (H - h2) * w1, (H - h2) * w2) - min3(W * h2, (H - h2) * w1, (H - h2) * w2)
		), H * (W2 - W1), W * (h2 - h1));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  double result = -1;
  int t;

  cin >> t;
  for(int i = 0; i < t; i++){
    int n, m;
    cin >> n >> m;

    double value = 0.0, cnt = 0.0;
    for(int j = 0; j < m; j++){
      int v;
      double r;
      cin >> v >> r;
      value += v * r;
      cnt += r;
    }
    result = max( result, value / cnt);
  }
  int p, q;
  cin >> p >> q;
  double value = 0.0, cnt = 0.0;
  for(int i = 0; i < q; i++){
    int v;
    double r;
    cin >> v >> r;
    value += v * r;
    cnt += r;
  }
  if(result - value / cnt > 0.0000001){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1232
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> VL;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  REP(i, n) cin >> a[i];
  ll sum[n + 1];
  sum[0] = 0;
  REP(i, n) sum[i + 1] = sum[i] + a[i];
  ll sum2[n + 1];
  REP(i, n + 1) sum2[i] = ((sum[i] - i) % k + k) % k;
  map<ll, VL> idx;
  REP(i, n + 1) idx[sum2[i]].push_back(i);
  ll ans = 0;
  REP1(i, n) {
    auto it = upper_bound(ALL(idx[sum2[i]]), i - k);
    ll l = it - idx[sum2[i]].begin();
    it = lower_bound(ALL(idx[sum2[i]]), i);
    it--;
    ll r = it - idx[sum2[i]].begin();
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	string str;
	cin>>str;

	lli data[200010]={0};
	REP(i,0,str.size()){
		if(str.at(i)=='#')data[i]=1;
	}

	/*c>dなら c<dにする、なおa,bの変換も忘れずに行う*/
	if(c>d){
		if(DEBUG)cout<<"unko0"<<endl;
		swap(c,d);
		swap(a,b);
	}

	/*a>bならa<bにできるようにbを進められるか?*/
	/*なお,aの隣のどちらかに石がある場合は動かす必要があるので動かす*/
	/*cに行く前に動かしきれなかったらNG*/

	data[a]=1;
	if(a>b){
		if(data[a-1]==1 || data[a+1]==1){
			if(DEBUG)cout<<"ugokasu0!"<<endl;
			lli flag=0;
			data[a]=0;
			for(lli i=a;i<=c;i++){
				/*そもそもaをそこまで持っていけないケース*/
				lli cnt=0;
				if(data[i]==1)cnt++;
				else cnt=0;
				if(cnt>=2){
					cout<<"No"<<endl;
					return 0;
				}
				if(data[i-1]==0 && data[i+1]==0 && data[i]==0){
					a = i;
					flag=1;
					data[a]++;
					if(DEBUG)cout<<"nextA="<<a<<endl;
					break;
				}
			}
			if(flag==0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else ;/*両方空いてればそのままやる*/
	}

	/*BをDにまず持っていけるか?*/
	lli cnt=0;
	REP(i,b,d){
		if(data[i]==1){
			cnt++;
			if(cnt>=2){
				if(DEBUG)cout<<"unko1"<<endl;
				cout<<"No"<<endl;
				return 0;
			}
		}
		else{cnt=0;}
	}

	/*BをDにもっていけたことにして同じことをする*/
	data[a]=0;
	data[d]=1;
	cnt=0;
	if(a>c){
		if(DEBUG)cout<<"unko2"<<endl;
		cout<<"No"<<endl;
		return 0;
	}
	REP(i,a,c){
		if(data[i]==1){
			cnt++;
			if(cnt>=2){
				if(DEBUG)cout<<"unko3"<<endl;
				cout<<"No"<<endl;
				return 0;
			}
		}
		else{
			cnt=0;
		}
	}

	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
/*
　　　　　 　 _... ..._
　　　　　 , ´⌒ ⌒ヽ
　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
　　　　　　△ﾑ,8ﾑﾌつ
　　　　　/(ﾝ_/＿ヽ＼
　　　　 ～～i_ﾌ_ﾌ～´
*/
	int n, q;
	ll ans = 0;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>start(q);
	vector<int>end(q);
	vector<ll>count(n + 1);
	count[0] = 0;
	count[1] = 0;
	rep0(i, q - 1) {
		scanf("%lld%lld", &start[i], &end[i]);
	}
	REP(2, s.length()) {
		if (s[i - 2] == 'A' && s[i - 1] == 'C') {
			ans++;
		}
		count[i] = ans;

	}
	rep0(k, q - 1) {
		printf("%lld\n", count[end[k]] - count[start[k]]);
	}
	return 0;
} 

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

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

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

int dfs(vector<vector<int>> const& v, int y, int x, vector<vector<bool>>& visited) {
    visited[y][x] = true;
    int res = 1;
    for(int i = 0; i < 4; ++i) {
        int ny = y + dy[i], nx = x + dx[i];
        if(ny < 0 || v.size() <= ny || nx < 0 || v[0].size() <= nx || visited[ny][nx] || v[ny][nx] == 0) {
            continue;
        }
        res = max(res, dfs(v, ny, nx, visited) + 1);
    }
    visited[y][x] = false;
    return res;
}

int main() {
    int m, n;
    while(cin >> m >> n, m) {
        vector<vector<int>> v(n, vector<int>(m));
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                cin >> v[i][j];
            }
        }
        vector<vector<bool>> visited(n, vector<bool>(m));
        int res = 0;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                if(v[i][j] == 1) {
                    res = max(res, dfs(v, i, j, visited));
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3156
// Last Change: 04/10/2019 23:24:43.
/////////////////////////////////////////////////////////////////////////////
// qを商とする。
//
// Kが奇数の時
//  a=q*K
//
// Kが偶数の時
//  a=q*K
//    or
//  a=q*K+K/2
//
//をa,b,cすべてが満たす。
//
//このvectorの使い方とか
/////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

ll Cnt(ll val) {
  return val * val * val;
}

int main() {
  ll N, K;
  cin >> N >> K;

  vector<ll> note(K + 1, 0);
  for (ll i = 1; i <= N; ++i) {
    ++note[i % K];
  }

  ll ans = 0;

  ans = Cnt(note[0]);

  // even number
  if (K % 2 == 0) {
    ans += Cnt(note[K / 2]);
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}



Measured memory_bytes: 1792
from sys import stdin, maxsize


def stdinput():
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    *A, = map(int, stdinput().split(' '))
    o = mergeSort(A, 0, n)

    print(*A)
    print(o)

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]

    cap = maxsize
    L.append(cap)
    R.append(cap)

    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    return i + j

def mergeSort(A, left, right):
    o = 0
    if left + 1 < right:
        mid = (left + right) // 2
        o += mergeSort(A, left, mid)
        o += mergeSort(A, mid, right)
        o +=  merge(A, left, mid, right)
    return o

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Measured memory_bytes: 63172
#include <iostream>
#include <cmath>
using namespace std;
#define Inf 2000000000000
#define N 100004
long long DP[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, w;
    cin >> n >> w;
    for (long long i = 1; i < N; i++) DP[i] = Inf;
    for (long long i = 1; i <= n; i++)
    {
        long long weight, value;
        cin >> weight >> value;
        for (long long pos = N - 1; pos >= 0; pos--)
        {
            if (DP[pos] != Inf)
            {
                if (pos + value < N) DP[pos + value] = min(DP[pos + value], DP[pos] + weight);
            }
        }
    }
    long long result = 0;
    for (long long i = 0; i < N; i++) if (DP[i] <= w) result = max(result, i);
    cout << result;
}


Measured memory_bytes: 1024
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin>>s;
  rep(i,s.size()) s[i]=tolower(s[i]);
  
  int cnt=0;
  string t;
  while(cin>>t){
    if(t=="END_OF_TEXT"){
      cout<<cnt<<endl;
      return 0;
    }
    rep(i,t.size()) t[i]=tolower(t[i]);
    if(t==s) cnt++;
  }
}


Measured memory_bytes: 3196
#include <stdio.h>

int main()
{
	int a, b;
	int max = (4294967295 / 2) * -1;

	if (scanf("%d %d", &a, &b) < 0)
		;
	
	if (max < (a * b))
		max = a * b;

	if (max < (a + b))
		max = a + b;

	if (max < (a - b))
		max = a - b;

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

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long k;
    double n,ans=0;
    cin>>n>>k;
    long long count;
    long long d=0;
    for(int i=1  ;i<n+1  ;i++){
        d=i;
        count=0;
        while (d<k){
            d*=2;
            count+=1;
        }
        ans+=(1/n)*pow(0.5,count);
    }
    printf("%.16f", ans);
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

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

	string ans = "NO";
	if(x==7) ans = "YES";
	if(x==5) ans = "YES";
	if(x==3) ans = "YES";
	ote(ans);
}
// 高橋くんの成長が祝われるなら YES, 祝われないなら NO と出力せよ。



Measured memory_bytes: 256
h,w,k = map(int,input().split())

box, ans = [], 0

for i in range(h):
    box.append(input())


for i in range(1 << h):
    for j in range(1 << w):
        count = 0
    
        for H in range(h):
            if i >> H & 1:
                continue
            
            for W in range(w):
                if j >> W & 1:
                    continue
                
                if box[H][W] == '#':
                    count += 1
            
        if count == k:
            ans += 1

print(ans)

Measured memory_bytes: 9200
import sys
input = sys.stdin.readline
 
def main():
  n = int(input())
  numList  = [int(input()) for _ in range(n)]
  maxVal = max(numList)
  workList = numList[:]
  workList.remove(maxVal)
  secondVal = max(workList)
  for num in numList:
    if num != maxVal:
      print(maxVal)
    else:
      print(secondVal)
      
if __name__ == '__main__':
    main()

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

int n;
map<long, long> mp;

int main() {
  cin >> n;
  long sum = 0;
  ++mp[0];
  
  while (n--) {
    long a;
    cin >> a;
    sum += a;
    ++mp[sum];
  }
  
  long ans = 0;
  for (auto&& p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

vector<int> e[200000];

int main(void) {
    int i, n, m;
    scanf("%d%d",&n,&m);
    REP (i,m) {
        int a, b;
        scanf("%d%d",&a,&b);
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    for (auto u: e[0]) {
        for (auto v: e[u]) {
            if (v == n-1) {
                puts("POSSIBLE");
                return 0;
            }
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 12016
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	x <- readInt
	print $ which 0 1 $ null $ do	
		i <- [ 1 .. x `div` 100 ]
		guard $ 100 * i <= x && ( x - 100 * i + 5 - 1 ) `div` 5 <= i
		return ()

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int main(void) {
    long long N, n, a, x, A[200005], B[200005], i, j;
    char S[200005];
    scanf("%s", S);
    N=strlen(S);
    
    B[N-1]=1;
    for (i=N-2; i>=0; i--) {
        B[i]=B[i+1]*10%2019;
    }
    
    /*
    for (i=0; i<N-1; i++) {
        printf("%lld\n", B[i]);
    }
    */
    
    A[N-1]=S[N-1]-'0';
    for (i=N-2; i>=0; i--) {
        A[i]=(A[i+1]+(S[i]-'0')*B[i])%2019;
    }
    
    /*
    for (i=0; i<N-1; i++) {
        printf("%lld\n", A[i]);
    }
    */
    
    A[N]=0;
    sort(A, A+N+1);
    
    /*
    for (i=0; i<N+1; i++) {
        printf("%lld\n", A[i]);
    }
    printf("\n");
    */
    
    x=0; n=0; a=A[0];
    for (i=1; i<N+1; i++) {
        if (A[i]==a) {
            n++;
            x+=n;
        }
        else {
            n=0;
            a=A[i];
        }
    }
    
    printf("%lld", x);
    
    return 0;
}


Measured memory_bytes: 7112
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int inf=1e9,mod=1e9+7,N=2e5+5;

void solve(){
	int n,d,x;
	cin>>n>>d>>x;
	rep(i,n){
		int c;
		cin>>c;
		x+=(d+c-1)/c;
	}
	cout<<x;
	
}
int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

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

int main () {

    int N;
    cin >> N;

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


    int numberOfWrongPos = 0;
    for (int i = 0; i < N; i++) {
        if (i+1 != p[i]) {
            numberOfWrongPos++;
        }
    }
    cout << ((numberOfWrongPos == 0 || numberOfWrongPos == 2)? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

	static int[] chars = new int[26];
	
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] flds = line.split(" ");
		int n = Integer.parseInt(flds[0]);
		int k = Integer.parseInt(flds[1]);
		for (int i=0; i<n; i++) {
			line = br.readLine();
			char ch = line.charAt(0);
			chars[ch - 'A']++;
		}
		List<Integer> list = new ArrayList<>();
		for (int i=0; i<26; i++) {
			if (chars[i] > 0) {
				list.add(chars[i]);
			}
		}
		long cnt = 0;
		while (true) {
			if (list.size() < k) {
				break;
			}
			Collections.sort(list);
			int idx = list.size() - 1;
			for (int i=0; i<k; i++) {
				int v = list.get(idx);
				v--;
				if (v > 0) {
					list.set(idx, v);
				} else {
					list.remove(idx);
				}
				idx--;
			}
			cnt++;
		}
		System.out.println(cnt);
		long end = System.currentTimeMillis();
//		System.out.println((end-start) + "ms");
	}

}


Measured memory_bytes: 12400
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 200005
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N;
    cin >> S;
    ll i = 0;
    ll cnt = 0;
    ll j = S.size() - 1;
    while(i < j) {
    	if(S[j] == 'R' && S[i] == 'W') {
    		swap(S[i], S[j]);
    		cnt++;
    		i++;
    		j--;
    	}
    	else if(S[j] == 'W') {
    		j--;
    	}
    	else if(S[i] == 'R') {
    		i++;
    	}
    	else if(S[j] == 'R') {
    		while( i < j && S[i] != 'W') {
    			i++;
    		}
    	}
    	else if(S[i] == 'W') {
    		while(i < j && S[j] != 'R') {
    			j--;
    		} 
    	}
    }

    cout << cnt << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3772
import java.io.*;
public class Main{  
    public static void main(String[] args){
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String txt1 = reader.readLine();
			int x = Integer.parseInt(txt1);
			int num;
			num = x * x * x;
			System.out.println(num);
        }catch(IOException e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24160
if __name__ == "__main__":
    n, a, b = map(int, input().split())

    ans = 0

    for i in range(1, n+1):
        s = str(i)
        tmp = 0
        for ss in s:
            tmp += int(ss)
        if a <= tmp <= b:
            ans += i

    print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<set>

using namespace std;

int main()
{
    int n;
    cin>>n;
    set<int> s;
    int a;
    for(int i=0; i<n; i++) {
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for(i = 0; i <= n; ++i) for(j = 0; j <= m; ++j) if(i * j + (n - i) * (m - j) == k) {
    printf("Yes");
    return 0;
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
# ABC069C - 4-adjacent (ARC080C)
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    f, t, m = 0, 0, 0  # two, four, misc
    for i in A:
        if i % 4 == 0:
            f += 1
        elif i % 2 == 0:
            t += 1
        else:
            m += 1
    m += t % 2
    print("Yes" if m - f <= 1 else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 14352
n = int(input())
p = list(input().split())

mycnt = 0
for i in range(n-2):
  j = int(p[i])
  k = int(p[i+1])
  l = int(p[i+2])
  if j < k < l or l < k < j:
    mycnt += 1

print(mycnt)

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

int main() {
	int l[50],n,k;
	scanf("%d%d",&n,&k);
	for(int i = 0; i < n; ++i)
		scanf("%d",l+i);
	sort(l,l+n);
	int a = 0;
	for(int i = 1; i <= k; ++i)
		a += l[n-i];
	printf("%d\n",a);
}

Measured memory_bytes: 256
#include <array>
#include <iostream>
#include <vector>

using namespace std;

constexpr int64_t N_SIZE{100 + 1};
constexpr int64_t W_SIZE{100000 + 1};
array<int64_t, N_SIZE> weight;
array<int64_t, N_SIZE> value;
array<array<int64_t, W_SIZE>, N_SIZE> dp;

int main(int argc, char* argv[]) {
  int64_t N, W;
  cin >> N >> W;
  weight[0] = value[0] = 0;
  for (int64_t i = 1; i <= N; ++i) {
    cin >> weight[i] >> value[i];
  }

  for (int64_t n = 0; n <= N; ++n) {
    fill_n(dp[n].begin(), W, 0);
  }
  for (int64_t n = 1; n <= N; ++n) {
    for (int64_t w = 0; w <= W; ++w) {
      if (w < weight[n]) {
        dp[n][w] = dp[n - 1][w];
      } else {
        dp[n][w] = max(dp[n - 1][w], dp[n - 1][w - weight[n]] + value[n]);
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 79104
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut t: Vec<i32> = vec![0; n + 1];
    let mut x: Vec<i32> = vec![0; n + 1];
    let mut y: Vec<i32> = vec![0; n + 1];

    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for i in 1..n+1 {
        t[i] = read();
        x[i] = read();
        y[i] = read();
    }

    let mut succeeded = true;

    for i in 0..n {
        let diff = (t[i+1] - t[i]) - (x[i+1] - x[i]).abs() - (y[i+1] - y[i]).abs();
        if diff < 0 || diff % 2 != 0 {
            succeeded = false;
            break;
        }
    }

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


Measured memory_bytes: 4352
#include <stdio.h>
#include <algorithm>
using namespace std;

const int MAXN = 16;

long long dp[(1 << MAXN) + 5];
long long sum[(1 << MAXN) + 5];
int a[MAXN][MAXN];

int main(void) {
    int n;

    scanf(" %d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf(" %d", &a[i][j]);
        }
    }

    for (int mask = 0; mask < 1 << n; mask++) {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int b1 = (mask >> i) & 1;
                int b2 = (mask >> j) & 1;
                if (b1 && b2) sum[mask] += a[i][j];
            }
        }
    }

    for (int mask = 0; mask < 1 << n; mask++) {
        dp[mask] = sum[mask];
        for (int sub = (mask - 1) & mask; sub > 0; sub = (sub - 1) & mask) {
            dp[mask] = max(dp[mask], dp[sub] + dp[mask ^ sub]);
        }
    }
    printf("%lld\n", dp[(1 << n) - 1]);

    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String str = sc.next();
        boolean flag = true;
        if (str.length() != a + b + 1) {
            flag = false;
        }
        if (str.charAt(a) != '-') {
            flag = false;
        }
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '-') {
                count++;
            }
        }
        if (count != 1) {
            flag = false;
        }
        System.out.println(flag ? "Yes" : "No");
    }
}

Measured memory_bytes: 22996
#include <cmath>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, x[1009], y[1009], r[1009]; double dist[1009][1009], d[1009]; bool used[1009];
int main() {
	scanf("%d%d%d%d%d",&x[0], &y[0], &x[1], &y[1], &n);
	for (int i = 2; i <= n + 1; i++) scanf("%d%d%d", &x[i], &y[i], &r[i]);
	for (int i = 0; i <= n + 1; i++) {
		for (int j = 0; j <= n + 1; j++) {
			dist[i][j] = hypot(1.0 * (x[i] - x[j]), 1.0 * (y[i] - y[j])) - r[i] - r[j];
			if (dist[i][j] < 0.0) dist[i][j] = 0.0;
		}
	}
	fill(d + 1, d + n + 2, 1.0e+15);
	for (int i = 0; i <= n + 1; i++) {
		int ptr = -1;
		for (int j = 0; j <= n + 1; j++) {
			if (!used[j] && (ptr == -1 || d[ptr] > d[j])) {
				ptr = j;
			}
		}
		used[ptr] = true;
		if (ptr == 1) break;
		for (int j = 0; j <= n + 1; j++) {
			if (!used[j]) {
				d[j] = min(d[j], d[ptr] + dist[ptr][j]);
			}
		}
	}
	printf("%.9lf\n", d[1]);
	return 0;
}

Measured memory_bytes: 8192