akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'





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

  int n;
  cin>>n;
  int c=0;
  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    c+= (a!=i);
  }

  if(c==2 or c==0) cout<<"YES"<<endl;
  else cout<< "NO"<<endl;


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n,a,b,ne=0;
	cin>>b;
	n=b;
	while(n!=0)
    {
        a=n%10;
        ne=ne*10+a;
        n=n/10;
    }
    if(b==ne)
        cout<<"Yes";
    else
        cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N; 
	cin >> N;
    vector<ll> A(N+1);
  	A.at(0) = 0;
  	for (int i = 1; i < N+1; i++) {
  		cin >> A.at(i);	
	}
  
	// Left[i] = A[1] - > A[i] までの和
  	// Right[i] = A[i] -> A[N] までの和
	vector<ll> Left(N+1);
	vector<ll> Right(N+1);
	Left.at(0) = 0;
	rep3(i,1,N){
  		Left.at(i) = Left.at(i-1) + A.at(i);
    }
	Right.at(N) = A.at(N);
	rep3rev(i,N-1,1){
  		Right.at(i) = Right.at(i+1) + A.at(i);
    }

	// | Left[i] - Right[i+1] | の min を求める
	ll temp;
  	ll min = Left.at(N);
  	rep3(i,1,N-1){
    	temp = abs(Left.at(i) - Right.at(i+1)); 
   		if(temp<min){min = temp;}
    }
  	cout << min << endl;
  return;
  
  	
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
  return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define LINE_BUF_SIZE 2000000

int main(){

    int i;
    int count=0,z_count=0,status=0;;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);

    for(i=0;i<strlen(line);i++){
        if(strncmp(&line[i],"A",1)==0 && status == 0){
            count = i+1;
            status = 1;
        }
        if(strncmp(&line[i],"Z",1)==0){
            z_count = i+1;
        }
    }
    
    printf("%d",z_count-count+1);

    return 0;

}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        String s = std.next();
        long k = std.nextLong();
        //  10^15
        String rest = s;
        long restLength = k;
        boolean countOne = false;
        while (rest.charAt(0) == '1') {
            rest = rest.replaceFirst("1", "");
            restLength--;
            if (restLength == 0) {
                countOne = true;
                break;
            }
        }

        if (countOne) {
            System.out.println(1);
        } else {
            System.out.println(rest.substring(0, 1));
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; 

double ff(double b,double l){
  return b*(l-b)*(l-b)/4;
}
int main(){
  double l;
  cin >> l;
  double left = 0;
  double right = l;
  for(int i=0; i<500; i++){
    double c1 = (left*2+right)/3;
    double c2 = (left+right*2)/3;
    if(ff(c1,l) > ff(c2,l)){
      right = c2;
    }
    else{
      left = c1;
    }
  }
  cout << fixed << setprecision(10) << ff(left,l) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main() {
	
	int a,b; 
	scanf("%d%d", &a,&b) ;
	
	if(a==b)
		printf("Draw"); 
			
	else if(a==1)

     	printf("Alice");
	
	else if (b==1)	
  
        printf("Bob");
	 	
	else if(a>b) 
	 	printf("Alice");
	 	
	else
	 printf("Bob") ;
	 
	 
	 
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
	long long A, B, C, K;

	cin >> A >> B >> C >> K;

	if (A >= K) {
		cout << K << endl;
	}
	else if (A + B >= K) {
		cout << A << endl;
	}
	else if (A + B + C > K) {

		long long minus = K - A - B;
		cout << A - minus << endl;
	}
	else if (A + B + C == K) {
		cout << A - C << endl;

	}
	else if (A < K) {
		cout << K << endl;
	}
	else
		cout << K << endl;


	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  string S, T;
  cin >> S >> T;
  int a;
  int ans=10000;
  a=S.size()-T.size();
  rep(i, a+1){
    int cou=0;
  rep(j, T.size()){
  if(S[j+i]!=T[j]){
  
  
  cou++;
  }
  }
  ans=min(cou,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

int main(){
  int N,M;
  std::string s;
  std::cin>>N;
  std::map<std::string,int> m;
  for(int i=0;i<N;++i){
    std::cin>>s;
    m[s]++;
  }
  std::cin>>M;
  for(int i=0;i<M;++i){
    std::cin>>s;
    m[s]--;
  }
  int ans=0;
  for(auto pair:m){
    ans=std::max(ans,pair.second);
  }
  std::cout<<ans<<std::endl;
  return 0;
}




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

int main() {
  int n;
  cin >> n;
  int values[n];

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

  for (int j = 0; j < n - 1; j++) {
    cout << values[j] << " ";
  }
  cout << values[n - 1] << endl;

  for (int i = 1; i < n; i++) {
    int value = values[i];
    int j = i - 1;
    while (j >= 0 && values[j] > value) {
      values[j + 1] = values[j];
      j--;
    }
    values[j + 1] = value;

    for (int j = 0; j < n - 1; j++) {
      cout << values[j] << " ";
    }
    cout << values[n - 1] << endl;
  }
}



Measured memory_bytes: 3072
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    writeln(48 - lread());
}


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

int main() {
    int n, z, w;
    cin >> n >> z >> w;
    int a[n];
    for (int i = 0; cin >> a[i]; i++) {
    }
    if (n == 1) {
        cout << abs(a[0] - w);
    } else {
        cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1]));
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int time = min(B, D) - max(A, C);
  cout << (time >= 0? time: 0) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
rest = [0] * (N+1)
for i in range(N):
    diff = B[i] - A[i]
    if diff >= 0:
        if B[i] >= A[i] + A[i+1]:
            res += A[i] + A[i+1]
            A[i+1] = 0
        else:
            res += B[i]
            A[i+1] -= diff
    else:
        res += B[i]
print(res)



Measured memory_bytes: 18476
#include<cstdio>
typedef long long ll;
ll gcd(ll p,ll q)
{
    if(q==0)
        return p;
    return gcd(q,p%q);
}
int main(void)
{
    ll a,b,c,d;
    scanf("%lld %lld %lld %lld" ,&a,&b,&c,&d);
    a--;
    ll l=c*d/gcd(c,d);
    printf("%lld" ,b-(b/c+b/d-b/l)-(a-(a/c+a/d-a/l)));
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;



int main()
{
	string S;
	cin >> S;
	reverse(S.begin(), S.end());

	bool kuriagari = false;

	ll ans[2] = { 0 };

	for (int i = 0; i < S.size(); ++i)
	{
		int n = S[i] - '0';

		ll tmp[2];

		tmp[0] = ans[0] + n;
		tmp[1] = ans[0] + 10 - n;

		if (i != 0)
		{

			n++;

			tmp[0] = min(tmp[0], ans[1] + n);
			tmp[1] = min(tmp[1], ans[1] + 10 - n);
		}
		ans[0] = tmp[0];
		ans[1] = tmp[1];


		
	}

	ans[1]++;

	cout << min(ans[0],ans[1]) << endl;

	return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <stdio.h>

typedef long long ll;

#define debug(x) cerr << #x << ": " << x << "\n";
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  int H1,H2,M1,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  cout << (H2-H1)*60+(M2-M1) - K << endl;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        /*2つの整数a,bの平均値xを求める
        xの小数点以下を切り上げた値を出力*/
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        double x = ((double)a + (double)b) / 2;
        int ans = (int)Math.ceil(x);
        System.out.println(ans);
    }
}


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

int main()
{
    int n,m;
    cin >>n >>m;
    if(n>12)
        cout << m <<endl;
    else if(n<6)
        cout << 0 << endl;
    else
        cout << m/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;
int main(void)
{
	string A;
	string B;
	string C;

	cin >> A;
	cin >> B;
	cin >> C;


	if (A.back() == B.front()) {
		if (B.back() == C.front()) {
			cout << "YES" << endl;
		}
		else
			cout << "NO" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = Long.parseLong(scan.next());
        long b = Long.parseLong(scan.next());
        long k = Long.parseLong(scan.next());
        scan.close();

        long ta = a;
        long ao = b;

        if (k >= ta) {
            k -= ta;
            ta = 0;
        } else {
            ta -= k;
            System.out.println(ta + " " + ao);
            return;
        }

        if (k >= ao) {
            System.out.println(0 + " " + 0);
        } else {
            ao -= k;
            System.out.println(ta + " " + ao);
        }

    }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

int main() {
    init_io();
    ll N, Q;
    string S;
    cin >> N >> Q >> S;
    V<ll> cnt(N + 10, 0);
    for(ll i = 1; i < N; i++) {
        cnt[i + 1] = cnt[i];
        if(S[i - 1] == 'A' && S[i] == 'C') cnt[i + 1]++;
    }
    DEBUG(cnt);
    for(ll i = 0; i < Q; i++) {
        ll l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1872
#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 ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#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;
}
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;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int r; cin >> r;
    cout << 2 * PI * r;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,m;cin >>n >> m;
    vector<int> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    int ret = 0;
    rep(i,m){
        vector<int> ki[n];
        rep(j,m){
            if(i == j)continue;
            ki[a[j]].push_back(b[j]);
            ki[b[j]].push_back(a[j]);
        }
        // rep(i,n)trace(i,ki[i]);
        queue<int> q;
        vector<int> vis(n);
        q.push(0);
        vis[0] = 1;
        while(q.size()){
            auto now = q.front();q.pop();
            for(auto next:ki[now]){
                if(vis[next])continue;
                vis[next] = 1;
                q.push(next);
            }
        }
        auto check = [&](){
            rep(i,n){
                if(!vis[i]){
                    return true;
                }
            }
            return false;
        };
        if(check()){
            // trace(i);
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3612
n, m = map(int, input().split())
h_ls = list(map(int, input().split()))

ab_ls = []
for i in range(m):
    tmp = list(map(int, input().split()))
    ab_ls.append(tmp)

no_set = set()
for item in ab_ls:
    if h_ls[item[0]-1] <= h_ls[item[1]-1]:
        no_set.add(item[0]-1)
    if h_ls[item[0]-1] >= h_ls[item[1]-1]:
        no_set.add(item[1]-1)

print(n - len(no_set))


Measured memory_bytes: 35572
#include<iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a >= b && a >= c) {
    cout << b + c << endl;
  } else if (b >= a && b >= c) {
    cout << a + c << endl;
  } else {
    cout << a + b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;



int main(){
    int n;
    cin >> n;
    int ans,a,b,c;
    a=0;
    b=0;
    c=0;
    ans=0;
    for (int i=0;i<n;i++){
        string s;
        cin >> s;
        int d=s.size();
        for (int j=0;j<d-1;j++){
            if(s.at(j)=='A'){
                if(s.at(j+1)=='B') ans++;
            }
        }
        
        if(s.at(0)=='B'){
            if(s.at(d-1)=='A') c++;
            else  b++;
        }
        
        else if (s.at(d-1)=='A') a++;
    }
    
    if (c>0) {
        ans+=c-1;
        if(b>0){
            b--;
            ans++;
        }
        if(a>0){
            a--;
            ans++;
        }
    }
    int f=min(a,b);
    ans+=f;
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1);
vector<ll> pw10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	string s; cin>>s;
	vector<ll> ans(s.sz,0); 
	ll tmp=-1,tmp2;
	rep(i,s.sz){
		ll tmp2;
		if(i<s.sz-1 && s[i]=='R' && s[i+1]=='L'){
			tmp2=i+1;
			//cout<<"tmp2:"<<tmp2<<endl;
		}
		if((i<s.sz-1 && s[i]=='L' && s[i+1]=='R') || i==s.sz-1){
			for(int j=i;j>=tmp+1;j--){
				if(abs(j-tmp2)%2==0) ans[tmp2]++;
				else ans[tmp2-1]++;
			}
			tmp=i;
			//cout<<"tmp:"<<tmp<<endl;
		}
	}
	rep(i,s.sz) cout<<ans[i]<<" ";
}

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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector <int> a(N, 0);
    for (int i = 0; i < N; i++) cin >> a[i];
    int m = 0;
    for (int i = 0; i < N; i++) {
        if (m < a[i]) m = a[i];
        else {
            if (abs(m - a[i])>= 2) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>str;
    n=sz(str);
    rep(i,0,n-1) cout<<"x";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
int main(int argc, char* argv[]) {
	int n;
	int a[10004];
	while (1) {
		cin >> n;
		if (n == 0)break;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			sum += a[i];
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] * n <= sum)ans += 1;
		}
		cout << ans<<"\n";
	}
}



Measured memory_bytes: 3132
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1L << 60;

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    auto dp = new long[][](n + 1, n + 1);
    fillAll(dp, -inf); // 最大化問題なので -inf で初期化するべき

    // 先手は X - Y の最大化
    // 後手は Y - X の最大化
    // をすると考えれば先手後手の場合分けが不要になる
    long dfs(int l, int r) {
        auto v = &dp[l][r];
        if (*v != -inf) {
            return *v;
        }
        if (r - l == 1) {
            return *v = a[l];
        }
        return *v = max(a[l] - dfs(l + 1, r), a[r - 1] - dfs(l, r - 1));
    }

    auto ans = dfs(0, n);

    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

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

signed main() {
    ll n, k;
    cin >> n >> k;
    
    n -= k;
    ll r = 1; 
    r += ceil((double)n / (k-1));
    
    mes(r);
    
    
    
    

}
    
    
    
    
    


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, M;
    cin >> N >> M;
    vec X(N);
    map<ll, ll> cnt;
    Rep (i, N) {
        cin >> X[i];
        cnt[X[i]]++;
    }

    map<ll, ll> p, m;
    for (auto e : cnt) {
        ll n = e.first, c = e.second;
        m[n%M] += c;
        p[n%M] += c/2;
    }

    // for (auto e : m) {
    //     cout << e.first << " " << e.second << "\n";
    // }

    ll ans = m[0]/2;
    if (M%2 == 0) ans += m[M/2]/2;
    for (ll i = 1; i < (M+1)/2; i++) {
        ll tmp = min(m[i], m[M-i]);
        ans += tmp;
        m[i] -= tmp;
        m[M-i] -= tmp;
        if (m[M-i] == 0) {
            ans += min(p[i], m[i]/2);
        } else {
            ans += min(p[M-i], m[M-i]/2);
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 19840
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n, m;
    cin>>n>>m;
    vector<vector<ll> > v(8, vector<ll>(n));
    rep(i, n){
        ll a, b, c;
        cin>>a>>b>>c;
        v[0][i] = a+b+c;
        v[1][i] = a+b-c;
        v[2][i] = a-b+c;
        v[3][i] = a-b-c;
        v[4][i] = -a+b+c;
        v[5][i] = -a+b-c;
        v[6][i] = -a-b+c;
        v[7][i] = -a-b-c;
    }
    ll ans = 0;
    rep(i, 8){
        sort(v[i].begin(), v[i].end(), greater<ll>());
        ll tmp = 0;
        rep(j, m) tmp += v[i][j];
        ans=max(ans, tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut nx = String::new();
    stdin().read_line(&mut nx).unwrap();
    let nx: Vec<usize> = nx.trim().split_whitespace().flat_map(str::parse).collect();
    let (n, x) = (nx[0], nx[1]);

    let mut ls = String::new();
    stdin().read_line(&mut ls).unwrap();
    let mut ds = [0; 101];
    let mut bounce = 1;
    for (i, l) in ls.trim().split_whitespace().flat_map(str::parse::<usize>).enumerate() {
        ds[i + 1] = ds[i] + l;
        if ds[i + 1] <= x {
            bounce += 1;
        }
    }
    println!("{}", bounce);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


ll dp[100010];

int main(){
    int n, m;
    cin >> n >> m;
    ll c[25];
    rep(i, m) cin >> c[i];

    rep(i, n + 1) dp[i] = i;
    rep(i, n + 1){
        rep(j, m){
            if (i >= c[j]) dp[i] = min(dp[i - c[j]] + 1, dp[i]);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3468
n = int(input())
al = list(map(int, input().split()))

if n == 1 and al[0] == 1:
    print(0)
else:
    i, j, num, ans = 0, 0, 1, 0
    while i < n:
        if al[i] != num:
            i += 1
        else:
            ans += i-j
            j = i+1
            num += 1
            i += 1

    # print(i, j, ans)

    if num != 1 and j != n:
        ans += i-j

    if num == 1:
        print(-1)
    else:
        print(ans)

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

using namespace std;

int32_t main()
{
  vector<uint32_t> group1{1,3,4,5,7,8,10,12};
  vector<uint32_t> group2{4,6,9,11};
  vector<uint32_t> group3{2};

  uint32_t x, y;
  cin >> x >> y;

  uint32_t group_x, group_y;
  for(uint32_t i = 0; i < group1.size();i++){
    if(x == group1[i]) group_x = 1;
    if(y == group1[i]) group_y = 1;
  }

  for(uint32_t i = 0; i < group2.size(); i++){
    if(x == group2[i]) group_x = 2;
    if(y == group2[i]) group_y = 2;
  }

  for(uint32_t i = 0; i < group3.size(); i++){
    if(x == group3[i]) group_x = 3;
    if(y == group3[i]) group_y = 3;
  }

  if(group_x == group_y){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	if (a < b)ans += a;
	else ans += b;
	if (c < d)ans += c;
	else ans += d;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <sstream>
#include <deque>
#define ll long long
using namespace std;
const int maxn=10000;

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	
	if(a>=b){
		cout<<"delicious";
		return 0;
	}
	int lated=b-a;
	if(lated<=x){
		cout<<"safe";
		return 0;
	}	
	cout<<"dangerous";
	
}

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

int main(){
	int n, count=1;
	cin >> n;
	int d[n];
	for(int i=0;i<n;i++) cin >> d[i];
	sort(d,d+n);
	for(int i=0; i<n-1; i++){
		int l=d[i];
		if(l!=d[i+1]) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        a: [usize; N],
    }
    a.sort();

    let mut ind = 0;
    let mut sum = 0;
    while ind < a.len() {
        let first_ind = ind;
        while a[ind] == a[first_ind] {
            ind += 1;
            if ind >= a.len() {
                break;
            }
        }
        if (ind - first_ind) >= a[first_ind] {
            sum += (ind - first_ind) - a[first_ind];
        } else {
            sum += ind - first_ind;
        }
    }

    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<stdio.h>
int a[5],temp;

void sort()
{
	int i,j;
	for(i=0;i<5;i++){
		for(j=0;j<5;j++){
			if(a[i]<a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
}

int main()
{
	int i,j;
	while((scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4]))!=EOF){
		sort();
		if((a[0]==a[1]&&a[0]==a[2]&&a[0]==a[3])||(a[1]==a[2]&&a[1]==a[3]&&a[1]==a[4]))printf("four card\n");
		else if((a[0]==a[1]&&a[0]==a[2]&&a[3]==a[4])||(a[0]==a[1]&&a[2]==a[3]&&a[2]==a[4]))printf("full house\n");
		else if((a[0]==a[1]&&a[0]==a[2])||(a[1]==a[2]&&a[1]==a[3])||(a[2]==a[3]&&a[2]==a[4]))printf("three card\n");
		else if((a[0]==a[1]&&a[2]==a[3])||(a[1]==a[2]&&a[3]==a[4])||(a[0]==a[1]&&a[3]==a[4]))printf("two pair\n");
		else if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3]||a[3]==a[4])printf("one pair\n");
		else if((a[0]==a[1]-1&&a[1]==a[2]-1&&a[2]==a[3]-1&&a[3]==a[4]-1)||(a[0]==1&&a[1]==10&&a[2]==11&&a[3]==12&&a[4]==13))printf("straight\n");
		else printf("null\n");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    if (s.equals("SUN")) {
      System.out.println(7);
    } else if (s.equals("MON")) {
      System.out.println(6);
    } else if (s.equals("TUE")) {
      System.out.println(5);
    } else if (s.equals("WED")) {
      System.out.println(4);
    } else if (s.equals("THU")) {
      System.out.println(3);
    } else if (s.equals("FRI")) {
      System.out.println(2);
    } else if (s.equals("SAT")) {
      System.out.println(1);
    }
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar(); }
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    return x * f;
}

typedef long long ll;

int n,a[4001],b[4001][4];
char s[4001];

int main() {
    n = read();
    ll ans = 0;
    for(int i = 1;i <= n;i++) {
        std::scanf("%c",s + i);
        if(s[i] == 'R') a[i] = 1;
        else if(s[i] == 'G') a[i] = 2;
        else a[i] = 3;
    }
    for(int i = 1;i <= n;i++) {
        b[i][1] = b[i - 1][1];
        b[i][2] = b[i - 1][2];
        b[i][3] = b[i - 1][3];
        b[i][a[i]]++;
    }
    for(int i = n;i >= 1;i--)
        for(int j = i - 1;j > 1;j--) {
            if(s[i] == s[j]) continue;
            int k = (1 ^ 2 ^ 3) ^ (a[i] ^ a[j]);
            ans += b[j - 1][k];
            if(j - (i - j) >= 1 && a[j - (i - j)] == k) ans--;
        }
    std::printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

int main()
{
  int n[1001] = {0};
  int N,M;
  cin>>N>>M;

  int ch;
  for(int i = 0;i < M;++i){
    cin>>ch;
    n[ch] = 1;
  }

  int count = 0;
  for(int i = 1;i <= M;++i){
    if(n[i] == 1){
      ++count;
    }
  }

  int ans = M - count;
  cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,redcount=0,ans=0;
    char c[200100];
    cin >> n >> c;
    rep(i,n) if(c[i] == 'R') redcount++;
    
    rep(i,redcount) if(c[i] == 'W') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3792
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int[] A = new int[N];
	for(int i = 0; i<N; i++) {
	    A[i] = sc.nextInt();
	}
	Arrays.sort(A);
	if(A[0] == 1) {
	    System.out.println(1);
	    return;
	}
	for(int i = 0; i<N; i++) {
	    if(A[i] % A[0] != 0) break;
	    if(i == N-1) {
		System.out.println(A[0]);
		return;
	    }
	}
	int cnt =1;
	for(int i = A[0]/cnt; i>=1; i=A[0]/cnt) {
	    cnt++;
	    if(A[0]%i != 0) continue;
	    for(int j = 1; j<N; j++) {
		if(A[j] % i !=0) break;
		if(j == N-1) {
		    System.out.println(i);
		    return;
		}
	    }
        }
	System.out.println(1);
    }
}

Measured memory_bytes: 50928
import numpy as np
n, q = map(int, input().split())
s = input()
lr = []
for i in range(q):
        l,r = map(int, input().split())
        lr.append([l,r])

n = len(s)
L = 0
R = 1
cntAC = [0] * n

for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        cntAC[i] += 1

# 累積和
cSum = np.cumsum(cntAC)


for _lr in lr:
    if _lr[L] == 1:
        print(cSum[_lr[R]-2])
    else:
        print(cSum[_lr[R]-2] - cSum[_lr[L]-2])
        

"""
ACACTACG
"""

Measured memory_bytes: 33024
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1 && b != 1) cout << "Alice";
  else if (a != 1 && b == 1) cout << "Bob";
  else {
    if (a == b) cout << "Draw";
    else if (a > b) cout << "Alice";
    else cout << "Bob";
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
N = input()
N = [int(n) for n in N]
A,B,C,D = N
op =['+','-']
ops = []
for a in op:
  for b in op:
    for c in op:
        ops.append(a + b + c)
        
for op in ops:
  S = "{}{}{}{}{}{}{}".format(A,op[0],B,op[1],C,op[2],D)
  if eval(S) == 7:
    print("{}=7".format(S))
    break

Measured memory_bytes: 60888
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

typedef pair<int, int> P;
queue<P> Q1;

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

char c[1001][1001];

int main() {

    int H, W;
    scanf("%d %d" ,&H, &W);
    for (int i = 0; i < H; i++) {
        scanf("%s", c[i]);
        for (int j = 0; j < W; j++) {
            if (c[i][j] == '#') {
                Q1.push(make_pair(i, j));
            }
        }
    }

    int ans = 0;

    while (true) {
        queue<P> Q2;
        while (!Q1.empty()) {
            P p = Q1.front(); Q1.pop();
            for (int i = 0; i < 4; i++) {
                int px = p.first + dx[i];
                int py = p.second + dy[i];
                if (px < 0 or px >= H or py < 0 or py >= W)
                    continue;
                if (c[px][py] == '#')
                    continue;
                c[px][py] = '#';
                Q2.push(make_pair(px, py));
            }
        }

        if (Q2.empty()) 
            break;
        else
            Q1 = Q2;

        ans++;
    }

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

}


Measured memory_bytes: 9600
function Main(input) {
	var list = input.split("\n")[1].split(" ");
   var output = 0;
  for(var i = 0; i < list.length; i++){
    list[i] = parseInt(list[i]);
  }
  list.sort(function(a,b){
  	return a - b;
  });
  while(list.length != 1){
    var x = list[0];
    var y = list[1];
    var make = (x + y) / 2;
    list.shift();
    list[0] = make;
  }
  console.log(list[0]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
using System;

class Program
{
    static void Main()
    {
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            }
        }
    }
}

Measured memory_bytes: 8956
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int n = stdIn.nextInt();
        String [] a = new String[n];
        String [] a2 = new String[n];

        for(int i = 0; i < n; i++){
        	a[i] = stdIn.next();
        	a2[i] = a[i];
        }
        stdIn.close();

        for(int i=0; i < n;i++) {
			for(int j=n-1; j > i; j--){
				if(cardnumber(a[j]) < cardnumber(a[j-1])){
					String tmp= a[j];
					a[j]=a[j-1];
					a[j-1]=tmp;
				}
			}
		}

		for(int i=0; i < n-1;i++) {
			int minj = i;
			for(int j=i; j < n; j++){
				if(cardnumber(a2[minj]) > cardnumber(a2[j])){
					minj = j;
				}
			}
			if(minj != i) {
				String tmp= a2[i];
				a2[i]=a2[minj];
				a2[minj]=tmp;
			}
		}

        out_put(a);
        System.out.println("Stable");
        out_put(a2);
        if(Arrays.equals(a,a2)) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
	}

	private static int cardnumber(String x){
		return Integer.valueOf(x.substring(1));
	}
	private static void out_put(String array[]){

        System.out.printf("%s", array[0]);

        if (array.length >1) {
        	for(int i = 1; i < array.length; i++){
        		System.out.printf(" %s", array[i]);
        	}
        }
        System.out.printf("%n");
    }
}



Measured memory_bytes: 26820
/**
 * @author: Jun
 * @date  : 03-17-2019
 **/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n,l;
string arr[105];

bool comp(string a, string b){
    for(int i=0;i<l;i++){
        if(a[i]!=b[i]){
            return a[i] < b[i];
        }
    }
    return a[0] < b[0];
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> l;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }
    sort(arr+1, arr+n+1, comp);
    for(int i=1;i<=n;i++){
        cout << arr[i];
    }
    return 0;
}

Measured memory_bytes: 256
c=[p]*gets.to_i
d=$<.map{|l|a,_,*b=l.split.map &:to_i;[a,b.map{|i|c[i]=i}]}.sort
(f=->n,e,a{t=d[n][1].map{|i|f[i,e+1,n]};d[n][1,0]=[a,e,a<0?:root:t==[]?:leaf:"internal node"]})[c.index(p),0,-1]
d.map{|i|puts"node %d: parent = %d, depth = %d, %s, %s"%i}

Measured memory_bytes: 75540
#!/usr/bin/env python3

while(True):
	try:
		a,b=map(int, input().split())
	except EOFError:
		break

	#euclidian algorithm	
	r=a%b
	x,y=a,b
	while(r>0):
		x=y
		y=r
		r=x%y
	gcd=y
	lcm=int(a*b/gcd)
	print("{0} {1}".format(gcd, lcm))

Measured memory_bytes: 6728
function Main(input) {
    ans = 0
    lines = input.split("\n")
    N = lines[0].split(" ")[0] * 1
    L = lines[0].split(" ")[1] * 1
    sum = 0
    diff = 0
    if (L > 0) {
        diff = -1 * L
    } else {
        if (N > Math.abs(L)) {
            diff = 0
        } else {
            diff = -1 * (L + N - 1)
        }
    }
    for(i =1; i <= N; i++) {
        sum += L + i - 1
    }
    ans = sum + diff
    console.log(ans)
    return ans
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372