akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
#define B(v) v.begin(), v.end()
int main()
{	
	ll n;
	cin>>n;
	ll a[n+10];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i && i<n)
		{
			swap(a[i],a[i+1]);
			ans++;
		}
		else if(a[i]==i && i==n)
		{
			swap(a[i],a[i-1]);
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n+1];
        for (int i=0; i<n+1; i++) arr[i] = sc.nextInt();

        long[] max = new long[n+1];
        max[0] = 1 - arr[0];
        if (max[0] < 0) {
            System.out.println(-1);
            return;
        }

        long INF = (long)1e14;
        for (int i=1; i<n+1; i++) {
            if (max[i-1]*2 - arr[i] < 0) {
                System.out.println(-1);
                return;
            }
            if (max[i-1]*2 - arr[i] > INF) {
                for (int j=i; j<n+1; j++) {
                    max[j] = INF;
                }
                break;
            } else {
                max[i] = max[i-1]*2 - arr[i];
            }
        }

//        System.out.println(max[n]);

        long sum = 0;
        long ans = 0;
        for (int i=n; 0<=i; i--) {
            sum = Math.min(sum, max[i]);
            ans += (sum+arr[i]);
            sum += arr[i];
//            System.out.println(sum);
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 58996
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
const int MOD = 1000000007;

template<typename T>
T mod_pow(T x, T n, T mod=MOD){
    T res = 1;
    while(n>0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int N;
ll A1[61], A0[61];
int main(void){
    cin >> N;
    REP(j,N){
        ll A;
        cin >> A;
        for(int i=0;i<=60;i++){
            if(A%2==0) A0[i]++;
            else A1[i]++;
            A /= 2;
        }
    }

    ll count = 0;
    for(ll i=0;i<=60;i++){
        ll r = mod_pow((ll)2, i);
        count += (((A1[i]*A0[i])%MOD)*(r%MOD))%MOD;
        count %= MOD;
    }
    cout << count % MOD << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 3e5 + 1;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue

int n, k;
ll ans;
int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        if((i + i) % k == 0){
            ll p = (i % k);
            ll cur = (n + p) / k;
            ll q = k - p;
            ans += (cur * ((n + q) / k));
            if(p == 0){
                ans -= cur;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int k,s,i,j,d,ans;
  ans = 0;
  cin >> k >> s;
  for (i=0;i<=k;i++) {
    for (j=0;j<=k;j++) {
      d = s-i-j;
      if (0<=d && d<=k) ans += 1;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int a[5], k;

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

    cin >> k;

    if (abs(a[0] - a[1]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[0] - a[2]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[0] - a[3]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[0] - a[4]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[1] - a[2]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[1] - a[3]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[1] - a[4]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[2] - a[3]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[2] - a[4]) > k) {
        cout << ":(" << endl;
    }
    else if (abs(a[3] - a[4]) > k) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;



int main() {
	long long n, a[200000],sum[200001],ans=0;
	cin >> n;
	sum[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	sort(sum, sum + n + 1);
	long long kaburi = 1;
	long long memo = sum[0];
	for (int i = 1; i < n+1; i++) {
		if (memo == sum[i]) {
			kaburi++;
			if (i == n) {
				ans += kaburi * (kaburi - 1) / 2;
			}
		}
		else {
			ans += kaburi * (kaburi - 1) / 2;
			kaburi = 1;
			memo = sum[i];
		}
	}
	cout << ans << endl;
	return 0;


}



Measured memory_bytes: 3456
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>

int main()
{
    int d[5];
    int min=10;
    int time=0;
    int mod;
    std::cin >> d[0] >> d[1] >> d[2] >> d[3] >> d[4];
    for(int i=0; i<5; i++){
        mod = d[i]%10;
        if(mod < min && mod > 0){
            min = mod;
        }
        if(mod == 0){
            time += d[i];
        }else{
            time += 10*(d[i]/10+1);
        }
    }
    time -= (10-min);
    std::cout << time << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
//const int MM = 1e9;
const int MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > pq;

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


bool IsPrime(int x){
    for (int i = 2; i*i <= x; i++){
        if (x % i == 0){
            return false;
        }
    }
    return true;
}

vector<pair<ll, ll> > PrimeFactor(ll N){
    vector<pair<ll, ll> > prime;
    for (int i = 2; i*i <= N; i++){
        if (N % i != 0) continue;
        int cnt = 0;
        while (N % i == 0){
            cnt++;
            N /= i;
        }
        prime.push_back({i, cnt});
    }
    if (N > 1){
        prime.push_back({N, 1});
    }
    return prime;
}

int main(){
    ll N, M; cin >> N >> M;
    vector<pair<ll, ll> > prime = PrimeFactor(M);
    ll res = 1;
    init();
    for (auto p : prime){
        ll cur = p.second;
        res *= COM(cur+N-1, cur);
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 12032
# すぬけ君は，数直線上の位置 x に住んでいます． 
# また，位置 a,b にはそれぞれ出前を行っている店 A,B が存在します．
# すぬけ君は，店 A,B のうち，より近いほうから出前をとることにしました． 
# どちらの店がすぬけ君の住んでいる位置により近いかを求めてください．
# ただし，数直線上の 2 点 s,t の間の距離は |s−t| で表されます．

input = gets.chomp.split
x = input[0].to_i
a = input[1].to_i
b = input[2].to_i

puts (x - a).abs < (x - b).abs ? "A" : "B"

Measured memory_bytes: 1788
#include <stdio.h>
int main(void){
  int N;
  int i;
  long long s=1;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    s=i*(s%(1000000000+7));
  }
  printf("%lld\n",s%(1000000000+7));
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i,N) cin >> vec[i];
  sort(All(vec));
  cout << vec[N-1] - vec[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	
	int k,x;
	int z = 500;
	scanf ("%d %d", &k, &x);
	if (k*z >= x){
		printf ("Yes\n");
	}
	else if (k*z <= x){
		printf ("No\n");
	}
	return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ll n;
    double m;
    cin>>n>>m;
    double sum=0;
    double a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    double x=4*m;
    sum/=x;
    ll c=0;
    for(ll i=0;i<n;i++){
        if(a[i]>=sum)c++;
    }
    if(c>=int(m))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define sd second
#define ft first
#define ios                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int32_t main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool flag = true;
    list<char> l;
    l.push_back('.');
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            flag = !flag;
        }
        else
        {
            char f, ch;
            cin >> f >> ch;
            if (f == '1')
            {
                if (flag)
                {
                    l.push_front(ch);
                }
                else
                {
                    l.push_back(ch);
                }
            }
            else
            {
                if (flag)
                {
                    l.push_back(ch);
                }
                else
                {
                    l.push_front(ch);
                }
            }
        }
    }
    string ans;
    for (auto x : l)
    {
        if (x == '.')
        {
            ans += s;
        }
        else
        {
            ans += x;
        }
    }
    if (!flag)
    {
        reverse(ans.begin(), ans.end());
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int cntb = 0;
	int cntab = 0;
	rep(i, N) {
		if (S[i] == 'a') {
			if (cntab < A + B) {
				cout << "Yes" << endl;
				cntab++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (S[i] == 'b') {
			if (cntab < A + B && cntb < B) {
				cout << "Yes" << endl;
				cntab++;
				cntb++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (S[i] == 'c') {
			cout << "No" << endl;
		}
		//cout << cntab << ' ' << cntb << endl;
	}
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N; cin >> N;
  vector<ll> T(N), A(N);
  for (int i = 0; i < N; ++i) cin >> T[i] >> A[i];

  ll a = 1, b = 1;
  for (int i = 0; i < N; ++i) {
    ll n = max((a+T[i]-1)/T[i], (b+A[i]-1)/A[i]);
    a = n*T[i], b = n*A[i];
  }

  cout << a+b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

int main(void) {
  int x, y;

  scanf("%d %d", &x, &y);

  printf("%d\n", gcd(x, y));

  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;

int main(){
  ll x,k,d;
  cin >> x >> k >> d;
  ll X = abs(x);
  if(X/d > k) cout << X-k*d << endl;
  else {
    ll e = X/d;
    k -= e;
    X -= e*d;
    if(k % 2 == 1) X = abs(X-d);
    cout << X << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int n,m,c,ans = 0,temp = 0;
    cin >> n >> m >> c;
    int b[m], a[n];
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        temp = 0;
        for(int j = 0; j < m; j++){
            int a;
            cin >> a;
            temp += a * b[j];
        }
        if(temp + c > 0) ans++;
    }
    cout << ans; 
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 int A,B,C;
 cin>>A>>B>>C;
 cout<<min(B/A,C)<<endl;
}

Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local edge_c, edge_p_cnt = {}, {}
local p = {}
for i = 1, n do
  edge_c[i] = {}
  edge_p_cnt[i] = 0
  p[i] = 0
end
for i = 1, n + m - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge_c[a], b)
  edge_p_cnt[b] = edge_p_cnt[b] + 1
end

local tasks = {}
for i = 1, n do
  if edge_p_cnt[i] == 0 then
    p[i] = 0
    table.insert(tasks, i)
  end
end

while 0 < #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  for i = 1, #edge_c[src] do
    local dst = edge_c[src][i]
    edge_p_cnt[dst] = edge_p_cnt[dst] - 1
    if edge_p_cnt[dst] == 0 then
      p[dst] = src
      table.insert(tasks, dst)
    end
  end
end
for i = 1, n do
  print(p[i])
end


Measured memory_bytes: 10876
def main():
    N,X = map(int,input().split())
    L = list(map(int, input().split()))
    D = 0
    count = 1

    for i in range(0,N):
        D = D + L[i]
        if D <= X:
            count = count + 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
        int x1,y1,x2,y2,a,b;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        a=x2-x1; b=y2-y1;
        printf("%d %d %d %d\n",x2-b,y2+a,x1-b,y1+a);
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
  int N, i;
  long long Sum = 0;
  string s;
  map<string, long long> S;
  cin >> N;
  
  for(i=0; i<N; i++){
    cin >> s;
    sort(s.begin(), s.end());
    S[s]++;
  }
  
  for(auto p : S){
    Sum += p.second * (p.second - 1) / 2;
  }
  cout << Sum << endl;
  return 0;
}

Measured memory_bytes: 11352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n; cin >> n;
    vector<ll> v(n);
    int cnt = 0; ll mn = 1e9, ans = 0;
    rep(i, n){
        cin >> v[i];
        if(v[i] < 0)cnt++;
        mn = min(mn, abs(v[i]));
        ans += abs(v[i]);
    }
    if(cnt % 2 != 0){
        ans -= 2*mn;
    }
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 1272
local n = io.read("*n")
local p, m = {}, {}
for i = 1, n do
  local a = io.read("*n")
  if 0 <= a then
    table.insert(p, a)
  else
    table.insert(m, a)
  end
end
table.sort(p)
table.sort(m, function(a, b) return a > b end)
local v = 0
local r1, r2 = {}, {}
if #m == 0 then
  v = p[1]
  for i = 3, #p do
    table.insert(r1, v)
    table.insert(r2, p[i])
    v = v - p[i]
  end
  table.insert(r1, p[2])
  table.insert(r2, v)
  v = p[2] - v
elseif #p == 0 then
  v = m[1]
  for i = 2, #m do
    table.insert(r1, v)
    table.insert(r2, m[i])
    v = v - m[i]
  end
else
  v = m[1]
  for i = 2, #p do
    table.insert(r1, v)
    table.insert(r2, p[i])
    v = v - p[i]
  end
  table.insert(r1, p[1])
  table.insert(r2, v)
  v = p[1] - v
  for i = 2, #m do
    table.insert(r1, v)
    table.insert(r2, m[i])
    v = v - m[i]
  end
end
print(v)
for i = 1, n - 1 do
  print(r1[i] .. " " ..r2[i])
end


Measured memory_bytes: 20956
N = int(input())
x = str(input())

y=[0]*N
left=''
right=''

for i in range(N):
    if (x[i]==')'):
        y[i]=-1
    else:
        y[i]= 1

for i in range(N):
    if y[i]==1:
        for j in range(i,N):
            if y[j]==-1:
                y[i]=y[j]=0
                break



for i in range(y.count(-1)):
    left=left+'('
for i in range(y.count(1)):
    right=right+')'

print(left+x+right)
        
quit()

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<pair<int, int> > dices(n);
    for (int i = 0; i < n; i++) {
        int d1, d2;
        cin >> d1 >> d2;
        dices[i] = make_pair(d1, d2);
    }

    bool ok = false;
    for (int i = 0; i < n-2; i++) {
        if ((dices[i].first == dices[i].second) && (dices[i+1].first == dices[i+1].second) && (dices[i+2].first == dices[i+2].second)) {
            ok = true;
        }
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> g(h+2, vector<char>(w+2));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> g[i][j];
        }
    }
    vector<vector<bool>> f(h+2, vector<bool>(w+2, true));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(g[i][j]=='o'){
                for(int d=0; d<3; d++){
                    f[i+dy[d]][j+dx[d]] = false;
                }
            }
            if(g[i][j] == 'x'){
                for(int d=0; d<9; d++){
                    f[i+dy[d]][j+dx[d]] = false;
                }   
            }
        }
    }

    int ans = 0;
    for(int i=2; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(f[i][j]) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3180
n,k = map(int, input().split())
a = list(map(int, input().split()))
sum = [0]*(len(a)+1)
for i,val in enumerate(a):
    ex = val*(val+1)/2/val
    sum[i+1] = sum[i]+ex
ma = 1
for i in range(n):
    if i+k <= n:
        ma = max(ma,sum[i+k]-sum[i])
    else:
        break
print(ma)

Measured memory_bytes: 71792
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

ans_list = []
m,n = map(int, input().split())
if m == 1 and n == 1:
    print(1)
else:
    fct = factorize(n)
    for div in divisorize(fct):
        ans_list.append(num(div))
    ans_list.sort()
    for number in ans_list:
        if number <= (n//m):
            ans = number
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

// AtCoder Beginner Contest 139
int main(){

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

    int ans = 0;
    int now = 1;
    while(now < b){
        ans++;
        now += a - 1;
    }

    cout << ans << endl;
    return 0;

}

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		int[] a= new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<k;i++) {
			sum+=a[i];
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 30216
#include <iostream>

using namespace std;

int K, N;
int ans[300005];
int t;

void prev(int a[])
{
	a[t]--;
	if(a[t] == 0) t--;
	else{
		for(int i = t+1;i < N; i++) a[i] = K;
		t = N-1;
	}
}

int main(void)
{
	cin >> K >> N;
	if(K % 2 == 0){
		cout << K/2 << " ";
		for(int i = 2; i <= N; i++){
			cout << K;
			if(i != N) cout << " ";
		}
		cout << endl;
		return 0;
	}
	
	for(int i = 0; i < N; i++) ans[i] = K/2+1;
	
	t = N-1;
	for(int i = 0; i < N/2; i++) prev(ans);
	
	for(int i = 0; i < N; i++){
		if(ans[i] == 0){
			i = N;
			continue;
		}
		cout << ans[i];
		if(i != N-1) cout << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3456
N, M = gets.split(" ").map(&:to_i)
ans = Array.new(N, "x")
flag = true
num = 0
M.times do |i|
    s, c = gets.split(" ").map(&:to_i)
    if ans[s - 1] == "x" || ans[s - 1] == c
        ans[s - 1] = c
    else
        flag = false
    end
end
 
if flag == false || (ans[0] == 0 && N > 1)
    puts -1
elsif N == 1
    if ans[0] == "x"
        puts 0
    else
        puts ans[0]
    end 
else
    if ans[0] == "x"
        ans[0] = 1
    end
    ans.each_with_index do |a, i|
        if a != "x"
           num += a * 10**(N - i - 1)
        end
    end
    puts num
end


Measured memory_bytes: 1788
#include<stdio.h>

int main(){
    int a, b, c, i;
    int count = 0;
    scanf("%d %d %d", &a, &b, &c);

    for(i = a; i <= b; i++){
        if(c % i == 0) count++;
    }

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

    return 0;
}


Measured memory_bytes: 2132
/*

                   بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
                  لآ اِلَهَ اِلّا اللّهُ مُحَمَّدٌ رَسُوُل اللّهِ
*/

/*
    Auther:   n0oO0o0Ob(None of them)
    from  :   https://n0oo0o0ob.sleek.page/

*/




#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define pb push_back

                                        #define noob n0oO0o0Ob
// ---------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
//----------------------------------
const ld PI = acos((ld)-1);
//----------------------------------

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int a;
	cin >> a;
    set<int> s;
    for(int i =  0; i < a; i++ ){
    	int x;
    	cin >> x;
		s.insert(x);
	}
	cout << s.size();

	return 0;
}










Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
ll n,c,g,a,we,ac,L[7],p[7],m,k,dp[500][500];
int main(){
cin>>n>>c,c*=n,m=n-1,k=1<<m;
forn(i,n)cin>>L[i],L[i]*=n;
sort(L,L+n);
iota(p,p+m,0);
do{
    memset(dp,0,sizeof(dp)),dp[L[m]][0]=1;
    forn(i,c) if(i%n) {
        we = p[i%n-1];
        forn(mask, k) if (!((1<<we)&mask))
            for (ac=i;ac<=c;ac++) dp[max(ac,min(c,L[we]+i))][mask+(1<<we)]+=dp[ac][mask];
    } g+=dp[c][k-1],a++;
}while(next_permutation(p,p+m));
printf("%.15f",g/pow(c/n,m)/a);
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    int N, MOD;
    while(cin >> N >> MOD){
        const int maxSize = 3*N+1;
        vector<long long> inv(maxSize);
        vector<long long> fact(maxSize);
        for(int i=0;i<2;i++) inv[i] = fact[i] = 1;
        for(int i=2;i<maxSize;i++){
            inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
            fact[i] = fact[i-1] * i % MOD;
        }
        vector<vector<long long>> dp(maxSize, vector<long long>(4*N+1, 0));
        dp[0][N] = 1;
        for(int i=0;i<3*N;i++){
            for(int j=0;j<=4*N;j++){
                int dj[] = {1, -1, 0};
                for(int k=0;k<3;k++){
                    if(j+dj[k] < 0 || 4*N < j+dj[k]) continue;
                    if(i+k+1 > 3*N) continue;
                    dp[i+k+1][j+dj[k]] += dp[i][j] * inv[i+k+1];
                    dp[i+k+1][j+dj[k]] %= MOD;
                }
            }
        }
        long long res = 0;
        for(int i=N;i<=4*N;i+=3) res = (res + dp[3*N][i]) % MOD;
        cout << (fact[3*N] * res) % MOD << endl;
    }
}

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

int main() {long N, K;
cin >> N >> K;
vector<long> x(N + 1);
erep(i, N) cin >> x.at(i);
long ans = 0;
erep(i, N){
  ans += min(x.at(i), K - x.at(i));
}


ans += ans;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	int x[5] = {a, b, c, d, e};
	int y[5] = {10-(a%10), 10-(b%10), 10-(c%10), 10-(d%10), 10-(e%10)};
	int amari = 10;
	int lasti = 0;
	int last = 0;
	int ans = 0;
	for(int i=0;i<5;i++){
		if(x[i]%10<=amari && x[i]%10!=0){
			amari = x[i]%10;
			lasti = i;
			last = x[i];
		}
	}
	if(last==0){
		last = x[0];
	}
	for(int i=0;i<5;i++){
		if(i!=lasti){
			if(y[i]!=10){
				ans += x[i]+y[i];
			}else{
				ans += x[i];
			}
		}
	}
	ans += last;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
import copy
n = int(input())
a = list(map(int, input().split()))
a_r = copy.copy(a)
a_r.reverse()
cumsum_gcd = [0]
cumsum_gcd_r = [0]
for i in range(n-1):
    cumsum_gcd.append(fractions.gcd(cumsum_gcd[i], a[i]))
    cumsum_gcd_r.append(fractions.gcd(cumsum_gcd_r[i], a_r[i]))
cumsum_gcd_r.reverse()
ans = []
for i in range(n):
    ans.append(fractions.gcd(cumsum_gcd[i], cumsum_gcd_r[i]))
print(max(ans))


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

public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long first = 0;
        long last = 0;
        // long sum = 0;
        int[] original = new int[n];
        int[] a = new int[n];

        int count = 0;
        int minusCount = 0;
        //int flagInt = 0;

        int min = 1000000000;
        long sum = 0;
        List<Long> list = new ArrayList<>();
        long eee = 0;
        int[][] zeroRange = new int[n][2];
        boolean zFlag = false;
        for(int i = 0; i < n; i++) {
            int tmp = scanner.nextInt();
            original[i] = tmp;
            if(zFlag) {
                zeroRange[count][0] = i;
                zFlag = false;
            }
            if(tmp == 0) {
                //flagInt = tmp;
                zeroRange[count][1] = i;
                count++;
                list.add(sum);
                sum = 0;
                zFlag = true;
            }
            
            a[i] = Math.abs(tmp);
            sum += Math.abs(tmp);

            eee += Math.abs(tmp);
            min = Math.min(min, Math.abs(tmp));
            if(tmp < 0) minusCount++;
            if(i == 0) {
                first -= a[i];
            } else {
                first += a[i];
            }
            if(i == n-1) {
                last -= a[i];
            } else {
                last += a[i];
            }
        }


        if(count == 0) {
            if(minusCount % 2 == 0) {
                System.out.println(sum);
            } else {
                long aaaa = Math.max(first, last);
                System.out.println(Math.max(aaaa, sum-(min*2)));
            }
        } else {
            System.out.println(eee);
            
        }
        

       

    }
}

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

int const b_max = 4, f_max = 3, r_max = 10;

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

	int a[5][4][11];

	for (int i = 1; i <= b_max; ++i) {
		for (int j = 1; j <= f_max; ++j) {
			for (int k = 1; k <= r_max; ++k) {
				a[i][j][k] = 0;
			}
		}
	}

	for (int i = 0; i < n; ++i) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}

	for (int i = 1; i <= b_max; ++i) {
		for (int j = 1; j <= f_max; ++j) {
			for (int k = 1; k <= r_max; ++k) {
				cout << ' ' << a[i][j][k];
			}
			cout << endl;
		}
		if (i != b_max) cout << "####################" << endl;
	}
}



Measured memory_bytes: 3104
/**/
/*
 * 	Meet me on the battlefield
*/
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const int inf=1e9;
const int mod=1e9+7;
#define dpr(x) cout<<#x<<": "<<x<<endl
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve()
{
	int n,k;
	cin>>n>>k;
	if((n+1)/2>=k)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
/**/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;

typedef long long ll;
const ll mod = 1000000007;

int main(){
    ll N,K;
    vector<pair<ll,ll>> V;
    vector<int> tar(150505,0);
    vector<ll> dp(101010,0),S(101010,0);
	
	cin>>N>>K;

    //Ｖに条件が変わる閉区間を順番に入れていく--------------------
    ll n=1;
	while(n*n<=N) {//√Nまでは１つずつなので[1,1]~[√N,√N]
		V.push_back({n,n});
        n++;
	}
	while(--n){//[N/√N+1,N/(√N-1)]~[N/2+1,N]
		ll L=V.back().second+1;
		ll R=N/n;
		//cout<<L<<" "<<R<<endl;
		if(L<=R) V.push_back({L,R});
	}
	//-------------------------------------------------------

    //V上の各閉区間に対して、隣の数の取りうる最大の区間と場合の数を求める
	REP(i,V.size()) {
		int x=0;
		for(int j=20;j>=0;j--){
            int y=x+(1<<j);
            if(y>=V.size()) continue;
            else if(V[i].second*V[y].second<=N) x=y;
        }
		tar[i]=x;
		dp[i]=V[i].second-V[i].first+1;
		//cout<<i<<" "<<V[i].first<<" "<<V[i].second<<" "<<tar[i]<<endl;
	}

    //最後の数が区間iに属するときの場合の数を求めていく
	REP(j,K-1){
		REP(i,V.size()) S[i+1]=(S[i]+dp[i])%mod;
        REP(i,V.size()) dp[i]=S[tar[i]+1]*(V[i].second-V[i].first+1)%mod;
	}
	
	ll ret=0;
	REP(i,V.size()) ret+=dp[i];
	cout<<ret%mod<<endl;
}

Measured memory_bytes: 3576
#input
N = int(input())
h = list(map(int, input().split()))

#output
dp = [0] * N
dp[1] = abs(h[1]-h[0])
if N >=3:
    dp[2] = min(abs(h[2]-h[0]), abs(h[2]-h[1])+abs(h[1]-h[0]))

for i in range(1, N-1):
    dp[i+1] = min(dp[i-1]+abs(h[i+1]-h[i-1]), dp[i]+abs(h[i+1]-h[i]))

print(dp[N-1])

Measured memory_bytes: 13776
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,ret,sum;
	while(cin >> n , n){
		ret = 0;
		vector< vector<char> > data(n,vector<char>(n+(n-1)*2,0));
		rep(i,n)rep(j,n){
			cin >> data[i][n-1+j];
			data[i][n-1+j]-='0';
		}
		rep(i,n){
			sum = 0;
			rep(j,n){
				if(data[i][n-1+j]==0)sum = 0;
				sum+=data[i][n-1+j];
				ret = max(ret,sum);
			}
		}
		rep(i,n){
			sum = 0;
			rep(j,n){
				if(data[j][n-1+i]==0)sum = 0;
				sum+=data[j][n-1+i];
				ret = max(ret,sum);
			}
		}
		rep(i,2*n-1){
			sum = 0;
			rep(j,n){
				if(data[j][i+j]==0)sum = 0;
				sum+=data[j][i+j];
				ret = max(ret,sum);
			}
		}	
		for(int i=n-1;i<n+(n-1)*2;i++){
			sum = 0;
			rep(j,n){
				if(data[j][i-j]==0)sum = 0;
				sum+=data[j][i-j];
				ret = max(ret,sum);
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1096
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

ll ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}

string s;

int main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	int n=s.length();
	for (int i=0;i<n;)
	{
		int j=i;
		while (j<n&&s[j]=='<') j++;
		int a=j-i;
		i=j;

		while (j<n&&s[j]=='>') j++;
		int b=j-i;
		i=j;

		if (a>=b) b--;else a--;
		ans+=(ll)a*(a+1)/2+(ll)b*(b+1)/2;
	}

	printf("%lld\n",ans);
	return 0;
}










Measured memory_bytes: 1172
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100001];

int main() {
	vector<char> s(4);
	for (int i = 0; i < 4; i++)
		cin >> s[i];

	sort(s.begin(), s.end());
	swap(s[1], s[3]);
	
	if (s[0] == '1' && s[1] == '9' && s[2] == '7' && s[3] == '4')
		cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
function Main(input) {
  const lines = input.split(' ');
  const str = lines[0] + lines[1];
  const num = parseInt(str, 10);
  const sqrt = Math.sqrt(num);
  if (Number.isInteger(sqrt)) {
    console.log("Yes");
  } else {
    console.log("No")
  }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
  ll i=0;
  while(i<S.size()) {
    if(S[i]=='d') {
      if(S.substr(i, 5)=="dream") {
	if(S.substr(i, 7)=="dreamer") {
	  if(i+7<S.size() and S[i+7]=='a') {
	    i+=5;
	  } else if(i+7<S.size() and (S[i+7]=='d' or S[i+7]=='e')) {
	    i+=7;
	  } else {
	    i+=7;
	  }
	} else {
	  i+=5;
	}
      } else {
	std::cout << NO << std::endl;
	return;
      }
    } else if(S[i]=='e') {
      if(S.substr(i, 5)=="erase") {
	if(S.substr(i, 6)=="eraser") {
	  i+=6;
	} else {
	  i+=5;
	}
      } else {
	std::cout << NO << std::endl;
	return;
      }
    } else {
      std::cout << NO << std::endl;
      return;
    }
  }
  std::cout << YES << std::endl;
}

int main(){
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if(x==1)
{
    cout<<"Hello World";
    return 0;
}
else if(x==2)
{
    int a,b;
    cin>>a>>b;
    cout<<a+b;
}
 return 0;
}


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

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

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

void re_index(std::vector<ll> &a, const std::vector<int> &ind) {
  size_t N = a.size();
  std::vector<ll> sub(N);
  rep(i, N) {
    sub[i] = a[ind[i]];
  }
  rep(i, N) {
    a[i] = sub[i];
  }

  return;
}

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

  std::vector<ll> A(N), B(N);
  rep(i, N) {
    std::cin >> A[i];
  }
  rep(i, N) {
    std::cin >> B[i];
  }

  std::vector<int> ind(N);
  rep(i, N) ind[i] = i;
  std::sort(ind.begin(), ind.end(), [&](int i, int j) {return B[i] < B[j];});
  re_index(A, ind);
  re_index(B, ind);

  std::vector<int> p(N);
  rep(i, N) p[i] = i;
  std::sort(p.begin(), p.end(), [&](int i, int j) {return A[i] < A[j];});

  rep(i, N) {
    if(A[p[i]] > B[i]) {
      std::cout << "No" << '\n';
      return 0;
    }
  }

  int cnt = 1;
  int start = 0;
  int x = start;
  while(p[x] != start) {
    x = p[x];
    ++cnt;
  }

  if(cnt < N) {
    std::cout << "Yes" << '\n';
    return 0;
  }

  rep(i, N - 1) {
    if(B[i] >= A[p[i + 1]]) {
      std::cout << "Yes" << '\n';
      return 0;
    }
  }

  std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 2952
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
   cin>>N;
  vector<int> d(N);
 
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }
  sort(d.begin(),d.end());
  int n;
  n=N/2;
  if(d.at(n-1)==d.at(n)){
  cout<<0<<endl;
  }
  else{
  cout<<d.at(n)-d.at(n-1)<<endl;
  }
}

Measured memory_bytes: 3712
def main():
    n = int(input().rstrip())
    old_dp = [0 for i in range(3)]
    for i in range(n):
        new_dp = [0 for i in range(3)]
        c = list(map(int, input().rstrip().split()))
        for i in range(3):
            for j in range(3):
                if i!=j:
                    new_dp[j] = max(new_dp[j], old_dp[i] + c[j])

        old_dp = new_dp
    print(max(old_dp[0], old_dp[1], old_dp[2]))

if __name__ == "__main__":
    main()

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

 
int main() {
  int N, L, S=0, T=300,ans;
  cin >> N >> L;
  VI A(N),B(N);
  vector<PII> P;
  REP (i,N) {
    A.at(i) = L + i;
    S += A.at(i);
  }
  REP (i,N) {
    B.at(i) = S - A.at(i);
    if(T > abs(A.at(i))) {
      T = abs(A.at(i));
      ans = B.at(i);
  }
  }
  cout << ans << endl;
  return 0;
}


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 

const int INF=1e9+5;
using ll=long long;

int main(){
	int n;
	scanf("%d", &n);
	int height[n];
	for(int i = 0; i < n; ++i) {
		cin >> height[i];
	}
	vector<int> dp(n,INF);
	dp[0] = 0; //dp[i] - > min cost to reach stone i
	for(int stone = 0; stone < n; ++stone) {
		for(int x : {1,2}) {
			if(stone + x < n) {
			 dp[stone + x] = min(dp[stone + x], dp[stone] + abs(height[stone]- height[stone + x]));
		}
		}
	}
	printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

bool solve(int px, int py){
  int n;
  cin>>n;
  vector<int> sx(n), sy(n);
  rep(i,n) cin>>sx[i]>>sy[i];

  vector<int> x,y;
  x.pb(px); y.pb(py);
  rep(i,n){
    vector<int> xx,yy;
    rep(j,x.size()){
      const int dx[]={-2,-2,-2,2,2,2,-1,0,1,-1,0,1};
      const int dy[]={-1,0,1,-1,0,1,-2,-2,-2,2,2,2};
      rep(k,12){
        int nx = x[j]+dx[k];
        int ny = y[j]+dy[k];
        if(nx<0 || nx>9 || ny<0 || ny>9) continue;
        if(abs(nx-sx[i])<=1 && abs(ny-sy[i])<=1){//dbg(mp(nx,ny));
          xx.pb(nx);
          yy.pb(ny);
        }
      }
    }
    swap(xx,x);
    swap(yy,y);
  }
  return x.size()>0;
}

int main(){
  int x,y;
  while(cin>>x>>y, x|y){
    if(solve(x,y)) cout<<"OK"<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}

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

int main()
{
    char a, b;
    cin >> a >> b;

    if(a=='H'){
        if(b=='H') cout << 'H';
        else cout << 'D';
    }
    else{
        if(b=='H') cout << 'D';
        else cout << 'H';
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()

def main():
    N, _, C = map(int, input().split())
    B = np.array(tuple(map(int, input().split())))
    A = [np.array(tuple(map(int, input().split()))) for _ in range(N)]

    ans = 0
    for a in A:
        if sum(a * B) + C > 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13124
N,M=(int(a) for a in input().split());
A=input();
A=A.split()
B = [int(s) for s in A]
sum = sum(B)

line = sum/4/M
point = 0;
length = len(B);

for i in range(length):
    if B[i] >= line:
        point += 1;
    else:
        pass;
    
if point >= M:
    print("Yes");
else:
    print("No");

Measured memory_bytes: 3064