akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll n,K;
vl a(101010),b(101010);

ll rec(ll k, ll plus, ll p){
	ll res = 0;
	if(p == -1){
		rep(i,n) if((a[i] - (a[i] & plus)) == 0) res += b[i];
		return res;
	}
	ll np = p;
	rep(i,n){
		if((a[i] - (a[i] & plus)) < 1<<p) res += b[i]; 
	}
	k -= 1<<p;
	plus += 1<<p;
	while((1<<np) > k) np--;
	return max(res,rec(k,plus,np));
}


int main(){
	cin >> n >> K;
	rep(i,n) cin >> a[i] >> b[i];
	ll p = -1;
	while((1<<(p+1)) <= K) p++;
	cout << rec(K,0,p) << endl;
}

Measured memory_bytes: 1920
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

void No() {
    cout << "No" << ln;
    exit(0);
}
void Yes() {
    cout << "Yes" << ln;
    exit(0);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    vector<int> deg(N);
    rep(i,M) {
        int a,b; cin >> a >> b;
        --a; --b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        deg[a]++;
        deg[b]++;
    }

    int cnt4 = 0;
    bool ok = 0;
    rep(i,N) {
        if (deg[i]&1) No();
        if (deg[i]==2) continue;
        else if (deg[i]==4) cnt4++;
        else ok = 1; 
    }
    if (ok or cnt4 >= 3) Yes();
    if (cnt4 <= 1) No();
    int a = -1, b = -1;
    rep(i,N) {
        if (a==-1 and deg[i]==4) a = i;
        else if (b==-1 and deg[i]==4) b = i;
    }
    vector<bool> check(N);
    check[a] = check[b] = 1;
    auto dfs=[&](auto&& self, int v, int pv)->void {
        for (auto nv : G[v]) {
            if (nv==pv) continue;
            if (nv==a) Yes();
            if (check[nv]) continue;
            check[nv] = 1;
            self(self,nv,v);
        }
    };

    dfs(dfs,a,-1);
    No();
}


Measured memory_bytes: 6784
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val list =
      for{
        in <- Source.stdin.getLines.toList
      } yield in

    list.map(_.split(" ").map(_.toInt).toList).init.foreach{ list =>
      val height = list.head
      val width = list.last
      val bw = "#."

      (1 to height).foreach{ row =>
        row match{
          case x if x % 2 == 0 => println((bw.reverse * width).take(width))
          case x if x % 2 == 1 => println((bw * width).take(width))
        }
      }
      println
    }
  }
}

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


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

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

	int* l = new int[k] {0};
	int* r = new int[k] {0};
	
	for (int i = 0; i < k; i++)
		cin >> l[i] >> r[i];

	int* s = new int[k] {0};
	int dp[200005] = { 0 };
	long long temp;

	dp[1] = 1;

	const int m = 998244353;

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < k; j++) {
			if (i - l[j] >= 1)
				s[j] = (s[j] + dp[i - l[j]]) % m;			
			if (i - r[j] - 1 >= 1) {
				temp = s[j] - dp[i - r[j] - 1];
				if (temp < 0)
					temp += m;
				s[j] = temp;
			}
			dp[i] = (dp[i] + s[j]) % 998244353;
		}		
	}

	cout << dp[n];



	return 0;
}

Measured memory_bytes: 4404
/*
* @author:  codancer
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef pair<int,int> pii;
bool ok(string s){
	string t=s;
	reverse(s.begin(),s.end());
	return s==t;
}
int main(){
	double L;
	cin>>L;
	double a=L/3;
	double b=L/3;
	double c=(L-a-b);
	printf("%.12lf\n",a*b*c);
	return 0;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,y=parseMap(split(readline()))
    ans="-1 -1 -1"
    for i in 0:n,j in 0:n
        if i+j<=n && 10000*i+5000*j+1000*(n-i-j)==y
            ans="$i $j $(n-i-j)"
            break
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 169852
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for _ in range(n)]
dp[0] = x[0]
for i, (a, b, c) in enumerate(x[1:]):
    dp[i+1][0] = a + max(dp[i][1], dp[i][2])
    dp[i+1][1] = b + max(dp[i][2], dp[i][0])
    dp[i+1][2] = c + max(dp[i][0], dp[i][1])
    
print(max(dp[-1]))

Measured memory_bytes: 48156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argN, argK;
	cin >> argN >> argK;

	string argS;
	cin >> argS;

	ll ret = 1;
	ll last = argS.size() - 1;
	ll numZeroBlock = 0;
	if (argS.at(last) == '0') {
		numZeroBlock++;
	}
	
	for (ll first = argS.size() - 2; 0 <= first; --first) {
		if (argS.at(first) == '1') {
			ret = max(ret, last - first + 1);
			continue;
		}
		else if (argS.at(first) == '0' && argS.at(first + 1) == '0') {
			ret = max(ret, last - first + 1);
		}
		else {
			++numZeroBlock;
			while (argK < numZeroBlock) {
				while (argS.at(last) == '1') {
					last--;
				}
				while (argS.at(last) == '0') {
					last--;
				}
				--numZeroBlock;
			}
			ret = max(ret, last - first + 1);
		}
	}

	cout << ret << endl;
}

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

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if ( k > a ){
        cout << 0 << " " << max(1ll * 0, b + a - k);
    }else cout << a - k << " " << b;
    return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    readLine()
    val nums = readLine()!!.trim().split(' ').sumBy { div2(it.toInt()) }
    println(nums)
}
fun div2(num:Int):Int {
    return when(num % 2){
        0 -> 1 + div2(num / 2)
        else -> 0
    }
}

Measured memory_bytes: 41376
#include <iostream>
#include <cmath>

int main()
{
  int x, a, b;
  
  std::cin >> x >> a >> b;

  int ax = a - x;
  int bx = b - x;

  if (abs(ax) < abs(bx)) {
    std::cout << "A" << std::endl;
  } else {
    std::cout << "B" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

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

    cout << (a + b) * h / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> factorisation(int n){
	vector<int> div;
    for(int i=1;i*i<=n;i++){
	  if(n%i==0){
		  div.emplace_back(i);
	     if(i!=n/i)div.emplace_back(n/i);	
	    }
	}
  return div;
}
void solve(){
   int n,ans;
   ans=0;
   cin>>n;
   vector<int> div=factorisation(n);
   sort(all(div));
   for(auto it:div){
	    int m=n/it-1;
	    if(m and n/m==n%m)ans+=m; 
	  }	
   cout<<ans<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

vint a;
int k;

bool check(int x) {
    int res = 0;
    rep(i,a.size()) res += (a[i]+x-1)/x - 1;
    return res <= k;
}

int main() {
    int n; cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a[i];
    int l = 0;
    int r = inf;
    while (r-l > 1) {
        int mid = (l+r)/2;
        if (check(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int N, M;
vector<bool> issafe; // issafe[v] := v が壊れていないかどうか

int main() {
    cin >> N >> M;
    issafe.assign(N+1, true);
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        issafe[a] = false; // a 段目は壊れてる
    }

    // DP テーブル
    vector<int> dp(N+1, 0); // 各段について 0 で初期化しておく

    // 初期条件
    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;

    // ループ
    for (int n = 2; n <= N; ++n) {
        if (issafe[n-1]) dp[n] += dp[n-1]; // n-1 段目が安全なら
        if (issafe[n-2]) dp[n] += dp[n-2]; // n-2 段目が安全なら
        dp[n] %= MOD; // 1000000007 で割る
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println((numA - 1) * (numB - 1));

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
using namespace std;
char s[maxn],t[maxn];
int L[30];
vector<int>q[30];
int main()
{

	cin>>s>>t;
	int ls=strlen(s),lt=strlen(t);
	for(int i=0;i<30;i++)
		L[i]=0;
	for(int i=0;i<ls;i++)
	{
		int a=s[i]-'a';
		q[a].push_back(i);
		L[a]++;
	}
	int o=1,sign=-1;
	long long ans=0;
	for(int i=0;i<lt;i++)
	{
		int a=t[i]-'a';
		if(q[a].empty())
		{
			o=0;
			break;
		}
		else
		{
			int S=upper_bound(q[a].begin(),q[a].end(),sign)-q[a].begin();
			if(S==L[a])
			{
				S=0;
				ans+=ls;
			}
			sign=q[a][S];
		}
		//printf("%lld %d\n",ans,sign);
	}
	ans+=sign+1;
	if(o)
		printf("%lld\n",ans);
	else
		printf("-1\n");
	
}
				

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define BIT(n, m) (((n) >> (m)) & 1)

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

const ll inf = 1e15;
const ll mod = 1000 * 1000 * 1000 + 7;
const double eps = 1e-9;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}


int H, L;
vector<string> T;
vector<int> hint;
vector<int> blow;
vector<int> h_count;
vector<int> t_mask;
int used_mask = 0;

void dfs(int pos, string &str, string &ans)
{
  if (ans == "-2") return;
  
  if (pos == str.size()){
    bool ok = true;
    REP(i, T.size()) if (ok){
      int h = h_count[i];
      int b = __builtin_popcount(used_mask & t_mask[i]) - h;
      ok = ok && h == hint[i] && b == blow[i];
    }
    if (ok){
      if (ans == "-1"){
        ans = str;
      } else {
        ans = "-2";
      }
    }
    return;
  }

  REP(i, 10) if ((used_mask & (1 << i)) == 0){
    str[pos] = '0' + i;
    used_mask = used_mask | 1 << i;

    bool ok = true;
    REP(j, T.size()) {
      h_count[j] += T[j][pos] == str[pos];
      if (h_count[j] > hint[j]) ok = false;
    }
    if (ok) dfs(pos + 1, str, ans);
    REP(j, T.size()) h_count[j] -= T[j][pos] == str[pos];
    
    used_mask = used_mask ^ 1 << i;
  }
}


int main(){
  int L, H;
  while (cin >> L >> H && L + H){
    T.resize(H);
    hint.resize(H);
    blow.resize(H);
    t_mask.resize(H);
    h_count.resize(H);
    fill(ALL(h_count), 0);
    used_mask = 0;
    REP(i, H){
      cin >> T[i] >> hint[i] >> blow[i];
      t_mask[i] = 0;
      REP(j, T[i].size()) t_mask[i] |= (1 << (T[i][j] - '0'));
    }
    string ans = "-1";
    string str(L, ' ');
    dfs(0, str, ans);
    if (ans != "-1" && ans != "-2"){
      cout << ans << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

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

int get(int i)
{
    int ret=0;
    while(i)
    {
        ret+=i%10;
        i/=10;
    }
    return ret;
}
int main()
{
    int n;
    int a,b;
    cin>>n;cin>>a>>b;

    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int q=get(i);
        if(q>=a&&q<=b)
            ans+=i;
    }cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define puts(i) cout<<i<<endl
int main(){
	int n;
	cin>>n;
	int a[n];
	int now=0,ma=0;
	rep(i,n){
		cin>>a[i];
		if(i==0)continue;
		if(a[i]<=a[i-1]){
			now++;
		}else{
			ma=max(ma,now);
			now=0;
		}
	}
	ma=max(ma,now);
	cout << ma << endl;
}


Measured memory_bytes: 640
n = int(input())
memo = [0] * (n+1)
def luca(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
    if memo[n] != 0:
        return memo[n]
    memo[n] = luca(n-1) + luca(n-2)
    return memo[n]


print(luca(n))

Measured memory_bytes: 3060
fun main() {
    val (a, b, c, k) = readLine()?.split(" ")?.map(String::toInt) ?: return
    if (k <= a) {
        println(k.toString())
        return
    }
    val r = k - a
    if (r - b > 0) {
        println((a - (r - b)).toString())
    } else {
        println(a.toString())
    }
}

Measured memory_bytes: 36436
mat = 3.times.map{ gets.split.map(&:to_i) }
def check(mat)
    mat[0][0] - mat[1][0] == mat[0][1] - mat[1][1] &&
    mat[0][1] - mat[1][1] == mat[0][2] - mat[1][2] &&
    mat[1][0] - mat[2][0] == mat[1][1] - mat[2][1] &&
    mat[1][1] - mat[2][1] == mat[1][2] - mat[2][2]
end

if check(mat) then puts "Yes"
else puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a;
  R a;
  ll ans=0;
  ll x=1;
  rep(i,3) {
    x*=a;
    ans+=x;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3648
// 4_abc140_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int ans = 0;
    char tmp = s[0];
    int nrev = 0;

    for(int i = 1; i < n; i++){
        if(tmp == s[i]) ans++;
        else nrev++;

        tmp = s[i];
    }

    if(nrev >= 2 * k){
        ans += 2 * k;
    }else{
        ans += (nrev / 2) * 2;
        ans += nrev % 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ACalc {
public:
  static void solve(istream &cin, ostream &cout) {
    int s;
    cin >> s;
    cout << s + s * s + s * s * s << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ACalc solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main() {
  int n,k,g,c,p;
  cin >> n >> k >> g >> c >> p;
  string t;
  cin >> t;
  vector<string> st(n);

  int sum=0;
  
  for(int i=0; i<k; i++){
      if(t[i] == 'r'){
        sum+=p;
      }
      if(t[i] == 's'){
        sum+=g;
      }
      if(t[i] == 'p'){
        sum+=c;
      }
      st.at(i) = "w";
    }
    
  for(int i=k; i<n; i++){
     if(t[i] != t[i-k]){
      if(t[i] == 'r'){
         sum+=p;
       }
       if(t[i] == 's'){
         sum+=g;
       }
       if(t[i] == 'p'){
         sum+=c;
       }
      st.at(i) = "w";
     }
    
     else{
      if(st[i-k] == "w"){
        st.at(i) = "nw"; 
      }
      
      else{
       if(t[i] == 'r'){
         sum+=p;
       }
       if(t[i] == 's'){
         sum+=g;
       }
       if(t[i] == 'p'){
         sum+=c;
       }
       st.at(i) = "w";
      }
    }
  }
 
 cout << sum << endl;
  
	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <unordered_map>

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  
  int N;
  std::cin>>N;
  
  uint64_t sum=0;
  std::unordered_map<int,int> A;
  for(int i=0;i!=N;i++)
  {
    int a;
    std::cin>>a;
    sum+=a;
    A[a]++;
  }
  
  int Q;
  std::cin>>Q;
  
  int B,C;
  for(int i=0;i!=Q;i++)
  {
    std::cin>>B>>C;
    
    sum=sum+(C-B)*A[B];
    
    A[C]=A[C]+A[B];
    A[B]=0;
    
    std::cout<<sum<<"\n";
  }
  
  std::cout<<std::endl;
  
  return 0;
}

Measured memory_bytes: 6996
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    s = cino(True)
    if s[len(s)-1]=='s':
        s += 'es'
    else:
        s += 's'
    print(s)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {

    int H, W;

    vector<vector<ll>> dp;
    vector<vector<char>> map;

    cin>>H>>W;
    dp.resize(H);
    map.resize(H);
    for(int i=0; i<H; ++i)
    {
        dp[i].resize(W);
        map[i].resize(W);
    }

    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            cin>>map[i][j];
        }
    }


    dp[0][0] = 1;
    ll bigNum = ll(1e9+7);

    bool flag = false;
    int iter=0;
    while(iter<W)
    {
        if(map[0][iter] == '#')
        {
            for(int j=iter; j<W; ++j)
                dp[0][j] = 0;

            flag = true;
        }
        else
            dp[0][iter] = 1;

        if(flag)
            break;

        iter++;
    }

    iter = 0;
    flag = false;
    while(iter<H)
    {
        if(map[iter][0] == '#')
        {
            for(int j=iter; j<H; ++j)
                dp[j][0] = 0;

            flag = true;
        }
        else
            dp[iter][0] = 1;

        if(flag)
            break;

        iter++;
    }

    for(int i=0; i<H-1; ++i)
    {
        for(int j=0; j<W-1; ++j)
        {
            if(map[i+1][j]=='#' && map[i][j+1]=='#')
                dp[i+1][j+1]=0;

            else if(map[i+1][j] =='#')
                dp[i+1][j+1] = dp[i][j+1];

            else if(map[i][j+1] =='#')
                dp[i+1][j+1] = dp[i+1][j];

            else
                dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1];
            
            dp[i+1][j+1]%=bigNum;
            
        }
    }


    cout<<dp[H-1][W-1]<<endl;

    return 0;
}


Measured memory_bytes: 9088
s=input()
i=0
j=len(s)-1
c=0
while i<j:
  l=s[i]
  r=s[j]
  if l==r:
    i+=1
    j-=1
  elif l=="x"!=r:
    i+=1
    c+=1
  elif l!="x"==r:
    j-=1
    c+=1
  else:
    print(-1)
    exit()
print(c)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
    int height;
    int width;
    int not_zero=1;
    int i,j=0;


    while(not_zero){
        scanf("%d",&height);
        scanf("%d",&width);

        if(height==0&&width==0){
            not_zero=0;
        }

        for(i=0;i<height;i++){
            if(i%2==1){
                for(j=0;j<width;j++){
                    if(j%2==1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
                printf("\n");
            }else{
                for(j=0;j<width;j++){
                    if(j%2==1){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
                printf("\n");
            }
        }

        if(not_zero){
            printf("\n");
        }
    }
    
    return 0;
}


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

signed
main(){
		int N;
		cin >> N;
		vector<int> w(N);
		for(int i=0;i<N;i++)
				cin >> w[i];


		int ans = 100000;
		int left, right;
		for(int lmax=0;lmax<=N;lmax++)
		{
				left = 0, right = 0;
				for(int i=0;i<lmax;i++)
				{
						left += w[i];
				}
				for(int i=lmax;i<N;i++)
				{
						right += w[i];
				}
				ans = min(ans, abs(left-right));
		}
		cout << ans << endl;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    m1,d1=parseMap(split(readline()))
    m2,d2=parseMap(split(readline()))
    if m1+1==m2 && d2==1
        println(1)
    else
        println(0)
    end
end
main()

Measured memory_bytes: 110088
// B - Collatz Problem
// https://atcoder.jp/contests/abc116/tasks/abc116_b
// +build ignore

package main

import "fmt"

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func main() {
	var s, ans int
	fmt.Scan(&s)
	as := []int{}
	as = append(as, s)
	for i := 0; i < 1000000; i++ {
		if as[i]%2 == 0 {
			if contains(as, as[i]/2) {
				ans = i + 2
				break
			}
			as = append(as, as[i]/2)
		} else {
			if contains(as, (3*as[i])+1) {
				ans = i + 2
				break
			}
			as = append(as, (3*as[i])+1)
		}
	}
	fmt.Println(ans)
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> as(N);
  rep(i, N) cin >> as.at(i);
  
  int lit = 1;
  int next = as.at(lit-1);
  
  rep(i, N) {
    if (next == 2) {
      cout << i+1 << endl;
      return 0;
    }
    next = as.at(next-1);
  }
  
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 640
import sys
n,k=map(int,input().split())
w=list(map(int,sys.stdin.readlines()))
def f():
 c=t=0
 for j in w:
  t+=j
  if t>m:
   t=j
   c+=1
   if c>=k:return 0
 return 1
l,r=max(w),sum(w)
while l<r:
 m=(l+r)//2
 if f():r=m
 else:l=m+1
print(r)


Measured memory_bytes: 15824
n,m=map(int,input().split())
drink=[list(map(int,input().split())) for i in range(n)]
drink.sort(key=lambda i:i[0])

tot,cnt=0,0
for i in range(n):
  if cnt+drink[i][1]>=m:
    tot+=drink[i][0]*(m-cnt)
    break
  else:
    cnt+=drink[i][1]
    tot+=drink[i][0]*drink[i][1]

print(tot)

Measured memory_bytes: 29028
#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>0 && y>0 && x<=w-r && y<=h-r){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
def main2():
    X, K, D = map(int, input().split())

    X = abs(X)

    r, m = divmod(X, D)

    if r <= K:
        mi = X - D*r
        K -= r
    else:
        mi = X - D*K
        K = 0
    
    K = K % 2

    if K == 0:
        print(mi)
    else:
        print(min(abs(mi-D), abs(mi+D)))

if __name__ == "__main__":
    main2()

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

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

  map<string, int> n;
  for(int i = 0; i < N; i++){
    if(n.count(s.at(i)) > 0){
      n.at(s.at(i)) += 1;
    }else{
      n[s.at(i)] = 1;
    }
  }

  int m = 0;
  for(auto it = n.begin(); it != n.end(); it++){
    if(it->second > m){
      m = it->second;
    }
  }

  for(auto it = n.begin(); it != n.end(); it++){
    if(it->second == m){
      cout << it->first << endl;
    }
  }
}

Measured memory_bytes: 26752
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX
int dx[4] = {0,-1,0,1};
int dy[4] = {1,0,-1,0};
int con;
int h, w, v;

vector<string> field;
vector<vector<bool>> visited;

bool solve(int x = 0, int y = 0, int xd = 0, int yd = 0, int z = 0){

	int nx ,ny , rx , ry;
	
	if(z < v) return false;
	v |= z;
	if(x == 0 && y == 0 && visited[y][x] && z == 7) return true;
	if(visited[y][x] == true) return false;
			
	visited[y][x] = true;
	
	for(int i = 0; i < 16; i++){
		nx = x + dx[xd], ny = y + dy[yd], rx = nx + dx[(xd+1)%4], ry = ny + dy[(yd+1)%4];
		if(nx < 0 || nx >= w || ny < 0 || ny >= h || field[ny][nx] == '#' || ((ny == 0 && nx == 0)? 0:visited[ny][nx])){
			xd = (xd + 3)%4, yd = (yd + 3)%4;
			continue;
		}
		
		if(rx >= 0 && rx < w && ry >= 0 && ry < h && (field[ry][rx] == '.')) xd = (xd + 1)%4, yd = (yd + 1)%4;

		
		if(y == h-1 && x == 0) z |= (1<<0);
		if(y == h-1 && x == w-1) z |= (1<<1);
		if(y == 0 && x == w-1) z |= (1<<2);
		
		if(solve(nx, ny, xd, yd, z)) return true;
	}
	
	
	
	return false;
}
signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	
	
	while(true){
		v = 0;
		
		cin>>h>>w;
		if(!h && !w) break;
		
		field.clear();
		visited.clear();
		field.resize(h);
		visited.resize(h, vector<bool>(w, false));
		
		for(int i = 0; i < h; i++){
			cin>>field[i];
		}

		
		cout<<YN(solve())<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3324
N = int(input())
Hs = list(map(int,input().split()))

ans = 'Yes'
for i in range(N-1, 0, -1):
  if Hs[i-1] > Hs[i]:
    if Hs[i-1] - Hs[i] == 1:
      Hs[i-1] -= 1
      continue
    else:
      ans = 'No'
      break
print(ans)

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

int main(){
  int N;
  cin >> N;
  int64_t x,y,z,w;
  int64_t max_z=0;
  int64_t min_z=1e10;
  int64_t max_w=-1e10;
  int64_t min_w=1e10;
  for(int i=0;i<N;i++){
    cin >> x >> y;
    z=x+y;
    w=x-y;
    max_z=max(max_z,z);
    min_z=min(min_z,z);
    max_w=max(max_w,w);
    min_w=min(min_w,w);
  }
  cout << max(max_z-min_z,max_w-min_w) << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],cnt[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,k,i,j,x,y,z;
    cin>>n>>k;
    for (i=1;i<=n;i++)
    {
    	cin>>arr[i];
    	cnt[i]=-1;
	}
	cnt[1]=0;
	x=1;
	y=0;
	j=1;
	while (1)
	{
		if (cnt[arr[x]]!=-1)
		{
			j=arr[x];
			y++;
			z=cnt[arr[x]];
			break;
		}
		x=arr[x];
		cnt[x]=y+1;
		y++;
		if (y==k)
		{
			cout<<x<<endl;
			return 0;
		}
	}

	k=k-z;
	y=y-z;
	k=k%y;	
	for (i=0;i<k;i++)
	{
		j=arr[j];
	}
	cout<<j<<endl;
}

Measured memory_bytes: 6780
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int n = scan.nextInt();

		if (n == 0) {
			System.out.println(x);
			System.exit(0);
		}

		List<Integer> p = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			p.add(scan.nextInt());
		}

		int y1;
		int y2;

		for (int i = 0; i <= 100; i++) {
			y1 = x - i;
			y2 = x + i;

			if (p.contains(y1)) {
				if (p.contains(y2)) {

				} else {
					System.out.println(y2);
					break;
				}
			} else {
				System.out.println(y1);
				break;
			}
		}

		scan.close();

	}

}


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

using namespace std;

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

	string d[] = {"S", "H", "C", "D"};
	bool card[4][13];

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			card[i][j] = false;
		}
	}

	for (int i = 0; i < n; i++)
	{
		string s;
		int m;

		cin >> s >> m;

		int id;
		for (int j = 0; j < 4; j++)
		{
			if (s == d[j])
			{
				id = j;
				break;
			}
		}

		card[id][m - 1] = true;
	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			if (!card[i][j])
			{
				cout << d[i] << " " << j + 1 << endl;
			}
		}
	}
}


Measured memory_bytes: 3140
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
let arr = [...input];
let ans = "";
for (let i = 0; i < arr.length; i++) {
    if (arr[i] === arr[i].toLowerCase()) {
        ans += arr[i].toUpperCase();
    } else {
        ans += arr[i].toLowerCase();
    }
}
console.log(ans.trim());



Measured memory_bytes: 16140
def divisors(n)
  b = Array.new
  for i in 1..((n**0.5))
    if n % i == 0
      b.push(i)
    end
  end
  len = b.length
  len.times{|i|
    if n/b[len-1-i] != b[len-1-i]
      b.push(n/b[len-1-i])
    end
  }
  b
end

n = gets.to_i
sum = 0
1.upto(n) do |i|
  sum += 1 if divisors(i).length == 8 && i&1 == 1
end
puts sum

Measured memory_bytes: 14712
import math

N, D = map(int, input().split())
X = []
for i in range(N):
    x_i = list(map(int, input().split()))
    X.append(x_i)

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue

        x_i = X[i]
        x_j = X[j]

        cache = float(0)
        for d in range(D):
            cache += (x_i[d] - x_j[d]) ** 2

        cache = math.sqrt(cache)

        if cache.is_integer():
            ans += 1

print(ans)



Measured memory_bytes: 3064
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)2e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    string s, t;
    cin>>s>>t;
    int ans = 0;
    f(i, s.length()) {
        if(s[i] != t[i]) ans++;
    }
    cout<<ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3796
m,d = map(int,input().split())
ans = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        r = list(str(j))
        if len(r) >= 2:
            if int(r[0])*int(r[1]) == i and int(r[0]) >= 2 and int(r[1]) >= 2:
                ans += 1
                #print(i,j)
print(ans)

Measured memory_bytes: 70160
'use strict'



function Main(input) {

  input = input.trim().split('\n')
  const N = parseInt(input[0])
  const a = input[1].split(' ').map(s => parseInt(s))
  const res = a.reduce((a, b) => a + b) / a.length

  let min = 0
  let diff = 9999
  for(let i = 0; i < N; ++i) {
    if(res === a[i])  {
      min = i
      break
    }
    
    let tmp = Math.abs(res - a[i])

    if (diff > tmp) {
      diff = tmp
      min = i
    }

  }

  console.log(min)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
    string s;
    cin >> s;

    sort(s.begin(), s.end());

    char before = 'a' - 1;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == before) continue;

        if (before + 1 != s[i]) {
            before++;
            cout << before << endl;
            return 0;
        }

        before++;
    }

    if (before == 'z') {
        cout << "None";
    } else {
        before++;
        cout << before;
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=2e3+20;

int n,k,b[maxn][maxn],w[maxn][maxn],K;

int S(int opt,int x,int y,int xx,int yy)
{
	if(opt==1) return b[xx][yy]-b[xx][y-1]-b[x-1][yy]+b[x-1][y-1];
	if(opt==2) return w[xx][yy]-w[xx][y-1]-w[x-1][yy]+w[x-1][y-1];
}

void init()
{
	n=read();k=read();K=2*k;
	REP(i,1,n)
	{
		int x=read()%K+1,y=read()%K+1,col=0;
		char ch;scanf("%c",&ch);
		b[x][y]+=ch=='B'; 
		w[x][y]+=ch=='W'; 
	}
	REP(i,1,K)
	{
		REP(j,1,K)
		{
			b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
		}
	}
}

void doing()
{
	int ans=0,res=0;
	REP(x,1,k)
	{
		REP(y,1,k)
		{
			int b=1,w=2;
			res=S(b,1,1,x,y) + S(b,x+k+1,1,K,y) + S(b,x+k+1,y+k+1,K,K) +
				S(b,1,y+k+1,x,K) + S(b,x+1,y+1,x+k,y+k) +
				S(w,x+1,1,x+k,y) + S(w,x+k+1,y+1,K,y+k) + S(w,x+1,y+k+1,x+k,K) + S(w,1,y+1,x,y+k);
			ans=max(ans,res);
			res=S(w,1,1,x,y) + S(w,x+k+1,1,K,y) + S(w,x+k+1,y+k+1,K,K) +
				S(w,1,y+k+1,x,K) + S(w,x+1,y+1,x+k,y+k) +
				S(b,x+1,1,x+k,y) + S(b,x+k+1,y+1,K,y+k) + S(b,x+1,y+k+1,x+k,K) + S(b,1,y+1,x,y+k);
			ans=max(ans,res);
		}
	}
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}



Measured memory_bytes: 32000
n = input()
il = list(map(int, input().split()))
ans = 0
fin = 0

while fin < 1:
    cnt = 0
    for i in range(len(il)):
        if il[i] % 2:
            fin = 1
            break
        else:
            cnt += 1                                                                                              

    if cnt == len(il):
        for i in range(len(il)):
            il[i] = il[i] / 2
        ans += 1
    else:
        break

print(ans)

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

int main() {
    int n;
    vector<int> lis;
    vector<int> v;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back(a);
    }

    for (auto a: v) {
        auto it = lower_bound(lis.begin(), lis.end(), a);
        if (it != lis.end()) {
            *it = a;
        } else {
            lis.push_back(a);
        }
    }

    cout << lis.size() << endl;
}



Measured memory_bytes: 3796
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef hitorie
    freopen(".in", "r", stdin);
#endif        
}

const int flag = 0;

void maincode() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> was;
    for (int& x : a) {
        cin >> x;
        was[x]++;
    }   
    for (int i = 1; i <= n; ++i)
        cout << was[i] << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}

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

vector<int> G[100000];
int pre[100000];
int color[100000];

void dfs1(int v, int p){
	for(auto x : G[v]) {
		if(x == p) continue;
		pre[x] = v;
		dfs1(x, v);
	}
}

void dfs2(int v, int c){
	color[v] = c;
	for(auto x : G[v]) {
		if(color[x] == -1) {
			dfs2(x, c);
		}
	}
}

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

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

	dfs1(0, -1);
	vector<int> ord;
	for(int v = N - 1; v != 0; v = pre[v]) {
		ord.push_back(v);
	}
	ord.push_back(0);

	reverse(ord.begin(), ord.end());

	memset(color, -1, sizeof color);
	for(int i = 0; i < ord.size(); i++) {
		if(i < (ord.size() + 1) / 2) color[ord[i]] = 0;
		else color[ord[i]] = 1;
	}
	for(int i = 0; i < ord.size(); i++) {
		dfs2(ord[i], color[ord[i]]);
	}

	int b = 0, w = 0;
	for(int i = 0; i < N; i++) {
		assert(color[i] != -1);
		if(color[i] == 0) b++;
		else w++;
	}

	if(b > w) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}
}


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

using namespace std;

void Main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = A * X + B * Y;
    for (int i = 1; i <= max(X, Y); ++i) {
        int temp = A * max(0, X - i) + B * max(0, Y - i) + C * 2 * i;
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int n;
int Case=0;
char box[7][7][7];
char tmp[7][7][7];
int live[27];
int death[27];
void copy(){
	for(int x=0;x<7;x++){
		for(int y=0;y<7;y++){
			for(int z=0;z<7;z++){
				tmp[x][y][z]=box[x][y][z];
			}
		}
	}
}
void reset(){
	for(int x=0;x<7;x++){
		for(int y=0;y<7;y++){
			for(int z=0;z<7;z++){
				box[x][y][z]='2';
			}
		}
	}
}
void scan(){
	if(Case>0)cout<<endl;
	cout<<"Case "<<++Case<<":\n";
	for(int z=1;z<=5;z++){
		for(int y=1;y<=5;y++){
			for(int x=1;x<=5;x++){
				cin>>box[x][y][z];
			}
		}
	}
	for(int i=0;i<27;i++)live[i]=death[i]=0;
	int m,k;
	for(cin>>m;m--;){
		cin>>k;
		live[k]=1;
	}
	for(cin>>m;m--;){
		cin>>k;
		death[k]=1;
	}
}

int cnt(int X,int Y,int Z){
	int res=0;
	for(int x=X-1;x<=X+1;x++){
		for(int y=Y-1;y<=Y+1;y++){
			for(int z=Z-1;z<=Z+1;z++){
				if(x==X && y==Y && z==Z)continue;
				if(tmp[x][y][z]=='1')res++;
			}
		}
	}
	return res;
}

void cal(){
	copy();
	for(int x=1;x<=5;x++){
		for(int y=1;y<=5;y++){
			for(int z=1;z<=5;z++){
				int c=cnt(x,y,z);
				if(tmp[x][y][z]=='0'){
					if(live[c])box[x][y][z]='1';
				}
				else{
					if(death[c]==0)box[x][y][z]='0';
				}
				
			}
		}
	}
}
void print(){
	for(int z=1;z<=5;z++){
		if(z>1)cout<<endl;
		for(int y=1;y<=5;y++){
			for(int x=1;x<=5;x++){
				cout<<box[x][y][z];
			}
			cout<<endl;
		}
	}
}

int main(){
	
	while(cin>>n,n){
		reset();
		scan();
		while(n--)cal();
		print();
	}
	
	return 0;
}


Measured memory_bytes: 1164
#include<stdio.h>
#include<string.h>

int main(){

  int sum,a,b;
  char x[1000];

  scanf("%s",x);

  while(x[0]!='0'){

    sum=0;
    b=strlen(x);
    for(a=0;a<b;a++){
      sum=sum+x[a]-48;
    }

    

    printf("%d\n",sum);
    
    scanf("%s",x);
  }
  return 0;
}
    
    
    



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

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


Measured memory_bytes: 256