akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#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))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

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

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

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;
#pragma endregion

signed solve()
{
	auto A = IN<string>();
	auto B = IN<string>();
	int min_num = atoi(A.c_str());
	int max_num = atoi(B.c_str());
	int a = atoi(A.substr(0, 3).c_str());
	int b = atoi(B.substr(0, 3).c_str());
	int ans = 0;
	for (int i = a; i <= b; ++i)
	{
		string str = to_string(i);
		int num = atoi((str + str.substr(1, 1) + str.substr(0, 1)).c_str());
		if (min_num <= num && num <= max_num)
			ans++;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int d;
    cin >> d;
    if (d == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    } else if (d == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if (d == 24) {
        cout << "Christmas Eve" << endl;
    } else if (d == 25) {
        cout << "Christmas" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
H, W = map(int, raw_input().split())
S = [raw_input() for i in range(H)]
C = [[0] * W for i in range(H)]
for i in range(H):
    for j in range(W):
        for di in range(-1, 2):
            if i + di < 0 or H <= i + di:
                continue
            for dj in range(-1, 2):
                if j + dj < 0 or W <= j + dj:
                    continue
                C[i][j] += 1 if S[i + di][j + dj] == "#" else 0
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            sys.stdout.write("#")
        else:
            sys.stdout.write(str(C[i][j]))
    print ""




Measured memory_bytes: 2692
program EDPCC
    implicit none
    integer(8)::N,i,j,k
    integer(8),dimension(3,100001)::H,dp
    read(5,*)N

    do i=1,N
        read(5,*)(H(j,i),j=1,3)
    end do

    dp=0

    do i=1,N+1
        do j=1,3
            do k=1,3
                if(j/=k)then
                    if(dp(j,i)+H(k,i)>dp(k,i+1))then
                        dp(k,i+1)=dp(j,i)+H(k,i)
                    end if
                end if
            end do
        end do
    end do

    print'(i0)',max(dp(1,N+1),max(dp(2,N+1),dp(3,N+1)))
end program EDPCC

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
#define M 1000000007
int main()
{
	long long a[200000], i,n, j, s=0, su=0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		s=(s+a[i])%M;
	}
	for (i = 0; i < n; i++)
	{
		s -= a[i];
		s+=M;
		s%=M;
		su += (a[i] * s)%M;
		su %= M;
	}
	cout << su;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[200000], c[200000];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[i] = a[i];
    }

    sort(c, c+n);

    int amax = c[n-1], amax2 = c[n-2];

    for (int i = 0; i < n; i++) {
        if (a[i] == amax) {
            cout << amax2 << endl;
        } else {
            cout << amax << endl;
        }
    }
    return 0;
}

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

int main()
{
    /*
    unsigned long long A;
    long double B;
    cin >> A >> B;

    unsigned long long C = B * 100;
    unsigned long long ans = A * C / 100;
    */
    long double A;
    long double B;
    cin >> A >> B;
    unsigned long long ans = A * B;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
from operator import mul
from functools import reduce
N, *A = map(int, open(0).read().split())

while len(A) > 1:
  n = len(A)
  if n & 1:
    A.append(1)
    n += 1
  L, R = A[:n//2], A[n//2:]
  A = [x * y for x, y in zip(L, R)]
x = A[0]
if x > 10 ** 18:
  x = -1
print(x)


Measured memory_bytes: 22152
#include<stdio.h>
int main(){
  int a[9],b[9],c,d,n,v,j,i,o,tmp,pl,A,B;
  char x[9];
  scanf("%d",&n);
  for(v=0;v<n;v++){
    scanf("%s",x);
    for(o=0;o<8;o++){
      a[o]=x[o]-48;
      b[o]=x[o]-48;
    }
    for(j=0;j<7;j++){
      for(i=7;i>j;i--){
	if(a[i]>a[i-1]){
	  tmp=a[i];
	  a[i]=a[i-1];
	  a[i-1]=tmp;
	}
	if(b[i]<b[i-1]){
	  tmp=b[i];
	  b[i]=b[i-1];
	  b[i-1]=tmp;
	}
      }
    }
    for(d=7,pl=1,A=0,B=0;d>=0;d--,pl=pl*10){
      A=A+a[d]*pl;
      B=B+b[d]*pl;
    }
    printf("%d\n",A-B);
  }
  return (0);
}

Measured memory_bytes: 596
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
  return i + 1;
}

int main(){
  int i, q;

  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);

  q = partition(0, n - 1);

  for(i = 0; i < n; i++){
    if(i) printf(" ");
    if(i == q) printf("[");
    printf("%d",A[i]);
    if(i == q) printf("]");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 992
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n = sc.nextInt()
    val ab = Vector.fill(n) {
      val a, b = sc.nextInt()
      (a, b)
    }

    val ans = ab
      .sortBy(_._2)
      .scanLeft((0, 0)) {
        case ((accA, accB), (a, b)) => (accA + a, b)
      }
      .forall { case (a, b) => a <= b }

    val ansStr = if (ans) "Yes" else "No"
    println(ansStr)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
}


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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = 3;
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		if(a[0] + a[1] == a[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

void lcs (string s,string t)
{
    int m=s.length();
    int n=t.length();
    int dp[m+1][n+1];
    for(int i=0;i<=m;i++)
        dp[i][0]=0;
    for(int j=0;j<=n;j++)
        dp[0][j]=0;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
           int q=0;
            if(s[i-1]==t[j-1]){
                q=1+dp[i-1][j-1];
            }
            else
                q=max(dp[i-1][j],dp[i][j-1]);
            dp[i][j]=q;
        }
    }
    int i=m,j=n,index=dp[m][n];
    char temp[index+1];
    temp[index]='\0';
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1]){
            temp[index-1]=s[i-1];
            i--;
            j--;
            index--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;

    }
    cout<<temp;
    //return dp[m][n];
}


int main()
{
   string s,t;
   cin>>s>>t;
   lcs(s,t);
   //cout<<ans;
   return 0;
}


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

int N;
int A[101010];
LL ans[101010];
LL T[101010];
vector<int> V, id;

void update(int t){
    while (t <= N){
        T[t]++;
        t += t & -t;
    }
}

LL read(int t){
    LL ret=0;
    while (t){
        ret += T[t];
        t -= t & -t;
    }
    return ret;
}

int main(){
    scanf("%d", &N);
    V.push_back(0);
    id.push_back(0);
    for (int i=1; i<=N; i++){
        scanf("%d", &A[i]);
        if (V.back() >= A[i]){
            int k = upper_bound(V.begin(), V.end(), A[i]) - V.begin();
            if (k > 1) update(k-1);
            if (k < V.size()) ans[id[k]] += A[i] - V[k-1];
        }
        else{
            if (!V.empty()) update(V.size());
            V.push_back(A[i]);
            id.push_back(i);
        }
    }
    for (int i=1; i<(int)V.size(); i++) ans[id[i]] += (read(N) - read(i-1)) * (V[i] - V[i-1]);
    for (int i=1; i<=N; i++) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 4084
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

bool solve() {
    indef(i32, n);
    i32 cnt4 = 0, cnt2 = 0;
    times(n, i) {
        indef(i32, a);
        if ((a%4) == 0) {
            cnt4++;
        } else if ((a%2) == 0) {
            cnt2++;
        }
    }
    cnt4 += cnt2/2;
    return n/2 <= cnt4;
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    out(solve() ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main()
{
    int a, b;

    std::cin >> a >> b;
    if(a>b){
       std::cout << "a > b" << std::endl;
    }
    if(a==b){
       std::cout << "a == b" << std::endl;
    }
    if(a<b){
       std::cout << "a < b" << std::endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;

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

    pair<ll, ll> p;
    p.first = 1;
    p.second = N;
    ll dist = N-1;
    for (int i = 2; i <= sqrt(N); i++) {
        if (N % i == 0) {
            dist = min(dist, i + N/i - 2);
        }
    }
    cout << dist << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string A;
    cin >> A;

    ll len = (ll)A.size();
    ll ans = (len * (len - 1)) / 2;

    vector<ll> alpha(26, 0);
    rep(i, A.size()) {
        alpha[A[i] - 'a']++;
    }

    rep(i, 26) ans -= (alpha[i] * (alpha[i] - 1)) / 2;

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lb long double
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < int , int >
#define pq priority_queue

using namespace std;

const int N = 200005;
const int M = 1000000007;
const lb PI = acos(-1);

ll n , k;
ll a[N];
ll mark[N] , cmp[N];

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

    ll i;

    cin >> n >> k;

    for(i = 1 ; i <= n ; i++)
        cin >> a[i];

    ll c = 1 , nr = 0 , ok = 0;

    while(k)
    {
        if(mark[c] == 1)
        {
            mark[c] = 2;
            cmp[++nr] = c;
        }
        else if(mark[c] == 2)
        {
            if(ok == 0)
                k %= nr , ok = 1;

            if(k == 0)
            {
                cout << c;
                return 0;
            }

            --k;

            if(k == 0)
            {
                cout << a[c];
                return 0;
            }
        }
        else mark[c] = 1 , --k;

        c = a[c];

        if(k == 0)
        {
            cout << c;
            return 0;
        }

    }

    return 0;
}


Measured memory_bytes: 7696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
 ll dp[200000];

int po(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}

ll nck(ll n, ll k) {
	ll ans=1;
	for(int i=1; i<=k; ++i)
		ans=ans*(n-i+1)%mod*dp[i]%mod;
	return ans;
}
int main()
{
	int n,q;
	string s;
	cin>>n>>s>>q;
	//cin>>s;
	vector<set<int >> v(26);
	for(int i=0;i<n;i++)
		v[s[i]-'a'].insert(i);
	while(q--)
	{
		int t;
		cin>>t;
		if(t==1)
		{
			int x;
			char y;
			cin>>x>>y;
			v[s[x-1]-'a'].erase(x-1);
			s[x-1]=y;
			v[y-'a'].insert(x-1);
		}
		else
		{
			int x,y;
			cin>>x>>y;
			x--;y--;
			
			ll ans=0;
			for(int i=0;i<26;i++)
			{
				auto z=v[i].lower_bound(x);
				if(z!=v[i].end()&&*z<=y)
					ans++;
			}
			cout<<ans<<endl;
		}
		
	}
	
}

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

int main(){
 int  a, b;
  cin >> a >> b ;
  
  string s[a];
  
  for(int i =0;i<a;i++)
    cin >> s[i] ;
  
   
 for(int i =0;i<a;i++)
  
      cout <<s[i]<<endl<<s[i]<<endl ;
  
  
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;

	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if((x+r>W)||(y+r>H)||(x-r<0)||(y-r<0))
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}

	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;
	int A[200005];

	cin >> N;
	rep(i,N) cin >> A[i];

	deque<int> que[22];
	rep(i,22) que[i].push_back(-1);
	rep(i,N){
		int mx = -1;
		rep(k,22){
			if( A[i] & (1<<k) ){
				while( que[k].size() >= 2 ) que[k].pop_front();
				que[k].push_back(i);
			}
			chmax(mx, que[k].front());
		}
		ans += i - mx;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
# ABC148 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
a=nl()
cur=1
ans=0

b=set(a)

if 1 in b:
    pass
else:
    print(-1)
    exit()

flg=True
for i in range(n):
    if i==a[i]:
        pass
    else:
        flg=False

if flg:
    print(0)


for i in range(n):
    if a[i]==cur:
        cur+=1
    else:
        ans+=1
print(ans)



Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
string s;
int ans=0,cnt=0;
int main()
{
	cin>>s;
	for(int i=0;i<(int)s.size();i++)
		if(!cnt)
		{
			++cnt;
			if(s[i]=='p')
				--ans;
		}
		else
		{
			--cnt;
			if(s[i]=='g')
				++ans;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n1 = Read();
            var n2 = Read();
            var n3 = Read();
            WriteLine(n1[0].ToString() + n2[1].ToString() + n3[2].ToString());
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define MAX 500000
int h,a[MAX+1];
void maheap(int i){
  int l,r,la;
  l = 2*i;
  r=2*i+1;

  if(l<=h&&a[l]>a[i])la=l;
  else la=i;
  if(r<=h&&a[r]>a[la])la=r;

  if(la!=i){
    swap(a[i],a[la]);
    maheap(la);
  }
}

int main(){
  cin >> h;
  for(int i=1;i<=h;i++)cin >>a[i];
  for(int i=h/2;i>=1;i--)maheap(i);
  for(int i=1;i<=h;i++){
    cout << " " << a[i];
  }
  cout << endl;
}

Measured memory_bytes: 5044
while True:
    i = list(map(lambda x: int(x), input().split(" ")))
    if i[0] == 0 and i[1] == 0:
        break
    count = 0
    for a in range(1, i[0] - 1):
        for b in range(a+1, i[0]):
            for c in range(b+1, i[0]+1):
                if a + b + c == i[1]:
                    count += 1
    print(count)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
string S;
int K;

int to[111];
int len[111][111];

int calcLen(int l,int r){
	int &ans=len[l][r];
	if(l==r)return ans=0;
	if(isalpha(S[l])){
		return ans=min(1+calcLen(l+1,r),K+1);
	}

	int p=l;
	int num=0;
	while(isdigit(S[p])){
		num=num*10+S[p]-'0';
		p++;
	}

	if(isalpha(S[p])){
		return ans=min(num+calcLen(p+1,r),K+1);
	}
	else{
		return ans=min(num*calcLen(p+1,to[p])+calcLen(to[p]+1,r),K+1);
	}
}


void findChar(int l,int r,int k){
	if(isalpha(S[l])){
		if(k){
			findChar(l+1,r,k-1);
		}
		else{
			cout<<S[l]<<endl;
		}
		return;
	}


	int p=l;
	int num=0;
	while(isdigit(S[p])){
		num=num*10+S[p]-'0';
		p++;
	}

	if(isalpha(S[p])){
		if(k<num){
			cout<<S[p]<<endl;
		}
		else{
			findChar(p+1,r,k-num);
		}
	}
	else{
		if(num*len[p+1][to[p]]>k){
			findChar(p+1,to[p],k%len[p+1][to[p]]);
		}
		else{
			findChar(to[p]+1,r,k-num*len[p+1][to[p]]);
		}
	}
}

void solve(){
	stack<int>st;
	int N=S.size();
	rep(i,N){
		if(S[i]=='('){
			st.push(i);
		}
		else if(S[i]==')'){
			to[st.top()]=i;
			st.pop();
		}
	}

	calcLen(0,N);

	if(len[0][N]<=K){
		cout<<0<<endl;
		return;
	}
	findChar(0,N,K);
}

signed main(){
	while(cin>>S>>K,S!="0"){
		solve();
	}
	return 0;
}


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

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

using namespace std;

int main(){
  int n,k,x,y;

  cin>>n;
  cin>>k;
  cin>>x;
  cin>>y;

  if(n>k){
    cout<<x*k+y*(n-k)<<endl;
  }else{
    cout<<x*n<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 int main( void ){   
    int m_Higher[10];  
    for( int i = 0;i < 10;i++ ) scanf( "%d",&m_Higher[i] );   
    bool Flg  = false;
    while( true ) {
        for( int i = 0;i < 10 - 1;i++ ){
            if( m_Higher[i] < m_Higher[i+1] ){
                int buf = m_Higher[i];
                m_Higher[i] = m_Higher[i+1];
                m_Higher[i+1] = buf;
                Flg = true;
            }
        }
        if( !Flg ) break;
        Flg = false;
    }
     for( int i = 0;i < 3;i++ ) printf( "%d\n",m_Higher[i] );    
    return 0;
} 

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000000

// 辺の（行先，容量，逆辺が保存されているG[to]での番地）．
struct edge {int to, cap, rev;};

vector<vector<edge>> G; //有向グラフとその残余グラフ．
vector<int> level; // sからの距離
vector<int> iter; // どこまで調べ終わったか．

void add_edge(int from, int to , int cap){
    G[from].push_back(edge{to, cap, (int)G[to].size()});
    G[to].push_back(edge{from, 0, (int)G[from].size() - 1});
}

//sからの最短距離をbfsで計算．levelに記録．
void bfs(int s){
    fill(ALL(level), -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()){
        int v = que.front(); que.pop();
        for (edge &e:G[v])
            if (e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
    }
}

//v から t へのパスを DFS で探し，そのパスで流せる最大流量を返す．
// mincap = 通った辺の中の最少容量
int flow_dfs(int v, int t, int mincap){
    if (v == t) return mincap;
    for (int &i = iter[v]; i <  G[v].size(); ++i){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = flow_dfs(e.to, t, min(mincap, e.cap));
            if (d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流
int max_flow(int s, int t){
    int flow = 0;
    while (true){
        bfs(s);
        if (level[t] < 0) return flow;
        fill(ALL(iter), 0);
        int f;
        while((f = flow_dfs(s, t, INF)) > 0)
            flow += f;
    }
}

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

// 二部マッチング．AOJ.
// Dinic ．O(EV²). 
int X, Y, E; cin >> X >>  Y >> E;
// 0 始点．1,..., X X頂点，X+1,...,X+Y+1, Y頂点，X+Y+2 終点．
G.assign(X + Y + 3, vector<edge>());
level.assign(X + Y + 3, 0);
iter.assign(X + Y + 3, 0);
rep(i, 0, E){
    int x, y; cin >> x >> y;
    add_edge(x+1, y+X+1, 1); 
}
// 始点とX点を結ぶ
rep(i, 1, X+1) add_edge(0, i, 1);
// 終点とY点を結ぶ
rep(i, X+1, X + Y + 2) add_edge(i, X + Y + 2, 1);


cout << max_flow(0, X+Y+2) << endl;

}




Measured memory_bytes: 3252
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::unordered_map<int64_t, int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A[t]++;
    }

    int64_t count = 0;
    int64_t even = 0;
    for (auto a: A) {
        if (a.second % 2 == 1) {
            // 奇数
            count++;
        }
        else {
            // 偶数
            even++;
        }
    }

    if (even % 2 == 0) {
        count += even;
    }
    else {
        count += even - 1;
    }

    std::cout << count  << std::endl;

    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll ts(n), as(n);
  rep(i, n) cin >> ts[i];
  rep(i, n) cin >> as[i];

  ll tmid = -1, tmax = 0;
  rep(i, n) {
    if (tmax < ts[i]) {
      tmid = i;
      tmax = ts[i];
    }
  }
  ll amid = -1, amax = 0;
  rep(i, n) {
    if (amax < as[n - 1 - i]) {
      amid = n - 1 - i;
      amax = as[n - 1 - i];
    }
  }

  if (tmid > amid || tmax != amax) {
    cout << 0 << endl;
    return 0;
  }
  ll maxv = tmax;

  ll ans = 1;
  tmax = 0;
  rep(i, tmid) {
    if (tmax == ts[i]) {
      ans = ans * tmax % mod;
    } else {
      tmax = ts[i];
    }
  }
  repLRE(i, tmid + 1, amid - 1) { ans = ans * maxv % mod; }
  amax = 0;
  rrepLRE(i, n - 1, amid + 1) {
    if (amax == as[i]) {
      ans = ans * amax % mod;
    } else {
      amax = as[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner src = new Scanner(System.in);
		int bad = -1;
		
		while(true) {
			
			
			int m = src.nextInt();
			int f = src.nextInt();
			int r = src.nextInt();
			
			int sum = m + f;
			
			if((m == bad) && (f == bad) && (r == bad)){
				
				break;
				
			}else if((sum < 30) || (m == bad) || (f == bad)) {
				
				System.out.println("F");
				
			}else if(80 <= sum) {
				
				System.out.println("A");
				
			}else if((65 <= sum) && (sum < 80)) {
				
				System.out.println("B");
				
			}else if((50 <= sum) && (sum < 65) || (50 <= r)) {
				
				System.out.println("C");
			
			}else if((30 <= sum) && (sum < 50)) {
				
				System.out.println("D");
				

			}	
		}
		

	}
}




Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum+=a[i];
  }
  if(sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
def main():
	x = int(input())
	while not IsPrime(x):
		x += 1
	print(x)

def IsPrime(n):
	if n < 2:
		return False
	elif n == 2:
		return True
	elif n % 2 == 0:
		return False
	
	sqrtN = int(n**0.5)
	for i in range(3, sqrtN, 2):
		if n%i == 0:
			return False
	return True

if __name__ == '__main__':
	main()


Measured memory_bytes: 3060
import sys
import functools

n = int(sys.stdin.readline())
a = [int(v) for v in sys.stdin.readline().split()]


@functools.lru_cache(maxsize=None)
def solve(k, m):
    if m == 0:
        return True
    if k == n or m < 0:
        return False

    return solve(k + 1, m) or solve(k + 1, m - a[k])


sys.stdin.readline()
for m in map(int, sys.stdin.readline().split()):
    print('yes' if solve(0, m) else 'no')


Measured memory_bytes: 9920
package main

import (
	"fmt"
)

func main() {
	var H, W, N int

	fmt.Scanf("%d", &H)
	fmt.Scanf("%d", &W)
	fmt.Scanf("%d", &N)

	//fmt.Println(H, W, N)

	size := W
	if H > W {
		size = H
	}

	//fmt.Println(size)

	n := N / size
	if N%size != 0 {
		n = n + 1
	}
	fmt.Println(n)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int n, m;
  int i, j;
  int temp;
  int end;
  int answer[5][100];
  int counter = 0;
  int array[1000][100];
  int sum[100];
  int ans[100];
  int s[5];

  while(1){
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0){
      break ;
    }
    s[counter] = m;
    for(j = 0; j < m; j++){
      sum[j] = 0;
    }

    for(i = 0; i < n; i++){
      for(j = 0; j < m; j++){
	scanf("%d", &array[i][j]);
      }
    }

    for(j = 0; j < m; j++){
      for(i = 0; i < n; i++){
	sum[j] = sum[j] + array[i][j];
      }
    }
    for(j = 0; j < m; j++){
      ans[j] = j;
    }


    


    //sort
    while(1){
      end = 0;

      for(j = 0; j < m - 1; j++){
      
      
	if(sum[j] < sum[j + 1]){
	  
	  temp = sum[j];
	  sum[j] = sum[j + 1];
	  sum[j + 1] = temp;

	  temp = ans[j];
	  ans[j] = ans[j + 1];
	  ans[j + 1] = temp;
	  end = 1;
	  
	}
	
      }
      if(end == 0){ break ; }
    }

    for(j = 0; j < m; j++){
      answer[counter][j] = ans[j];
    }
    answer[counter][j] = 1000;
    counter++;

  

    
  }

  for(i = 0; i < counter; i++){
      for(j = 0; j < s[i]; j++){
        printf("%d", answer[i][j] + 1);
        if(j < s[i]-1){printf(" "); }
      }
     printf("\n");
    }  
  

  return 0;
}
    
    

    

    

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    long n = Long.parseLong(in.readLine());
    long a = 1;
    
    for(int i=1; i<=Math.sqrt(n); i++){
      if(n%i==0)
        a = n/i;
    }
    
    System.out.println((int)Math.log10(a)+1);
  }
}

Measured memory_bytes: 22100
// https://atcoder.jp/contests/dp/tasks/dp_m
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define infinity (ll)4e18
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll n, k;
    cin >> n >> k;
    ll a[n + 1];
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    ll dp[k + 1];
    ll pre[k + 1];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        pre[0] = dp[0];
        for (ll j = 1; j <= k; j++)
            pre[j] = (dp[j] + pre[j - 1]) % mod;
        for (ll j = 0; j <= k; j++)
        {
            if (j - a[i] > 0)
                dp[j] = (pre[j] - pre[j - a[i] - 1]) % mod;
            else
                dp[j] = pre[j] % mod;
        }
    }
    cout << (dp[k] + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 1792
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n, q;
LL a[101010];
LL rui[101010], rui2[101010];
LL x;

void solve(){
    cin >> x;
    int l = 0, r = n;
    while(r - l > 1){
        int mid = (l + r)/2;
        int lpos = lower_bound(a, a + n, x - (a[mid] - x)) - a;
        int aoki = mid - lpos + 1;
        int taka = n - mid - 1;
        if(aoki <= taka){
            l = mid;
        }else{
            r = mid;
        }
    }
    LL ans = rui[n] - rui[r];
    int len = n - l - 1;
    int t_first = n - len*2;
    if(t_first > 0)ans += rui2[t_first];
    cout << ans << endl;
    return;
}

int main(){
    cin >> n >> q;
    REP(i, n)cin >> a[i];
    REP(i, n){
        rui[i + 1] = rui[i] + a[i];
    }
    rui2[1] = a[0];
    rui2[2] = a[1];
    for(int i = 2;i < n;i++){
        rui2[i + 1] += rui2[i - 1];
        rui2[i + 1] += a[i];
    }
    REP(qqq, q)solve();
}

Measured memory_bytes: 4224
def main():
    N, *A = map(int, open(0).read().split())
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    ans = 0
    b = A[N // 2]
    for i in range(N):
        ans += abs(A[i] - b)
    print(ans)
    return


main()


Measured memory_bytes: 25180
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a[parseInt(sc.next())-1] = i+1;
		}
		sc.close();
        PrintWriter pw = new PrintWriter(out);
		for (i = 0; i < n; i++) {
				pw.print(a[i]);
				pw.print(" ");
		}
		pw.println();
		pw.flush();
	}
}


Measured memory_bytes: 49108
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
// #include <utility>
using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;

int main(){
    int a,b,t;
    cin>>a>>b;
    if (a>b){
     t = a;
        a = b;
        b = t;
    }
    for (size_t i = 0; i < b; i++)
    {
        cout << a;
    }
    return 0;
}

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

int main(){
  int a , b , c , d ;
  cin >> a >> b >> c >> d ;
  
  if(a+b > c + d){
    cout << "Left" << endl ; 
  }
  else if(a + b < c + d){
    cout << "Right" << endl ; 
  }
  else {
    cout << "Balanced" << endl ; 
  }
  
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll       long long int
#define fast     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define MOD      1000000007
#define pb       push_back
#define PI 3.1415926
#define ordered_set tree<ll, null_type,less_equal<>, rb_tree_tag,tree_order_statistics_node_update> 
int32_t main() 
{ fast
	double n;
	cin>>n;
	cout<<2*PI*n<<endl;

 

  }

Measured memory_bytes: 3800
n = int(input())
s = input()
sum_w = s.count("W")
ans = n
lw = [0]*n
count = 0
for i in range(n):
    lw[i] = count
    if s[i] == "W":
        count += 1
for i in range(n):
    left_w = lw[i]
    right_w = sum_w-left_w
    if s[i] == "W":
        right_w -= 1
    right_e = (n-i-1)-right_w
    sum = left_w+right_e
    if sum < ans:
        ans = sum
print(ans)


Measured memory_bytes: 15264
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
if n <= 3:
  print(max(a))
  exit()

a = tuple(a)
dp = [[-10**15]*3 for i in range(n)]

dp[0][2] = a[0]
dp[1][2] = a[1]
dp[2][2] = a[0]+a[2]
dp[3][2] = max(a[0],a[1])+a[3]
dp[3][1] = a[0]+a[3]
for i in range(2,n-2):
  if i%2 == 0:
    dp[i+2][2] = dp[i][2]+a[i+2]
    dp[i+2][0] = max(dp[i][0]+a[i+2],dp[i-1][1]+a[i+2],dp[i-2][2]+a[i+2])
  else:
    dp[i+2][2] = max(dp[i][2],dp[i][1],dp[i-1][2])+a[i+2]
  dp[i+2][1] = max(dp[i][1]+a[i+2],dp[i-1][2]+a[i+2])
if n%2 == 1:
  c = min(a[0],a[-1])
  dp[n-1][2] -= c
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))


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

using namespace std;
#define taskname "A"
#define pb  push_back
#define mp  make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2005;
const int maxm = 1e4 + 5;
int a[maxn];
int n , k , q;
int res = 2e9;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP", "r",stdin);
        freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> k >> q;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    for(int i = 1 ; i <= n ; ++i){
        vector<int> can , tmp;
        int now = a[i];
        for(int j = 1 ; j <= n + 1 ; ++j){
            if(now > a[j] || j == n + 1){
                sort(tmp.begin(),tmp.end());
                for(int c = 0 ; c + k - 1 < (int)tmp.size() ; ++c){
                    can.pb(tmp[c]);
                }
                tmp.clear();
            }else{
                tmp.pb(a[j]);
            }
        }
        sort(can.begin(),can.end());
//        if(can.size() >= q)cout << now << " " << can.size() << endl;
        if(can.size() >= q)res = min(res , can[q - 1] - now);
    }
    cout << res;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main() {
	speed;
	string s;
	cin >> s;
	int ans=0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i - 1] == s[i]) {
			ans++;
			if (s[i] == '1')s[i] = '0';
			else s[i] = '1';
		}
	}

	cout << ans;
	ed;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main() {
    int N, M, K;
    cin>>N>>M>>K;
    int number;
    int check=0;
    rep(i, N+1){
        rep(j, M+1){
            number=M*i+N*j-2*i*j;
            if(number==K){
                check=1;
                goto move;
            }
        }
    }
    move:;
    if (check==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes";
    }
    else{cout<<"No";}
}


Measured memory_bytes: 3616
#include <iostream>
#include <string.h>

using namespace std;
char Field[52][52];
int w, h;

void DFS(int y, int x)
{
	Field[y][x] = 0;
	for(int i = -1; i <= 1; ++i)
	{
		for(int j = -1; j <= 1; ++j)
		{
			int X = x + j;
			int Y = y + i;
			if((0 < X && X <= w) && (0 < Y && Y <= h) && Field[Y][X] == '1')
			{
				DFS(Y, X);
			}
		}
	}
}

void solve()
{
	while(cin >> w >> h, w || h)
	{
		memset(Field, 0, sizeof(Field));
		for(int i = 1; i <= h; ++i)
		{
			for(int j = 1; j <= w; ++j)
			{
				cin >> Field[i][j];
			}
		}

		int count = 0;
		for(int i = 1; i <= h; ++i)
		{
			for(int j = 1; j <= w; ++j)
			{
				if(Field[i][j] == '1')
				{
					count++;
					DFS(i, j);
				}
			}
		}
		cout << count << endl;
	}
}

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

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

int main(){
    int ans=0;
    for (int i = 0; i < 4; i++){
        char c; cin>>c;
        if(c=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout<<ans<<endl;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main() {
  int N;
  cin>>N;
  int A[N][3];
  rep(j,3){
    rep(k,N){
      cin>>A[k][j];
    }
  }
  A[N-1][3]=0;

  int manzoku=0;
  rep(k,N){
    manzoku+=A[k][1];
    if(A[k+1][0]-A[k][0]==1){
      int m=A[k][0]-1;
      manzoku+=A[m][2];
    }
  }
  cout << manzoku<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;




public class Main{

	static class Node{
		int val;
		Node p,left,right;
		Node(int val){
			this.val=val;
			this.left=null;
			this.right=null;
		}
	}
	static Node root;
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		for(int i=0;i<n;i++){
			String  str=scanner.next();
			if(str.equals("insert")){
				int val=scanner.nextInt();
				root=insert(root,val);
			}
			else if(str.equals("print")){
				inorder(root);
				System.out.println();
				preorder(root);
				System.out.println();
			}else if(str.equals("find")){
				find(root,scanner.nextInt());
			}
		}
	}
	private static void find(Node node,int x) {
		// TODO Auto-generated method stub
		if(node==null){
			System.out.println("no");
			return;
		}	
		else if(node.val==x){
			System.out.println("yes");
			return;
		}	
		else if(node.val>x){
			find(node.left, x);
		}else find(node.right, x);
	}
	private static void preorder(Node node) {
		// TODO Auto-generated method stub
		if(node==null)
			return;
		else{
			System.out.print(" "+node.val);
			preorder(node.left);
			preorder(node.right);
		}
	}
	private static void inorder(Node node) {
		// TODO Auto-generated method stub
		if(node==null)
			return;
		else{
			inorder(node.left);
			System.out.print(" "+node.val);
			inorder(node.right);
		}
	}
	private static Node insert(Node node,int val) {
		// TODO Auto-generated method stub
		if(node==null){
			node=new Node(val);
		}
		else{
			if(val<node.val){
				node.left=insert(node.left,val);
			}
			else node.right=insert(node.right,val);
		}
		
		return node;
	}

}



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

int main() {

	int D; cin >> D;
	switch (D) {
	case 25:cout << "Christmas" << endl; break;
	case 24:cout << "Christmas Eve" << endl; break;
	case 23:cout << "Christmas Eve Eve" << endl; break;
	case 22:cout << "Christmas Eve Eve Eve" << endl; break;
	}

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from math import ceil,floor

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

# def func(a):
#    return tmp

S = input()

ans = 0

for i in range(0,len(S)//2):
    if S[i]!=S[len(S)-i-1]:
        ans=ans+1

print(ans)


Measured memory_bytes: 38256
#include <cstdio>
#include <climits>

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

    int* r = new int[n];
    scanf("%d", &r[0]);
    scanf("%d", &r[1]);

    int min = (r[0] > r[1]) ? r[1] : r[0];
    int max_profit = r[1] - r[0];
    for (int i=2; i<n; i++) {
        scanf("%d", &r[i]);
        if (min > r[i]) {
            min = r[i];
        } else if (max_profit < r[i] - min) {
            max_profit = r[i] - min;
        }
    }
    printf("%d\n", max_profit);

    return 0;
}

Measured memory_bytes: 3416