akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	rep(i, n) cin >> a[i + 1];
	vector<int> ans(n + 1);
	int cnt = 0;
	for (int i = n; i >= 1; i--) {
		int sum = 0;
		for (int j = i * (n / i); j > i; j -= i) {
			sum += ans[j];
		}
		if (sum % 2 == a[i]) ans[i] = 0;
		else {
			ans[i] = 1;
			cnt++;
		}
	}
	cout << cnt << endl;
	rep(i, n + 1) {
		if (ans[i] == 1) cout << i << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2432
//in the name of allah                
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll a[N] , val[N] , ps[N];
bool ok[N];

int main(){
        ios_base::sync_with_stdio(false);cin.tie(NULL);
        int n;cin >> n;
        for(int i=0 ; i<n ; i++)
                cin >> a[i];
        sort(a , a+n);
        for(int i=0 ; i<n ; i++){
                ps[i] = (i ? ps[i-1] : 0) + a[i];
                ok[i] = (i ? (2*ps[i-1] >= a[i]) : true);                
        }
        for(int i=n-2 ; i>=0 ; i--)
                ok[i] &= ok[i+1];
        int ans=0;
        for(int i=0 ; i<n ; i++){
                bool f = true;
                if(i+1<n && !ok[i+1])
                        f = false;
                ans += f;
        }
        cout << ans << "\n";
        return 0; 
}

Measured memory_bytes: 1920
W,N,v,w,i,m,*p;s(){scanf("%d,%d",&v,&w);}main(n){for(s();W=v;){int c[1001]={s()};for(n=v;s(p=c),n--;)for(m=i=W+1;i--;m-=*p++==*c)*p=i<w|*p>p[w]+v?*p:p[w]+v;printf("Case %d:\n%d\n%d\n",++N,*c,m);}}

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

int main()
{
	long long NMAX = 100, VMAX = 1000;
	long long N,W;
	cin >> N >> W;

	vector<long long> w(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}

	vector<vector<long long>> dp(N+1, vector<long long>(NMAX*VMAX+1, 10000000000));
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= NMAX*VMAX; j++) {
			if (v[i] > j) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j]);
			}
		}
	}

	long long ans = -1;
	for (int i = 0; i <= NMAX*VMAX; i++) if (dp[N][i] <= W) ans = i;

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

Measured memory_bytes: 80256
<?php
fscanf(STDIN, "%d %d", $text_strlen, $num);
fscanf(STDIN, "%s", $text);
for( $i=0; $i<$num; $i++ )
{
  fscanf(STDIN, "%d %d", $start, $end);
  $checkList[] = array( "start"=>$start, "end"=>$end );
}


$text = str_split( $text );
$ACList = array();
$ACList[1] = 0;
for( $i=1; $i<$text_strlen; $i++ )
{
  if( $text[$i-1] == "A" && $text[$i] == "C" )
  { $ACList[$i+1] = $ACList[$i]+1; }
  else
  { $ACList[$i+1] = $ACList[$i]; }
}


foreach( $checkList as $check )
{
  $count = $ACList[$check["end"]] - $ACList[ $check["start"] ];
  echo $count."\n";
}

?>

Measured memory_bytes: 55796
n, q = map(int, input().split())
s = input()

cnt = 0
ans = [0]
for i in range(n-1):
    if s[i:i+2] == 'AC':
        cnt += 1
    ans.append(cnt)

for i in range(q):
    l, r = map(int, input().split())
    print(ans[r-1]-ans[l-1])


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

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

  int count = 0;
  int ans = 0;
  
  for(int i=0; i<3;i++){
    if(s[i] == 'R'){
      count++;
    }else {
      if(ans < count) ans = count; 
      count = 0;
    }
  }
  if(ans< count)  ans = count;
  cout << ans << endl;
  
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long N, K;
vector<long long> A;

bool C(long long x) {
    long long cnt = 0;
    for(int i=0; i<N; ++i) {
        if(A[i] == 0) {
            if(x >= 0) cnt += N - 1;
        } else if(A[i] > 0) {
            long long tmp;
            if(x < 0) tmp = (x - A[i] + 1) / A[i];
            else tmp = x / A[i];
            int l = upper_bound(begin(A), end(A), tmp) - begin(A);
            cnt += l;
            if(i < l) --cnt;
        } else {
            long long tmp;
            if(x >= 0) tmp = (-1) * (x / abs(A[i]));
            else tmp = (abs(x) + abs(A[i]) - 1) / abs(A[i]);
            int l = end(A) - lower_bound(begin(A), end(A), tmp);
            cnt += l;
            if(i >= N - l) --cnt;
        }
    }
    //cout << x << ' ' << (cnt / 2) << endl;
    return cnt >= 2 * K;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    sort(begin(A), end(A));

    long long l = -1000000000000000000, r = 1000000000000000000;
    //long long l = 18, r = 20;
    while(r - l > 1) {
        long long m = (l + r) / 2;
        if(C(m)) r = m;
        else l = m;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	
	bool flag = true;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		if (((x + y) % 2) != (t % 2)||t<x+y) {
			flag = false;
			break;
		}
	}
	cout << ((flag) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int H,W;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>H>>W;
    bool cc[H+2][W+2];
    memset(cc,0,sizeof(cc));
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            char c;
            cin>>c;
            if(c=='#')cc[i][j]=true;
        }
    }
    
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(cc[i][j]){
                bool flag=false;
                for(int k=0;k<4;k++){
                    if(cc[i+dx[k]][j+dy[k]])flag=true;
                }
                if(!flag){
                    cout<<"No"<<"\n";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<"\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type r struct {
	index int
	p     int
}

func main() {
	var n int
	fmt.Scan(&n)
	as := make(rs, n)
	for i, _ := range as {
		fmt.Scan(&as[i].p)
		as[i].index = i + 1
	}
	sort.Sort(as)
	for i, _ := range as {
		fmt.Println(as[i].index)
	}
}

type rs []r

func (a rs) Len() int           { return len(a) }
func (a rs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a rs) Less(i, j int) bool { return a[i].p < a[j].p }


Measured memory_bytes: 5888
#include"bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;


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

	cout << ceil((double)(N - 1) / (double)(K - 1)) << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
 
using namespace std;
 
const int MAXH = 10;
const int MAXW = 20;
int W,H;
char field[MAXH][MAXW];
bool come[MAXH][MAXW];
int dx[] = {0,1,0,-1,1,1,-1,-1};
int dy[] = {1,0,-1,0,1,-1,1,-1};
 
void input(){
  for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++) cin >> field[i][j];
}
 
string comp(const string& s1, const string& s2){
   
  int len = min(s1.length(),s2.length());
  string s ="";
 
  for(int i = 0; i < len; i++){
    if(s1[i] != s2[i]) return s;
    s+=s1[i];
  }
  return s;
}
 
void print(const vector<string>& v){
  cout << endl;
  for(int i = 0; i < v.size(); i++)
    cout << v[i] << endl;
  cout << endl;
}
 
void solve(){
  vector<string> V;
 
  for(int i = 0; i < H; i++) 
    for(int j = 0; j < W; j++)
      for(int d = 0; d < 8; d++){
        memset(come,false,sizeof(come));
 
        string s = "";
        int x=j,y=i;
 
        while(!come[y][x]){
          s += field[y][x];
          come[y][x] = true;
          y = (y+dy[d]+H)%H;
          x = (x+dx[d]+W)%W;
        }
 
        V.push_back(s);
      }
 
  sort(V.begin(),V.end());
  // print(V);
  
  string ans = "";
 
  for(int i = 1; i < V.size(); i++){
     
    string tmp = comp(V[i-1],V[i]);
     
    if(tmp.length() == ans.length()) ans = min(ans,tmp);
    else if(tmp.length() > ans.length()) ans = tmp;
  }
   
  if(ans.length() > 1)cout << ans << endl;
  else cout << "0" << endl;
}
 
int main(){
 
  while(cin >> H >> W && H+W){
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1516
#include <stdio.h>

int main(void){
	int a,b,c;
	int i,count=0;
	
	scanf("%d %d %d",&a,&b,&c);

	for(i = a;i <= b;i++){
		if(c%i==0){
			count++;
		}
	}
	printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 596
void main(){
	char[] val = inln!char();
	writeln( (val[0]=='H')^(val[1]=='H')?'D':'H');
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a, a + n); sort(b, b + n);
    if (n & 1) {
        cout << b[n / 2] - a[n / 2] + 1 << '\n';
    } else {
        cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1<< '\n';
    }
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int m;
  cin >> m;
  vector<int> t(m);
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }
  sort(d.begin(), d.end());
  sort(t.begin(), t.end());
  int j = 0;
  for (int i = 0; i < m; i++) {
    while (d[j] < t[i] && j < n) j++;
    if (d[j] != t[i]) {
      cout << "NO" << endl;
      return 0;
    } else {
      j++;
    }
  }
  cout << "YES" << endl;

  return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b; cin >> a >> b;
  if(a==1){
    if(b==1) cout << "Draw" << endl;
    else cout << "Alice" << endl;
  }
  else{
    if(b==1) cout << "Bob" << endl;
    else if(a<b) cout << "Bob" << endl;
    else if(a>b) cout << "Alice" << endl;
    else cout << "Draw" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3596
n = int(input())
*a, = map(int, input().split())

ans = 0
j = 0
flag = True
while flag:
    flag = False
    for i in range(n - 1, j, -1):
        if a[i] < a[i - 1]:
            a[i], a[i - 1] = a[i - 1], a[i]
            flag = True
            ans += 1
    j += 1
else:
    print(*a)
    print(ans)



Measured memory_bytes: 5608
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
d = 0
for i in range(N):
  a, b = As[i], Bs[i]
  if a < b:
    d += (b-a)//2
  else:
    d -= a-b
if d >= 0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 4596
#include<iostream>
#include<math.h>

using namespace std;

int main() {
  
  int n, count = 0;
  float d;
  cin>>n>>d;
  
  while(n--) {
    int x,y;
    cin>>x>>y;
    
    
    
	if(sqrt(pow(x, 2) + pow(y, 2)) <= d)
     count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(begin(a), end(a));
    for(int i = 0; i < n - 1; i++){
        cout << a[i].second << " ";
    }
    cout << a[n - 1].second << "\n";
}

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	ll n, m, l, a[105][105], b[105][105], c[105][105];

	cin >> n >> m >> l;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {

			cin >> a[i][j];

		}
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= l; j++) {

			cin >> b[i][j];

		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= l; j++) {

			c[i][j] = 0;
			for (int k = 1; k <= m; k++) {

				c[i][j] += a[i][k] * b[k][j];

			}
			if (j != l)cout << c[i][j] << " ";

		}
		cout << c[i][l] << endl;
	}

	return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    int p[n];
    rep(i,n){
        cin >> p[i];
    }
    ll dp[n][n+1];
    ll INF = 1001001001001001001;
    rep(i,n)rep(j,n+1)dp[i][j] = INF;
    rep(i,n){
        if(i == 0){
            dp[i][0] = a;
            dp[i][p[i]] = 0;
        }else{
            int x = p[i];
            dp[i][0] = dp[i-1][0] + a;
            srep(j,1,n+1){
                if(j < x){
                    dp[i][j] = dp[i-1][j] + a;
                }else if(j == x){
                    rep(k,x+1){
                        dp[i][x] = min(dp[i][x], dp[i-1][k]);
                    }
                }else{
                    dp[i][j] = dp[i-1][j] + b;
                }
            }
        }
    }
    ll ans = INF;
    rep(j,n+1)ans = min(ans, dp[n-1][j]);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 198976
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  val m = (1 << 9) - 1

  def solve(sc: => Scanner): Unit = {
    println(getPrimeList.filter(_ % 5 == 2).take(sc.nextInt).force.mkString(" "))
  }

  def recursive(now: Int, A: Array[List[Int]]): Int = {
    if (A(now).size == 0) (now) else {
      val next = A(now).head
      A(now) = A(now).filter(_ != next)
      A(next) = A(next).filter(_ != now)
      recursive(next, A)
    }
  }

  def getPermutation(now: Long = 0): Stream[Long] = {
    Stream.cons(now, getPermutation(now + 1))
  }

  def getPrimeList(): Stream[Long] = {
    getPrimeListRecursive(getPermutation(2))
  }

  def getPrimeListRecursive(A: Stream[Long]): Stream[Long] = {
    Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))
  }

  def check(A: Array[List[Int]]): Boolean = {
    A.map(_.size == 0).fold(true)((a, b) => a & b)
  }

  def shift(n: Long): Long = {
    if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)
  }

  def unShift(n: Long): Long = {
    if (n == 0) (0) else (unShift(n >> 1) + 1)
  }

  def calc(v: Long): Long = (v + 1) * v / 2

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 31608
N, P = map(x -> parse(Int64,x), split(readline(STDIN)))
function primes(n)
    prime_factors = Dict{Int64, Int64}()
    divisor = 2
    
    while divisor^2 <= n
        count = 0
        while n % divisor == 0
            count += 1
            n ÷= divisor 
        end
        if count > 0
            prime_factors[divisor] = count
        end
        divisor += 1
    end
    
    if n > 1
        prime_factors[n] = 1
    end
    
    return prime_factors
end
primes_dic = primes(P)
cal_k(pair) = pair.first ^  floor(Int, pair.second / N)
answer = length(primes_dic) == 0 ? 1 : mapreduce(x->cal_k(x), *, primes_dic)
println(answer)

Measured memory_bytes: 111684
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def factorization(n):
    # 参考: https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
    dic = defaultdict(int)
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            dic[i] = cnt
            
    if temp!=1:
        dic[temp] = 1


    return dic

def main():
    n = int(input())
    prime_dic = factorization(n)
    ans = 0
    for p in prime_dic:
        j = 1
        while prime_dic[p] >= j:
            ans += 1
            prime_dic[p] -= j
            j += 1            
    
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 10728
import math
n, m, d = map(int, input().split())

# sum = 0
# for i in range(1,n+1):
#     cnt = 0
#     if i + d <= n:
#         cnt += 1
#     if i - d > 0:
#         cnt += 1
#     sum += cnt / n / n * (m-1)

if d != 0:
    print(2 * (n - d - d) * (m-1) / n / n + 2*d * (m-1) / n / n)
else:
    print((m-1)/n)

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

const int P=1e9+7;

#define M 100005
typedef long long ll;

int num[26];
char str[M];

ll ans=0;

void dfs(int x,ll res=1) {
	if(x==25) {
		ans=(ans+res)%P;
		return;
	}
	dfs(x+1,res*num[x+1]%P);
	dfs(x+1,res);
}

int main() {
	int n;
	scanf("%d",&n);
	scanf("%s",str+1);
	for(int i=1;i<=n;++i)
		num[str[i]-'a']++;
	dfs(-1);
	printf("%lld\n",((ans-1)%P+P)%P);
	return 0;
}


Measured memory_bytes: 384
N,M = map(int,input().split())
X= list(map(int,input().split()))
X.sort()
distance =[0]*(M-1)
for i in range(M-1):
    distance[i] = X[i+1]-X[i]

d_sum = sum(distance)
distance.sort()
if N>=M:
    d_sum = 0

elif N !=1:
    for i in range(N-1):
        d_sum-=distance[(M-2)-i]

print(d_sum)


Measured memory_bytes: 13968
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
ok = True
for i, si in enumerate(s):
    if i%2:
        if si == "R":
            ok = False

    else:
        if si == "L":
            ok = False

print("Yes" if ok else "No")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a, b,c ; cin >> a >> b >> c;
    int k; cin >> k;
    rep(i,k) {
        if (a < b) {
            if (b < c) {
                cout << "Yes" << endl;
                return 0;
            }
            else c *= 2;
        } 
        else {
            b *= 2;
        }
    }
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	int n;
	cin >> n;
	vector<long long> H;
	REP(i, n) {
		long long a;
		cin >> a;
		H.push_back(a);
	}
	H[0] -= 1;
	for (int i = 1; i < H.size(); ++i) {
		if (H[i] != H[i - 1]) {
			H[i]--;
		}
		if (H[i] < H[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1400
import sys
input=sys.stdin.readline

n,m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

dp = [0]*(n+1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2,n+1):
    if i in a:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[n]%(10**9+7))


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	repp(i,1,s.size())
	{
		if(s[i]==s[i-1])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   if (s == "AAA" || s == "BBB")
      cout << "No" << endl;
   else
      cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<pair<int,int>> b(m,pair<int,int>());
    vector<long long> sum(n,0);
    for(int i = 0;i < n;i++){
        cin >> a[i];     
    } 
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i++){
        if(i == 0)sum[i] = a[i];
        else sum[i] = sum[i-1]+a[i];
    }
    for(int i = 0;i < m;i++){
        cin >> b[i].second >> b[i].first;
    }
    sort(b.begin(),b.end());
    int MIN[m];
    int s = 0;
    for(int i = 0;i < m;i++){
        MIN[i] = upper_bound(a.begin(),a.end(),b[i].first)-a.begin();
    }
    for(int i = m-1;i >= 0;i--){
        if(MIN[i] >= 0){
            for(int j = s;j <= MIN[i] && j <= b[i].second + s;j++){
                if(j == MIN[i] || j == b[i].second + s){
                    s = j;
                    break;
                }
                if(j < n){
                    a[j] = b[i].first;
                }
            }
        }
    }
    long long SUM = 0;
    for(int i = 0;i < n;i++){
        SUM += a[i];
    }
    cout << SUM << endl;
}

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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
// const int mx = 1e7 + 5;
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mx = 1e5 + 5;
ll freq[mx] = {};

/********************************************************************/
int main() {
	FAST();
	ll n;
	cin >> n;
	ll ar[n] = {};
	ll ans = 0;
	for (int i = 0 ; i < n; i++) {
		cin >> ar[i];
		ans ^= ar[i];
	}
	vi ret;
	for (int i = 0 ; i < n; i++) {
		ret.pb(ans ^ ar[i]);
	}
	for (auto x : ret)
		cout << x << ' ';
	return 0;
}

Measured memory_bytes: 6856
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    bool yellow = false;
  	cin >> n;

    rep(i,n){
        char c;
        cin >> c;
      	//cerr << c << endl;
        if(c == 'Y'){
            yellow = true;
            break;
        }
    }

    cout << (yellow ? "Four" : "Three") << endl;

    return 0; 
}

Measured memory_bytes: 256
/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const int md=1e8;
  const ll MAX=1e5+5;
  //
  //
  int main(){
  	ll n,a,b,x,y;
  	cin>>n>>a>>b>>x>>y;
  	string str;
  	cin>>str;
  	str=','+str;
  	rep(i,a+1,x+1)
  			if(str[i]=='#'&&str[i-1]=='#')	{cout<<"No";return 0;}
  		rep(i,b+1,y+1)
  			if(str[i]=='#'&&str[i-1]=='#')	{cout<<"No";return 0;}
  	if(x<y){
  		cout<<"Yes";
  	}
  	else{
  		rep(i,b,y+1)
  			if(str[i]=='.'&&str[i+1]=='.'&&str[i-1]=='.'){cout<<"Yes";return 0;}
  		cout<<"No";
  	}
  	return 0;
  }  			


Measured memory_bytes: 772
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int n,k;
	cin>>n>>k;
	int sum = 0;
	if(k < 0){
		int last = (n + k - 1);
		if(last>=0){
			for(int i=k;i<=last;i++)
				sum += i;
		}else{
			for(int i=k;i<last;i++){
				sum += i;
			}
		}
	}else{
		for(int i=k+1;i<n+k;i++){
			sum+=i;
		}
	}	

	cout<<sum<<endl;
	

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a,data[7];
	while(cin>>n,n){
		memset(data,0,sizeof(data));
		for(int i=0;i<n;i++){
			cin>>a;
			if(a<10)data[0]++;
			else if(a<20)data[1]++;
			else if(a<30)data[2]++;
			else if(a<40)data[3]++;
			else if(a<50)data[4]++;
			else if(a<60)data[5]++;
			else data[6]++;
		}
		for(int i=0;i<7;i++){
			cout<<data[i]<<endl;
		}
	}
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<pair<long long, long long> > D(N);
	vector<long long> E(N);
	vector<long long> COUNT(N, 1);
	vector<pair<long long, long long> > ANS;
	for (int i = 0; i < N; i++) cin >> D[i].first, D[i].second = i, E[i] = D[i].first;
	sort(D.begin(), D.end());
	sort(E.begin(), E.end());
	for (int i = N - 1; i > 0; i--) {
		long long C = COUNT[D[i].second];
		long long ND = D[i].first - (N - C * 2);
		long long it = lower_bound(E.begin(), E.end(), ND) - E.begin();
		if (D[it].first != ND || i <= it) {
			cout << -1 << endl;
			return 0;
		}
		ANS.push_back({ D[i].second, D[it].second });
		COUNT[D[it].second] += COUNT[D[i].second];
	}
	vector<vector<long long> > V(N);
	for (int i = 0; i < N - 1; i++) {
		V[ANS[i].first].push_back(ANS[i].second);
		V[ANS[i].second].push_back(ANS[i].first);
	}
	vector<long long> Dists(N, -1);
	Dists[D[0].second] = 0;
	queue<long long> Q;
	Q.push(D[0].second);
	while (!Q.empty()) {
		long long P = Q.front();
		Q.pop();
		for (long long NP : V[P]) {
			if (Dists[NP] == -1) {
				Dists[NP] = Dists[P] + 1;
				Q.push(NP);
			}
		}
	}
	long long SUM = 0;
	for (int i = 0; i < N; i++) SUM += Dists[i];
	if (SUM != D[0].first) cout << -1 << endl;
	else for (int i = 0; i < N - 1; i++) cout << ANS[i].first + 1 << " " << ANS[i].second + 1 << endl;
}

Measured memory_bytes: 12784
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int ans = sorv(n);
			System.out.println(ans);
		}
		
	}
	
	public static int sorv(int n) {
		int c1 = sa(1,0,0,n - 200);
		int c2 = sb(0,1,0,n - 300);
		int c3 = sc(0,0,1,n - 500);
		
		int ans = c1;
		if (ans > c2) ans = c2;
		if (ans > c3) ans = c3;
		return ans;
	}
	
	public static int sa(int a, int b, int c, int las) {
		if(las < 0) return 999999999;
		if(las == 0 && a % 5 == 0) return 380 - (int)(380 * 5 * 0.2);
		if(las == 0) return 380;
		int c1 = sa(a+1,b,c,las - 200);
		int c2 = sb(a,b+1,c,las - 300);
		int c3 = sc(a,b,c+1,las - 500);
		if(a+1 % 5 == 0) c1 += 380 - (int)(380 * 5 * 0.2);
		int ans = c1;
		if(ans > c2) ans = c2;
		if(ans > c3) ans = c3;
		if(a % 5 == 0) ans += 380 - (int)(380 * 5 * 0.2);
		else ans += 380;
		return ans;
	}
	public static int sb(int a, int b, int c, int las) {
		if(las < 0) return 999999999;
		if(las == 0 && b % 4 == 0) return 550 - (int)(550 * 4 * 0.15);
		if(las == 0) return 550;
		int c1 = sa(a+1,b,c,las - 200);
		int c2 = sb(a,b+1,c,las - 300);
		int c3 = sc(a,b,c+1,las - 500);
		int ans = c1;
		if(ans > c2) ans = c2;
		if(ans > c3) ans = c3;
		if(b % 4 == 0) ans += 550 - (int)(550 * 4 * 0.15);
		else ans += 550;
		return ans;
		
	}
	
	public static int sc(int a, int b, int c, int las) {
		if(las < 0) return 999999999;
		if(las == 0 && c % 3 == 0) return 850 - (int)(850 * 3 * 0.12);
		if(las == 0) return 850;
		int c1 = sa(a+1,b,c,las - 200);
		int c2 = sb(a,b+1,c,las - 300);
		int c3 = sc(a,b,c+1,las - 500);
		int ans = c1;
		if(ans > c2) ans = c2;
		if(ans > c3) ans = c3;
		if(c % 3 == 0) ans += 850 - (int)(850 * 3 * 0.12);
		else ans += 850;
		return ans;
	}
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int W, H;
    std::cin >> H >> W;

    vector<vector<int>> W_v(H, vector<int>(W, 0));
    REP(hi, H) {
        string s;
        std::cin >> s;
        REP(wi, W) {
            int cnt = 0;
            while(true) {
                if(s[wi] == '#') {
                    break;
                }
                else {
                    cnt++;
                }
                wi++;
                if(wi == W) {
                    break;
                }
            }
            fill(W_v[hi].begin() + wi - cnt, W_v[hi].begin() + wi, cnt);
        }
    }

    int ans = 0;
    REP(wi, W) {
        REP(hi, H) {
            int cnt = 0;
            while(true) {
                if(W_v[hi][wi] == 0) {
                    break;
                }
                else {
                    cnt++;
                }
                hi++;
                if(hi == H) {
                    break;
                }
            }
            REP(ci, cnt) {
                ans = max(ans, cnt + W_v[hi - ci - 1][wi]);
            }
        }
    }

    std::cout << ans - 1 << std::endl;

    return 0;
}


Measured memory_bytes: 16000
import sys
sys.setrecursionlimit(10 ** 6)


def main():
    n, A, B, C = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    INF = 10 ** 9

    def dfs(cur, a, b, c):
        if cur == n:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
        ll = l[cur]
        ret0 = dfs(cur + 1, a, b, c)
        ret1 = dfs(cur + 1, a + ll, b, c) + 10
        ret2 = dfs(cur + 1, a, b + ll, c) + 10
        ret3 = dfs(cur + 1, a, b, c + ll) + 10
        return min(ret0, ret1, ret2, ret3)

    print(dfs(0, 0, 0, 0))


main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
	int a, b,gamen=1;
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		if (gamen < b) { gamen *= 2; }
		else { gamen += b; }
	}
	cout << gamen << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
string s, t;
int main() {
	cin >> s >> t;
	bool f = false;
	for (int i = 0; i < s.size(); ++i) {
		if (s.substr(i) + s.substr(0, i) == t) f = true;
	}
	cout << (f ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = []
for i in range(m):
  p,x = map(int,input().split())
  px.append([p,x])
for i in range(m):
    time = 0
    for j in range(n):
        if j+1 == px[i][0]:
            time += px[i][1]
        else:
            time += t[j]
    print(time)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 < tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 > tmp2 )  return  1;
}

int main(void){
    int N;
    scanf("%d",&N);
    int X[N];
    int CX[N];
    for(int i=0;i<N;i++){
        scanf("%d",&X[i]);
        CX[i]=X[i];
    }
    //sort
    qsort(X,N,sizeof(int),comp);
    
    /*for(int i=0;i<N;i++){
        printf("%d",X[i]);
    }*/
    int chu_min = X[N/2-1];
    int chu_max = X[N/2];
    //printf("%d %d",chu_min,chu_max);
    for(int i=0;i<N;i++){
        if(CX[i]<=chu_min){
            printf("%d\n",chu_max);
        }else{
            printf("%d\n",chu_min);
        }
    }
    return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt = 1;
  rep(i, N-1){
    if(S[i] != S[i+1]) cnt ++;
  }
  cout << cnt << endl;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int x;
int main() {
    cin >> x;
    int obj = x % 100;
    int cnt = x / 100;
    int ans = 0;
    for(int f = 0; f < 50; ++f) {
        ans = f*5;
        for(int e = 0; e < 50; ++e) {
            ans += e*4;
            for(int d = 0; d < 50; ++d) {
                ans += d*3;
                for(int c = 0; c < 100; ++c) {
                    ans += c*2;
                    if((obj-ans) <= cnt-(f+e+d+c) && (obj-ans) >= 0) {
                        // cout << f << " " << e << " " << d << " " << c << endl;
                        // cout << obj << " " << ans << endl;
                        cout << 1 << endl;
                        return 0;
                    }
                    ans -= c*2;
                }
                ans -= d*3;
            }
            ans -= e*4;
        }
    }
    cout << 0 << endl;
}

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

int p[111111], h[111111], d[111111];
vector<vector<int>> g;
int f(int w, int x, int k) {
    d[x] = k;
    int m = -1;
    for(int y : g[x]) {
        if(y == w)
            continue;
        p[y] = x;
        m = max(m, f(x, y, k + 1));
    }
    return h[x] = m + 1;
}
int main() {
    int n, u, v;
    cin >> n >> u >> v;
    g.resize(n + 1);
    for(int i = 1; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    f(0, v, 0);
    int l = (d[u] - 1) / 2;
    while(l--)
        u = p[u];
    cout << h[u] + d[u] - 1 << endl;
    return 0;
}


Measured memory_bytes: 13312
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    int W = 0;
    int R = 0;

    for (int i = 0; i < N; ++i) {
        if (S[i] == 'R') {
            ++R;
        } else {
            ++W;
        }
    }

    for (int i = 0; i < N; ++i) {
        if (i < R) {
            if (S[i] == 'W') { // should be swapped
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3720
table = [[None] * 101 for _ in range(101)]

def comb(n, r):
  if not table[n][r] is None:
    return table[n][r]
  
  if n == r or r == 0:
    table[n][r] = 1
  elif r == 1:
    table[n][r] = n
  else:
    table[n][r] = comb(n - 1, r - 1) + comb(n - 1, r)
    
  return table[n][r]

N, P = map(int, input().split())
biscuits = [int(x) for x in input().split()]

num_even = len([x for x in biscuits if x % 2 == 0])
num_odd = N - num_even

A = 0

for r in range(num_even + 1):
  A += comb(num_even, r)

B = 0

for r in range(num_odd + 1):
  if r % 2 == P:
    B += comb(num_odd, r)
    
print(A * B)
  
  

Measured memory_bytes: 41580
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
from collections import Counter
s = Counter(s)
t = Counter(t)
ans = 0
for k, v in s.items():
    if k in t:
        ans = max(ans, max(v - t[k], 0))
    else:
        ans = max(ans, v)
print(ans)


Measured memory_bytes: 3316
n = int(input())
arr = []
for i in range(n):
    s = list(str(input()))
    s.sort()
    k = ''
    for i in range(10):
        k += s[i]
    arr.append(k)
arr.sort()
ans = 0
count = 1
for i in range(n - 1):
    if arr[i] == arr[i + 1]:
        count += 1
        if i == n - 2:
            ans += count * (count - 1) // 2
    else:
        ans += count * (count - 1) // 2
        count = 1
print(ans)

Measured memory_bytes: 10612
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

int main(int argc, char const *argv[])
{
  int r;
  cin >> r;
  cout << r*r;
  
  return 0;
}


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

#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int

using namespace std;

///ISNNJB

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main()
{
    /***freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    return 0;
}



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

int main(){
  double R = 0;
  cin >> R;
  cout << R * 2 * 3.141592;
  return 0;
}

Measured memory_bytes: 3796
#include <iostream>

using namespace std;
typedef long long LL;

int main() {
    LL N, A, B, ans = 0;
    cin >> N >> A >> B;
    if (A == 0) {
        cout << 0 << endl;
    } else {
        ans += N / (A + B) * A;
        ans += N % (A + B) >= A ? A : N % (A + B);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[51];
int main(){
  int n,m;cin>>n>>m;
  for(int i = 0; m > i; i++){
  	int c,d;cin>>c>>d;
    a[c-1]++;
    a[d-1]++;
  }
  for(int i = 0; n > i; i++){
  	cout << a[i] << endl;
  }
}
  

Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

G = [[0] * W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            G[h][w] = '#'
            continue
        tmp = 0
        for i in range(-1, 2, 1):
            for j in range(-1, 2, 1):
                if (0 <= h + i < H and 0 <= w + j < W):
                    if S[h + i][w + j] == '#':
                        tmp += 1
        G[h][w] = tmp

for tmp in G:
    print (*tmp, sep = '')


Measured memory_bytes: 3444
using System.Linq;
using System.Collections.Generic;
using System;
class Program
{
    static void Main()
    {
        Func<int> InputNumber = () => int.Parse(Console.ReadLine());
        Func<string> InputString = () => Console.ReadLine();
        Func<IEnumerable<int>> InputNumbers = () => Console.ReadLine().Split(' ').Select(x => int.Parse(x));
        Func<string[]> InputStrings = () => Console.ReadLine().Split(' ');
        
        var NAB = Console.ReadLine().Split(' ');
        var N = long.Parse(NAB[0]);
        var A = long.Parse(NAB[1]);
        var B = long.Parse(NAB[2]);

        if (A > B || N == 1 && A != B)
        {
            Console.WriteLine(0);
        }
        else
        {
            long min = A * (N - 1) + B;
            long max = A + B * (N - 1);
            Console.WriteLine(max - min + 1);
        }
    }
}

Measured memory_bytes: 13140