akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();

			int[] y = x.OrderBy(p => p).ToArray();
			int m1 = y[n / 2 - 1];
			int m2 = y[n / 2];
			for (int i = 0; i < n; i++) {
				if (x[i] <= m1) {
					//System.Diagnostics.Debug.WriteLine($"{x[i]}<={m1} : {m2}");
					Console.WriteLine(m2);
				} else {
					//System.Diagnostics.Debug.WriteLine($"{x[i]}> {m1} : {m1}");
					Console.WriteLine(m1);
				}
			}

		}
	}
}


Measured memory_bytes: 53980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n,k; cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
    }else{
        cout << n-k << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<sstream>
#include<algorithm>
using namespace std;

typedef long long LL;

LL FizzBuzzStringLength(LL n)
{
	LL x1=1,x2=10;
	LL digitLength=1;
	LL result=0;
	while(x1<=n)
	{
		LL upper = min(x2-1,n);
		LL length = upper-x1+1;
		LL fizzbuzzNum = upper/15 - (x1-1)/15;
		LL fizzNum = upper/3 - (x1-1)/3 - fizzbuzzNum;
		LL buzzNum = upper/5 - (x1-1)/5 - fizzbuzzNum;

		result += (length-fizzNum-buzzNum-fizzbuzzNum)*digitLength;
		result += fizzNum*4 + buzzNum*4 + fizzbuzzNum*8;

		x1*=10;
		x2*=10;
		++digitLength;
	}
	return result;
}
string FizzBuzz(LL n)
{
	if(n%15==0)
		return "FizzBuzz";
	if(n%5==0)
		return "Buzz";
	if(n%3==0)
		return "Fizz";
	stringstream s;
	s<<n;
	return s.str();
}

string Solve(LL s)
{
	LL low=1,hi=1e18+1000,mid;

	while(low<hi)
	{
		mid=(low+hi)/2;
		LL temp = FizzBuzzStringLength(mid);
		if(temp<=s)
			low = mid+1;
		else
			hi = mid;
	}
	--low;
	stringstream ss;
	for(int i=0; i<20; ++i)
		ss << FizzBuzz(low+i);
	string str(ss.str());
	int begin = int(s-FizzBuzzStringLength(low-1)-1);

	return str.substr(begin,20).c_str();
}

int main()
{
	LL s;
	scanf("%lld",&s);
	printf("%s\n",Solve(s).c_str());
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	for (int i = 2; i < S.size(); i += 2) {
		bool ok = true;
		for (int j = 0; j < (S.size() - i) / 2; j++) {
			if (S[j] != S[(S.size() - i) / 2 + j]) ok = false;
		}
		if (ok) {
			cout << S.size() - i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <stack>
#include <bitset>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;


ll bitdp[1 << 23];
bool flag[1 << 23];
int table[24][24];
int n;
const int mod = 1e9+7;

int main(){
    cin >> n;
    queue<int> q[24];
    //テーブル情報
    rep(i,n){
        rep(j,n){
            cin >> table[i][j];
            if(i==0 && table[i][j] == 1) bitdp[1 << j] = 1;
        }
    }

    rep(i,n){
        if(table[0][i] == 1){
            q[0].push(1 << i);
            flag[1<<i] = true;
        }
    }

    reps(j,1,n){
        while(!q[j-1].empty()){
            int pat = q[j-1].front();
            q[j-1].pop();
            
            rep(k,n){
                if(table[j][k] == 1 && ((pat >> k) & 1) == 0){
                    int new_pat = pat | 1 << k;
                    bitdp[new_pat] = (bitdp[new_pat] + bitdp[pat] ) % mod;
                    if(flag[new_pat] == false){
                        q[j].push(new_pat);
                        flag[new_pat] = true;
                    }
                }
            }
        }
    }

    cout << bitdp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 24448
form = "{}-{}"

while True:
	n = int(raw_input())
	if n == 0:
		break
	
	page = map(int,raw_input().split() + [0])
	
	start = page[0]
	for i in xrange(n):
		if page[i] + 1 != page[i + 1]:
			if page[i] != start:
				print form.format(start, page[i]),
			else:
				print start,
			start = page[i + 1]
	print

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void dump_(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, k);

  i64 res = 0;
  reps(i, 1, k) {
    reps(j, i + 1, k) {
      if (i % 2 != j % 2) ++res;
    }
  }

  OUTL(res);
  return 0;
}


Measured memory_bytes: 256
# Simple Calculator

end = 0
while end == 0:
    n = [i for i in input().rstrip().split()]
    a = int(n[0])
    op = n[1]
    b = int(n[2])

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        end += 1



Measured memory_bytes: 5604
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> v;
  int cnt = 0;
  bool b = false;
  for(int i = 0; i < s.size(); i++) {
    if(b) {
      if(s[i] == '0') {
        cnt++;
      } else {
        if(cnt > 0) v.push_back(cnt);
        cnt = 1;
        b = false;
      }
    } else {
      if(s[i] == '1') {
        cnt++;
      } else {
        if(cnt > 0) v.push_back(cnt);
        cnt = 1;
        b = true;
      }
    }
  }
  if(cnt > 0) v.push_back(cnt);
  if(v.size() == 1) {
    cout << s.size() << endl;
    return 0;
  }
  if(v.size() == 2) {
    cout << max(v[0], v[1]) << endl;
    return 0;
  }
  int l = 0, r = v.size() - 1;
  while(r - l > 1) {
    if(v[r] < v[l]) {
      v[r - 1] += v[r];
      r--;
    } else {
      v[l + 1] += v[l];
      l++;
    }
  }
  cout << max(v[l], v[r]) << endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int n,k,ans=0;
vector<int> in;
vector<vector<int>> tree;

int dfs(int x){
  int t=INF;
  rep(i,tree[x].size()){
    t=min(t,dfs(tree[x][i]));
  }
  if(t==INF)t=0;
  t++;
  if(t<=k&&in[x]!=0)ans++;
  return t;
}

signed main(){
    cin>>n>>k;
    in=vector<int>(n);
    tree=vector<vector<int>>(n);
    rep(i,n)cin>>in[i];
    rep(i,n){
      if(in[i]!=0)tree[in[i]-1].pb(i);
    }
    rep(i,n){
        if(in[i]==0){
          ans++;
          dfs(i);
        }
    }
    cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 13640
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: String,
    }

    let chars = n.chars();
    let mut sum = 0u64;
    for item in chars {
        let item = item as u64 - 48;
        sum += item;
    }

    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+7;
ll arr[N];
map<ll ,ll >mp;
int main(){
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>arr[i];
		mp[arr[i]+i]++;
	}
	ll sum=0;
	for(ll i=n;i>=1;i--){
		sum+=mp[i-arr[i]];
		mp[i+arr[i]]--;
	}
	cout<<sum<<endl;
	
	return 0;
}

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

void printlcs(int n, int m,string a,int arr[][1001]){
    int i=0,j=0;
    string ans;
    while(i <n && j <m){
        if(arr[i][j] == 1){
           ans  += a[i];
           i++;
           j++;
        }
        else{ 
        if(arr[i][j] == 0)
         j++;
        else
         i++; 
     }
    }
     ans += '\0';
    cout << ans;
     
}
void lcs(string a , string b){
 int a_len = a.length(); 
 int b_len = b.length();
 int dp[a_len+1][b_len+1] = {0};
 int arr[a_len][1001];

    for(int i=0; i<=a_len; i++){
        for(int j=0; j<=b_len; j++){
            
                dp[i][j] = 0;
        }
    }
    for(int i=1; i<=a_len;i++ ){ 
        for(int j=1; j<=b_len;j++){
            if(a[i-1] == b[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            }
     
        }
    }
  int len = dp[a_len][b_len];
  char ans[len+ 1];
  ans[len] = '\0';
  int i = a_len, j = b_len;
  while(i>0 && j>0){
     if(a[i-1] == b[j-1]){
         ans[len-1] = a[i-1];
         i--;
         j--;
         len--;
     }
     else if(dp[i-1][j] > dp[i][j-1]){
         i--;
     }
     else
       j--;

  }
   cout << ans;
}

int main() {
    string a,b;
    cin >> a >> b;
    lcs(a,b);
    return 0;
}


Measured memory_bytes: 35456
import numpy as np
n,m=map(int,input().split())
L=[list(map(int,input().split())) for i in range(m)]
list = np.asarray(L)

MAX=np.max(list,axis=0)
MIN=np.min(list,axis=0)

ans = MIN[1]-MAX[0]+1
if ans>0:
  print(MIN[1]-MAX[0]+1)
else:
  print(0)


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


namespace _DSU {
	constexpr int BUF = 212345 * 2;
	int ptr = 0;
	int mem[BUF];
	int* get(int size) {
		ptr += size;
		return mem + ptr - size;
	}
	void reset() {
		ptr = 0;
	}
}
constexpr int N = 112345;
LL A[N];
LL B[N];
int C[N];
class UF {
private:
	int *par, *rank;
public:
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	UF(int n) :par(_DSU::get(n + 10)), rank(_DSU::get(n + 10)) {
		for (int i = 0; i<n; i++) {
			par[i] = i, rank[i] = 0;
		}
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		if (rank[x] < rank[y])swap(x, y);
		par[y] = x;
		if (rank[x] == rank[y])rank[x]++;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

pair<LL, int> w[N];
typedef vector<int> V;
typedef vector<V> VV;
int main() {
	int n, m;
	cin >> n >> m;
	for (int i : range(n)) {
		cin >> A[i] >> B[i];
		if (A[i] < B[i])A[i] = B[i];
		A[i] -= B[i];
		w[i] = { A[i] ,i };
	}
	sort(w, w + n);
	VV g(n);
	for (int i : range(m)) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	UF uf(n);
	for (int i : range(n)) {
		int v = w[i].second;
		C[v] = 1;
		LL nA = A[v];
		LL nB = B[v];
		for (int u : g[v]) {
			if (C[u] == 0)continue;
			u = uf.find(u);
			if (uf.same(v, u))continue;
			nB += B[u];
			LL d = max(A[v]-(A[u] + B[u]), 0ll);
			chmin(nA, A[u] + d);
			uf.unite(v, u);
		}
		v = uf.find(v);
		A[v] = nA;
		B[v] = nB;
	}
	{
		int u = uf.find(0);
		cout << A[u]+B[u] << endl;
	}

	return 0;
}


Measured memory_bytes: 10492
S = input()

A = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if S == A[0]:
    ans = 7
elif S == A[1]:
    ans = 6
elif S == A[2]:
    ans = 5
elif S == A[3]:
    ans = 4
elif S == A[4]:
    ans = 3
elif S == A[5]:
    ans = 2
elif S == A[6]:
    ans = 1

print(ans)

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

stack<int> S1;
stack< pair<int,int> > S2;

int main(){
	char str[20000]; cin>>str;
	int i=0,sum=0;

	while(str[i]!='\0'){

		if(str[i]=='\\')
			S1.push(++i);
		else if(str[i]=='/'){
			++i;

			if(!S1.empty()){
				sum += i-S1.top();

				if(!S2.empty()){
					int temp = 0;
					while( !S2.empty() && S1.top()<S2.top().first ){
						temp += S2.top().second;
						S2.pop();
					}
					S2.push( make_pair(S1.top(),i-S1.top()+temp) );
				}else
					S2.push( make_pair(S1.top(),i-S1.top()) );

				S1.pop();
			}

		}else if(str[i]=='_')
			++i;

	}

	while(!S1.empty()) S1.pop();

	cout<<sum<<endl;
	if(S2.size()!=0){
		cout<<S2.size()<<" ";

		int size = S2.size();
		for(int i=0;i<size;i++){
			S1.push(S2.top().second);
			S2.pop();
		}

		for(int i=0;i<size;i++){
			if(i) cout<<" ";
			cout<<S1.top();
			S1.pop();
		}
		cout<<endl;

	}else cout<<S2.size()<<endl;

	cin.sync(); cin.get();
}

Measured memory_bytes: 3244
#include<iostream>

#include<cctype>
using namespace std;

int main()
{
	string ch;
	int num[26]={},i;
	int test;

while(cin>>ch){
	for(i=0;i<ch.size();i++)
		if( isupper(ch[i])) ch[i] =  tolower(ch[i]);
 
	for(i=0;i<ch.size();i++){
		test = ch[i] - 'a';
		num[test]++;

		}

}

cout <<"a : " <<num[0] <<"\n";
cout <<"b : " <<num[1] <<"\n";
cout <<"c : " <<num[2] <<"\n";
cout <<"d : " <<num[3] <<"\n";
cout <<"e : " <<num[4] <<"\n";
cout <<"f : " <<num[5] <<"\n";
cout <<"g : " <<num[6] <<"\n";
cout <<"h : " <<num[7] <<"\n";
cout <<"i : " <<num[8] <<"\n";
cout <<"j : " <<num[9] <<"\n";
cout <<"k : " <<num[10] <<"\n";
cout <<"l : " <<num[11] <<"\n";
cout <<"m : " <<num[12] <<"\n";
cout <<"n : " <<num[13] <<"\n";
cout <<"o : " <<num[14] <<"\n";
cout <<"p : " <<num[15] <<"\n";
cout <<"q : " <<num[16] <<"\n";
cout <<"r : " <<num[17] <<"\n";
cout <<"s : " <<num[18] <<"\n";
cout <<"t : " <<num[19] <<"\n";
cout <<"u : " <<num[20] <<"\n";
cout <<"v : " <<num[21] <<"\n";
cout <<"w : " <<num[22] <<"\n";
cout <<"x : " <<num[23] <<"\n";
cout <<"y : " <<num[24] <<"\n";
cout <<"z : " <<num[25] <<"\n";
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n;
  cin >> n;
  REP(i,50010){
    I j=i * 1.08;
    if (j == n){
       cout << i << endl;
       return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}



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

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		if (BR.readLine().equals("ABC")) System.out.println("ARC");
		else System.out.println("ABC");
	}
}


Measured memory_bytes: 25380
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"unicode/utf8"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var strs []string
	var a, b, sum int64
	var digits int
	for scanner.Scan() {
		strs = strings.Split(scanner.Text(), " ")
		a, _ = strconv.ParseInt(strs[0], 10, 64)
		b, _ = strconv.ParseInt(strs[1], 10, 64)

		sum = a + b
		// goでlen(string)はbyte数が返る
		digits = utf8.RuneCountInString(strconv.FormatInt(sum, 10))

		fmt.Printf("%d\n", digits)
	}
}



Measured memory_bytes: 1080
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define N 200012
typedef long long ll;
struct edge{int to,nxxt;}e[N];
int head[N],cnt=1,n,du[N],va[N],dp[N],ans;
bool ban[N];
queue<int>q;
char ch[N];
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void dfs(int te,int la)
{
	int fir=-1,sec=-1;
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la||ban[j])continue;
		dfs(j,te);if(dp[j]>fir)sec=fir,fir=dp[j];
		else if(dp[j]>sec)sec=dp[j];
	}
	if(fir>=0&&sec>=0)ans=max(ans,va[te]+fir+sec);
	else if(fir>=0)ans=max(ans,va[te]+fir);
	ans=max(ans,va[te]);
	if(fir>=0)dp[te]=va[te]+fir;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);du[x]++,du[y]++;
	}
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)if(du[i]==1&&ch[i]=='B')q.push(i),ban[i]=1;
	while(!q.empty())
	{
		int a1=q.front();q.pop();
		for(int i=head[a1];i;i=e[i].nxxt)
		{
			int t1=e[i].to;du[t1]--;if(ch[t1]=='W')continue;
			if(du[t1]==1)ban[t1]=1,q.push(t1);
		}
	}
	//for(int i=1;i<=n;i++)printf("%d ",ban[i]);puts("");
	//for(int i=1;i<=n;i++)printf("%d ",du[i]);puts("");
	int sum=0;
	for(int i=1;i<=n;i++)
	{if(ban[i])continue;
		sum+=du[i];
		if(ch[i]=='B')sum+=du[i]&1;
		else sum+=(du[i]%2==0);
		if(ch[i]=='B'&&(du[i]&1))va[i]=2;
		else if(ch[i]=='W'&&(du[i]%2==0))va[i]=2;
	}
	//for(int i=1;i<=n;i++)printf("%d ",va[i]);puts("");
	dfs(1,1);
	//printf("%d\n",sum);
	sum-=ans;if(sum<0)sum+=2;
	printf("%d\n",sum);
}
/*
5
3 1
2 5
5 1
3 4
WWBWB

6
3 1
4 5
2 6
6 1
3 4
WWBWBB
*/

Measured memory_bytes: 11264
n,m=gets.split.map(&:to_i)
hs=gets.split.map(&:to_i)
check=[true]*n
abs=m.times.map{gets.split.map(&:to_i)}.sort
abs.each do |an,bn|
  if hs[an-1]<hs[bn-1]
    check[an-1]=false
  elsif hs[bn-1]<hs[an-1]
    check[bn-1]=false
  else
    check[an-1]=false
    check[bn-1]=false
  end
end
puts check.count(true)


Measured memory_bytes: 24696
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()
ind = 0
p = inf
for i,num in enumerate(a):
    if num == 1:
        ind = i
for i in range(k):
    l = ind-i
    r = l+k-1
    ans = 1
    if l > 0:
        ans += (l+k-2)//(k-1)
    if r < n-1:
        ans += (n-r-1+k-2)//(k-1)
    p = min(ans,p)
print(p)

Measured memory_bytes: 89232
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <unordered_set>
#include <vector>

#ifdef GONGKUNPENG
#include <cassert>
#define _GG 1
#else
#define _GG 0
#endif

#define uint unsigned
#define ll long long
#define ull unsigned long long
#define vector std::vector
#define ms(a, v) memset(a, v, sizeof(a))
#define ufor(i, n) for (int i = 1; i < n; ++i)
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)
using std::max;
using std::min;
using std::sort;
using std::swap;

#define _GIO 1

#if _GIO
struct _gio {
#define BFSZ 1 << 18
#define blank(x) (x == ' ' || x == '\t' || x == '\n' || x == '\r')

  char rcha;
  bool rneg;
#if _GG
#else
  char ruf[BFSZ], wuf[BFSZ], *r1, *r2, *w1;
#endif

  _gio() {
    rcha = ' ';
#if _GG
#else
    r1 = r2 = ruf, w1 = wuf;
#endif
  }

  ~_gio() {
#if _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout);
#endif
  }

  inline void flush() {
#ifdef _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout), w1 = wuf;
#endif
  }

  inline int readc() {
#if _GG
    return getchar();
#else
    return (r1 == r2 && (r2 = (r1 = ruf) + fread(ruf, 1, BFSZ, stdin), r1 == r2)
                ? -1
                : *r1++);
#endif
  }

  template <typename T, typename... Args>
  void read(T &x, Args &... args) {
    read(x), read(args...);
  }

  inline void read() {}

  inline void read(char *s) {
    while (blank(rcha)) rcha = readc();
    while (!blank(rcha) && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  inline void readl(char *s) {
    while (blank(rcha)) rcha = readc();
    while (rcha != '\n' && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  template <typename T>
  inline void read(T &x) {
    x = rcha = rneg = 0;
    while (!isdigit(rcha) && rcha != '-') rcha = readc();
    rcha == '-' && (rneg = true, rcha = readc());
    while (isdigit(rcha)) x = (x << 3) + (x << 1) - 48 + rcha, rcha = readc();
    rneg && (x = -x);
  }

  inline void writec(char c) {
#if _GG
    putchar(c);
#else
    (w1 - wuf == BFSZ) && (fwrite(wuf, 1, BFSZ, stdout), w1 = wuf);
    *w1++ = c;
#endif
  }

  template <typename T, typename... Args>
  void write(const T &x, const Args &... args) {
    write(x), write(args...);
  }

  template <typename T, typename... Args>
  void writel(const T &x, const Args &... args) {
    write(x), write(args...);
    writec('\n');
  }

  inline void write() {}

  inline void write(const char &c) { writec(c); }

  template <typename T>
  void write(T x) {
    if (x < 0) {
      writec('-');
      write(-(long long)(x));
      return;
    }
    if (x > 9) write(x / 10);
    writec(x % 10 ^ 48);
  }

  inline void write(const char *s) {
    while (*s) writec(*s++);
  }
#undef BFSZ
} io;
#endif

const int INF = 0x3f3f3f3f;
const int MAXN =
#ifdef GONGKUNPENG
    15
#else
    1000005
#endif
    ;

int main() {
  int n;
  char buf[16];
  io.read(n);
  std::unordered_set<std::string> s;
  while (n--) {
    io.read(buf);
    s.insert(buf);
  }
  io.writel(s.size());
  return 0;
}

Measured memory_bytes: 17400
fn main() {
    let mut l = read::<usize>();
    let cands = (0..20).map(|x| (1 << x) - 1).collect::<Vec<_>>();

    let mut members = vec![];
    for (i, &cand) in cands.iter().enumerate().rev() {
        if cand + 1 <= l {
            l -= cand + 1;
            members.push(i);
        }
    }

    let mut edges = vec![];
    let mut added = 0;
    for i in 1..members[0] + 1 {
        edges.push((i - 1, i, 0));
        edges.push((i - 1, i, 1 << (i - 1)));
        added += 1 << (i - 1);
    }

    for &mem in members.iter().skip(1) {
        edges.push((mem, members[0], added + 1));
        added += cands[mem] + 1;
    }

    println!("{} {}", members[0] + 1, edges.len());
    for (l, r, c) in edges {
        println!("{} {} {}", l + 1, r + 1, c);
    }
}

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()
}


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

int main(){
    int n;
    long long l;
    cin >> n;
    
    if(n==0){
        l = 2;
    }else if(n==1){
        l = 1;
    }else{
        long long x = 2, y=1;
        for(int i=0;i<n-1;i++){
        
            l = x + y;
            x = y;
            y = l;
        }
    }
    
    cout << l << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mkp(x, y) make_pair(x, y)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << max(a+b,max(a-b, a*b));
}

Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
bridges = []
m.times{bridges << gets.chomp.split.map(&:to_i)}

ties = 0
max = n * (n - 1) / 2
result = [max]
parent = []
1.upto(n){|i| parent[i] = i}
group = Hash.new(1)

(m - 1).downto(1){|i|
    a, b = bridges[i]
    pa = a
    pa = parent[pa] while pa != parent[pa]
    pb = b
    pb = parent[pb] while pb != parent[pb]
    if pa != pb
        y, x = [pa, pb].minmax
        parent[a] = parent[b] = parent[x] = y
        ties += group[x] * group[y]
        group[y] += group[x]
        group.delete(x)
    end
    result << max - ties
}
puts result.reverse

Measured memory_bytes: 14536
from heapq import heappop, heappush, heapify

n, m = map(int, input().split())
q = []
for x in input().split():
    heappush(q, -int(x))

for i in range(m):
    item = (-heappop(q))//2
    heappush(q, -item)

print(-sum(q))


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

int main(){
    int a,n; cin >> a >> n;
    for(int i=0;i<n;i++){
        int b; cin >> b;
        a-=b;
    }
    if(a<=0) cout << "Yes" << endl; 
    else cout << "No" << endl; 
    return 0;
}

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

using namespace std;

const int N = 100'001;

using ll = long long;

ll dp[N];

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

    fill(dp + 1, dp + N, LLONG_MAX);

    int n, cap;
    cin >> n >> cap;

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        ll w;
        int v;
        cin >> w >> v;
        for (int j = N - 1; j >= v; --j) {
            if (dp[j - v] == LLONG_MAX) continue;
            dp[j] = min(dp[j], dp[j - v] + w);
            if (dp[j] <= cap) ans = max(ans, j);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
  char s[10001];
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  for(int i = 0; i < strlen(s); ++i){
    s[i] = s[i] + n;
    if(s[i] > 'Z') s[i] = s[i] - 26;
  }
  puts(s);
  return 0;
}

Measured memory_bytes: 256
#include"iostream"
#include"algorithm"
using namespace std;
int main()
{
	long long int n, flag = 0, cnt = 100;
	while (cin >> n) {
		for(;;) {
			cnt += cnt / 100;
			flag++;
			if ( cnt >= n ) {
				break;
			}
		}
		cout << flag << endl;
	}
	return 0;
} 

Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int main()
{
	char s[99],c[99];
	int len=0,i,x=0,flg=0,f=0;
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<=len;i++){
		if(s[i]!=s[len-1-i]){
			flg=1;
		}
	}
	if(flg==1){
		printf("No\n");
	}
	else{
		x=len/2;
		for(i=0;i<x;i++){
			if(s[i]!=s[i+1+x]){
				f=1;
			}
		}
		if(f==0){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}	
	return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <iomanip>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;

int main(void) {
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	if (W / 2 == x && H / 2 == y) {
		
		cout << setprecision(10) << (W*H) / 2 << endl;
		cout << 1 << endl;
	}
	else {
		
		cout << setprecision(10) << (W*H) / 2 << endl;
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <numeric>
/*#include <stdlib.h>
#include <string>
#include <vector>
#include <iostream>
#include <forward_list>*/
using namespace std;

#define SCAN_INT(i) scanf("%lld", i)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define PRINT_INT(i) printf("%lld\n", i)
#define PRINT_TWO_INT(i, j) printf("%d %d\n", i, j)
#define PRINT_THREE_INT(i, j, k) printf("%d %d %d\n", i, j, k)

int main()
{
    long long int N, A, B;
    scanf("%lld %lld %lld", &N, &A, &B);

    long long int block = N / (A + B);
    long long int rem = N - (A + B) * block;

    long long int result = block * A + min(rem, A);
    printf("%lld", result);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <map>

using namespace std;
using ll = long long;

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

	vector <vector <int> > v(n);
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		a-- ; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	vector <int> cost(n);
	ll cnt = 0;
	int max = 0;
	for (int i = 0; i < n; ++i)
	{
		int c;
		cin >> c;
		cnt += c;
		if (c > max)
			max = c;
		cost[i] = c;
	}

	sort(cost.begin(), cost.end(), greater<int>());

	vector<int> edge(n, 0);
	stack<int> s;

	int idx = 0;
	s.push(0);

	while (!s.empty())
	{
		int oya = s.top();
		s.pop();
		edge[oya] = cost[idx];
		idx++;

		for (int child : v[oya])
		{
			if (edge[child] == 0)
			{
				s.push(child);
			}
		}
	}


	cout << cnt - max << endl;
	for (int i : edge)
		cout << i << " ";

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int matrix = H * W;
    int colum = h * W;
    int line = w * H;

    cout << (matrix - colum - line) + (h*w);
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
v = list(map(int, input().split()))
v.sort()
v.reverse()

ans = 0.0
for i in range(a):
	ans += v[i]

ans /= a
# print("{0:.20f}".format(ans))
print(ans)

cnt = 0
cnt2 = 0
for i in range(n):
	if v[a-1] == v[i]:
		cnt += 1
		if i >= a-1:
			cnt2 += 1

comb = [[0 for i in range(55)] for j in range(55)]
for i in range(55):
	comb[i][i] = 1
	comb[i][0] = 1
	for j in range(1,i):
		comb[i][j] = comb[i-1][j-1] + comb[i-1][j]

ans2 = 0

if v[0] == v[a-1]:
	for i in range(a-1, b):
		if v[i] != v[0]:
			break
		num = i+1
		ans2 += comb[cnt][num]
else:
	num = cnt-cnt2+1
	ans2 += comb[cnt][num]
print(ans2)


Measured memory_bytes: 39408
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	k = I()
	s = S()

	if len(s) <= k:
		print(s)
	else:
		print(s[:k]+'...')

if __name__ == '__main__':
	solve()


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
string S, T;
signed main(){
  cin >> N >> S >> T;
  vi a;
  int i = 0;
  while (i<N){
    if(S[i] == S[i+1]){
      a.push_back(2);
      i += 2;
    }else{
      a.push_back(1);
      i++;
    }
  }
  
  int ans = 1;
  rep(i,a.size()){
    if(i==0 && a[0] == 1) ans *= 3; 
    else if(i==0 && a[0] == 2) ans *= 6;
    else if(a[i-1] == 1 && a[i] == 1){ ans *= 2; ans %= mod;}
    else if(a[i-1] == 1 && a[i] == 2){ ans *= 2; ans %= mod;}
    else if(a[i-1] == 2 && a[i] == 1){ ans *= 1; ans %= mod;}
    else if(a[i-1] == 2 && a[i] == 2){ ans *= 3; ans %= mod;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  int ans = 1;
  rep(i, 10)
  {
    if (ans == N)
    {
      cout << ans << endl;
      return 0;
    }
    else if (ans >= N)
    {
      cout << ans / 2 << endl;
      return 0;
    }
    ans *= 2;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll A, B, C, X, Y;

int main()
{
  cin >> A >> B >> C >> X >> Y;
  if (A + B <= 2 * C) {
    cout << A * X + B * Y << endl;
    return 0;
  }
  ll Z = 2 * min(X, Y);
  X -= Z/2;
  Y -= Z/2;
  if (A > 2 * C) {
    Z += 2 * X;
    X = 0;
  }
  if (B > 2 * C) {
    Z += 2 * Y;
    Y = 0;
  }
  cout << A * X + B * Y + C * Z << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl
use POSIX qw(floor ceil);

my ($n,$k) = map {$_ - 0} split(/\s+/o,<STDIN>);

my $tot = 0;
for(my $a=1;$a<=$n;$a++){
  my $ma = $a % $k;
  my $mb = ( $k - $ma ) % $k;
  my $mc = $mb;
  next unless ($mb + $mb) % $k == 0;
  $tot += &mcnt($mb) * &mcnt($mc);
  #print "$a $ma $mb(" . &mcnt($mb) . ") $mc(" . &mcnt(0) . ")\n";
}

print "$tot\n";
exit(0);

sub mcnt {
  my $m = shift;
  return 0 if $m > $n;
  return int($n/$k) if $m==0;
  return 1+int(( $n - $m ) / $k);
}


Measured memory_bytes: 1792
#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

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;

#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 REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

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


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;


#define MAX_N 100000
i64 N;
i64 H[MAX_N];

void solve() {
  i64 max_cnt = 0;

  i64 cnt = 0;
  REP(i, N - 1) {
    if (H[i] >= H[i + 1]) {
      cnt++;
      chmax(max_cnt, cnt);
    } else {
      cnt = 0;
    }
  }

  cout << max_cnt << endl;
}

int main() {
  cin >> N;
  REP(i, N) cin >> H[i];

  solve();

  return 0;
}

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

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	int start = s[0] - '0';
	deque<int> set;
	int prev = start;
	int count = 1;
	for (int i = 1; i < n; i++) {
		if (prev != s[i] - '0') {
			set.push_back(count);
			count = 1;
		}
		else {
			count++;
		}
		prev= s[i] - '0';
	}
	set.push_back(count);
	if (set.size() <= 2 * k) {
		cout << n << endl;
	}
	else {
		if (start == 0) {
			set.push_front(0);
		}
		if (set.back()==0) {
			set.push_front(0);
		}
		int maxi = 0;
		for (int i = 0; i < 2 * k + 1; i++) {
			maxi += set[i];
		}
		int prev = maxi;
		for (int i = 0; i < set.size() - 2 * k - 2; i += 2) {
			prev = prev - set[i] - set[i + 1] + set[2 * k + 1 + i] + set[2 * k + i + 2];
			int temp = max(maxi, prev);
			maxi = temp;
		}
		if (set.size() % 2 == 0) {
			maxi = max(maxi, prev - set[set.size() - 2 * k - 2] - set[set.size() - 2 * k - 1] + set[set.size() - 1]);
		}
		cout << maxi << endl;

	}
	return 0;
}

Measured memory_bytes: 4128
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    vector<LL> march(5, 0);
    int n;
    LL ans=0;
    string s;

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> s;
        if(s[0]=='M'){
            march[0]++;
        }else if(s[0]=='A'){
            march[1]++;
        }else if(s[0]=='R'){
            march[2]++;
        }else if(s[0]=='C'){
            march[3]++;
        }else if(s[0]=='H'){
            march[4]++;
        }
    }

    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans+=march[i]*march[j]*march[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n, Y;
    cin >> n >> Y;
    REP(x, n + 1){
        REP(y, n + 1){
            ll z = n - x - y;
            ll m = 10000 * x + 5000 * y + 1000 * z;
            if(z >= 0 && m == Y){
                cout << x << ' ' << y << ' ' << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


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

signed main()
{
  cout << fixed << setprecision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;

  vector<long double> p(n+1, 0);
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;

    p[i] = ((x + 1) / 2.0) + p[i-1];
  }

  long double ans = 0;

  for (int i = 0; i < n-k+1; ++i) ans = max(ans, p[i+k] - p[i]);

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 6324
use proconio::marker::Usize1;
use fixedbitset::FixedBitSet;

fn main() {
    proconio::input! {
        n:usize,
        k:i64,
        xs:[Usize1;n],
    }

    // ループを探す: 0->a->b->c->d->b->c->d
    let mut paths   = vec![0];
    let mut bset = FixedBitSet::with_capacity(n); // loop確認検索用
    let mut curr = 0usize;
    bset.insert(0);
    let v0 = loop {
        let next = xs[curr];
        if bset[next] { // ループ判定
            break next;
        }
        bset.insert(next);
        paths.push(next);
        curr = next;
    };
    let i0 = paths.iter().position(|&v| v == v0).unwrap();
    let cycle = (paths.len() - i0) as i64;
    if k <= (i0 as i64) {
        println!("{}", paths[k as usize] + 1); 
    } else {
        println!("{}", paths[i0 + ((k-(i0 as i64)) % cycle) as usize] + 1);
    }
}

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

const int inf = (int)((1U<<31)-1);

class Segment_Tree{
private:
  int N;
  vector<int> nlist;
public:
  Segment_Tree(int n){
    N = 1;
    while(N < n) N *= 2;
    nlist.resize(2*N-1);
    for(int i=0;i<2*N-1;++i){
      nlist[i] = inf;
    }
  }
  
  void update(int k,int x){
    k += N - 1;
    nlist[k] = x;
    while(k > 0){
      k = (k-1)/2;
      nlist[k] = min(nlist[k*2+1],nlist[k*2+2]);
    }
  }
  
  int query(int a,int b){
    return query(a,b,0,0,N);
  }
  
  int query(int a,int b,int x,int l,int r){
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return nlist[x];
    int m = (l+r)/2;
    return min(query(a,b,2*x+1,l,m),query(a,b,2*x+2,m,r));    
  }
};

int main(){
  int n;
  int q;
  cin>>n>>q;
  Segment_Tree st(n);
  for(int i=0;i<q;++i){
    int com,x,y;
    cin>>com>>x>>y;
    if(com == 0){
      st.update(x,y);
    }
    if(com == 1){
      cout<<st.query(x,y+1)<<endl;
    }
  }
  return 0;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int p, q, r;
    cin >> p >> q >> r;

    cout << min(min(p + q, q + r), p + r) << endl;

    return 0;
%>

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 5005
#define int long long
#define maxm 250 
int n, m, dis[maxn], val[maxn][maxm];
int Ans, ans[maxn][maxn], Q[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

struct node
{
	int num, id;
	node(int _id = 0, int _num = 0) { num = _num, id = _id; }
}S[maxm][maxn];

signed main()
{
	n = read(), m = read();
	for(int i = 2; i <= n; i ++) dis[i] = read() + dis[i - 1];
	for(int i = 1; i <= n; i ++) 
		for(int j = 1; j <= m; j ++) val[i][j] = read();
	for(int i = 1; i <= m; i ++) S[i][0].id = n + 1;
	for(int i = n; i >= 1; i --)
	{
		for(int j = 1; j <= m; j ++)
		{
			int top = Q[j];
			ans[i][i] += val[i][j]; ans[i][i + 1] -= val[i][j];
			while(top && S[j][top].num <= val[i][j]) 
			{
				int l = S[j][top].id, r = S[j][top - 1].id;
				int t = val[i][j] - S[j][top].num; 
				ans[i][l] += t, ans[i][r] -= t; 
				top --;
			}
			S[j][++ top] = node(i, val[i][j]);
			Q[j] = top;
		}
	}
	for(int i = n; i; i --)
	{
		for(int j = i; j <= n; j ++)
			ans[i][j] += ans[i][j - 1];
		for(int j = i; j <= n; j ++) ans[i][j] += ans[i + 1][j];
		for(int j = i; j <= n; j ++) 
			Ans = max(Ans, ans[i][j] - dis[j] + dis[i]); 
	}
/*	for(int i = 1; i <= n; i ++)
		for(int j = i; j <= n; j ++)
			cout << "* " << i << " " << j << " " << ans[i][j] << endl;*/
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 225408
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
using var = long long;
#define rep(i,n) for(var i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<var> a(n);rep(i,n){cin>>a[i];}
#define in(a) var a;cin>>a;
#define out(a) cout<<a;

int main()
{
	in(k);
	in(x);

	for (var i = x - k + 1; i < x; i++) {
		out(i);
		out(" ");
	}
	out(x);
	for (var i = x + 1; i < x+k; i++) {
		out(" ");
		out(i);
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int h, m, s;
  scanf("%d", &s);
  h = s / 3600;
  m = (s % 3600) / 60 ;
  s = (s % 3600) % 60 ;

  printf("%d:%d:%d\n", h,m,s);

  return 0;
}

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

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

	vector<string> s(N);

	for (int i = 0; i < N; i++) {
		cin >> s.at(i);
	}

	map<string, int> cnt;
	for (string x : s) {
		if (cnt.count(x)) {
			cnt.at(x)++;
		}
		else {
			cnt[x] = 1;
		}
	}
	int max = 0;
	string ans;

	for (int i = 0; i < N; i++) {
		if (max < cnt.at(s.at(i))) {
			max = cnt[s.at(i)];
		}
	}

	for (auto x : cnt) {
		if (max == x.second) {
			cout << x.first << endl;
		}
	}

	/*for (int i = 0; i < N; i++) {
		if (max == cnt.at(s.at(i))) {
			cout <<  << endl;
		}
	}
	*/

	return 0;
}

Measured memory_bytes: 26752