akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
#include <bitset>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

vector<vec> G;
vector<bool> goal;

bool memo[50][1001];
bool move(int v, int t){
    if(memo[v][t]) return true;
    if(t == 0){
        return goal[v];
    }else{
        if(G[v].size() == 0) return false;
        for(int i=0;i<G[v].size();i++){
            int to = G[v][i];
            if(move(to, t-1)){
                memo[v][t] = true;
                return true;
            }
        }
        return false;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vec abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];

    G.assign(n, vec(0));
    for(int i=0;i<m;i++){
        int u, v;
        cin >> u >> v;
        G[u-1].push_back(v-1);
    }

    bitset<50> cango[50][1001];
    for(int j=0;j<n;j++){
        cango[j][0].set(j);
        for(int k=0;k<G[j].size();k++){
            int to = G[j][k];
            cango[j][1].set(to);
        }
    }
    for(int i=2;i<=1000;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<G[j].size();k++){
                int to = G[j][k];
                cango[j][i] |= cango[to][i-1];
            }
        }
    }

    goal.assign(n, false);
    goal[n-1] = true;
    for(int t=1;t<=n;t++){
        vector<bool> goal_new = goal;
        for(int i=0;i<n;i++){
            if(goal[i]) continue;
            bool able = true;
            for(int j=0;j<3;j++){
                bool ableany = false;
                for(int k=0;k<n;k++){
                    if(!goal[k]) continue;
                    if(goal[k] && cango[i][abc[j]][k]){
                        ableany = true;
                        break;
                    }
                }
                if(!ableany){
                    able = false;
                    break;
                }
            }
            if(able){
                if(i == 0){
                    cout << t << endl;
                    return 0;
                }
                goal_new[i] = true;
            }
        }
        goal = goal_new;
    }

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

Measured memory_bytes: 1628
//Shubham Vijayvargiya

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define sz(a) (int)(a.size())
#define set(a,b) memset(a,b,sizeof(a))
#define let(x,a) __typeof(a) x(a)
#define rep(i, begin, end) for (ll i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) (v).begin(),(v).end()
#define sll(x) { scanf("%lld",&x); }
#define si(x) { scanf("%d",&x); }
#define slf(x) { scanf("%lf",&x); }
#define pll(x) { printf("%lld\n",x); }
#define pi(x) { printf("%d\n",x); }
#define tcases() long long testcases; cin>>testcases ; while(testcases--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...);
}

#else
#define trace(...)
#endif

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;

const ll mod=1000000007;
//----------------------------------------------------------------------------------------------------------------------------------------------//


int main(){
//	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	string s;
	cin>>s;
	rep(i,0,sz(s)-1){
		if(s[i]=='A' && s[i+1]=='C')
			return 0*puts("Yes");
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
M=1000003
f=[1]
for i in range(1,M):f.append(f[i-1]*i%M)
for _ in'_'*int(input()):
	x,d,n=map(int,input().split())
	t=x*pow(d,M-2,M)%M
	print([pow(x,n,M),(M-n>=t>0)*1and f[t+n-1]*pow(f[t-1],M-2,M)*pow(d,n,M)%M][d>0])

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

int main(){
  string ord;
  int topping=0;
  cin >> ord;


  for(int i=0;i<3;i++){
    if(ord.at(i)=='o')topping++;
  }
  cout << 700 + (topping*100) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
ll n, k;
#define size 3000
vector<ll> fac(size, 0);   // n!(mod M)
vector<ll> ifac(size, 0);  // k!^{M-2} (mod M)
vector<ll> inv(size, 0);   // k!^{M-2} (mod M)
////////////////////////////////////////////////
void fac_mod() {
  // fac[i] = i! (mod M)
  fac[0] = 1;
  fac[1] = 1;
  REP(i, size) { fac[i + 1] = fac[i] * (i + 1) % MOD; }
}
////////////////////////////////////////////////
void ifac_mod() {
  // ifac[i] = 1/i! (mod M)
  ifac[0] = 1;
  ifac[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < size; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    ifac[i] = ifac[i - 1] * inv[i] % MOD;
  }
}
////////////////////////////////////////////////
ll nCk_mod(ll n, ll k) {
  // nCk (mod M)
  if (n == 0 && k == 0) return 1;
  if (n < k || k < 0) return 0;
  return fac[n] * (ifac[n - k] * ifac[k] % MOD) % MOD;
}
////////////////////////////////////////////////
int main() {
  init();
  cin >> n >> k;
  fac_mod();
  ifac_mod();
  for (int i = 1; i <= k; i++) {
    cout << nCk_mod(n - k + 1, i) * nCk_mod(k - 1, i - 1) % MOD << endl;
  }
}


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

using namespace std;

const int N = 100010;

int n, m, i, d[N], x, y;

vector<int> v[N];

inline int maxim(int x, int y) {
    return (x > y ? x : y);
}

void dfs(int x) {
    for (int i = 0; i < v[x].size(); ++i) {
        if (d[ v[x][i] ] == 0) {
            dfs(v[x][i]);
        }
        d[x] = maxim(d[x], d[ v[x][i] ] + 1);
    }
}

int main() {
    cin >> n >> m;
    for (i = 1; i <= m; ++i) {
        cin >> x >> y;
        v[x].push_back(y);
    }
    for (i = 1; i <= n; ++i) {
        if (d[i] == 0) {
            dfs(i);
        }
    }
    m = 0;
    for (i = 1; i <= n; ++i) {
        m = maxim(m, d[i]);
    }
    cout << m << "\n";
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// === debug ===
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// === end ===

int main() {
  ll N, D;
  ins(N, D);

  int ans = 0;
  rep(i, N) {
    ll x, y;
    ins(x, y);
    if (D * D >= x * x + y * y)
      ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3600
def ketanowa(p):
    ans = 0
    p = str(p)
    for i in p:
        ans += int(i)
    return ans


def main():
    temp1 = input()
    temp1 = temp1.split(" ")
    n1 = int(temp1[0])
    n2 = int(temp1[1])
    if n2!=100:
        print((100**n1) * n2)
    else:
        if n1==0:
            print(101)
        if n1==1:
            print(10100)
        if n1==2:
            print(1010000)

if __name__ == '__main__':
    main()


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

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

  vector<bool> prime(50100, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i * i < 50100; ++i) {
    if(prime[i]) {
      for(int j = i * i; j < 50100; j += i) {
        prime[j] = false;
      }
    }
  }

  vector<int> vec;
  for(int i = 2; i <= 50000; ++i) {
    if(prime[i]) vec.push_back(i);
  }

  int n;
  while(cin >> n, n != 0) {
    int ans = 0;
    for(int i = 0; vec[i] <= n / 2; ++i) {
      if(prime[n - vec[i]]) ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;
int a[N];
int main(){
    string a;
    cin >> a;
    int aa = 0 , bb = 0;
    for(auto c:a){
        if(c == 'B') bb++;
        else aa++;
    }
    if(aa &&bb ){
        cout <<"Yes\n";
    }else{
        cout <<"No\n";
    }




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int d;cin>>d;
	if(d==25)cout<<"Christmas\n";
	else if(d==24)cout<<"Christmas Eve\n";
	else if(d==23)cout<<"Christmas Eve Eve\n";
	else cout<<"Christmas Eve Eve Eve\n";
	
	
	return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int cnt = 0;
  for(int i = 0; i < S.size(); i++){
    cnt += (S.at(i) == T.at(i));
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A,B,C,D;
    cin >>A >>B>>C>>D;
    cout << min(A,B)+min(C,D) << endl;



}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

ll b[114];

int main() {
	IOS();
	ll n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'L') {
			if (i != 0 && s[i - 1] == 'L') ans++;
		} else {
			if (i != n - 1 && s[i + 1] == 'R') ans++;
		}
	}
	dump(min(n - 1, ans + 2 * k));

	return 0;
}


Measured memory_bytes: 512
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))

n = II()
s = IS()
k = II()
a = []
for i in s:
    if i == s[k-1]:
        a.append(i)
    else:
        a.append('*')
print(''.join(a))


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

int main(){
    bool nonp[1500000] = {};
    vector<int> p;
    for(int i = 2; i < 1500000; i++){
        if(!nonp[i]){
            p.push_back(i);
            for(int j = i+i; j < 1500000; j += i)   nonp[j] = true;
        }
    }

    int n;
    while(cin >> n, n){
        if(!nonp[n]){
            cout << 0 << endl;
        }else{
            auto it = upper_bound(p.begin(), p.end(), n);
            cout << *it - *(it-1) << endl;
        }
    }

    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    char c;cin >>c;
    if(c>='a'&&c<='z')puts("a");
    else puts("A");
    return 0;
}


Measured memory_bytes: 3564
N = int(input())
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

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

print(max(result))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define N 1001
 
void Length(char *X, char *Y){
  int c[N][N];
  int i, j, m, n;
  m = strlen(X);
  n = strlen(Y);
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(j = 0; j <= n; j++) c[0][j] = 0;
  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(X[i-1] == Y[j-1]) c[i][j] = c[i-1][j-1] + 1;
      else if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }
  printf("%d\n",c[m][n]);
}
 
int main(){
  int i, n;
  char X[N], Y[N];
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s%s", X, Y);
    Length(X, Y);
  }
  return 0;
}

Measured memory_bytes: 5608
n = int(input())
inlist = [a for a in input().split()]

outlist = []
for i in range(n-1,-1,-1):
    outlist.append(inlist[i])

for j in range(n):
    if j<n-1:
        print(outlist[j],end=' ')
    if j==(n-1):
        print(outlist[j])


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

long long calc(long long n, long long m) {
    long long ret = 0;
    for (long long i = 0; i < n; i++) {
        ret += i * (n-i);
        ret %= mod;
    }
    ret = ret * m % mod * m % mod;
    return ret;
}

int main() {
    GetInv(); GetFactorial();
    int n, m, k; cin >> n >> m >> k;
    long long ans = calc(n, m) + calc(m, n);
    ans %= mod;
    ans = ans * combination(n*m-2, k-2) % mod;
    cout << ans << endl;
    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD =  (int)1e9 + 7;
const int MOD = 998244353;
const double EPS = 1e-9;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

	COMinit();


	int N, M, K;
	cin >> N >> M >> K;

	int ans = 0;
	int B = 1;

	rrep(i, 0, N)
	{
		if (i == N - 1)B *= M;
		else B *= (M - 1);
		B %= MOD;
		if (i <= K)
		{
			ans += B * COM(N - 1, N - 1 - i);
			ans %= MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15644
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, t;std::cin >> n >> t;
  ll ans = t;
  ll prev;std::cin >> prev;
  for(int i=1;i<n;i++){
    ll now;std::cin >> now;
    ll sa = now - prev;
    ans += min(t, sa);
    prev = now;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  ss <- replicateM n BS.getLine

  let siz = ord 'z' - ord 'a' + 1

  hmin <- VM.new siz
  VM.set hmin (10^9::Int)

  h <- VM.new siz

  let countS [] = return ()
      countS (s:xs) = do
        VM.set h (0::Int)
        forM_ [0..(BS.length s - 1)] $ \i -> do
          let c = BS.index s i
              j = ord c - ord 'a'
          m <- VM.read h j
          VM.write h j (m+1)
        forM_ [0..(siz-1)] $ \i -> do
          x <- VM.read hmin i
          y <- VM.read h i
          VM.write hmin i (min x y)
        countS xs

  countS ss

  hmin' <- V.freeze hmin
  
  putStrLn $
    concatMap
    (\c -> take (hmin' V.! (ord c - ord 'a')) (repeat c))
    ['a'..'z']

Measured memory_bytes: 508
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec;
use std::vec::Vec;
use std::collections::HashSet;


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i32 = sc.read();
    let mut s: HashSet<i32> = HashSet::new();
    for _i in 0..n {
        let h: i32 = sc.read();
        s.insert(h);
    }
    println!("{}", s.len());
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
import sys
from itertools import combinations
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M,Q=map(int,input().split())
    a,b,c,d=[0]*Q,[0]*Q,[0]*Q,[0]*Q
    for i in range(Q):
        a[i],b[i],c[i],d[i]=map(int,input().split())
        a[i]-=1
        b[i]-=1
    ans=0
    tmp_l=[[i] for i in range(1,M+1)]
    next=[]
    for _ in range(N-1):
        for l in tmp_l:
            for i in range(l[-1],M+1):
                next.append(l+[i])
        tmp_l=next[:]
        next=[]
    for A in tmp_l:
        tmp=0
        for i in range(Q):
            if A[b[i]]-A[a[i]]==c[i]:
                tmp+=d[i]
        ans=max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 107592
a, b, x = gets.chomp.split.map(&:to_f)

full = a * a * b

# 半分以上水が入っている場合
if full / 2 < x
  # 容器の空白部分から求める
  empty = full - x
  # empty = a * a * y / 2
  y = empty * 2 / (a * a)
  rad = Math.atan( y / a )
  theta = rad * 180 / Math::PI
else
  # 水の部分から求める
  # x = a * y * b / 2
  y = x * 2 / (a * b)
  rad = Math.atan( b / y )
  theta = rad * 180 / Math::PI
end

puts theta

Measured memory_bytes: 3836
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int dif[20];
int calc(int depth) {
  if (depth == n) { return 0; }
  if (dif[depth] == 0) { return calc(depth + 1); }
  int ret = 1000;
  int d = dif[depth];
  assert(1 <= d && d <= 9);
  FOR(r, depth, n) {
    FOREQ(i, depth, r) {
      dif[i] = (dif[i] - d + 10) % 10;
    }
    ret = min(ret, calc(depth + 1) + 1);
    FOREQ(i, depth, r) {
      dif[i] = (dif[i] + d + 10) % 10;
    }
  }
  return ret;
}

int main() {
  while (scanf("%d", &n), n) {
    REP(i, n) {
      char c;
      scanf(" %c ", &c);
      dif[i] = c - '0';
    }
    REP(i, n) {
      char c;
      scanf(" %c ", &c);
      dif[i] = (dif[i] - (c - '0') + 10) % 10;
    }
    printf("%d\n", calc(0));
  }
}

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

typedef long long ll;
const int N = (int)1e5 + 50, INF = (int)1e9 + 50;
typedef pair<int, int> P;

int n;
P p[N];
ll res[N];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> p[i].first, p[i].second = i;
    sort(p, p + n, greater<>());
    int r = 0;
    int mn = INF;
    for(int i = 0; i < n; ) {
        while(r < n && p[r].first == p[i].first) {
            mn = min(mn, p[r].second);
            r++;
        }
        res[mn] += 1LL * (p[i].first - p[r].first) * r;
        i = r;
    }
    for(int i = 0; i < n; i++) cout << res[i] << "\n";
}

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

using std::cin;
using std::cout;
using std::endl;

bool check_vec(std::vector<int> v, int t) {
	for (std::vector<int>::iterator itr = v.begin(); itr != v.end(); ++itr) {
		if (*itr == t) {
			return true;
		}
	}
	return false;
}

int main(void) {
	int a,b,c;
	cin >> a >> b >> c;
	
	bool awake = true;
	bool loop = false;
	bool goal = false;
	std::vector<int> ta,ts;
	int t = 0;
	int cycle = 0;

	for (int i = 1; !(goal) && !(loop); i++) {
		if (i%60 == 0) {
			cycle = 0;
		}
		t++;
		cycle++;
		if (awake) {
			if (i%60 == c) {
				goal = true;
				cout << i << endl;
			}
			if (t == a) {
				awake = false;
				if (check_vec(ts,cycle)) {
					cout << -1 << endl;
					loop = true;
				}
				else {
					ts.push_back(cycle);
				}
				t = 0;
			}
		}
		if (!(awake) && t == b) {
			awake = true;
			t = 0;
			if (check_vec(ta,cycle)) {
				cout << -1 << endl;
				loop = true;
			}
			else {
				ta.push_back(cycle);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3156
N = int(input())
A = list((i, j) for i, j in enumerate(map(int, input().split())))
dictL = {}
dictR = {}

ans = 0
for i in range(N):
    l, r = A[i][1] + A[i][0], A[i][0] - A[i][1]
    if l not in dictL:
        dictL[l] = 1
    else:
        dictL[l] += 1
    if r not in dictR:
        dictR[r] = 1
    else:
        dictR[r] += 1

for i in dictL.keys():
    if i in dictR.keys():
        ans += dictL[i] * dictR[i]
        
print(ans)  


Measured memory_bytes: 76620
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

unsigned long long modInverse(unsigned long long n, ll p) 
{ 
    return power(n, p - 2); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
unsigned long long nCrModPFermat(unsigned long long n, 
                                 ll r) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    unsigned long long fac[n + 1]; 
    fac[0] = 1; 
    for (ll i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % MOD; 
  
    return (fac[n] * modInverse(fac[r], MOD) % MOD * modInverse(fac[n - r], MOD) % MOD) % MOD; 
} 


int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,c,f;
	ll ans=0;
	cin>>n;
	for(i=1;n-2*i>i-1;i++)
	{
	    ans+=nCrModPFermat(n-2*i-1,i-1);
	    ans%=MOD;
	}
	cout<<ans;
	return 0;
}


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

#define LL long long
#define ULL unsigned long long int
LL INF=1000000000000000001;
#define mx 100009
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define INP freopen("in.txt","r",stdin)
#define OP  freopen("in.txt","w",stdout)

#define sf 	scanf
#define pf 	printf
#define F  	first
#define S  	second
#define pb 	push_back
#define NL	pf("\n")
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%I64d",&x);
#define sll(x,y)	sf("%I64d%I64d",&x,&y);
#define slll(x,y,z)	sf("%I64d%I64d%I64d",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v)		sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(i=0;i<n;i++)
#define FORE(i,n)	for(i=1;i<=n;i++)
#define FORR(i,n)	for(i=n-1;i>=0;i--)
#define FORRE(i,n)	for(i=n;i>0;i--)
// graph direction array [4]
//int X[4]={0,0,1,-1};
//int Y[4]={1,-1,0,0};

//bool cmp( int a,int b ){
//	return  a>b ;
//}



int main(){

//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
	LL n,m,i,j,k,t,d,bs,cs=0,c,sq,x,s,f,v;
	cin>>n;
	cout<<(n/3)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int cup[3];
	char c1, c2;

	cup[0] = 1;
	cup[1] = cup[2] = 0;

	while(scanf("%c,%c", &c1, &c2) != EOF){
		c1 -= 65;
		c2 -= 65;
		
		int temp = cup[c1];
		cup[c1] = cup[c2];
		cup[c2] = temp;
	}

	for(int i=0; i<3; i++){
		if(cup[i] == 1) printf("%c\n", i+65);
	}

	return 0;
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

ll n;

int main()
{
	ll cnt, ret;
	cnt = 0;
	cin >> n;

	for( ret=1; cnt < n; ret++){
		cnt += ret;
	}
	cout << ret-1 << endl;

	return 0;
}


Measured memory_bytes: 256
import bisect
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    L=list(mi())

    ans = 0
    L.sort()
    for ai in range(N):
        for bi in range(ai+1,N):
            a,b = L[ai],L[bi]

            left = bisect.bisect_left(L,abs(a-b)+1)
            right = bisect.bisect_right(L,a+b-1)

            count = right - left

            if left <= ai <= right:
                count -= 1

            if left <= bi <= right:
                count -= 1
            
            ans += count
            # if count > 0:
            #     print(a,b,count) 
            

    print(ans//3)


if __name__ == "__main__":
    main()

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

struct ot{
    int cnt[10], sum;
};


int n,m,memo[10] = {0,2,5,5,4,5,6,3,7,6};
ot dp[10001];

signed main() {
    cin >> n >> m;
    rep(i,m) {
        int a,cost;
        cin >> a;
        cost = memo[a];
        if (dp[cost].sum == 1) {
            repm(j,10) {
                if (dp[cost].cnt[j] && a > j) {dp[cost].cnt[j]=0,dp[cost].cnt[a]=1;break;}
            }
        }
        if (!dp[cost].sum) dp[cost].cnt[a]++,dp[cost].sum=1;
        rep1(j,n-cost) {
            if (dp[j].sum && dp[j].sum + 1 > dp[j+cost].sum) {
                rep(k,10) dp[j+cost].cnt[k] = dp[j].cnt[k];
                dp[j+cost].cnt[a]++;
                dp[j+cost].sum = dp[j].sum+1;
            }
            if (dp[j].sum && dp[j].sum +1 == dp[j+cost].sum) {
                bool f=false;
                repm(k,10) {
                    int d=0;
                    if (k == a) d++;
                    if (dp[j].cnt[k]+d > dp[j+cost].cnt[k]) {f=true;break;}
                    if (dp[j].cnt[k]+d < dp[j+cost].cnt[k]) break;
                }
                if (f) {
                    rep(k,10) dp[j+cost].cnt[k] = dp[j].cnt[k];
                    dp[j+cost].cnt[a]++;
                    dp[j+cost].sum = dp[j].sum+1;
                }
            }
        }
    }
    repm(i,10) rep(j,dp[n].cnt[i]) cout << i;
    cout << endl;
}


Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int K = GetInt();
		int[] V = new int[2 * N];
		for(int i = 0; i < N; i++)
		{
			int v = GetInt();
			V[i] = v;
			V[i + N] = v;
		}

		int ans = 0;
		for(int i = 1; i <= Math.Min(N, K); i++)
		{
			for(int left = 0; left <= N; left++)
			{
				int right = left + i - 1;
				if((right < N) || (right >= 2 * N))
					continue;
				
				int sum = 0;
				List<int> list = new List<int>();
				for(int j = 0; j < i; j++)
				{
					sum += V[left + j];
					list.Add(V[left + j]);
				}
				list.Sort();
				for(int j = 0; j < Math.Max(0, K - i); j++)
				{
					if(j == list.Count)
						break;

					if(list[j] >= 0)
						break;
					sum -= list[j];
				}
				ans = Math.Max(ans, sum);
			}
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 11220
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

int n;
string str;

struct thing
{
    int place;
    int state;
}arr[60];
int sz;

bool compare(struct thing a, struct thing b)
{
    return a.place < b.place;
}

int main()
{
    cin >> n;
    cin >> str;
    sz = 0;
    for (char c = 'a'; c <= 'z'; ++c)
    {
        int first = str.find(c);
        int last = str.rfind(c);
        if (first == last)
            continue;
        arr[sz].place = first;
        arr[sz].state = 1;
        arr[++sz].place = last;
        arr[sz++].state = -1;
    }

    sort(arr, arr + sz + 1, compare);

    int ans = 0, tot = 0;
    for (int i = 0; i <= sz; ++i)
    {
        tot += arr[i].state;
        ans = max(ans, tot);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using ll = long long;
int main() {
    ll n, m, d;
    std::cin >> n >> m >> d;
    ll k = (d == 0 ? n : (n - d) * 2);
    ll a = k * (m - 1);
    ll b = n * n;
    printf("%.10lf\n", (double)a / b);
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e6 + 5;
const LL maxm = LL(1e18)+5;
LL dp[maxn][2];


int main()
{
    string s;
    cin >> s;
    reverse(ALL(s));
    int sz = s.size();
    dp[0][1] = INF;

    _for(i,0,sz){
        int num = s[i] - '0';
        //不额外付钱
        LL n1 = dp[i][0] + num;
        LL n2 = (num == 9)?INF:(dp[i][1] + num + 1);
        dp[i+1][0] = min(n1 , n2);

        //cout << n1 << " "<<n2 << endl;

        n1 = (num == 0)?INF:dp[i][0] + 10 - num;
        n2 = dp[i][1] + 9 - num;

        //cout << n1 << " "<<n2 << endl;

        dp[i+1][1] = min(n1,n2);
    }

    //cout << dp[sz][1] << endl;

    cout << min(dp[sz][0],dp[sz][1] + 1) << endl;

    return 0;
}


Measured memory_bytes: 17028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for(int i = 2; i < s.size(); i++){
        if(s[i] == 'C'){
            if((s[i-1] == 'B') && (s[i-2] == 'A')) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
bingo=[list(map(int,input().split())) for i in range(3)]
n=int(input())
ans="No"
tmp1=0
tmp2=0
tmp3=0
tmp4=0
tmp5=0
for i in range(n):
    tmp1=int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k]==tmp1:
                bingo[j][k]=0
for l in range(3):
    for m in range(3):
        tmp2+=bingo[l][m]
    if tmp2==0:
        ans="Yes"
    tmp2=0
for n in range(3):
    for o in range(3):
        tmp3+=bingo[o][n]
    if tmp3==0:
        ans="Yes"
    tmp3=0
for p in range(3):
    tmp4+=bingo[p][p]
if tmp4==0:
    ans="Yes"
tmp5=bingo[0][2]+bingo[1][1]+bingo[2][0]
if tmp5==0:
    ans="Yes"
print(ans)

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

import itertools

h, w, k = map(int, input().split())
field = [input() for _ in range(h)]

field = [list(f) for f in field]

black_h = {}
black_w = {}
black_i = {}

tot = 0

for ih in range(h):
    for iw in range(w):
        black_h[ih] = 0
        black_w[iw] = 0
        black_i[(ih,iw)] = 0

for ih in range(h):
    for iw in range(w):
        if field[ih][iw] == '#':
            black_h[ih] += 1
            black_w[iw] += 1
            black_i[(ih,iw)] += 1
            tot += 1
            
#print(black_h)
#print(black_w)
#print(black_i)
#print(tot)

ans = 0

for n_comb_h in range(h+1):
    for v_h in itertools.combinations([i for i in range(h)],n_comb_h):
        for n_comb_w in range(w+1):
            for v_w in itertools.combinations([i for i in range(w)],n_comb_w):
                tmp = 0
                for i_h in v_h:
                    tmp += black_h[i_h]
                for i_w in v_w:
                    tmp += black_w[i_w]
                for i_h in v_h:
                    for i_w in v_w:
                        if black_i[(i_h, i_w)] == 1:
                            tmp -= 1
                if tmp == tot-k:
                    ans += 1
                    
print(ans)

Measured memory_bytes: 9292
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    X, Y = map(int, readline().split())
    
    for i in range(X+1):
        j = X - i
        if 2 * i + 4 * j == Y:
            print('Yes')
            return
            
    print('No')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61692
from math import sqrt
def solve(n):
  s = list(map(float,input().split()))
  m = sum(s)/n
  a = sqrt(sum([(si-m)**2 for si in s])/n)
  print('{0:.6f}'.format(a))

while True:
  n = int(input())
  if n==0:break
  solve(n)


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

typedef long long ll;
const ll MOD = 1e9 + 7;

int n,m;

int main(){
    scanf("%d%d", &n, &m);
    if(abs(n - m) >= 2) puts("0");
    else{
        long long Out = 1;
        for(int i = 1; i <= n; i++){
            Out = 1LL * i * Out % MOD;
        }
        for(int i = 1; i <= m; i++){
            Out = 1LL * i * Out % MOD;
        }
        if(n == m) Out = 1LL * 2 * Out % MOD;
    printf("%d",Out);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 2012;
ll n, a[MN], pos[MN], dp[MN][MN];
int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cout << fixed << setprecision(15);

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

  sort(pos, pos+n, [&] (int i, int j) { return a[i] > a[j]; });
  sort(a, a+n, greater<ll>());

  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    ll val = a[i-1], p = pos[i-1] + 1;
    for (int l = 0; l < i; l++) {
      int r = n - i + l + 2;
      dp[l+1][r] = max(dp[l+1][r], dp[l][r] + val * abs(p - l - 1));
      dp[l][r-1] = max(dp[l][r-1], dp[l][r] + val * abs(p - r + 1));
    }
  }

  ll ans = 0;
  for (int i = 0; i <= n; i++)
    ans = max(ans, dp[i][i+1]);
  cout << ans << '\n';

  return 0;
}



Measured memory_bytes: 35304
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const ll MAXN = 1e5 + 10;
ll n, k, a[MAXN];

int main(){

cin >> n >> k;

int kek = 0;

ll to = 0;

for(int i = 1; i <= n; ++i) {
    cin >> a[i];
    if(!to) {to = a[i];}
    else {to = __gcd(to, a[i]);}

    if(a[i] > k) {kek = 1;}
    else if(a[i] == k) {kek = 2;}
}

if(kek == 2) {cout << "POSSIBLE";return 0;}
else if(kek == 0) {cout << "IMPOSSIBLE";return 0;}

if(k % to == 0) {cout << "POSSIBLE";}
else {cout << "IMPOSSIBLE";}

return 0;
}



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

using namespace std;

const int Nmax = 105;
typedef long long ll;

struct
{
    int weight;
    ll cost;
} a[Nmax];

int N,W;

int main()
{
    cin >> N >> W;
    for(int i = 1; i <= N; ++i)
        cin >> a[i].weight >> a[i].cost;

    ll dp[N + 1][W + 1];
    memset(dp,0,sizeof(dp));

    for(int i = 1; i <= N; ++i)
        for(int j = 1; j <= W; ++j)
            if(a[i].weight <= j)
                dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - a[i].weight] + a[i].cost);
            else
                dp[i][j] = dp[i - 1][j];

    cout << dp[N][W];
    return 0;
}


Measured memory_bytes: 79104
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pii > VPI;
typedef vector<pll > VPL;
const int mod = 1000000007;

int n;
vector<string> G;
char s[12];

void Dfs(int p, int tot){
    //:cout << p << " , " << tot << endl;
    if(p > n){
        cout << s + 1 << '\n';
        return;
    }
    REP(i, 0, tot){
        s[p] = 'a' + i;
        Dfs(p + 1, tot);
    }
    s[p] = 'a' + tot + 1;
    Dfs(p + 1, tot + 1);
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    s[n + 1] = '\0';
    Dfs(1, -1);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll a;
  cin >> a;
  string s;
  cin >> s;
  if(a >= 3200){
    cout << s;
  }else{
    cout << "red";
  }
}


Measured memory_bytes: 256
from itertools import chain

def main():
    N = int(input())
    t = list(map(int, input().split()))
    v = list(map(int, input().split()))

    vmax = list(chain.from_iterable([i] * (2 * j) for i, j in zip(v, t)))
    vmax = [min(v1,v2) for v1, v2 in zip([0] + vmax, vmax + [0])]

    now = 0
    for i in range(1,len(vmax)):
        vmax[i] = min(vmax[i], now + 0.5)
        now = vmax[i]
    
    now = 0
    for i in range(len(vmax)-1,0,-1):
        vmax[i] = min(vmax[i], now + 0.5)
        now = vmax[i]

    ans = 0
    for i in range(len(vmax)-1):
        if vmax[i] == vmax[i+1]:
            ans += 0.5 * vmax[i]
        else:
            ans += (vmax[i] + vmax[i+1]) * 0.5 / 2

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 42992