akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#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 fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;

	cin >> n;

	int dumn = n;

	int ans = 0;
	rep(i, 0, cnt_digit(n)) {
		ans += dumn % 10;
		dumn /= 10;
	}

	if (n % ans == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	

	
		
	



}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	auto itn = s.find("N") != string::npos;
	auto itw = s.find("W") != string::npos;
	auto its = s.find("S") != string::npos;
	auto ite = s.find("E") != string::npos;
	bool valid = (!(itw ^ ite)) && !(itn ^ its);
	cout << (valid ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
   long long a;
   cin>>a;
   long long p;
   p=1;
   long long d=1000000000+7;
   for(long long i=1;i<=a;i++){
      p=p*i;
      p=p%d;
   }
  
   cout<<p<<endl;

}



Measured memory_bytes: 256
use std::cmp::Ordering;
use whiteread::parse_line;

fn main() {
    let a: String = parse_line().unwrap();
    let b: String = parse_line().unwrap();

    let ans = match a.len().cmp(&b.len()) {
        Ordering::Less => "LESS",
        Ordering::Greater => "GREATER",
        Ordering::Equal => {
            let mut a_iter = a.as_str().chars();
            let mut b_iter = b.as_str().chars();
            let mut ans = "EQUAL";
            for _ in 0..a.len() {
                match a_iter.next().unwrap().cmp(&b_iter.next().unwrap()) {
                    Ordering::Less => {
                        ans = "LESS";
                        break;
                    }
                    Ordering::Greater => {
                        ans = "GREATER";
                        break;
                    }
                    Ordering::Equal => continue,
                };
            }
            ans
        }
    };
    println!("{}", ans);
}


Measured memory_bytes: 2100
//g++ main.cpp -I ac-library
#include <bits/stdc++.h>
#include <atcoder/convolution>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

using namespace atcoder;
using mint = modint998244353;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vec<int> A(N),B(M);
    for(auto& x:A) cin >> x;
    for(auto& x:B) cin >> x;
    auto C = convolution(A,B);
    for(int i=0;i<C.size();i++) cout << C[i] << (i+1!=C.size()? " ":"\n");
}


Measured memory_bytes: 19008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,x,t;
cin >> n >> x >> t;
int result;
if (n%x!=0)
{
    /* code */


result = (n/x +1)*t ;
}
if (n%x==0)
{
    result = (n/x)*t;
}


cout << result  << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

const int mod=1e9+7;

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

	cout<<180+(n-3)*180<<endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)


int N, S;
int ans;

void dfs(int s, int i, int cnt) {
	if (cnt == N&& s == S) {
		ans++;
		return;
	}
	else if (cnt == N || s > S||i==10){
		return;
	}
	else {
		dfs(s + i, i + 1, cnt + 1);
		dfs(s, i + 1, cnt);
	}
}

int main() {
	while (cin >> N >> S && (N != 0 || S != 0)) {
		ans = 0;
		dfs(0, 0, 0);
		cout << ans << endl;
	}
}


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

double segment(double x1, double y1, double x2, double y2);
double inclination(double x1, double y1, double x2, double y2);

int main(void)
{
    int x1, x2, y1, y2, x, y;
    double a, b, c;
    int n, i;

    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    a = inclination(x1, y1, x2, y2);
    b = -1.0;
    c = segment(x1, y1, x2, y2);
    //ax+by+c=0
    scanf("%d",&n);

    if (a > 2000000000) {
        for (i = 0; i < n; i++) {
            scanf("%d %d", &x, &y);
            if (x < x1) {
                printf("%.10lf %.10lf\n",x+2.0*(x1-x), (double)y);
            } else {
                printf("%.10lf %.10lf\n",x-2.0*(x-x1), (double)y);
            }
        }
    } else {
        for (i = 0; i < n; i++) {
            scanf("%d %d", &x, &y);
            printf("%.10lf %.10lf\n",x-2.0*a*(a*x+b*y+c)/(a*a+b*b)
                    ,y-2.0*b*(a*x+b*y+c)/(a*a+b*b));
        }
    }
    return 0;
}

double segment(double x1, double y1, double x2, double y2)
{
    //*切片
    double a, b1, b2;
    a = inclination(x1, y1, x2, y2);
    if (a > 2000000000.0) {
        return 2100000000.0;
    }
    b1 = -a * x1 + y1;
    b2 = -a * x2 + y2;
    return (b1 + b2) / 2;
}

double inclination(double x1, double y1, double x2, double y2) 
{
    //*傾き
    if (-0.00000000002 < x2 - x1 && x2 - x1 < 0.00000000002) {
        return 2100000000.0;
    } else {
        return (y2 - y1) / (x2 - x1);
    }
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=(1<<21);
int main(){

  typedef struct{
    int a;
    int b;
    int c;
  }wear;
  wear st[200];

  int d,n;
  int t[200];
  cin>> d>> n;
  for(int i=0;i<d;i++){
    cin>> t[i];
  }

  for(int i=0;i<n;i++){
    cin>> st[i].a>> st[i].b>> st[i].c;
  }

  int dp[d][n];

  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      if(i==0 && st[j].a<=t[0] && st[j].b>=t[0]) dp[i][j]=0;
      else dp[i][j]=-INF;
    }
  }

  for(int i=1;i<d;i++){
    for(int j=0;j<n;j++){
      if(st[j].a<=t[i] && st[j].b>=t[i]){
	for(int k=0;k<n;k++){
	  dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(st[k].c-st[j].c));
	}
      }
    }
  }

  int m=0;
  for(int i=0;i<n;i++){
    m=max(m,dp[d-1][i]);
  }

  cout<< m<< endl;
}

Measured memory_bytes: 1316
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <limits>
#include <iomanip>
//std::numeric_limits<int>::max(), min()

int main (void) {
  double N, K;
  std::cin >> N >> K;

  double ans = 0.;
  for(int i=1; i<=N; i++){
    int p = std::log2(K/i) >= 0 ? std::ceil(std::log2(K/i)) : 0. ;

    ans += ( (1./N) * std::pow(0.5, p) );
  }

  std::cout << std::setprecision(13) << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string S, T; cin >> S >> T;
  vector<vector<int>> dp(S.size() + 1, vector<int> (T.size() + 1, (0)));
  for(int i = 0; i < S.size(); i++) {
    for(int j = 0; j < T.size(); j++) {
      if(S[i] == T[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
    }
  }
  string ans = "";
  int i = S.size(), j = T.size();
  while(i > 0 && j > 0) {
    if(S[i - 1] == T[j - 1]) {
      ans += S[i - 1];
      i--; j--;
    } else {
      if(dp[i][j - 1] > dp[i - 1][j]) j--;
      else i--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 38576
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int maxN = 3000005;
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
vector<int> fac; //precompute fac array
vector<int> ifac;
int modInverse(int n){ 
    return p(n, MOD-2); 
}  
int nCr(int n, int r){   
    if(r == 0)  return 1; 
    return m(m(m(fac[n])*m(ifac[r]))*m(ifac[n-r])); 
} 
signed main(){
    fast();
    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    fac.resize(maxN);
    ifac.resize(maxN);
    fac[0] = 1; 
    int ans = 0;
    for (int i=1; i<maxN; i++){
        fac[i] = m(m(fac[i-1])*m(i));
    }
    for(int i=0; i<maxN; i++){
        ifac[i] = modInverse(fac[i]);
    }
    for(int i=c1; i<=c2; i++){
        ans = m(m(ans) + m(nCr(r2+i+1, i+1)-nCr(r1+i, i+1)));
    }
    cout << ans << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

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

int main(){
  int N,num;
  string S;
  cin>>N>>S;
  for(int i=0;i<S.size();i++){
    num=S.at(i)+N;
    if(num>90)
      num-=26;
  	char j=num;
    cout<<j;
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a,b,c,d;
    
    scanf("%d",&a);
    scanf("%d",&b);
    
    c=2*a+2*b;
    d=a*b;
    
    printf("%d %d\n",d,c);
    
    return 0;
}


Measured memory_bytes: 2104
from collections import Counter

s=input()[::-1]
ans=0
lst=[0]
num=0
p=1
for i in s:
    lst.append((int(i)*p+lst[-1])%2019)
    p=p*10%2019

ans=sum(x*(x-1)//2 for x in Counter(lst).values())
print(ans)

Measured memory_bytes: 76212
#include <iostream>
#include <string>
#define INF 1e+9
using namespace std;

int main(){
	int dp[1001][1001] = {};
	string s1,s2;
	cin >> s1 >> s2;
	for(int i = 0;i < s1.length();i++){
		for(int j = 0;j < s2.length();j++){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for(int i = 1;i <= s1.length();i++) dp[i][0] = i;
	for(int i = 1;i <= s2.length();i++) dp[0][i] = i;
	for(int i = 1;i <= s1.length();i++){
		for(int j = 1;j <= s2.length();j++){
			if(s1[i - 1] == s2[j - 1]) dp[i][j] = dp[i - 1][j - 1];
			else{
				dp[i][j] = min(min(dp[i - 1][j],dp[i][j - 1]),dp[i - 1][j - 1]) + 1;
			}
		}
	}
	cout << dp[s1.length()][s2.length()] << endl;
	return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,m;
    ll tmp;
    cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    vector<Pll> cake(n, Pll(0, 0));
    rep(n){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0LL;
    rep(2){
        repp(j, 2){
            repp(k, 2){
                repp(c, n){
                    cake[c].first = (i==0?1:-1)*x[c] + (j==0?1:-1)*y[c] + (k==0?1:-1)*z[c];
                    cake[c].second = c;
                }
                sort(rall(cake));
                ll total[3] = {0,0,0};
                repp(c, m){
                    total[0] += x[cake[c].second];
                    total[1] += y[cake[c].second];
                    total[2] += z[cake[c].second];
                }
                ans = max(ans, abs(total[0]) + abs(total[1]) + abs(total[2]));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def solve():
    S = input()
    alpha_map = {}
    for c in S:
        if not c in alpha_map.keys():
            alpha_map[c] = 1
        else:
            alpha_map[c] = alpha_map[c] + 1
    if any(x > 1 for x in alpha_map.values()):
        print("no")
    else:
        print("yes")

solve()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
#include <inttypes.h>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
#define INF 1<<21
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main(){
    int N,A,max;

    std::cin >> N >> A;
	max = A;
	std::vector<int> x(N+1);
x[0]=0;
	for (int i = 1; i <= N; i++) {
		std::cin >> x[i];
		max = std::max(max, x[i]);
	}
	
	std::vector<std::vector<std::vector<long long >>>dp(N + 5, std::vector<std::vector<long long>>(N + 5, std::vector<long long>(N*max + 5, 0)));
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k <= N*max; k++) {
				if (i == 0 && j == 0 && k == 0) {
					dp[i][j][k] = 1;
				}
				else if (i>=1&&k < x[i]) {
					dp[i][j][k] = dp[i - 1][j][k];
				}
				else if (i >= 1 && j >= 1 && k >= x[i]) {
					
dp[i][j][k] = dp[i - 1][j][k]+dp[i-1][j-1][k-x[i]];
				}
				else {
					dp[i][j][k] = 0;
				}
			}
		}
	}
	long sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += dp[N][i][i*A];
	}
	std::cout << sum << std::endl;
	
    return 0;
}

Measured memory_bytes: 60672
#include<stdio.h>
int main(void){
    int gakuseki,i = 0;
    double W,H;
    double BMI;
    while(scanf("%d,%lf,%lf",&gakuseki,&W,&H) == 3){
        BMI = W/H/H;
        if(BMI>=25){
            printf("%d\n",gakuseki);
            i++;
        }
    }
    if(i == 0){
        printf("該当無し\n");
    }
    return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<long> vec;
int main(){
  long n,k,sum,a; cin>>n>>k;
  vec HP(n);
  rep(i,n) cin>>HP[i];
  
  if(n<=k){cout<<0;}
  else{
  sort(HP.begin(), HP.end());
  reverse(HP.begin(), HP.end());
    
    
   sum=0;
   for(int i=k;i<n;i++){
     sum+=HP[i];
   }
  cout<<sum;
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
int main(){
  int n;
  while(cin >> n && n){
	vector<pair<int,int> > book(n);
	for(int i = 0;i < n;i++){
	  cin >> book[i].first >> book[i].second;
	}
	sort(book.begin(),book.end());
	int sum = 0;
	if(n == 1 ){
	  cout << book[0].first*2+book[0].second << endl;
	  continue;
	}
	for(int i = n-2;i >= 0;i--){
	  sum+=book[i].first;
	}

	if(sum >= book[n-1].first){
	  sum = 0;
	  for(int i = 0;i < n;i++){
		sum+=book[i].first + book[i].second;
	  }
	  cout << sum << endl;

	}else{
	  int amari = book[n-1].first - sum;

	  vector<int> dp(amari+1,-1);
	  dp[0] = 1;
	  for(int i = 0;i < n-1;i++){
		for(int j = amari;0 <= j;j--){
		  if(dp[j] == 1 && book[i].second+j <= amari){
			dp[j+book[i].second] = 1;
		  }
		}
	  }
	  int amari_max = 0;
	  for(int i = 0;i <= amari;i++){
		if(dp[i] == 1)amari_max = max(amari_max,i);
	  }
	  sum = 0;
	  for(int i = 0;i < n;i++){
		sum+= book[i].first + book[i].second;
	  }
	  assert(amari-amari_max >= 0);
	  cout << sum + amari - amari_max << endl;
	  
	  
	}
	
  }
  return 0;
}

Measured memory_bytes: 1208
n,k = map(int,input().split())
h_list = list(map(int,input().split()))
h_list.sort(reverse=True)
if k>= len(h_list):
  print(0)
elif k ==0 :
  print(sum(h_list))
else:
  del h_list[:k]
  print(sum(h_list))
 


Measured memory_bytes: 25768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ull fun(ull n) {
	if (n < 2) {
		return 1;
	} else {
		return n * fun(n - 2);
	}
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    rp(i, 0, n) cin >> a[i];
    sort(a, a + n);
    ll aa = 0, bb = 0;
    rp(i, 0, n)
    {
        if (i % 2 == 0)
            aa += a[i];
        else
            bb += a[i];
    }
    ce(llabs(aa - bb));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,k,cnt=0,h;
    cin >> n >> k;
    rep(i,n){
        cin >> h;
        if(h>=k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll diff = a - b;
  if (k % 2) diff = -diff;
  cout << diff << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/

/*==================================================*/

int main() {

    string s;
    cin>>s;
    bool flag = false;
    REP(i,0,s.size()){
        if(s[i] == 'A' ){
            flag = true;
        }else if(s[i] == 'C'  && flag){
            cout<<"Yes"<<endl;
            return 0;
        }else{
            flag = false;
        }
    }

    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int[] c = new int[4];
		for(int i=0;i<s.length;i++){
			if(s[i]=='K')c[0]++;
			if(s[i]=='U')c[1]++;
			if(s[i]=='P')c[2]++;
			if(s[i]=='C')c[3]++;
		}
		System.out.println(Math.min(c[0], Math.min(c[1], Math.min(c[2], c[3]))));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
N, M = map(int, input().split())
p = []
s = []
for _ in range(M):
	tp,ts = map(str,input().split())
	p.append(int(tp))
	s.append(ts)

cnt = [0] * (N+1)
flg = [0] * (N+1)
cnt_AC = 0
cnt_WA = 0
for i in range(M):
	cp = p[i]
	if flg[cp] == 1:
		continue
	else:
		if s[i] == 'AC':
			cnt_AC += 1
			cnt_WA += cnt[cp]
			flg[cp] = 1
		else:
			cnt[cp] += 1
print(cnt_AC, end = " ")
print(cnt_WA)

Measured memory_bytes: 14896
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static bool[,] graph = new bool[8, 8];
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            for(var i=0;i<M;i++)
            {
                var AB = Sarray();
                graph[AB[0] - 1, AB[1] - 1] = graph[AB[1] - 1, AB[0] - 1] = true;
            }
            var visited = new bool[8];
            visited[0] = true;
            WriteLine(dfs(0, N, visited));
        }

        static int dfs(int v,int N,bool[] visited)
        {
            var all = true;
            for(var i=0;i<N;i++)
            {
                if (!visited[i]) all = false;
            }
            if (all) return 1;
            var ret = 0;
            for(var i=0;i<N;i++)
            {
                if (!graph[v, i]) continue;
                if (visited[i]) continue;
                visited[i] = true;
                ret += dfs(i, N, visited);
                visited[i] = false;
            }
            return ret;
        }
    }
}

Measured memory_bytes: 18848
import sys
input = sys.stdin.readline
k, n = [int(w) for w in input().split()]
a_li = [int(w) for w in input().split()]

dist = k - a_li[-1] + a_li[0]

for i in range(1, n):
    dist = max(dist, a_li[i] - a_li[i - 1])

print(k - dist)


Measured memory_bytes: 31528
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    string a, b;
    cin >> a >> b;
    ll r = (ll)b.size();
    ll tmp = 0;
    
     
    rep(i, (ll)a.size()-(ll)b.size()+1) {
        tmp = 0;
        rep(j, (ll)b.size()) {
            if(a[i+j] != b[j]) {
                tmp ++;
            }
        }
        r = min(r, tmp);
        
    }
    mes(r);
    
    
    
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,q,a[100009];
    scanf("%d%d%d",&n,&k,&q);
    memset(a,0,sizeof(a));
    for(int i=1;i<=q;i++)
    {
        int x;
        scanf("%d",&x);
        a[1]++;
        a[x]--;
        a[x+1]++;
        a[n+1]--;
    }
    for(int i=1;i<=n;i++)
    {
        a[i]+=a[i-1];
        //printf("%d\n",k-a[i]);
        if(k-a[i]<=0)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}

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

int main()
{
	map<char, int> CtoI;
	CtoI['S'] = 0;
	CtoI['H'] = 1;
	CtoI['C'] = 2;
	CtoI['D'] = 3;
	
	map<int, char> ItoC;
	ItoC[0] = 'S';
	ItoC[1] = 'H';
	ItoC[2] = 'C';
	ItoC[3] = 'D';
	
	int N, I;
	char C;
	bool card[52];
	
	for(int i = 0; i < 52; ++i)
	{
		card[i] = true;
	}
	
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> C >> I;
		card[CtoI[C] * 13 + I - 1] = false;
	}
	
	for(int i = 0; i < 52; ++i)
	{
		if(card[i])
		{
			cout << ItoC[i / 13] << " " << i % 13 + 1 << endl;
		}
	}

    return 0;
}



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

s=input()

check = [0]*n

for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        check[i] = check[i-1]+1
    else:
        check[i] = check[i-1]

for _ in range(q):
    x,y = map(int,input().split())
    print(check[y-1]-check[x-1])

Measured memory_bytes: 51444
#include <bits/stdc++.h>
using namespace std;
const   int MaxN=1e5+5;
int n,m,deg[MaxN],res,f[MaxN];
vector<int> a[MaxN];
queue<int> que;

void Xuli()
{
    for(int i=1;i<=n;i++)
        if (deg[i]==0) que.push(i);
    while (que.size())
    {
        int u=que.front();
        que.pop();
        for(int i=0;i<a[u].size();i++)
        {
            int v=a[u][i];
            f[v]=max(f[v],f[u]+1);
            deg[v]--;
            if (deg[v]==0) que.push(v);
        }
        res=max(res,f[u]);
    }
    printf("%d",res);
}

int main()
{

    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        a[x].push_back(y);
        deg[y]++;
    }
    Xuli();
}


Measured memory_bytes: 6528
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int N,x;
	int A[100];
	cin >> N >> x;
	
	if (x == 1 || x == 2 * N - 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		int a = x - N;
			for (int i = 0; i < 2*N-1; i++) {
				cout << (i + a + (2 * N - 1)) % (2 * N - 1) + 1 << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 1536
def main():
    N, M = list(map(int, input().split()))
    if N % 2 == 1:
        for i in range(M):
            print(i + 1, N - i - 1)
            
    else:
        s = set()
        t = 0
        for i in range(M):
            a, b = i + 1, N - i - t
            if (b - a) in s or (a + N - b) in s or b - a == a + N - b:
                t += 1
                b = N - i - t
            print(a, b)
            s.add(b - a)
            s.add(N + a - b)

main()


Measured memory_bytes: 17312
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int N;
vector <int> wins[100005];

int dfs(int u)
{
    vector <int> depths;
    for (int v : wins[u])
    {
        depths.push_back(dfs(v));
    }
    sort(depths.begin(), depths.end(), greater<int>());
    int maxDepth = 0;
    for (int i = 0; i < depths.size(); i++)
    {
        int depth = depths[i];
        maxDepth = max(depth + i + 1, maxDepth);
    }
    return maxDepth;
}

int main()
{
    scanf("%d", &N);
    for (int i = 2; i <= N; i++)
    {
        int a; scanf("%d", &a);
        wins[a].push_back(i);
    }
    printf("%d\n", dfs(1));
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define vi vector<int>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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 = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,Q;
    cin >> n >> m >> Q;
    vector<P> rail(m);
    rep(i,m) {
        int l,r;
        cin >> l >> r;
        l--; r--;
        rail[i] = {l,r};
    }
    vector<vi> ans(n,vi(n,0));
    rep(i,n) {
        rep(j,m) {
            if(rail[j].first >= i) ans[i][rail[j].second]++;
        }
        rep(j,n-1) ans[i][j+1] += ans[i][j];
    }
    rep(_,Q) {
        int p,q;
        cin >> p >> q;
        p--; q--;
        cout << ans[p][q] << endl;
    }
}


Measured memory_bytes: 3456
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
typedef long long LL;
using namespace std;
LL ans;
int a, b, c, x;
int main() {
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; i++)
		for(int j = 0; j <= b; j++)
			if((x - 500 * i - 100 * j >= 0) && (x - 500 * i - 100 * j <= c * 50))
				ans++;
	cout << ans << endl;
	
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,k; cin>>n>>k;
  map<int,int> m;
  rep(i,n){
    int a; cin>>a;
    m[a]++;
  }
  vi v;
  int cnt=0;
  for(auto e: m){
    cnt++;
    v.push_back(e.second);
  }
  vsort(v);
  int ans=0;
  rep(i,cnt-k){
    ans+=v[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10744
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
class obj
{
public:
    ll a;
    ll b;
    ll c;
    ll d;
    obj(ll x,ll y,ll z,ll e):a(x),b(y),c(z),d(e)
    {

    }
};
ll ans=0;
void fun(ll n,ll m,ll q,vector<obj>&v,vector<ll>&seq,ll i,ll prev)
{
    if(i==n)
    {
        ll cal=0;
        for(ll i=0;i<q;i++)
        {
            ll a=v[i].a;
            ll b=v[i].b;
            ll c=v[i].c;
            ll d=v[i].d;
            if(seq[b-1]-seq[a-1]==c)
            {
                cal+=d;
            }
        }
        ans=max(ans,cal);
        return;
    }
    for(ll j=prev;j<=m;j++)
    {
        seq[i]=j;
        fun(n,m,q,v,seq,i+1,j);
    }
}
int main()
{
fast;
ll n,m,q;
cin>>n>>m>>q;
vector<obj>v;
for(ll i=0;i<q;i++)
{
    ll x,y,z,e;
    cin>>x>>y>>z>>e;
    v.pb(obj(x,y,z,e));
}
vector<ll>seq(n,1);
fun(n,m,q,v,seq,0,1);
cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=10005;
const int NN=2005;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    ll a,b,n;
    cin >> a >> b >> n;
    ll ans=(a*n)/b-a*(n/b);
    for (ll i=n-1;i>=max(n-10000000,1ll);i--){
        ans=max(ans,(a*i)/b-a*(i/b));
    }
    for (ll i=1;i<=min(n,10000000ll);i++){
        ans=max(ans,(a*i)/b-a*(i/b));
    }
    for (ll i=b-10000000;i<=b+10000000;i++){
        if (i<=0 || i>n)continue;
        ans=max(ans,(a*i)/b-a*(i/b));
    }
    cout << ans << E;
    r0;
}
/*









*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    string s;
    cin >> s;
    if (s[0]==s[2]) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#python 3.5.2

N = int(input())
s_list = [input() for i in range(N)]
cnt = sum([s.count("AB") for s in s_list])
a_end, b_start, a_b = 0, 0, 0

for s in s_list:
    if s[0] == "B" and s[-1] == "A":
        a_b += 1
    elif s[0] == "B":
        b_start += 1
    elif s[-1] == "A":
        a_end += 1
if a_b == 0:
    cnt += min(a_end, b_start)
else:
    cnt += a_b - 1
    if a_end >= 1:
        cnt += 1
        a_end -= 1
    if b_start >= 1:
        cnt += 1
        b_start -= 1
    cnt += min(a_end, b_start)
print(cnt)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#ifndef ONLINE_JUDGE
#define show(a) cout<<""#a""<<" is "<<a<<endl;
#define shw(a,b)cout<<"-->"<<a<<" "<<b<<endl;
#define print(arr,xx)for(int i=0;i<xx;i++)cout<<arr[i]<<" \n"[i==xx-1];
#define here cout<<"here\n";
#define fastio ;
#else
#define show(a)  ;
#define shw(a,b) ;
#define print(arr,xx) ;
#define here
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif
int caseno = 0;
#define print_case cout<<"Case "<<++caseno<<": ";
#define fout freopen("output.txt","w",stdout);
#define fin freopen("input.txt","r",stdin);
#define pb push_back
#define pi acos(-1.0)
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > vii;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
void yesno(bool okk) {cout << (okk ? "YES" : "NO") << endl; if (!okk)return;}
const int primemod = 1000000007;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define ass(XX) (if(!XX){cout<<-1<<endl;return;})
const ll maxsize = 1 * 1000000 + 9;
#define fi first
#define se second
#define inf 1<<25
const double eps = 1e-10;
const int N = 210;
ll n, m;
void solve() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i])cnt++;
    }
    cout << cnt << endl;
}

int main() {
#ifndef ONLINE_JUDGE
    fin
    fout
#endif
    ///-----
    fastio
    int T;
    T = 1;
    // cin >> T;
    while (T--) {
        // yesno(solve());
        solve();
    }
    ///-----
    return 0 ;
}



Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n; 
    vector<int> a(n+1,0), x(n+1,0);
    for(int i=1; i<=n; ++i){
        cin >> a[i];
    }
    x[1]=accumulate(a.begin(),a.end(),0);
    for(int i=2; i<n; i+=2){
        x[1] -= 2*(a[i]);
    }
    cout << x[1] << " ";
    for(int i=2; i<=n; ++i){
        x[i]=2*a[i-1]-x[i-1];
        cout << x[i] << " ";
    }
	cout << endl;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
 
LL pos[2][100005];
 
void solve(LL id,LL num){
	LL sgn = 1,tmp = num;
	if(num < 0) sgn = -1,tmp = -num;
	for(LL i = 0;i <= 19;i ++){
		pos[id][i] = tmp % 3;
		tmp /= 3;
	}
	for(LL i = 0;i <= 19;i ++){
		if(pos[id][i] == 2 || pos[id][i] == -2){
			pos[id][i + 1] += pos[id][i] / 2;
			pos[id][i] = - pos[id][i] / 2;
		}
		else if(pos[id][i] == 3 || pos[id][i] == -3){
			pos[id][i + 1] += pos[id][i] / 3;
			pos[id][i] = 0;
		}
	}
	for(LL i = 0;i <= 19;i ++) pos[id][i] *= sgn;
}
 
char ch[45];
LL x[100005],y[100005],exs[2] = {0};
 
LL pwr(LL x,LL y){
	LL ret = 1;
	while(y --) ret *= x; return ret;
}
 
int main(){
	LL n;
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> x[i] >> y[i];
		exs[(x[i] + y[i]) & 1] = 1;
	}
	if(exs[0] && exs[1]){ cout << -1 << endl; return 0; }
	if(exs[0]){
		cout << 40 << endl;
		for(LL i = 0;i <= 19;i ++) cout << pwr(3LL,i) << ' ' << pwr(3LL,i) << (i == 19 ? '\n' : ' ');
	}
	if(exs[1]){
		cout << 39 << endl;
		for(LL i = 0;i <= 18;i ++) cout << pwr(3LL,i) << ' ' << pwr(3LL,i) << ' ';
		cout << pwr(3LL,19) << endl;
	}
	
	for(LL i = 1;i <= n;i ++){
		solve(0,x[i]); solve(1,y[i]);
//		for(LL j = 0;j <= 19;j ++) cout << pos[1][j] << (j == 19 ? '\n' : ' ');
		for(LL j = 0;j <= 18;j ++){
			if(pos[0][j] == -2){ pos[0][j] = 1; pos[0][j + 1] --; }
			if(pos[1][j] == -2){ pos[1][j] = 1; pos[1][j + 1] --; }
			if(pos[0][j] == 2){ pos[0][j] = -1; pos[0][j + 1] ++; }
			if(pos[1][j] == 2){ pos[1][j] = -1; pos[1][j + 1] ++; }
			
			if(pos[0][j] && pos[1][j]){
				ch[j << 1] = (pos[0][j] == 1 ? 'R' : 'L');
				ch[(j << 1) + 1] = (pos[1][j] == 1 ? 'U' : 'D');
			}
			if(!pos[0][j] && !pos[1][j]){ ch[j << 1] = 'L'; ch[(j << 1) + 1] = 'R'; }
			if(pos[0][j] && !pos[1][j]){
				if(pos[0][j] == 1){ pos[0][j] = -2; pos[0][j + 1] ++; ch[j << 1] = ch[(j << 1) + 1] = 'L'; }
				if(pos[0][j] == -1){ pos[0][j] = 2; pos[0][j + 1] --; ch[j << 1] = ch[(j << 1) + 1] = 'R';  }
			}
			if(!pos[0][j] && pos[1][j]){
				if(pos[1][j] == 1){ pos[1][j] = -2; pos[1][j + 1] ++; ch[j << 1] = ch[(j << 1) + 1] = 'D'; }
				if(pos[1][j] == -1){ pos[1][j] = 2; pos[1][j + 1] --; ch[j << 1] = ch[(j << 1) + 1] = 'U';  }
			}
//			cout << pos[1][j] << ' ';
		}
//		cout << pos[1][19] << endl;
		if(pos[0][19] && !pos[1][19]) ch[38] = (pos[0][19] == 1 ? 'R' : 'L');
		if(!pos[0][19] && pos[1][19]) ch[38] = (pos[1][19] == 1 ? 'U' : 'D');
		if(!pos[0][19] && !pos[1][19]) ch[38] = 'R',ch[39] = 'L';
		if(pos[0][19] && pos[1][19]) ch[38] = (pos[0][19] == 1 ? 'R' : 'L'),ch[39] = (pos[1][19] == 1 ? 'U' : 'D');;
		cout << ch << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d %d",$a,$b);

if(($a+$b)%3 == 0) {
    echo 'Possible';

}else if ($a%3 == 0 )
{
    echo 'Possible';   
}else if ($b%3 == 0 )
{
    echo 'Possible';   
}
else{
    echo 'Impossible';
}

Measured memory_bytes: 4728
#chirstmas eve
n,k=map(int,input().split())
lists=[] 
for i in range(n):
    a=int(input())
    lists.append(a)
lists=sorted(lists)
ans=10**10
for i in range(n-k+1):
    ans=min(ans,lists[i+k-1]-lists[i])
print(ans)  

Measured memory_bytes: 8280
#include <stdio.h>
#include <string.h>

int main()
{
    int k, l;
    char ch[101], ch2[101]={};
    scanf("%d", &k);
    scanf("%s", ch);
    l=strlen(ch);

    if (l<=k) printf("%s\n", ch);
    else {
        strncpy(ch2, ch, k);
        printf("%s...\n", ch2);
    }
    return 0;
}


Measured memory_bytes: 1732
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int h = sc.nextInt();
		// スペース区切りの整数の入力
		int n = sc.nextInt();
		int a =0;
      
      	for(int i=0;i<n;i++){
          a = a + sc.nextInt();
        }
     	 // 出力
     	if(a>=h){
          System.out.println("Yes");
        }
      	else{
		  System.out.println("No");
      	
        }
	}
}


Measured memory_bytes: 48260
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
 
#define MAXN 500002

int block_sze;
int ans = 0;
int freq[MAXN] = {};
int arr[MAXN] = {};
int answer[MAXN] = {};
int cl,cr;
int bl[MAXN] = {};

struct query
{
    int id, l, r, lc;
    bool operator < (const query& rhs)
    {
        return (bl[l] == bl[rhs.l]) ? (r < rhs.r) : (bl[l] < bl[rhs.l]);
    }
}queries[MAXN];

 
inline void add(int idx)
{
    if(!freq[arr[idx]]) ans++;
    freq[arr[idx]]++;
}
 
inline void remove(int idx)
{
    freq[arr[idx]]--;
    if(!freq[arr[idx]]) ans--;
}

int n,q,l,r,i;
 
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/
         
    cin>>n>>q;
 
    for(i = 0; i < n; i++)
    {
        cin>>arr[i];
    }
 
    ans = 0;
 
    for(i = 0; i < q; i++)
    {
        cin>>l>>r;
        l--,r--;
        queries[i].l = l;
        queries[i].r = r;
        queries[i].id = i;
    }
    
    block_sze = sqrt(n)+1;
 
    for(i = 0; i < n+1; i++)
    {
        bl[i] = (i-1)/block_sze + 1;
    }

    sort(queries,queries+q);    
 
    cl = 0,cr = -1;
    for(i = 0; i < q; i++)
    {
        l = queries[i].l,r = queries[i].r;
 
        for(; cl < l ;)
        {
            remove(cl);
            cl++;
        }
        for(; r < cr ;)
        {
            remove(cr);
            cr--;
        }

        for(; l < cl ;)
        {
            cl--;
            add(cl);
        }

        for(; cr < r ;)
        {
            cr++;
            add(cr);
        }
 
        answer[queries[i].id] = ans;
    }
 
    for(i = 0; i < q; i++)
    {
        cout<<answer[i]<<'\n';
    }

    return 0;
} 

Measured memory_bytes: 19420
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const int MAX_N = 405;
vector<ll> a(MAX_N);
vector<ll> a_sum(MAX_N+1, 0);
vector<vector<ll>> memo(MAX_N, vector<ll>(MAX_N, -1));

// Get minimum cost in [l,r)
ll dfs(int l, int r){
    if(memo[l][r] != -1){return memo[l][r];}
    if(r-l <= 1){return 0;}
    ll ret = 1e18;
    for(int i=l+1; i<r; i++){
        ll val = 0;
        val += dfs(l, i);
        val += dfs(i, r);
        ret = min(val, ret);
    }
    ret += a_sum[r] - a_sum[l];
    memo[l][r] = ret;
    return ret;
}

int main(){
    int n; cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
        a_sum[i+1] = a_sum[i] + a[i];
    }
    cout << dfs(0, n) << "\n";
    return 0;
}

Measured memory_bytes: 1536