akhauriyash/Code-Regression huggingface dataset:
// B - Tap Dance
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; cin>>S;
	string ans = "Yes";
	for(int i=0; i<S.size(); ++i)
		if((i%2==1 && S[i]=='R') || (i%2==0 && S[i]=='L')){ ans = "No"; break; }
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

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

  vector<string> D(K);
  for(int i = 0; i < K; i++) {
    cin >> D[i];
  }

  for(int i = N; i < 100000; i++) {
    string s = to_string(i);
    bool fflag = true;
    bool flag;
    for(int j = 0; j < s.size(); j++) {
      flag = false;
      for(int k = 0; k < K; k++) {
	if(s[j] == D[k][0]) {flag = true; break;}
      }
      if(flag) {fflag = false; break;}
    }
    if(fflag) {cout << i << endl; return 0;}
  }

  cout << N << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 36
int isStable(char in[N][2],char out[N][2],int n){
  int i,j,a,b;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
    for(b=a+1;b<n;b++){
      if(in[i][1]==in[j][1] && in[i][0]==out[b][0] && in[j][0] == out[a][0] && in[i][1]==out[b][1] && in[j][1] == out[a][1]){
        return 0;
      }
    }
      }
    }
  }
  return 1;
}
int main(){
  int i,n,j,min;
  char a[N][2],b[N][2],c[N][2],d[3]; 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
    strncpy(b[i],a[i],2);
    strncpy(c[i],a[i],2);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(b[j][1] <b[j-1][1]){    
    strncpy(d,b[j],2);
    strncpy(b[j],b[j-1],2);
    strncpy(b[j-1],d,2);
      }
    }
  }
  for(i=0;i<n;i++){
    if(i<n-1) printf("%c%c ",b[i][0],b[i][1]);
    else printf("%c%c\n",b[i][0],b[i][1]);
  }
  if(isStable(&a[0],&b[0],n)==0) printf("Not stable\n");
  else printf("Stable\n");
     for(i=0;i<n;i++){
      min=i; 
      for(j=i;j<n;j++){
    if(c[j][1]<c[min][1]) min=j;
      }
      if(i==min) continue;
       strncpy(d,c[i],2);
       strncpy(c[i],c[min],2);
       strncpy(c[min],d,2);
      }
    for(i=0;i<n;i++){
      if(i<n-1) printf("%c%c ",c[i][0],c[i][1]);
      else printf("%c%c\n",c[i][0],c[i][1]);
    }
    if(isStable(&a[0],&c[0],n)==0) printf("Not stable\n");
    else printf("Stable\n");
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        vi v(3);
        rep(i,3)cin>>v[i];
        sort(all(v));
        bool flag=false;
        if(v[0]==5)if(v[1]==5)if(v[2]==7)flag=true;
        cout<<(flag?"YES":"NO")<<endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
// typedef vector vec;

ll mod = 1e9 + 7;

#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
// cout<<endl;


int main()
{
	fastio();
	int a, b;
	cin>>a>>b;
	int ma = max(a, b);
	int mi = min(a, b);
	rep(i, ma) cout<<mi;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
const int BUF = 10005;
const int MOD = 1000000007;


int modPow(int p, int n) {
    if (n == 0) return 1;
    int t = modPow(p, n / 2);
    return n % 2 == 0 ? 1LL * t * t % MOD : 1LL * t * t % MOD * p % MOD;
}


int nVal;
int val[BUF];

void read() {
    cin >> nVal;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}


void work() {
    map<int, int> factor2cnt[BUF];

    for (int loop = 0; loop < nVal; ++loop) {
        int v = val[loop];
        for (int i = 2; i * i <= v; ++i) {
            if (v % i == 0) {
                int cnt = 0;
                while (v % i == 0) {
                    v /= i;
                    ++cnt;
                }
                factor2cnt[loop][i] = cnt;
            }
        }
        if (v > 1) factor2cnt[loop][v] = 1;
    }

    map<int, int> maxFactor2cnt;
    for (int i = 0; i < nVal; ++i) {
        for (map<int, int>::iterator iter = factor2cnt[i].begin(); iter != factor2cnt[i].end(); ++iter) {
            if (!maxFactor2cnt.count(iter->first)) {
                maxFactor2cnt[iter->first] = 0;
            }
            maxFactor2cnt[iter->first] = max(maxFactor2cnt[iter->first], iter->second);
        }
    }

    int base = 1;
    for (map<int, int>::iterator iter = maxFactor2cnt.begin(); iter != maxFactor2cnt.end(); ++iter) {
        for (int loop = 0; loop < iter->second; ++loop) {
            base = 1LL * base * iter->first % MOD;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < nVal; ++i) {
        int toAdd = base;
        for (map<int, int>::iterator iter = factor2cnt[i].begin(); iter != factor2cnt[i].end(); ++iter) {
            int toRepeat = iter->second;
            int inv = modPow(iter->first, MOD - 2);
            for (int j = 0; j < toRepeat; ++j) {
                toAdd = 1LL * toAdd * inv % MOD;
            }
        }
        ans = (ans + toAdd) % MOD;
    }

    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

using namespace std;

long long prime = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s != "AAA" && s != "BBB") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

const ll MAX = 200010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// NのP乗をMで割った余りを返す
ll pow_mod(ll n,ll k,ll m){
  if(k==0){
    return 1;
  }else if(k%2==1){
    return pow_mod(n,k-1,m)*n%m;
  }else{
    ll t=pow_mod(n,k/2,m);
    return (t*t)%m;
  }
}

//(10*9*8)/(3*2*1);
//10*9*8 -> ansMul
//3*2*1 -> ansDiv
long long calcComb(ll a, ll b) {
	if (b > a - b) return calcComb(a, a - b);


	ll ansMul = 1;
	ll ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}
	//ansMul / ansDivをやりたい
	//ansDivの逆元を使って求めよう！

	ll ans = ansMul * pow_mod(ansDiv,MOD - 2,MOD);
	return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll H,W,A,B;
  cin >> H >> W >> A >> B;
  ll ans=0;
  COMinit();
  for(int i=1;i<=H-A;i++){
    ans+=(COM(i-1+B-1,i-1)*COM(H+W-B-i-1,H-i)%MOD);
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
import numpy as np
[H,W,A,B] = list(map(int,input().split()))

output = np.zeros((H,W))
output[0:(H-B),0:A]=1
output[(H-B):,A:]=1

for i in range(H):
    out = ""
    for j in range(W):
        out += str(int(output[i,j]))
    print(out)

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

using namespace std;

long long dfs(int n, int r,
        vector<int>& ri, vector<vector<long long>>& graph,
        long long cur_d, int cur_r, int cur_pos) {
    if (cur_r == (1 << r) - 1) {
        return cur_d;
    }

    long long res = (1LL << 48);
    for (int i = 0; i < r; i++) {
        if ((cur_r & (1 << i)) == 0) {
            res = min(res, dfs(n, r, ri, graph,
                    cur_pos == -1 ? 0 : cur_d + graph[cur_pos][ri[i]], cur_r | (1 << i), ri[i]));
        }
    }

    return res;
}

int main() {
    int n, m, r;
    cin >> n >> m >> r;

    vector<int> ri(n);
    for (int i = 0; i < r; i++) {
        cin >> ri[i];
        ri[i]--;
    }

    vector<vector<long long>> graph(n, vector<long long>(n, (1LL << 48)));
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        graph[a - 1][b - 1] = c;
        graph[b - 1][a - 1] = c;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (graph[j][k] > graph[j][i] + graph[i][k]) {
                    graph[j][k] = graph[j][i] + graph[i][k];
                }
            }
        }
    }

    cout << dfs(n, r, ri, graph, 0, 0, -1) << endl;
}


Measured memory_bytes: 512
fun main(args:Array<String>):Unit {
    var num = readLine()!!.trim().toInt()
    var weight = maxWeight(num)
    while (weight != 0){
        print(
                when{
                    (weight - 1) / 2 < num -> {
                        num -= weight
                        '+'
                    }
                    (-weight + 1) / 2 > num -> {
                        num += weight
                        '-'
                    }
                    else -> '0'
                }
        )
        weight /= 3
    }
    println()
}
fun maxWeight(num:Int):Int {
    var n = num * 2
    var res = 1
    while (n != 0){
        n /= 3
        res *= 3
    }
    return res / 3
}


Measured memory_bytes: 30676
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> c(n-1), s(n-1), f(n-1);
    rep(i, n-1) {
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i, n-1) {
        ll time = 0;
        for (int j = i; j < n-1; j++) {
            time = max(time, s[j]);
            time += (f[j] - ((time - s[j]) % f[j])) % f[j];
            time += c[j];
        }
        cout << time << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
string inc(string s) {
  int mi = -1;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] != '0') mi = i;
  }
  int id = -1;
  for (int i = 0; i < n; i++) {
    // i 桁めをインクリメントするには
    if (s[i] == '9') continue;

    int n1 = (int)(s[i + 1] - '0');
    int n2 = (int)(s[i] - '0') + 1;
    if (i >= mi or (int)abs(n1 - n2) <= 1) {
      s[i]++;
      id = i;
      break;
    } else continue;
  }
  
  for (int i = id - 1; i >= 0; i--) {
    s[i] = s[i + 1];
    s[i]--;
    if (!('0' <= s[i] and s[i] <= '9')) s[i] = '0';
  }
  return s;
}

int main() {
  
  string n = "100000000000000";
  int k; cin >> k;
  for (int i = 0; i < k - 1; i++) {
    n = inc(n);
    string a = n;
    reverse(ALL(a));
  }


  reverse(ALL(n));
  cout << stoll(n) << endl;
  return 0;
}


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

int n, a[100005], dp[100005];

int main() {
  int n, k; cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    dp[i] = 0x3f3f3f3f;
   	for (int j = max(1, i - k); j < i; j++)
      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {
	int a, b;	cin >> a >> b;
	int dif = 0;
	int sum = 0;

	dif = b - a;

	for (int i = 1; i < dif; i++) {
		sum += i;
	}

	cout << sum - a << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
hs = tuple(map(int, input().split()))

a, b = 0, abs(hs[1] - hs[0])

for i in range(2, n):
  c = hs[i]
  a, b = b, min(a + abs(c - hs[i-2]), b + abs(c - hs[i-1]))

print(b)


Measured memory_bytes: 14236
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned short int uns;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define pb push_back
#define mp make_pair
#define pf push_front
#define fi first
#define se second
#define sqr(a) ((a) * (a))
#define pi 3.1415926535897932
#define eps 0.0000001
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define vpp vector<pii>

using namespace std;

int n, m, k;

int main()
{
    int x;
    cin >> n >> m >> x;
    vector<int> cnt(n + 1);
    for(int i = 1;i <= m;i++){
        int a;
        cin >> a;
        cnt[a] = 1;
    }
    int ans = 0, res = 0;
    for(int i = x;i <= n;i++)
        ans += cnt[i];
    for(int i = x;i >= 0;i--)
        res += cnt[i];

    cout << min(ans, res);

    return 0;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main() {
  int H,W;
  cin>>H>>W;
  int dp[10][10];
  rep(i,10){
    rep(j,10){
      dp[i][j]=10000001;
    }
  }
  int c;
  rep(i,10){
    rep(j,10){
      cin>>c;
      dp[i][j]=c;
    }
  }

  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
}
ll ans=0;
int A;
rep(i,H){
  rep(j,W){
    cin>>A;
    if(A!=-1){
    ans+=dp[A][1];
    }
  }
}
cout<<ans<<endl;
return 0;
}




Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

int main()
{
	int n, m; cin >> n >> m;
	int res = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << res << endl;
}

Measured memory_bytes: 256
let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let ns = [|a; b|]
let _ = for i = 0 to k - 1 do let r = i mod 2 in ns.(1 - r) <- ns.(1 - r) + ns.(r) / 2; ns.(r) <- ns.(r) / 2 done;
  Printf.printf "%d %d\n" ns.(0) ns.(1)

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    string s,s1="erase",s2="dream";
    cin>>s;
    
    for(int i=0;i<s.size();i+=5){ //5文字飛ばし
        
        if(s[i]!='e'&&s[i]!='d'){
            cout<<"NO"<<"\n";
            return 0;
        }
        if(s[i]=='e'){
            for(int j=0;j<5;j++){
                if(i+j==s.size()||s[i+j]!=s1[j]){
                    cout<<"NO"<<"\n";
                    return 0;
                }
            }
            //eraseまで一致
            if(i+5<=s.size()-1&&s[i+5]=='r')i++; //六文字飛ばしさせる
        }else if(s[i]=='d'){
            for(int j=0;j<5;j++){
                if(i+j==s.size()||s[i+j]!=s2[j]){
                    cout<<"NO"<<"\n";
                    return 0;
                }
            }
            //dreamまで一致
            if((i+7<=s.size()-1&&s[i+5]=='e'&&s[i+6]=='r'&&s[i+7]!='a')||(i+6==s.size()-1&&s[i+5]=='e'&&s[i+6]=='r'))i+=2; //六文字飛ばしさせる
        }
        
    }
    cout<<"YES"<<"\n";
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

string s;

int main(){

    cin >> s;

    for(int i = 0; i < s.length(); i = i + 2){
        cout << s[i];
    }


}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 512
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
a = a.sort
INF = (10 ** 6)
arr = Array.new(INF+1,0)
a.each do |i|
    if arr[i] == 2
        next 
    end
    sa = i
    while i < 10 ** 6 + 1
        arr[i] += 1 
        i += sa
    end
end
count = 0
a.each do |i|
    if arr[i] == 1
        count += 1
    end
end
puts count

Measured memory_bytes: 39840
let [| A; B; C |] = stdin.ReadLine().Split() |> Array.map int
let K = stdin.ReadLine() |> int

let rec solver x y i =
    if x < y then i
    else solver x (y * 2) (i + 1)

let s1 = solver A B 0
let s2 = solver (B <<< s1) C 0

if s1 + s2 <= K then "Yes"
else "No"
|> stdout.WriteLine


Measured memory_bytes: 28016
int D[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
struct{int x,y;}m[200];
main(i,N,mx,my,Mx,My,n,d){
	for(;scanf("%d",&N),N;printf("%d %d\n",Mx-mx+1,My-my+1)){
		m[0].x=m[0].y=Mx=mx=My=my=0;
		for(i=1;i<N;i++){
			scanf("%d%d",&n,&d);
			m[i].x=m[n].x+D[d][0],m[i].y=m[n].y+D[d][1];
			if(Mx<m[i].x)Mx=m[i].x;
			if(mx>m[i].x)mx=m[i].x;
			if(My<m[i].y)My=m[i].y;
			if(my>m[i].y)my=m[i].y;
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int min(int a, int b){
	if(a<b)return a;
	else return b;
}

ll gcd(ll a, ll b){
	if(b == 0)return a;
	return gcd(b,a%b);
}


int main(void){
	string s;
	cin>>s;
	int cnt1=0,cnt2=0;
	int n=s.length();
	rep(i,n){
		if(i%2==0 && s[i]=='0')cnt1++;
		else if(i%2==1 && s[i]=='0')cnt2++;
	}

	int ans=n/2+n%2-cnt1+cnt2;
	if(ans > cnt1+n/2-cnt2)ans=cnt1+n/2-cnt2;
	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 512
N, K = map(int, input().split())

def expectation(pp):
    return 1 + (0.5 * (pp - 1))

p = list(map(int, input().split()))
ep = tuple(map(expectation, p))

cum = [0]
cum_append = cum.append
for i in range(N):
    cum_append(cum[i] + ep[i])

result = 0

for i in range(0, N - K + 1):
    tmp = cum[i + K] - cum[i]
    result = max(result, tmp)
    
print(result)



Measured memory_bytes: 83336
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL H,W;
int main()
{
    cin >> H >> W;
    LL sol = (H * W + 1) / 2;
    if(H == 1 || W == 1){
        cout << 1;
        return 0;
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    string t;
    for (int i = 0; i < n; ++i)
        t += v[i];
    cout << t << endl;
}

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

using namespace std;

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

class Graph{
public:
  int v;
  vector<int> visited,visiting;
  vector<int> e[100];
  Graph(int m){
    v = m;
    visited = vector<int>(v);
    visiting = vector<int>(v);
  }

  void addEdge(int e1,int e2){
    if (find(e[e1].begin(),e[e1].end(),e2)==e[e1].end()){
      e[e1].push_back(e2);
    }
  }

  int dfs(int vv){
    int ret = 0;
    visited[vv] = 1;
    visiting[vv] = 1;
    rep(i,e[vv].size()){
      if(!visited[e[vv][i]]){
        ret += dfs(e[vv][i]);
      } else if (visiting[e[vv][i]]==1){
        return 1;
      }
    }
    visiting[vv] = 0;
    return ret;
  }
  int isDAG(){
    rep(i,v){
      int m = dfs(i);
      if (m>0){
        return 1;
      }
    }
    return 0;
  }
};

int main(){

  int v,e;
  cin >> v >> e;
  Graph g(v);
  rep(i,e){
    int e1,e2;
    cin >> e1 >> e2;
    g.addEdge(e1,e2);
  }
  cout << g.isDAG() << endl;

  return 0;
}



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

using namespace std;

int main()
{
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2])
			|| (s[2] == s[3] && s[1] == s[2])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e5 + 9, OO = (int) 1e6 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(0);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void READ() {
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
}
int n, heights[N], mem[N];

ll dp(int i) {
	if (i >= n)
		return OO;
	if (i == n - 1)
		return 0;
	if (mem[i] != -1)
		return mem[i];
	ll a = dp(i + 1) + abs(heights[i] - heights[i + 1]);
	ll b = dp(i + 2) + abs(heights[i] - heights[i + 2]);
//	cout << i << " " << a << " " << b << el;
	mem[i] = min(a, b);
	return mem[i];

}

int main() {
//	READ();
	OUTPUT();
	clr(mem, -1);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> heights[i];
	}
	cout << dp(0);

	return 0;

}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)

int main() {
    // your code goes here
    ll h,w;
    cin >> h >> w;
  if(h==1||w==1) cout << "1" << endl;
  else  if(h%2==0||w%2==0) cout << (h*w)/2;
    else cout << (h*w+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int32;

namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			var n = ri;
			var k = ri;
			var ans = 0;
			for (int i = 1; i <= n; i++)
				if (ri >= k) ans++;
			Console.WriteLine(ans);

		}
		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });
		var solver = new Program.Solver();
		/* 
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//*/
		solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion


Measured memory_bytes: 15176
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s, t, u; int a, b;

void solve()
{
    cin >> s >> t >> a >> b >> u;
    if (u==s) {
        sout(a-1); nout(b);
    }else{
        sout(a); nout(b-1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int count = 0, n = s.size()/2, size = s.size();
    char a,b;
    for(int i=0; i<n; i++){
        if(s.at(i) != s.at(size-1-i)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] value = new int[n];
		int[] cost = new int[n];
		
		for(int i=0; i<n; i++) {
			value[i] = sc.nextInt();
		}
		
		for(int i=0; i<n; i++) {
			cost[i] = sc.nextInt();
		}
		
		int[] nums = new int[n];
		
		for(int i=0; i<n; i++) {
			nums[i] = value[i] - cost[i];
		}
		
		int sum = 0;
		
		for(int i=0; i<n; i++) {
			if(nums[i] > 0) {
				sum += nums[i];
			}
		}
		
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
import sys
from collections import deque
N,K=map(int, sys.stdin.readline().split())

al=[ [] for _ in range(N+1) ]	#隣接リスト
for _ in range(N-1):
    a,b=map(int, sys.stdin.readline().split())
    al[a].append(b)
    al[b].append(a)
   
mod=10**9+7
ans=1

#dfs
start=1
Visit=[ 0 for _ in range(N+1) ] #訪問した頂点
q=deque()
q.append((start,K)) #(現在位置、使用できる色の数)
Visit[start]=1

while q:
    fro,k=q.pop()
    ans*=k  #答えに使用できる色の通り数をかける
    ans%=mod
    if fro==1:  #ルートノードの時は
        num=K-1
    else:       #ルートノードじゃない時は
        num=K-2  #K-2色使用できる
    for to in al[fro]:
        if Visit[to]==0:
            Visit[to]=1	#訪問済みVisitに1をセットする。4行上のpopleftの直後でVisitをセットすると同じ頂点がqに入り、TLEする
            q.append((to,num))
            num-=1
print ans

Measured memory_bytes: 52764
n = int(input())
w = []
for i in range(n):
    w.append(input())
a = 1

import collections

for i in range(n):
    if i < n-1:
        if w[i][-1] == w[i+1][0]:
            a = a
        else:
            a = 0

c = collections.Counter(w)
if c.most_common()[0][1] > 1:
    a = 0
else:
    a = a

if a == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int n,c;

vector<vector<int>> d(30+1,vector<int>(30+1));
vector<int> mod0(30 + 1,0);
vector<int> mod1(30 + 1,0);
vector<int> mod2(30 + 1,0);

ll calc(int x,int y,int z){
	ll ans = 0;
	for(int i = 1; i <=c; i++) {
		ans += mod0[i] * d[i][x];
		ans += mod1[i] * d[i][y];
		ans += mod2[i] * d[i][z];
	}
	return ans;
}

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

	for(int i = 1; i <= c; i++) {
		for(int j = 1; j <=c; j++) {
			cin>>d[i][j];
		}
	}

	
	int x;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			cin>>x;
			if ((i + j) % 3 == 0){
				mod0[x]++;		
			}
			else if ((i + j) % 3 == 1){
				mod1[x]++;
			}
			else{
				mod2[x]++;
			}
		}
	}
	ll ans = LINF;
	for(int i = 1; i <= c; i++) {
		for(int j = 1; j <= c ; j++) {
			for(int k = 1; k <= c; k++) {
				if (i != j && j != k && i != k){
					ans = min(ans,calc(i,j,k));
				}
			}
		}
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		while(true){
			int x = stdin.nextInt();
			int h = stdin.nextInt();
			if(x != 0 && h != 0) {
				double s = x*Math.sqrt(4*h*h+x*x) + x*x;
				System.out.println(s);
			} else{
				break;
			}
		}

	}
}

Measured memory_bytes: 26188
#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;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

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

	string s;
	cin >> s;
	if(s.back() == 's') {
		cout << s << "es";
	}
	else {
		cout << s << "s";
	}

	return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");

        int num1 = Integer.parseInt(line[0]);
        int num2 = Integer.parseInt(line[1]);
        ArrayList<Integer> aryNum = new ArrayList<Integer>();
        int[] totalCol = new int[num2];

        for(int i = 0; i < num1; i++){
        	String[] input = br.readLine().split(" ");
        	int total = 0;
        	for(int j = 0; j < num2; j++){
        		total += Integer.parseInt(input[j]);
        		aryNum.add(Integer.parseInt(input[j]));
        		totalCol[j] += Integer.parseInt(input[j]);
        	}
        	aryNum.add(total);
        }

        int count = 1;
        int lastTotal = 0;
        for(int num : aryNum){

        	System.out.print(num);
        	if(count % (num2 + 1) == 0){
        		lastTotal += num;
        		System.out.println();
        	}else{
        		System.out.print(" ");
        	}
        	count++;
        }

        for(int num : totalCol){
        	System.out.print(num + " ");
        }
        System.out.println(lastTotal);

    }
}

Measured memory_bytes: 31304
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto s = read!(string).array;
    if (s.length == 3) {
        s.reverse();
    }
    writeln(s);
}


Measured memory_bytes: 256
import sys
n = map(int, raw_input().split())
x = map(int, raw_input().split())
if n[0]>n[1]:
    print(0)
else:
    x.sort()
    ma = max(x)
    mi = min(x)
    z=[]
    for y in range(len(x)-1):
        z.append(x[y+1]-x[y])
    z.sort()
    z.reverse()
    z=z[:n[0]-1]
    print(ma-mi-sum(z))


Measured memory_bytes: 11252
N = int(input())

arr = [0 for _ in range(N+1)]
for x in range(1,N+1):
    F1 = True
    for y in range(x,N+1):
        F2 = True
        for z in range(y,N+1):
            n = (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)
            if n > N:
                if y == z:
                    F2 = False
                break
            else:
                if x == y and y == z:
                    arr[n] += 1
                elif (x == y) or (y == z) or (z == x):
                    arr[n] += 3
                else:
                    arr[n] += 6
        if F2 == False:
            if x == y:
                F1 = False
            break
    if F1 == False:
        break

for i in arr[1:]:
    print(i)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
  int n, m;
  cin >> n;
  vector<string> s;
  map<string,int> d;
  string x;

  rep(i,n) {
    cin >> x;
    s.push_back(x);
    d[x]++;
  }
  cin >> m;
  rep(i,m) {
    cin >> x;
    s.push_back(x);
    d[x]--;
  }

  int ans = 0;
  rep(i,n+m) {
    string k = s[i];
    ans = max(ans,d[k]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
import Data.Char (isUpper)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BSC8

readString :: ByteString -> [String]
readString = map BSC8.unpack . BSC8.words

getString :: IO [String]
getString = readString <$> BSC8.getLine

main :: IO ()
main = do
  [(s:ss)] <- getString
  if isUpper s
    then putStrLn "A"
    else putStrLn "a"

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

template<int SZ>
struct SegmentTree {
    int n;
    long long st[2*SZ];

    SegmentTree() {
        memset(st, 128, sizeof(st));
    }

    void init(int _n) {
        n = _n;
    }

    long long query(int l, int r) {
        long long ret = -1e18;
        for (l+=n, r+=n; l<r; l>>=1, r>>=1) {
            if (l&1) ret = max(ret, st[l++]);
            if (r&1) ret = max(ret, st[--r]);
        }
        return ret;
    }

    void update(int p, long long val) {
        p += n;
        for (st[p]=max(st[p], val); p>1; p>>=1)
            st[p>>1] = max(st[p], st[p^1]);
    }
};

pair<int, int> a[200005];
SegmentTree<200005> up, down;

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

    int n;
    cin >> n;
    map<int, int> compress;
    for (int i=0; i<n; i++) {
        cin >> a[i].first >> a[i].second;
        compress[a[i].second];
    }

    sort(a, a + n);
    int idx = 0;
    for (auto &p : compress)
        p.second = idx++;

    up.init(n);
    down.init(n);
    long long ret = 0;
    for (int i=0; i<n; i++) {
        int y = compress[a[i].second];
        ret = max({ret, a[i].first - a[i].second + up.query(y, n), a[i].first + a[i].second + down.query(0, y)});
        up.update(y, a[i].second - a[i].first);
        down.update(y, -a[i].first - a[i].second);
    }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 20784
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,x;
		int count = 0;
		while(true){
			n = sc.nextInt();
			x = sc.nextInt();
			if(n==0&&x==0)break;
			for(int i=1;i<=n-2;i++){
				for(int j=i+1;j<=n-1;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
			count=0;
		}
	}
}



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

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

const ll INF = 1e12;

ll W, H, x, y;

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

Measured memory_bytes: 256
from fractions import gcd

n = int(input())
a_l =[int(i) for i in input().split()]

left=[0]
right=[0]

for i in range(1,n+1):
    left.append(gcd(left[i-1],a_l[i-1]))
    right.append(gcd(right[i-1],a_l[n-i]))
right=right[::-1]

ans=1
for i in range(n):
    ans=max(ans,gcd(left[i],right[i+1]))
print(ans)

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(void){
    string L; cin >> L;
    int N = L.size();
    mint dp[N+1][2];
    dp[0][0] = 1;
    REP(i,N){
        if(L[i]=='0') dp[i+1][0] = dp[i][0];
        else dp[i+1][0] = dp[i][0]*2;
        dp[i+1][1] = dp[i][1]*3;
        if(L[i]=='1') dp[i+1][1] += dp[i][0];
    }
    mint ans = dp[N][0] + dp[N][1];
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 2048
n = int(input())
p = list(map(int,input().split()))


count = 0

for i in range(1,n-1):
    ppp = [p[i-1], p[i], p[i+1]]
    
    if ppp[1] != max(ppp) and ppp[1] != min(ppp):
        count+=1

print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef unsigned long long Long;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int n;
  cin >> n;
  n *= 2;
  vector<int> v(n);
  for (int& x : v) {
    cin >> x;
  }

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

  int res = 0;
  for (int i = 0; i < v.size(); i += 2) {
    res += v[i];
  }

  cout << res;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    long sum = 0;
    rep(i, 0, N)
    {
        cin >> X[i];
        sum += X[i];
    }
    double p;
    p = sum / (double)N;
    p += 0.5;
    int p2 = p;
    double ans = 0;
    rep(i, 0, N)
    {
        ans += abs(p2 - X[i]) * abs(p2 - X[i]);
    }

    cout << (int)ans << endl;
}


Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")



N = int(sys.stdin.readline())
ans =1
while ans * 2 <=N:
    ans *= 2
print(ans)




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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

// a^b
ll mypow(ll a, ll b) {
    if (b == 0) return 1;
    ll tmp = mypow(a, b / 2);
    if (b % 2) return (((tmp*tmp) % MOD)*a) % MOD;
    else return (tmp*tmp) % MOD;
}
 
// nCk
ll comb(ll n, ll k) {
    ll res = 1;
    k = min(n - k, k);
    for (ll i = n - k + 1; i <= n; i++) res = (res*i) % MOD;
    for (ll i = 1; i <= k; i++)res = (res*mypow(i, MOD - 2)) % MOD;
    return res;
}

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

    ll n,d,x;
    while(cin>>n>>d>>x, n){
        vector<vector<ll>> dp(2222,vector<ll>(2222,0));
        dp[0][0]=1;
        vector<ll> sum(2222,0);
        d%=MOD;
        for(int i=1;i<=min(d,n);i++){
            sum[0]=dp[i-1][0];
            for(int j=1;j<=n;j++){
                sum[j]=sum[j-1]+dp[i-1][j];
                sum[j] %= MOD;
                //cout<<sum[j]<<endl;
            }
            for(int j=1;j<=n;j++){
                dp[i][j]=sum[j-1];
                dp[i][j]+=MOD;
                if(j-x>=0) dp[i][j]-=sum[j-x];
                dp[i][j]%=MOD;
            }
        }
        ll res=0;
        for(int i=1;i<=min(d,n);i++){
            //cout<<dp[i][n]<<endl;
            res += dp[i][n] * comb(d,i);
            res %= MOD;
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 41632
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N,K;
        String S;
        N = sc.nextInt();
        K = sc.nextInt();
        S = sc.next();
        String[] array = S.split("",0);
        for (int i = 0; i < N; i++) {
            if (i==K-1) array[i] = array[i].toLowerCase();            
            System.out.print(array[i]);
        }
    }
}

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

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

	map<int , int > m;
	for (int i = 1 ; i < n ; i++){
		int x;
		cin >> x;
		m[x]++;
	}

	for (int i = 1 ; i <= n ; i++){
		cout << m[i] << endl;
	}
	
	return 0;
}



Measured memory_bytes: 13008
import java.util.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		double [][] dp=new double [n+1][n];
		double [] p=new double [n];
		for(int i=0;i<n;i++)
		{
			p[i]=in.nextDouble();
		}
		dp[0][0]=1.0d-p[0];
		dp[1][0]=p[0];
		for(int i=1;i<n;i++)
		{
			dp[0][i]=dp[0][i-1]*(1.0000000000d-p[i]);
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<n;j++)
			{
				dp[i][j]=dp[i-1][j-1]*p[j]+dp[i][j-1]*(1.0000000000d-p[j]);
			}
		}
		Double ans=0.0;
		for(int i=n/2+1;i<=n;i++)
		{
			ans=ans+dp[i][n-1];
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 133924