akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main(){
	int n, k;
	cin >> n >> k;
	vector<int> input;
	REP(i, n) {
		int a;
		cin >> a;
		input.push_back(a);
	}
	sort(input.begin(), input.end());
	int ans = input[k-1] - input[0];
	for (int i = 0; i+k-1 < n; ++i) {
		ans = min(ans, input[i + k - 1] - input[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i, N) cin >> b[i];
    vector<int> ans;
    while(b.size() > 0){
        int t = -1;
        rep(i, b.size()){
            if(i == b[i]-1){
                t = i;
            }
        }
        if(t < 0) break;
        else{
            ans.push_back(t+1);
            b.erase(b.begin() + t);
        }
    }
    if(b.size() > 0){
        cout << -1 << endl;
    }else{
        rep(i, N){
            cout << ans[N-1-i] << endl;
        }
    }
    return 0;
}


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

int main()
{
    ll h, w;
    cin >> h >> w;
    P m[h][w];
    rep(i, h)
    {
        string s;
        cin >> s;
        rep(j, s.size())
        {
            if (s[j] == '#')
                m[i][j] = {-1, -1};
            else
                m[i][j] = {0, 0};
        }
    }
    rep(i, h) rep(j, w)
    {
        P p = m[i][j];
        if (p.first == -1 && p.second == -1) continue;
        if (p.first == 0)
        {
            for (ll k = i; k < h; k++)
            {
                if (k == h - 1 || m[k + 1][j].first == -1)
                {
                    for (ll l = i; l <= k; l++)
                    {
                        m[l][j].first = k - i + 1;
                    }
                    break;
                }
            }
        }
        if (p.second == 0)
        {
            for (ll k = j; k < w; k++)
            {
                if (k == w - 1 || m[i][k + 1].second == -1)
                {
                    for (ll l = j; l <= k; l++)
                    {
                        m[i][l].second = k - j + 1;
                    }
                    break;
                }
            }
        }
    }
    ll ans = 0;
    rep(i, h) rep(j, w)
    {
        P p = m[i][j];
        ans = max(ans, p.first + p.second - 1);
    }
    cout << ans << endl;
    return 0;
}


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

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

int n;
bool c[100000];

int main() {
	ios::sync_with_stdio(false);
	
	while(cin >> n, n) {
		rep(i, n) cin >> c[i];
		rep(i, n/2) {
			if(c[2*i] ^ c[2*i+1]) {
				int j=2*i;
				while(j>=0 && c[j] ^ c[2*i+1]) {
					c[j] = c[2*i+1];
					j--;
				}
			}
		}
		int r = 0;
		rep(i, n) {
			if(!c[i])r++;
		}
		cout << r << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1292
//file_name:ABC45_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b,h;
    scanf("%d%d%d",&a,&b,&h);


    ll ans = 0;

    ans = (a+b)*h/2;

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



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

using namespace std;

int calc_sum(int x) {
  if (x == 1) return 1;
  else return x + calc_sum(x - 1);
}

int main() {
  int n, result;
  cin >> n;
  result = calc_sum(n);
  cout << result << endl;
  return 0;
}

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<string,int>;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  rep(i,n){
    if(s[i] == 'S') ++a;
    if(s[i] == 'E') ++b;
    if(s[i] == 'N') ++c;
    if(s[i] == 'W') ++d;
  }
  bool flag = false;
  if(a > 0 && b > 0 && c > 0 && d > 0) flag = true;
  else if(a == 0 && b > 0 && c == 0 && d > 0) flag = true;
  else if(a > 0 && b == 0 && c > 0 && d == 0) flag = true;
  if(flag) puts("Yes");
  else puts("No");
  return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cout << setprecision(10);
	cin >> s; 
	//Rの左端、Lの右端を取得する操作を繰りかえす
	int startR = 0  ,lastL;
	vector<int> Rdepo(0) , Ldepo(0);
	vector<int> Mdepo(0);
	for(int i = 0 ; i < s.size() ; i++){
		//Rが出てきたときにその左がLならいい
		//右端のLを取得する
		if(s[i] == 'L' &&s[i-1] == 'R'){
			Mdepo.push_back(i-1);
			//値が集まる左側を保持しておく
		}
		if(i!= 0 && s[i] == 'R' && s[i-1] == 'L'){
			lastL = i-1;
			Rdepo.push_back(startR);
			Ldepo.push_back(lastL);
			startR= i ;
		}
	}
	Rdepo.push_back(startR);
	Ldepo.push_back(s.size() - 1 );


	vector<int> ans(s.size(),0);
	//startR,lastL,Mを使って勝てそうな気がする
	for(int i = 0 ; i < Mdepo.size() ; i ++ ){
		int sum =   Ldepo[i]- Rdepo[i]+ 1; 
		int left = sum / 2 ;
		int right = sum / 2 ;
		if(sum %  2 == 1){
			right ++ ;
		}
		//範囲が奇数なら、もう一個は＋１

		if(sum %2 == 1){
			//範囲が奇数だったら、片方が大きい数字、片方が小さい数字
			//Mdepo[i] - Rdepo[i] + 1 でRの個数
			//sum - ↑で　Lの個数
			int tmp = Mdepo[i] - Rdepo[i] + 1;
			int num = max( tmp  , sum - tmp) ;
			if(num == tmp){
				//Rのほうが多い
				int path = num - 1;
				if(path % 2 == 0){
					swap(left,right);
					//leftのほうが大きくなる
				}
			}else{
				int path = num - 1 ;
				if(path %2 == 0){
					//rightのほうが大きいのでそのまま
				}else{
					swap(left,right);
				}
			}
		}
		ans[Mdepo[i]] = left;
		ans[Mdepo[i]+1] = right;
	}
	for(auto x : ans){
		cout << x << " " ;
	}
	cout << endl;
}


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

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

    int a, b;
    cin >> a >> b;

    int ans = a - 1;

    if(b >= a) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005



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

        int a;
        cin >> a;
        int  p=100.00;
        int l=1;
        int h=a;
         double t=(101.00)/(100.00);
        double r=t;
        for(int i=0; i<=5000; i++){
           int x=p*t;
           p=x;
           if(x>=a){
               cout << i+1;
               return 0;
           }

       }
      //  cout << h+1;
        

}

Measured memory_bytes: 3596
N = gets.to_i
A = gets.split.map(&:to_i).sort
dp = Array.new(A.max + 1, 0)
W = Hash.new(0)
A.each do |a|
  W[a] += 1
  next if W[a] > 1
  (1 .. dp.size).each do |k|
    break if a * k >= dp.size
    next if dp[a * k] > 0
    dp[a * k] = a
  end
end
puts A.reject{|a| W[a] > 1 || dp[a] < a }.count


Measured memory_bytes: 51096
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

static const int MAX = 12;
int h, w, c;
int G[MAX][MAX], V[MAX][MAX];
int ans, cnt;

void init() {
  FOR(y, 1, h + 1) FOR(x, 1, w + 1) V[y][x] = 0;
  cnt = 0;
}

void fillc(int color, int y, int x, int prec) {
  G[y][x] = V[y][x] = color;
  cnt++;
  rep(i, 4) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (G[ny][nx] == prec && !V[ny][nx]) fillc(color, ny, nx, prec);
  }
}

void solve(int d) {
  int tmp[MAX][MAX];
  if (d == 4) {
    rep(i, 2) {
      init();
      fillc(c, 1, 1, G[1][1]);
    }
    ans = max(ans, cnt);
    return;
  }

  FOR(i, 1, 7) {
    FOR(y, 1, h + 1) FOR(x, 1, w + 1) tmp[y][x] = G[y][x];
    init();
    fillc(i, 1, 1, G[1][1]);
    solve(d + 1);
    FOR(y, 1, h + 1) FOR(x, 1, w + 1) G[y][x] = tmp[y][x];
  }
}

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

  while (true) {
    cin >> h >> w >> c;
    if (h == 0 && w == 0 && c == 0) break;
    rep(y, h + 2) rep(x, w + 2) G[y][x] = 0;
    rep(y, h) rep(x, w) cin >> G[y + 1][x + 1];
    ans = 0;
    solve(0);
    cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,e,t;
int x[100005];
ll dp[100005];
int main(){
    scanf("%d%d%d",&n,&e,&t);
    for (int i = 1 ; i <= n; i++){
        scanf("%d",&x[i]);
    }
    int pivot = 0;
    ll mn = 1000000000000000000;
    dp[0] = 0;
    for (int i = 1; i <= n; i++){
        dp[i] = 1000000000000000000;
        while (pivot < i && 2*(x[i]-x[pivot+1]) > t) {
            mn = min(mn,dp[pivot]-2*x[pivot+1]);
            pivot++;
        }
        //printf("pivot for %d = %d\n",i,pivot);
        dp[i] = min(2*x[i]+mn,dp[pivot]+t);
        //printf("%lld first\n",dp[i]);
        /*dp[i] = 1000000000000000000;
        for (int j = 0; j < i; j++){
            if ((x[i]-x[j+1])*2 <= t){
                //printf("pivot at %d\n",j);
            }
            //printf("%lld + %d\n",dp[j],max(t,(x[i]-x[j+1])*2));
            dp[i] = min(dp[i],dp[j]+max(t,(x[i]-x[j+1])*2));
        }
        printf("%lld second\n",dp[i]);*/
    }
    printf("%lld",dp[n]+e);
}


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

int ans = 0;

void dfs(int n, int s, int k){
	if( s < 0 ) return;
	
	if( n == 0 ){
		if( s == 0 ) ans++;
	}else{
		if( 9 < k ) return;
		for(int i = k; i <= 9; i++){
			dfs(n-1, s - i, i + 1);
		}
	}
}

int main(){
	int n, s;
	while( cin >> n >> s, n || s ){
		ans = 0;
		dfs(n, s, 0);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int a[5];
    cins(a, a + 5);
    int k;
    cin >> k;
    if(a[4] - a[0] <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}


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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        
        char ch;
        cin>>ch;
        if(ch<='Z')
            cout<<"A";
        else
            cout<<"a";
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{

    int Q;
    cin >> Q;
    double p = 3.1415926535;

    cout << 2 * Q * p << endl;

    return 0;
}


Measured memory_bytes: 3788
N,M=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
from functools import reduce
x=reduce(lambda x,y:x*y//gcd(x,y),A)
print(0 if any([x//a%2==0 for a in A]) else (M+x//2)//x)

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

int main() {
  ll N;
  cin >> N;
  ll MOD = 998244353;
  ll ans = 1;
  ll M = 0;
  map<int,int> dist;

  bool b = false;
  for (ll i = 0; i < N; i++) {
    ll e;
    cin >> e;
    M = max(M,e);
    if (i == 0 && e != 0) b = !b;
    dist[e] += 1;
  }
  if (dist[0] != 1) b = !b;
  
  if (b) {
    cout << 0 << endl;
    return 0;
  }
  
  for (ll i = 0; i < M; i++) {
    if (!dist.count(i)) {
      cout << 0 << endl;
      return 0;
    }
    for (int j = 0; j < dist[i+1]; j++) {
      ans *= dist[i];
      ans %= MOD;
    }
    ans %= MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4992
program table_tennis_training
  implicit none
  integer(8) :: n, a, b
  read(*,*) n, a, b
  if (mod(b - a, 2) == 0) then
    write(*,'(i0)') (b - a) / 2
  else
    write(*,'(i0)') min(a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2)
  end if
end program table_tennis_training

Measured memory_bytes: 2896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();

		int[] value = new int[w];
		for (int i = 0; i < value.length; i++) {
			value[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;

			int t;
			t = value[a];
			value[a] = value[b];
			value[b] = t;
		}

		for (int i = 0; i < value.length; i++) {
			System.out.println(value[i]);
		}
	}
}

Measured memory_bytes: 26124
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String strAry[] = br.readLine().split(" ");
    
        int x = Integer.parseInt(strAry[0]);
        int y = Integer.parseInt(strAry[1]);
        int z = Integer.parseInt(strAry[2]);
        
        String result;
    
        result = x >= y ? "No" : y < z  ? "Yes" : "No";
        
        System.out.println(result);
    }
}

Measured memory_bytes: 24228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Time Complexity
 */
public class Main {

	final static int sec = 1000_000_000;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int n, T;
		line = br.readLine();
		n = parseInt(line.substring(0, line.indexOf(' ')));
		T = parseInt(line.substring(line.indexOf(' ') + 1));

		boolean tle = false;
		long sum = 0;

		line = br.readLine();

		outer:
		for (char c : line.toCharArray()) {
			if ('0' <= c && c <= '9') {
				int k = c - '0';
				long _sum;
				if (k == 0) {
					_sum = 1;
				} else {
					_sum = n;
					for (int i = 0; i < k - 1; i++) {
						_sum *= n;
						if (_sum > sec) {
							tle = true;
							break outer;
						}
					}
				}
				sum += _sum;
				if (sum > sec) {
					tle = true;
					break outer;
				}
			}
		}

		sum *= T;
		if (sum > sec) {
			tle = true;
		}

		System.out.println(tle ? "TLE" : sum);

	}
}

Measured memory_bytes: 24352
x, k ,d = map(int, input().split())


if k > abs(x)//d:
    k -= abs(x)//d
    diff = abs(x)%d
    if k % 2 == 0:
        print(diff)
    else:
        print(abs(diff-d))
else:
    if x >= 0:
        print(abs(x-k*d))
    else:
        print(abs(x+k*d))


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

int main() {
    
    int a,b,k;
    cin>>a>>b>>k;
    int i,j;
    j=0;
    for(i=100;i>=1;i=i-1){
        if(a%i==0 & b%i==0){
            j=j+1;
            if(j==k){
                cout<<i<<endl;
            }
            }
            
        }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/******************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >;
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/******************************************/
using namespace std;
int n,a,b;
vector<int> v[100000];
int step[2][100000];
void dfs(int fx,int d,int c){
	step[c][d]=step[c][fx]+1;
	for(int i=0;i<v[d].size();i++)
	if(v[d][i]!=fx)
	dfs(d,v[d][i],c);
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	step[0][0]=-1;
	step[1][n-1]=-1;
	dfs(0,0,0);
	dfs(n-1,n-1,1);
	int black=0,white=0;
	for(int i=0;i<n;i++){
		if(step[0][i]<=step[1][i])
		black++;
		else
		white++;
	}
	if(black>white)
	cout<<"Fennec";
	else
	cout<<"Snuke";
	re 0;
}

Measured memory_bytes: 12800
from numba import jit

@jit
def abc175_b():
    n = int(input())
    l = list(map(int, input().split(' ')))
    cnt = 0

    for i in range(0, n - 2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c,b+c>a,c+a>b
                if (l[i] + l[j] > l[k]) and (l[j] + l[k] > l[i]) and (l[k] + l[i] > l[j]):
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    abc175_b()

Measured memory_bytes: 115828
MOD = 10 ** 9 + 7

n, k = map(int, input().split())
alst = list(map(int, input().split()))

alst.sort()

if n == k:
    ans = 1
    for num in alst:
        ans *= num
        ans %= MOD
    print(ans)
    exit()

if k == 1:
    print(alst[-1] % MOD)
    exit()

if alst[0] >= 0:
    ans = 1
    alst.sort(reverse = True)
    for i in range(k):
        ans *= alst[i]
        ans %= MOD
    print(ans)
    exit()

if alst[-1] <= 0:
    ans = 1
    if k % 2 == 1:
        alst = alst[::-1]
    for i in range(k):
        ans *= alst[i]
        ans %= MOD
    print(ans)
    exit()

blst = []
for num in alst:
    try:
        blst.append([abs(num), abs(num) // num])
    except ZeroDivisionError:
        blst.append([abs(num), 0])
blst.sort(reverse = True,key = lambda x:x[0])
if blst[k - 1] == 0:
    print(0)
    exit()
    
minus = 0
last_minus = 0
last_plus = 0
ans_lst = []
for i in range(k):
    if blst[i][1] == -1:
        minus += 1
        last_minus = blst[i][0]
    elif blst[i][1] == 1:
        last_plus = blst[i][0]
    else:
        print(0)
        exit()
    ans_lst.append(blst[i][0])

next_minus = 0
next_plus = 0
flg_minus = False
flg_plus = False

for i in range(k, n):
    if blst[i][1] == -1 and (not flg_minus):
        next_minus = blst[i][0]
        flg_minus = True
    if blst[i][1] == 1 and (not flg_plus):
        next_plus = blst[i][0]
        flg_plus = True
    if (flg_plus and flg_minus) or blst[i][1] == 0:
        break

if minus % 2 == 0:
    ans = 1
    for num in ans_lst:
        ans *= num
        ans %= MOD
    print(ans)

else:
    minus_s = last_minus * next_minus
    plus_s = last_plus * next_plus
    ans = 1
    if minus == k:
        ans_lst.remove(last_minus)
        ans_lst.append(next_plus)
    elif minus_s == plus_s == 0:
        if next_minus == 0:
            ans_lst.remove(last_minus)
            ans_lst.append(next_plus)
        else:
            print(0)
            exit()
        
    elif minus_s > plus_s:
        ans_lst.remove(last_plus)
        ans_lst.append(next_minus)
    else:
        ans_lst.remove(last_minus)
        ans_lst.append(next_plus)
    for num in ans_lst:
        ans *= num
        ans %= MOD
    print(ans)


Measured memory_bytes: 42608
import sys

sys.setrecursionlimit(10 ** 7)
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7

s = input().strip()

dp = [[0] * 2 for _ in range(100005)]
dp[0][0] = 1

n = len(s)
for i in range(n):
    if s[i] == "0":
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][1]
    else:
        dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD

    if s[i] == "0":
        dp[i + 1][1] += dp[i][1] * 2 % MOD
    else:
        dp[i + 1][0] += dp[i][0] * 2 % MOD
        dp[i + 1][1] += dp[i][1] * 2 % MOD

ans = (dp[n][0] + dp[n][1]) % MOD
print(ans)


Measured memory_bytes: 19688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] line = Console.ReadLine().Trim().Split(' ').Select(s => int.Parse(s)).ToArray();
            int x = line[0];
            int y = line[1];
            int total = 0;
            switch (x)
            {
                case 1:
                    total += 300000;
                    break;
                case 2:
                    total += 200000;
                    break;
                case 3:
                    total += 100000;
                    break;
            }
            switch (y)
            {
                case 1:
                    total += 300000;
                    break;
                case 2:
                    total += 200000;
                    break;
                case 3:
                    total += 100000;
                    break;
            }
            if (x == 1 && y == 1)
            {
                total += 400000;
            }
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13268
pub struct Scanner {
	handle: std::io::Stdin,
	buffer: std::collections::VecDeque<String>
}

impl Scanner {
	pub fn new() -> Scanner {
		Scanner {
			handle: std::io::stdin(),
			buffer: std::collections::VecDeque::new()
		}
	}
	pub fn next<T: std::str::FromStr>(&mut self) -> Result<T, T::Err> {
		if self.buffer.len() == 0 {
			loop {
				let mut available = String::new();
				self.handle.read_line(&mut available).unwrap();
				self.buffer = available.split_whitespace().map(String::from).collect();
				if self.buffer.len() > 0 {
					break;
				}
			}
		}
		T::from_str(&self.buffer.pop_front().unwrap())
	}
}

fn gcd(m: i64, n: i64) -> i64 {
	if m == 0 {
		n
	} else {
		gcd(n % m, m)
	}
}

fn two_p(p: i64) -> i64 {
	if p == 0 {
		1
	} else {
		(2 * two_p(p - 1)) % 1000000007
	}
}

fn main() {
	let mut scanner = Scanner::new();
	let n: i64 = scanner.next().unwrap();
	let mut size = std::collections::HashMap::<(i64,i64,i64),i64>::new();
	let mut zero_total: i64 = 0;
	for _ in 0..n {
		let mut a: i64 = scanner.next().unwrap();
		let mut b: i64 = scanner.next().unwrap();
		if a == 0 && b == 0 {
			zero_total = (zero_total + 1) % 1000000007;
			continue;
		}
		let mut sign = 1;
		if a < 0 {
			sign *= -1;
			a *= -1;
		}
		if b < 0 {
			sign *= -1;
			b *= -1;
		}
		sign = if a == 0 {
			-1
		} else if b == 0 {
			1
		} else {
			sign
		};
		let g = gcd(a as i64,b as i64);
		let s = size.entry((sign,(a as i64)/g,(b as i64)/g)).or_insert(0);
		*s += 1;
	}
	let mut total: i64 = 1;
	for (k1,v1) in size.iter() {
		match size.get(&(-k1.0,k1.2,k1.1)) {
			Some(v2) => {
				if k1.0 > 0 {
					total = (total * ((two_p(*v1) + two_p(*v2) - 1) % 1000000007)) % 1000000007;
				}
			}
			None => total = (total * two_p(*v1)) % 1000000007
		}
	}
	total = ((total + zero_total - 1) % 1000000007 + 1000000007) % 1000000007;
	println!("{}", total);
}


Measured memory_bytes: 14760
#include<bits/stdc++.h>
using namespace std;
const int nax = 5e5 + 10;
/*
int lc[nax * 60], rc[nax * 60], root[nax * 60];
int sg[nax * 60];
int cnt;

inline void update (int &v, int x, int y, int pos, int val) {
    ++ cnt;
    sg[cnt] = sg[v];
    lc[cnt] = lc[v];
    rc[cnt] = rc[v];
    v = cnt;
    if (x == y) {
        sg[v] = val;
    } else {
        int mid = x + y >> 1;
        if (pos <= mid) update(lc[v], x, mid, pos, val);
        else update(rc[v], mid + 1, y, pos, val);
        sg[v] = sg[lc[v]] + sg[rc[v]];
    }
}

inline int query (int v, int x, int y, int l, int r) {
    if (x == y) {
        return sg[v];
    } else {
        int mid = x + y >> 1;
        if (l > mid) return query(rc[v], mid + 1, y, l, r);
        else if (r <= mid) return query(lc[v], x, mid, l, r);
        else return query(lc[v], x, mid, l, mid) + query(rc[v], mid + 1, y, mid + 1, r);
    }
}
*/

int n, q;
int c[nax];
int lst[nax];
int bit[nax];

void update (int i, int val) {
    for (; i < nax ; i += i & -i)
        bit[i] += val;
}

int get (int i) {
    int res = 0;
    for (; i > 0 ; i -= i & -i)
        res += bit[i];
    return res;
}

vector <pair <int, int>> query[nax];
int ans[nax];


int main () {
    cin.tie(0)->sync_with_stdio(false);
    cin >> n >> q;
    for (int i = 1 ; i <= n ; ++ i) {
        cin >> c[i];
    }

    for (int i = 1 ; i <= q ; ++ i) {
        int l, r;
        cin >> l >> r;
        query[r].emplace_back(l, i);
    }

    for (int i = 1 ; i <= n ; ++ i) {
        if (lst[c[i]]) {
            update(lst[c[i]], -1);
        }
        update(i, 1);

        for (auto &[l, idx] : query[i]) {
            ans[idx] = get(i) - get(l - 1);
        }
        lst[c[i]] = i;
    }

    for (int i = 1 ; i <= q ; ++ i) {
        cout << ans[i] << '\n';
    }

}


Measured memory_bytes: 33244
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define  int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=100005;

int32_t main()
{
    IOS;
    int a,b;
    cin>>a>>b;
    int ans=max((int)0,a-2*b);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
A, B, C = gets.split(' ').map(&:to_i)
if A == B && B == C && A % 2 == 0
  puts '-1'
elsif A % 2 == 1 || B % 2 == 1 || C % 2 == 1
  puts '0'
else
  s = []
  t = []
  s[0] = A - B
  s[1] = B - C
  s[2] = C - A
  3.times do |i|
    cnt = 0
    while s[i] % 2 == 0
      s[i] /= 2
      cnt += 1
    end
    t[i] = cnt
  end
  puts t.min
end

Measured memory_bytes: 1788
#include <iostream>
#include <set>
#include <vector>
#include <stack>
#include <string>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    int temp = n/k;
    cout << n - temp*k << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    if K >= 1e3:
        K = 105

    T = ''
    for i in range(len(S)):
        if S[i] == '1':
            T += '1'
        else:
            T += S[i] * K

        if S[i] != '1':
            break

    print(T[K - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 61924
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

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

	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0; i < n; ++i) {
		if(s[i] != '?') {
			cout << s[i];	
		} else {
			cout << 'D';
		}
	}
	cout << "\n";
    
	return 0;
}


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

int main(){
 int N;
  string S;
  
  cin >> N;
  cin >> S;
  
  int count=0;
  
  for(int i=0;i<N-2;i++){
   if(S.at(i)=='A' && S.at(i+1)=='B'){
    if(S.at(i+2)=='C'){
      count++;
    }
     else{
      continue; 
     }
    }
    
  else{
   continue; 
  }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999



int data[10][10];

void jump(int y,int x){
    int dy[]={-2,-2,-2,-1,0,1,2,2,2,1,0,-1};
    int dx[]={-1,0,1,2,2,2,1,0,-1,-2,-2,-2};
    rep(i,12){
        int ddy = y+dy[i];
        int ddx = x+dx[i];
        if(  ddx>=0 && ddy>=0 && ddx<10 && ddy<10  ){
            data[ddy][ddx] = -1;
        }
    }
}


vector<pii> spr(int y,int x){
    vector<pii> ret;
    for(int i=-1;i<=1;i++){
        for(int j=-1;j<=1;j++){
            int ddy = y+i;
            int ddx = x+j;
            if(  ddx>=0 && ddy>=0 && ddx<10 && ddy<10  ){
                if(data[ddy][ddx]==-1){
                    data[ddy][ddx] = 0;
                    ret.pb(pii(ddy,ddx));
                }
            }
        }
    }
    rep(i,10){
        rep(j,10){
            if(data[i][j]==-1){
                data[i][j]=0;
            }
        }
    }
    return ret;
}

int main(){
    int x,y;
    while(cin>>x>>y){
        if(x==0&&y==0)break;
        rep(i,10)rep(j,10)data[i][j]=0;
        int n;
        cin>>n;
        vector<pii> sp;
        rep(i,n){
            int a,b;
            cin>>a>>b;
            sp.pb(pii(b,a));
        }

        jump(y,x);
        rep(i,n){
            int sy = sp[i].first;
            int sx = sp[i].second;
            vector<pii> pos = spr(sy,sx);
            rep(j,pos.size()){
                int yy = pos[j].first;
                int xx = pos[j].second;
                jump(yy,xx);
            }
        }
        bool f=false;
        rep(i,10){
            rep(j,10){
                if(data[i][j]==-1){
                    f=true;
                }
            }
        }
        if(f)cout<<"OK"<<endl;
        else cout<<"NA"<<endl;
    }
}

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

using namespace std;

int n, f[10100];

int main() {
    for(int i = 1;i <= 100; ++i) {
        for(int j = 1;j <= 100; ++j) {
            for(int k = 1;k <= 100; ++k) {
                int ans = i * i + j * j + k * k + i * k + j * k + i * j;
                if(ans <= 10000) f[ans] += 1;
            }
        }
    }
    int n; cin >> n;
    for(int i = 1;i <= n; ++i)
        cout << f[i] << endl;
    return 0;
}

Measured memory_bytes: 3632
sa = list(input())
sb = list(input())
sc = list(input())

v = sa.pop(0)
while True:
    if v == 'a':
        if len(sa) == 0:
            print('A')
            break
        v = sa.pop(0)
    elif v == 'b':
        if len(sb) == 0:
            print('B')
            break
        v = sb.pop(0)
    else:
        if len(sc) == 0:
            print('C')
            break
        v = sc.pop(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
int n, k, q;
int a[maxx];
map <int, int> cnt;

int main() {
	scanf("%d %d %d", &n, &k, &q);
	for(int i = 1; i <= q; i++) {
		scanf("%lld", &a[i]);
		cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		int num = k - (q - cnt[i]);
		if(num > 0) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 5760
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 20:59:55 2020

@author: naoki
"""
import sys 

N,X,T = map(int,input().split())

for i in range(N):
    if X*i<N and N<=X*(i+1):
        time = T*(i+1)
        print(time)
        sys.exit
    

Measured memory_bytes: 9052
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
const int maxn = 303, mod = 1e9 + 7;
string s;
int n, q;

ll d, m, dm, ans;
void add(int i) {
	if(s[i] == 'C') ans += dm;
	if(s[i] == 'M') m++, dm += d;
	if(s[i] == 'D') d++;
}
void pop(int i) {
	if(s[i] == 'M') m--;
	if(s[i] == 'D') d--,  dm -= m;
}

ll solve(int k) {
	d = 0, m = 0, dm = 0, ans = 0;
	for(int i = 0; i < n; i++) {
		if(i - k >= 0) pop(i-k);
		add(i);
	}
	return ans;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> s >> q;
	for(int k; q--;) {
		cin >> k;
		cout << solve(k) << '\n';
	}
	return 0;
}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        if(tmp >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

n, m = [int(w) for w in input().split()]
links = [[] for i in range(n + 1)]
mark = [-1] * (n + 1)

for i in range(m):
    a, b = [int(w) for w in input().split()]
    links[a].append(b)
    links[b].append(a)

q = deque([1])
while q:
    now = q.popleft()
    for l in links[now]:
        if mark[l] == -1:
            q.append(l)
            mark[l] = now

if -1 in mark[2:]:
    print("No")
else:
    print("Yes")
    print("\n".join([str(w) for w in mark[2:]]))


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll N, M;
    cin >> N >> M;
    vector<ll> A, sum;
    sum.push_back(0);
    map<ll, ll> mp;
    mp[0]++;
    for(int i = 0; i < N; i++) {
        ll in;
        cin >> in;
        A.push_back(in);
        sum.push_back((sum.back() + A[i]) % M);
        mp[sum.back()]++;
    }
    ll ans = 0;
    for(int i = 0; i < sum.size(); i++) {
        ll val = sum[i];
        //cout << i << " " << val << endl;
        ans += mp[val] * (mp[val] - 1) / 2;
        mp[val] = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, a;
  int x=0;
  int y=1000000000;
  cin >> N;
  for (int i = 0; i<N; i++) {
    cin >> A;
    while (A%2 == 0) {
      A /= 2;
      x++;
    }
    if (y > x) {
      y = x;
    }
    x = 0;
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

gcd(long long x, long long y){ return x % y != 0 ? gcd(y , x % y) : y;}

int main(){
  int a1, m1, a2, m2, a3, m3, x, i, j;
  long long move1, move2, move3;
  while(scanf("%d%d%d%d%d%d",&a1,&m1,&a2,&m2,&a3,&m3)&&a1&&m1&&a2&&m2&&a3&&m3){
    x = 1;
    i = 0;
    do{
      x = a1 * x % m1;
      i++;
    }while(x != 1);
    move1 = i;
    i = 0;
    do{
      x = a2 * x % m2;
      i++;
    }while(x != 1);
    move2 = i;
    i = 0;
    do{
      x = a3 * x % m3;
      i++;
    }while(x != 1);
    move3 = i;

    move1 = move1 * move2 / gcd(move1, move2);
    move1 = move1 * move3 / gcd(move1, move3);

    printf("%lld\n", move1);
  }
  return 0;
}

Measured memory_bytes: 600
def main():
   a, b, c=map(int, input().split())
   if a%2==0 or b%2==0 or c%2==0:
      print(0)
   elif a>=b and a>=c:
      print(b*c)
   elif b>=a and b>=c:
      print(a*c)
   else:
      print(a*b)
main()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    string color;
    
    cin >> N;
    
        for (int i = 1; i <= N; i++){
            cin >> color;
            
                if (color == "Y"){
                    cout << "Four" << endl;
                    break;
                }
                if (i == N){
                    cout << "Three" << endl;
                }
        }       
        
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int n, a, b, c;
int ans = INF;
int kado[8];
vector<vector<int>> use(4);

void solve(int i = 0) {
	if (i == n) {
		if (use[1].size() == 0 || use[2].size() == 0 || use[3].size() == 0) {
			return;
		}
		else {
			int kl[4] = { 0 };
			rep(j, 1, 4) {
				rep(k, 0, use[j].size()) {
					kl[j] += use[j][k];
				}
			}
			int sub = 10*(use[1].size()+use[2].size()+use[3].size()-3)+abs(a - kl[1]) + abs(b - kl[2]) + abs(c - kl[3]);
			ans = min(ans, sub);
		}
	}
	else {
		rep(j, 0, 4) {
			use[j].push_back(kado[i]);
			solve(i + 1);
			use[j].pop_back();
		}
	}

	return;
}

int main() {

	cin >> n >> a >> b >> c;
	rep(i, 0, n) {
		cin >> kado[i];
	}
	
	solve();

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let nm: Vec<usize> = read_vec();
    let mut xm: Vec<i64> = read_vec();

    // N >= Mなら終了
    if nm[0] >= nm[1] { println!("{}", 0); return; }

    xm.sort();

    let mut distance: Vec<i64> = Vec::new();

    // 座標間の移動距離を求める
    for i in 0..(nm[1] - 1)
    {
        let d: i64 = (xm[i + 1] - xm[i]).abs();
        distance.push(d);
    }

    // 座標間の移動距離を小さい方からresultに加算する。
    // 加算回数はM - N回
    distance.sort();

    let mut result = 0_i64;
    for i in 0..(nm[1] - nm[0])
    {
        result += distance[i];
    }
    println!("{}", result);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  // int型の2次元配列(3×4要素の)の宣言
  string s;
  cin>>s;
  int count1=0;
  int count2=0;
  // 入力 (2重ループを用いる)
  for (int i = 0; i < s.size(); i++) {
    if(i%2==0){
      if(s.at(i)=='0')
        count1++;
      else
        count2++;
    }
    else{
      if(s.at(i)=='0')
        count2++;
      else
        count1++;
    }
  }
  cout<<min(count1,count2)<<endl;   
    
  }

Measured memory_bytes: 512