akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstring>

using vec = std::vector<int>;
using mat = std::vector<vec>;
constexpr int MAX_H = 8;
constexpr int MAX_W = 8;

bool visited[MAX_H][MAX_W];

bool is_reach(int N)
{
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (!visited[i][j]) return 0;
        }
    }
    return 1;
}

bool dfs(int x, int y, int sum, int idx, const mat &p,
         const std::vector<std::pair<int, int>> &start)
{
    int N = p.size();
    if (sum == 0) {
        if (idx == (int)start.size()) {            
            return is_reach(N);
        }

        int nx = start[idx].first;
        int ny = start[idx].second;
        
        visited[ny][nx] = 1;
        bool res = dfs(nx, ny, p[ny][nx], idx + 1, p, start);
        visited[ny][nx] = 0;
        return res;
    } 

    constexpr int dx[] = {-1, 0, 1, 0};
    constexpr int dy[] = {0, -1, 0, 1};        
    
    bool res = 0;    
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        
        if (nx < 0 || nx >= N || ny < 0 || ny >= N ||
            p[ny][nx] < 0 || sum + p[ny][nx] > 0) {
            continue;
        }
        if (!visited[ny][nx]) {
            visited[ny][nx] = 1;
            res |= dfs(nx, ny, sum + p[ny][nx], idx, p, start);
            visited[ny][nx] = 0;
        }
    }

    return res;
}

int main()
{
    while (1) {
        int N;
        std::cin >> N;
        if (N == 0) {
            break;
        }
        
        mat p(N, vec(N));
        std::vector<std::pair<int, int>> start;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                std::cin >> p[i][j];            
                if (p[i][j] < 0) {
                    start.emplace_back(j, i);
                }
            }
        }
        
        memset(visited, 0, sizeof(visited));
        std::cout << (dfs(-1, -1, 0, 0, p, start) ? "YES" : "NO") << std::endl;
    }
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

mt19937 mt_engine(chrono::steady_clock::now().time_since_epoch().count());
template <class T> enable_if_t<is_integral_v<T>, T> rng(T l, T r) {
  return uniform_int_distribution<T>(l, r - 1)(mt_engine);
}
template <class T> enable_if_t<is_floating_point_v<T>, T> rng(T l, T r) {
  return uniform_real_distribution<T>(l, r)(mt_engine);
}

struct stopwatch {
  clock_t t = clock();
  void restart() { t = clock(); }
  int elapsed() const { return (clock() - t) * 1000 / CLOCKS_PER_SEC; }
  void operator()(string s = "Time") const {
    cerr << s + ": " << elapsed() << " ms\n";
  }
} sw;

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

auto chmax = [](auto&& a, auto b) { return a < b ? a = b, 1 : 0; };

constexpr int n = 365, m = 26;
int c[m], s[n][m];

int type[n];
int score(int lim = n) {
  vector<int> last(m, -1);
  int res = 0;
  for (int i = 0; i < lim; ++i) {
    res += s[i][type[i]];
    last[type[i]] = i;
    for (int j = 0; j < m; ++j) {
      res -= c[j] * (i - last[j]);
    }
  }
  return res;
}

void solve() {
  vector<vector<pair<int, array<int, m>>>> v(n + 1);
  v[0].resize(1);
  v[0].back().second.fill(-1);
  for (int i = 0; i < n; ++i) {
    for (auto [sum, last] : v[i]) {
      int cost = 0;
      for (int j = 0; j < m; ++j) {
        cost += c[j] * (i - last[j]);
      }
      for (int j = 0; j < m; ++j) {
        int nsum = sum - cost;
        nsum += s[i][j];
        nsum += c[j] * (i - last[j]);
        auto nlast = last;
        nlast[j] = i;
        v[i + 1].emplace_back(nsum, nlast);
      }
    }
    sort(rbegin(v[i + 1]), rend(v[i + 1]));
    v[i + 1].resize(min<int>(size(v[i + 1]), 500));
  }
  auto [sum, last] = v[n][0];
  for (int i = n; i--; ) {
    type[i] = max_element(begin(last), end(last)) - begin(last);
    assert(last[type[i]] == i);
    sum -= s[i][type[i]];
    for (int j = 0; j < m; ++j) {
      sum += c[j] * (i - last[j]);
    }
    for (auto [nsum, nlast] : v[i]) {
      last[type[i]] = nlast[type[i]];
      if (nsum == sum and nlast == last) {
        last = nlast;
        break;
      }
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int _n;
  cin >> _n;
  assert(_n == n);
  for (int j = 0; j < m; ++j) {
    cin >> c[j];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> s[i][j];
    }
  }
  solve();
  for (int i = 0; i < n; ++i) {
    cout << type[i] + 1 << '\n';
  }
  sw();
  cerr << score() << '\n';
}


Measured memory_bytes: 502540
using System;
using System.Linq;
using System.Collections.Generic;




namespace ConsoleApplication1 {

    class ClassMain {

       public static int countDays(int y, int m, int d){
        //195 200
           int allday = 0;
           for (int i = 1; i < y; i++) {
               allday += (i % 3 == 0) ? 200 : 195;
           }
           for (int i = 1; i < m; i++) {
               if (y % 3 == 0) {
                   allday += 20;
               }
               else {
                   if (i % 2 == 1) { allday += 20; }
                   else { allday += 19; }
               }
           }


           return allday+d;

       }


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = ints[0];
                int n = int.Parse(line);                
                if (n == 0) { break; }

                int daymill = countDays(1000,1,1);

                for (int i = 0; i < n; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    int y = ints[0]; int m = ints[1]; int d = ints[2];
                    //Console.WriteLine( countDays(y, m, d));
                    Console.WriteLine(daymill-countDays(y,m,d));
                }
                
                    
                    //Console.WriteLine();
                    
                



            }
        }
    }
}

Measured memory_bytes: 5952
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    cout<<(N < 1000 ? "ABC" : "ABD")<<endl;
}


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

int main()
{
	int H,W;
	char s[55][55];
	int dx[]={0,1,0,-1};
	int dy[]={1,0,-1,0};
	
	cin >> H >> W;
	for(int i=0;i<=H+1;i++)
		for(int j=0;j<=W+1;j++)
			s[i][j]='.';
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
			cin >> s[i][j];
	
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(s[i][j]=='.')continue;
			bool flag=false;
			for(int k=0;k<4;k++)
				if(s[i+dx[k]][j+dy[k]]=='#')flag=true;
			if(flag==false)
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define gcd __gcd
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int N, M;
  ci(N, M);
  ve<int> k(M), p(M);
  ve<ve<int>> s(M);
  rep(i, M){
    ci(k.at(i));
    rep(j, k.at(i)){
      int d;
      ci(d);
      s.at(i).pb(d);
    }
  }
  rep(i, M){
    ci(p.at(i));
  }
  int cnt = 0;
  rep(i, 2 << N){
    bool f = true;
    rep(j, M){
      int c = 0;
      each(l, s.at(j)){
        if((i >> (l - 1)) & 1 == 1){
          c++;
        }
      }
      if(c % 2 != p.at(j)){
        f = false;
      }
    }
    if(f == true){
      cnt++;
    }
  }
  co(cnt / 2);
}

Measured memory_bytes: 256
#include <cstdio>

/*
max(N- [x2, ..., xN] [ 1 2 3 4 ... 4 3 2], 0)

(1 + z + z^2 + ... + z^N) (1 + z^2 + z^4 + ... + z^{2N}) ...
f(z) = 1/[(1-z){(1-z^2)(1-z^3)...(1-z^{N/2})}^2]


[z^N] (N f(z) - z * f'(z))/(1-z)
[z^N] (f(z)(N - z * f'(z)/f(z)))/(1-z)

f'(z)/f(z) = 1/(1-z) + 2(2z/(1-z^2) + 3z^2/(1-z^3) + ...

log f = \sum_{i=2}^{N/2}

f(z) = (1-z)(1-z^{N/2+1})^2(1-z^{N/2+2})^2... / [(1-z)(1-z^2)...]^2

*/

int n, m;

int dp[5001];

int main(){
  scanf("%d%d", &n, &m);

  dp[0] = 1;
  dp[1] = m-1;
  if(n & 1){
    dp[(n+1)/2] += m-1;
    if(dp[(n+1)/2] >= m) dp[(n+1)/2] -= m;
    dp[(n+1)/2+1] = 1;
  }
  for(int i = (n+1)/2+1; i <= n; i++){
    int j;
    for(j = n; j >= 2 * i; j--){
      dp[j] = (dp[j] - dp[j-i]) + (dp[j-2*i] - dp[j-i]);
      if(dp[j] >= m) dp[j] -= m;
      else {
        if(dp[j] < 0) dp[j] += m;
        if(dp[j] < 0) dp[j] += m;
      }
    }
    for(; j >= i; j--){
      dp[j] -= 2 * dp[j-i];
      if(dp[j] < 0) dp[j] += m;
      if(dp[j] < 0) dp[j] += m;
    }
/*
    for(int j = n; j >= i; j--){
      dp[j] -= dp[j-i];
      if(dp[j] < 0) dp[j] += m;
    }
    for(int j = n; j >= i; j--){
      dp[j] -= dp[j-i];
      if(dp[j] < 0) dp[j] += m;
    }
*/
  }
  for(int i = 0; i <= n; i++){
    for(int j = 1; ; j++){
      int k = j * (3 * j - 1) / 2;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
      k += j;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
    }
  }
  for(int i = 0; i <= n; i++){
    for(int j = 1; ; j++){
      int k = j * (3 * j - 1) / 2;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
      k += j;
      if(k > i) break;
      if(j&1){
        dp[i] += dp[i - k];
        if(dp[i] >= m) dp[i] -= m;
      }
      else {
        dp[i] -= dp[i - k];
        if(dp[i] < 0) dp[i] += m;
      }
    }
  }

/*
  for(int i = 0; i <= n; i++) dp[i] = 1;
  for(int i = 2; i <= n/2; i++){
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
    for(int j = i; j <= n; j++){
      dp[j] += dp[j-i];
      if(dp[j] >= m) dp[j] -= m;
    }
  }
 

  if(n & 1){
    for(int j = (n+1)/2; j <= n; j++){
      dp[j] += dp[j-(n+1)/2];
      if(dp[j] >= m) dp[j] -= m;
    }
  }
*/

  int c = 0;
  for(int i = 0; i <= n; i++){
    c = (c + (long long) (n - i) * dp[i]) % m;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

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

    sort(A,A+N);

    cout << abs(A[0]-A[N-1])<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
#define ALL(a)  (a).begin(),(a).end()
int n,k;

int main(){
    cin>>n>>k;
    vector<ll>num(k,0);
    for(int i=1;i<=n;i++)num[i%k]++;
    ll res=0;
    rep(a,k){
        int b=(k-a)%k;
        int c=(k-a)%k;
        if((b+c)%k!=0)continue;
        res+=num[a]*num[b]*num[c];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n; cin>>n; cout<<((n<=999)?"ABC":"ABD")<<endl;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(d >= abs(a-b) && d >= abs(c-b)){
    puts("Yes");
  }
  else if(d >= abs(a-c)){
    puts("Yes");
  }
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        if (((a * b) & 1) == 1) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, pair<int, int> > p;
 
#define MOD 1000000007

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

    ll N;
    cin >> N;

    vector<ll> A(N);

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

    ll ans = 0;

    for(ll i = 1; i < N; i++) {
        if(A[i] < A[i - 1]) {
            ans += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
int main() {
    double a, c, ans;
    ans = 0;
    string b;
    cin >> a;
    vector<int> vec(a);
    for (int i = 0; i < a; i++) {
        cin >> c;
        cin >> b;
        if (b == "JPY") ans += c;
        else ans += c * 380000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int r;
    cin>>r;
    cout<<3*r*r<<endl;

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

Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/30 18:46:55 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=100010;

int po[maxn],dis[maxn];
int cha[maxn],tmp[maxn];
int ans[maxn];
int n;

void work(int a[],int b[])
{
    for (int j=1;j<n;++j)
        tmp[j]=a[b[j]];
    for (int j=1;j<n;++j)
        a[j]=tmp[j];
    return;
}

int main()
{
    IOS;
    cin>>n;
    for (int j=1;j<=n;++j)
        cin>>po[j];
    for (int j=1;j<n;++j)
        dis[j]=po[j+1]-po[j];
    for (int j=1;j<n;++j)
        cha[j]=j;
    int m;
    LL num;
    cin>>m>>num;
    for (int j=1;j<=m;++j)
    {
        int x;
        cin>>x;
        swap(cha[x-1],cha[x]);
    }
    while (num)
    {
        if (num&1) work(dis,cha);
        work(cha,cha);
        num/=2LL;
    }
    cout<<po[1]<<".0\n";
    LL sum=po[1];
    for (int j=1;j<n;++j)
    {
        sum+=dis[j];
        cout<<sum<<".0\n";
    }
    cout<<flush;
	return 0;
}


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

using namespace std;

int gcd(int a, int b)
{
    if(b==0)
        return a;
    gcd(b, a%b);
}

int main ()
{
    int n;
    while(cin>>n)
    {
        int a[100];
        for(int i=0; i<n; i++)
            cin>>a[i];
        int lcm= (a[0]*a[1])/gcd(a[0], a[1]);
        for(int i=2; i<n; i++)
        {
            lcm= (lcm*a[i])/gcd(lcm,a[i]);
        }
        cout<<lcm<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
n,k = map(int, input().split())
n_list = [0]*n

for i in range(k):
    num = input()
    num_list = list(map(int,input().split()))
    for j in num_list:
        n_list[j-1] = 1
cnt = 0
for i in n_list:
    if i == 0:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 9208
from collections import deque

N = int(input())
a =list(map(int,input().split()))

d = deque()

for i in range(N):
    if i % 2 == 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

if N % 2 != 0:
    d.reverse()
print(*d)

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

int main() {
    long long N, M;
    cin >> N >> M;
    vector<vector<long long>> AB(N, vector<long long>(2));
    for (long long i = 0; i < N; i++) cin >> AB.at(i).at(0) >> AB.at(i).at(1);
    sort(AB.begin(), AB.end());
    long long ans = 0;
    for (long long i = 0; i < N; i++) {
        long long a = AB.at(i).at(0);
        long long b = AB.at(i).at(1);
        if (M <= b) {
            ans += a * M;
            break;
        } else {
            ans += a * b;
            M -= b;
        }
    }
    cout << ans << endl;
}

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

int main() {
  long int n,x,ans;
  bool prime=1;
  cin>>n;
  x=0;
  ans=1;
  vector<long int> a(1000,1001);
  vector<long int> b(1000,1);
  
  for(int i=2;i<=n;i++){
    for(int j=0;j<1000;j++){
      if(i%a.at(j)==0){
        b.at(j)++;
        prime*=0;
        int y=i;
        while(y%a.at(j)==0){
          y/=a.at(j);
          if(y%a.at(j)==0)b.at(j)++;
          else break;
        }
      }
      else if(a.at(j)==1001)break;
    }
    if(prime==1){
      a.at(x)=i;
      b.at(x)++;
      x++;
    }
    prime=1;
  }
  for(int i=0;i<n;i++){
    ans*=b.at(i);
    if(ans>=1000000007)ans%=1000000007;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

// void solve(ll K, ll A, ll B);

// vector<ll> dp(1000000000 + 1);

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    for(ll i = 0; i < N; i++)
    {
        ll K;
        cin >> K;
        for(ll k = 0; k < K; k++)
        {
            ll temp;
            cin >> temp;
            A[temp-1]++;
        }
    }
    
    ll cnt = 0;
    for(ll i = 0; i < M; i++)
    {
        if(A[i] == N)
            cnt++;
    }
    
    cout << cnt << endl;
}

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

int __power(int x , int p) {
	int res = 1;
	while(p) {
		if(p & 1) res = (res * x);
		p /= 2;
		x *= x;
	}
	return res;
}

pair<int,int> powers(int n) {
	int a = 0 , b = 0 , k = 1;
	while(1) {
		if(__power(5 , k) <= n) a += (n/__power(5,k++));
		else break;
	}
	k = 1;
	while(1) {
		if(__power(2 , k) <= n) b += (n/__power(2,k++));
		else break;
	}
	return {b,a};
}

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

	int  n;
	cin >> n;
	pair<int,int> p1 , p2;
	p1 = powers(n) , p2 = powers(n/2);
	p2.first += n/2;
	if(n & 1) {
		p1.first -= p2.first , p1.second -= p2.second;
		cout << min(p1.first , p2.second) << "\n";
	}
	else cout << min(p2.first , p2.second) << "\n"; 

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認


ll tableF[200010];
ll tableI[200010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n < 0 || r < 0 || n < r){
      return 0;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約200ms
   fill(tableF,tableF+200010,-1);
   fill(tableI,tableI+200010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}

int main(){
   modfill(MOD);
   ll S;
   cin >> S;
   ll ans = 0;
   FOR(i,1,S){
      if(i * 3 > S) continue;
      ans += modCON(S-2*i-1,i-1,MOD);
      while(ans < 0) ans += MOD * (ll)1000000000;
      ans %= MOD;
   }
   cout << ans << endl;
}

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

int main(){
	int n;
	while(cin >> n){
	int s = 0;
	for(int i = 0 ; i <= 9 ; i++)
	for(int j = 0 ; j <= 9 ; j++)
	for(int k = 0 ; k <= 9 ; k++)
	for(int l = 0 ; l <= 9 ; l++)
		if( i+j+k+l==n)s++;
	cout << s << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define int long long 
#define pb push_back
#define fr first
#define sc second
#define sz(v) ((int)(v).size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repd(i,a,p) for(int i=a-1;i>=p;i--) 
#define M 1000000007
#define vi vector<int>
#define vp vector<pair<int,int> >
#define ml map<int,int>
#define MPI 3.1415926536
using namespace std;
//priority_queue is best for traversing elements when it is needed in a sorted order
//dsu is pel concept
int n,m,k=0,t,i,j,c=0,x,s=0,a,b;string s1;
signed main()
{
	int x;
	cin>>x>>n;
	vi v(n);
	int v2[200]={0};
	rep(i,0,n){
		cin>>v[i];
		v2[v[i]]=1;
	}
	int min1=M;int k2=M;
	rep(i,0,102)
	{
		if(v2[i]==0&&abs(i-x)<min1)
	    {
	    	min1=min(min1,abs(i-x));
	    	k2=i;
		 } 
	}
	cout<<k2;
}

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

#define int long long

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
const int INF = 1e18;

const int VARI = 5; // パターンの数
int dp[200010][VARI]; // dp[i][j]: 座標iまで見たとき、区間jを見た時の最小コスト

signed main() {
  // 入力
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) { cin >> v[i]; }

  const int one = 0; // 左のゼロ区間
  const int two = 1; // 右のゼロ区間
  const int three = 2; // 左の偶数区間
  const int four = 3; // 右の偶数区間
  const int five = 4; // 奇数区間

  // 初期化
  fill(dp[0], dp[N+1], INF);
  dp[0][one] = 0;
  dp[0][two] = 0;
  dp[0][three] = 0;
  dp[0][four] = 0;
  dp[0][five] = 0;

  // DP
  for (int i = 0; i < N; i++) {
    // 左のゼロ区間
    int cost1 = v[i];
    chmin(dp[i+1][one], dp[i][one] + cost1);

    // 左の偶数区間
    int cost2 = v[i] == 0 ? 2 : v[i] % 2; // 0だったら最低2回通る必要がある。
    chmin(dp[i+1][two], min(dp[i][one], dp[i][two]) + cost2);

    // 奇数区間
    int cost3 = v[i] == 0 ? 1 : (v[i] % 2 == 0); // 0だったら最低1回通る必要がある
    chmin(dp[i+1][three], min({dp[i][two], dp[i][three], dp[i][one]}) + cost3);

    // 右の偶数区間
    int cost4 = v[i] == 0 ? 2 : v[i] % 2;
    chmin(dp[i+1][four], min({dp[i][three], dp[i][four], dp[i][two], dp[i][one]}) + cost4);

    // 右のゼロ区間
    int cost5 = v[i];
    chmin(dp[i+1][five], min({dp[i][four], dp[i][three], dp[i][two], dp[i][one], dp[i][five]}) + cost5);
  }

  int ans = INF;
  // 座標Nを見た時、区間iの最小値が答えになる
  for (int i = 0; i < VARI; i++) {
    chmin(ans, dp[N][i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include<stdlib.h>
 
int comp( const void *c1, const void *c2 );

int main(void){
    int n, d[100], i, c=1, m=100;
    
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &d[i]);
	}
        qsort( d, n, sizeof(int), comp);

	for(i = 1; i < n; i++){
             if( d[i - 1] < d[i] ) c++;
        }
    printf("%d\n", c);

    return 0;
}

int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;
 
  if( tmp1 < tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 > tmp2 )  return  1;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
		return;
	}
	int a,b;
	cin >> a >> b;
	cout << a+b << endl;
}

void solve()
{
}


Measured memory_bytes: 256
import collections
def dfs(i, cumul, cc, k, s): return (cumul if k == 0 else 0) if (i == len(s) or k == 0) else (dfs(i+1,  cumul * cc[s[i]], cc,k - 1, s) +dfs(i+1,  cumul, cc, k, s))
print dfs(0,  1 , collections.Counter([raw_input()[0] for _ in range(int(raw_input()))]), 3, 'MARCH')


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n,i,j,k;
  string s, t;

  ll ans = 0;
  cin >> n;
  cout << 3 * n * n << '\n';

  ktj();
}


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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//########################################################################




int main()
 {
	int n; cin>>n;
	vector<vector<int>> graph(n);
	for(int i=0;i<n;i++)
	{
	    string s; cin>>s;
	    for(int j=0;j<n;j++)
	    {
	        if(s[j]=='1')
	        {
	            graph[i].pb(j);
	        }
	    }
	}
	int ans=-1;
	for(int i=0;i<n;i++)
	{
	    queue<int> q;
	    q.push(i);
	    vector<int> d(n,-1);
	    d[i]=0;
	    
	    while(!q.empty())
	    {
	        int v = q.front(); q.pop();
	        for(int x:graph[v])
	        {
	            if(d[x]==-1)
	            {
	                d[x]=d[v]+1;
	                q.push(x);
	            }
	            else if(d[x]==d[v])
	            {
	                cout<<"-1\n"; return 0;
	            }
	        }
	    }
	    ans=max(ans,*max_element(d.begin(),d.end())+1);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 512
if __name__ == '__main__':
    n = int(input())

    testimony = {}
    for i in range(n):
        a = int(input()) # 証言数
        for j in range(a):
            who, ans = list(map(int, input().split(' ')))
            if j == 0:
                testimony[i + 1] = [{
                    'who': who,
                    'ans': ans
                }]
            else:
                testimony[i + 1].append({
                    'who': who,
                    'ans': ans
                })

    # print(testimony)
    # testimony = {1: [{'who': 2, 'ans': 1}], 2: [{'who': 1, 'ans': 1}], 3: [{'who': 2, 'ans': 0}]}

    max_honest = 0
    for i in reversed(range(2 ** n)):
        check_list = bin(i)[2:].zfill(n)
        # print(check_list) # 000 - 111
        ng_flag = 0
        for j in range(n):
            if check_list[j] == '1' and (j + 1) in testimony:
                for k in testimony[j + 1]: #正直者j +1さんの意見を順にチェック
                    if check_list[k['who'] - 1] != str(k['ans']):
                        ng_flag = 1
                        break
        if ng_flag == 0:
            if check_list.count('1') > max_honest:
                max_honest = check_list.count('1')

    print(max_honest)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string t;
  cin >> t;
  int n = (int) s.size();
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      ++cnt;
    }
  }
  cout << cnt << '\n';
}


Measured memory_bytes: 3880
use std::cmp::*;
use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: i32 = sc.read();
    let q: usize = sc.read();
    let mut abcd: Vec<(usize, usize, i32, i32)> = vec![(0, 0, 0, 0); q];
    for i in 0..q {
        abcd[i].0 = sc.read();
        abcd[i].1 = sc.read();
        abcd[i].2 = sc.read();
        abcd[i].3 = sc.read();
    }
    let mut bfs: VecDeque<Vec<i32>> = VecDeque::new();
    for i in 1..=m {
        bfs.push_back(vec![i]);
    }
    let mut ans = 0;
    while !bfs.is_empty() {
        let b = bfs.pop_front().unwrap();
        if b.len() == n {
            ans = max(ans, sum(&b, &abcd));
        } else {
            let max = *b.last().unwrap();
            for i in max..=m {
                let mut vec_new = b.clone();
                vec_new.push(i);
                bfs.push_back(vec_new);
            }
        }
    }
    println!("{}", ans);
}

fn sum(v: &Vec<i32>, abcd: &Vec<(usize, usize, i32, i32)>) -> i32 {
    let mut res = 0;
    for e in abcd.iter() {
        if v[e.1 - 1] - v[e.0 - 1] == e.2 {
            res += e.3;
        }
    }
    return res;
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

int main() {
    int N;
    cin >> N;
    double sum = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        sum += (1.0 / a);
    }
    double ans = 1.0 / sum;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int W = sc.nextInt();
    int[] w = new int[N+1];
    int[] v = new int[N+1];

    for (int i = 1; i < N+1; i++) {
      w[i] = sc.nextInt();
      v[i] = sc.nextInt();
    }

    sc.close();

    long[][] dp = new long[N+1][W+1];

    for (int i = 1; i < N + 1; i++) {
      for (int j = 1; j < W + 1; j++) {
        if (w[i] > j) {
          dp[i][j] = dp[i - 1][j];
        } else {
          dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
        }
      }
    }

    System.out.println(dp[N][W]);

  }

}

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

#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 RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N; cin >> N;
    vector<ll> T(N); REP(i, N) cin >> T[i];
    vector<ll> A(N); REP(i, N) cin >> A[i];
    
    if (T[N-1] != A[0]) {
        cout << 0 << endl;
        return 0;
    }
    
    REP(i, N-1) if (A[i] > A[i+1] && A[i] > T[i]) {
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1;
    FOR(i, 1, N-1) if (T[i-1] == T[i] && A[i] == A[i+1]) {
        ans *= min(T[i], A[i]);
        ans %= MOD;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
n=int(input())
s=list(input())

ans=0
a=0
b=0
c=0
for i in range(n):
    if s[i]=="R":
        a+=1
    if s[i]=="G":
        b+=1
    if s[i]=="B":
        c+=1
ans=a*b*c

for i in range(n):
    for j in range(i+1,n):
        if 2*j-i>n-1:
            break
        if s[i]!=s[j] and s[i]!=s[2*j-i] and s[j]!=s[2*j-i]:
            ans=ans-1
    

print(ans)

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

int main() {
  string s; cin >>s;
  int cnt = 0;
  char buf = s.at(0);
  
  for (int i=1; i<s.size(); i++){
    if (s.at(i) != buf){
      cnt++;
      buf = s.at(i);
    }
  }
  
  cout <<cnt <<endl;
  
  //cout <<ans <<endl;
  
  //if (ans) cout <<"YES" <<endl;
  //else cout <<"NO" <<endl;
  
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
typedef long long lint;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define all(x) (x).begin(),(x).end()
#define INF (1LL<<60)
#define MOD 1000000007
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
int main(){
    while(1){
        lint n,m;
        cin>>n>>m;
        if(n==0&&m==0)break;
        vector<lint> a(n);
        rep(i,n)cin>>a[i];
        vector<lint> list(all(a));
        rep(i,n)rep(j,i+1){
            list.push_back(a[i]+a[j]);
        }
        list.push_back(0);
        sort(all(list));
        lint ans=0;
        for(lint val:list){
            auto itr=upper_bound(all(list),m-val);
            if(itr!=list.begin())chmax(ans,val+*prev(itr,1));
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 10796
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(void){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> a(2*n, 0);
	a[0] = 1;
	if(s[0] == 'W' || s[n*2-1] == 'W'){
		cout << 0 << endl;
		return 0;
	}
	int cnt = 1;
	for(int i = 1; i < n*2; ++i){
		if(a[i-1] == 1){
			if(cnt % 2 == 1){
				if(s[i] == 'W'){
					a[i] = 1;
					cnt++;
				}else{
					a[i] = -1;
				}
			}else{
				if(s[i] == 'B'){
					a[i] = 1;
					cnt++;
				}else{
					a[i] = -1;
				}
			}
		}else{ // -1
			if(cnt % 2 == 1){
				if(s[i] == 'W'){
					a[i] = -1;
					cnt--;
				}else{
					a[i] = 1;
				}
			}else{
				if(s[i] == 'B'){
					a[i] = -1;
					cnt--;
				}else{
					a[i] = 1;
				}
			}
		}
		if(cnt == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	if(cnt =! 1){
		cout << 0 << endl;
		return 0;
	}
	long long ans = 1;
	int cnta = 0;
	int cntb = 0;
	for(int i = 0; i < n*2; ++i){
		if(a[i] == 1){
			cnta++;
		}else{
			ans *= cnta - cntb;
			ans %= MOD;
			cntb++;
		}
	}
	if(cnta != cntb){
		cout << 0 << endl;
		return 0;
	}
	// for(int i = 0; i < n*2; ++i){
	// 	cout << a[i] << endl;
	// }
	for(int i = 1; i <= n; ++i){
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}
ll era[1000001];    //era[i]=iを割り切る最小の素数
void era_init(){
    era[1]=1;
    rep(i,2,1000000){
        if(era[i]==0){
            era[i]=i;
            for(ll j=i*2;j<=1000000;j+=i){
                if(era[j]==0)era[j]=i;
            }
        }
    }
}
map<ll,ll> prime_fac(ll x){
    map<ll,ll> mp;
    while(x>1){
        ll d=era[x];
        auto itr=mp.find(d);
        if(itr==mp.end()){
            mp[d]=1;
        }else{
            mp[d]++;
        }
        x/=d;
    }
    return mp;
}

int main(){fastio
    ll n;cin>>n;
    ll a[n];
    era_init();
    map<ll,ll> l;
    rep(i,0,n-1){
        cin>>a[i];
        map<ll,ll> mp=prime_fac(a[i]);
        for(auto itr=mp.begin();itr!=mp.end();++itr){
            ll a=(itr)->first;
            ll b=(itr)->second;
            if(l.find(a)==l.end()){
                l[a]=b;
            }else{
                l[a]=max(l[a],b);
            }
        }
    }
    ll L=1;
    for(auto itr=l.begin();itr!=l.end();++itr){
        ll a=(itr)->first;
        ll b=(itr)->second;
        L=mod(L*hpow(a,b));
    }
    ll sum=0;
    rep(i,0,n-1){
        sum=mod(sum+(L*hpow(a[i],i_7-2)));
    }
    cout<<sum<<endl;
    
    
    return 0;
}





Measured memory_bytes: 12060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    string s;
    for (int l = 0; l < 1200; ++l) {
        string t;
        getline(cin, t);
        s += t;
    }
    map<char, int> ans;
    for (int j = 97; j < 123; ++j) ans.emplace((char)j, 0);
    for (char i : s) {
        int code = (int)i;
        if (!((65 <= code && code <= 90) || (90 <= code && code <= 122))) continue;
        if (65 <= code && code <= 90) i = (char)(code + 32);
        ans[i]++;
    }
    for (pair<char, int> k : ans) cout << k.first << " : " << k.second << endl;
}



Measured memory_bytes: 3160
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int A[3][3];
    bool a[3][3] = {false};
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> A[i][j];
        }
    }
    int N;cin>>N;
    int b;
    for(int i=0;i<N;i++){
        cin >> b;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(A[j][k]==b){
                    a[j][k] = true;
                }
            }
        }
    }
    if(a[0][0]==true&&a[1][0]==true&&a[2][0]==true){
        cout << "Yes" << endl;
    }else if(a[0][1]==true&&a[1][1]==true&&a[2][1]==true){
        cout << "Yes" << endl;
    }else if(a[0][2]==true&&a[1][2]==true&&a[2][2]==true){
        cout << "Yes" << endl;
    }else if(a[0][0]==true&&a[0][1]==true&&a[0][2]==true){
        cout << "Yes" << endl;
    }else if(a[1][0]==true&&a[1][1]==true&&a[1][2]==true){
        cout << "Yes" << endl;
    }else if(a[2][0]==true&&a[2][1]==true&&a[2][2]==true){
        cout << "Yes" << endl;
    }else if(a[0][0]==true&&a[1][1]==true&&a[2][2]==true){
        cout << "Yes" << endl;
    }else if(a[0][2]==true&&a[1][1]==true&&a[2][0]==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
} 

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

int main(){
   int n,x,L;
   int l=0;
   int cnt =1;
   cin>> n>>x;
   for(int i=0;i<n;++i){
       cin>> L;
       l += L;
       if(l<=x){
           ++cnt;
       }
   }
   cout << cnt <<endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		char c = s.next().charAt(0);
		
		if(c>=65 && c<=90) {
			System.out.println("A");
		}
		else
			System.out.println('a');
	}

}


Measured memory_bytes: 35444