akhauriyash/Code-Regression huggingface dataset:
N, X, Y = map(int, input().split())
d = {k: 0 for k in range(1, N)}
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        m = min(abs(j - i),
                abs(X - i) + 1 + abs(j - Y),
                abs(Y - i) + 1 + abs(j - X))
        d[m] += 1
for k in range(1, N):
    print(d[k])


Measured memory_bytes: 48604
#include <iostream>
#include <vector>

using namespace std;


void insertion_sort(vector<int> &as);
void print_vector(const vector<int> &as);

int main(){
    int n;
    cin >> n;
    vector<int> as(n);
    for(auto &a : as) cin >> a;
    insertion_sort(as);
    return 0;
}

void insertion_sort(vector<int> &as){
    print_vector(as);
    for(size_t i = 1; i != as.size(); ++i){
        int key;
        key = as[i];
        int j = i - 1;
        for(; j != -1 && as[j] > key; --j){
            as[j + 1] = as[j];
        }
        as[j + 1] = key;
        print_vector(as);
    }
}

void print_vector(const vector<int> &as){
    size_t i = 0;
    for(auto a : as){
        ++i;
        cout << a;
        if(i!=as.size()) cout << ' ';
    }
    cout << endl;
}

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

const int maxn = 1010;
int n, m, u[200010], v[200010], chk[maxn];
bool vis[maxn][maxn], ok[maxn][maxn];
vector<int> G[maxn];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &u[i], &v[i]);
        G[u[i]].push_back(v[i]);
    }
    for (int i = 1; i <= n; i++) {
        memset(chk, 0, sizeof(chk));
        queue<int> q;
        for (int j : G[i]) {
            q.push(j), chk[j] = j;
        }
        while (!q.empty()) {
            int v = q.front(); q.pop();
            vis[i][v] = 1;
            if (i == v) continue;
            for (int u : G[v]) if (~chk[u]) {
                if (chk[u] == chk[v]) continue;
                chk[u] = !chk[u] ? chk[v] : -1, q.push(u);
            }
        }
        for (int j : G[i]) {
            if (!~chk[j]) ok[i][j] = 1;
        }
    }
    for (int i = 1; i <= m; i++) {
        printf("%s\n", ok[u[i]][v[i]] == vis[v[i]][u[i]] ? "same" : "diff");
    }
    return 0;
}

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

int main() {
	long n,d=0;
	cin>>n;
	string a,b,c;
	cin>>a>>b>>c;
	
	for(int i=0;i<n;i++){
		if(a.at(i)==b.at(i)){
		 if(a.at(i)!=c.at(i)){
		 	d++;
		 }
		}
		else if(c.at(i)==b.at(i)){
		if(a.at(i)!=c.at(i)){
		 	d++;
		 }	
		
		}
		else if(c.at(i)==a.at(i)){
			if(a.at(i)!=b.at(i)){
		 	d++;
		 }
			
		}
		else{
			d+=2;
		}
	}
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){

  char moji;
  
  scanf("%c", &moji);
  
  if((moji >= 'A') && (moji <= 'Z')){
  printf("A\n");
  }else if((moji >= 'a') && (moji <= 'z')){
  printf("a\n");
  }
  
  return 0;
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> vp[100001];
int d[100001];
int INF=1000100010;
int n;
int dijkstra(int st){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,n+1) d[i]=INF;
    d[st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        if(d[t]<pi.first) continue;
        for(auto it:vp[t]){
            if(d[it.second]>d[t]+it.first){
                d[it.second]=d[t]+it.first;
                pq.push(make_pair(d[it.second],it.second));
            }
        }
    }
}
int cnt[100001];
int main(){
    int k,ai;
    cin>>n>>k;
    rep(i,n){
        cin>>ai;
        if(ai==0) vp[0].pb(1,i+1);
        else vp[i+1].pb(1,ai);
        ++cnt[ai];
    }
    FOR(i,1,n+1){
        if(cnt[i]==0) vp[0].pb(1,i);
    }
    dijkstra(0);
    int ans=0;
    FOR(i,1,n+1)if(d[i]<=k) ++ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11076
K = int(input())
A,B = map(int,input().split())
c = 0

if (B-A) >= K:
  print("OK")
  c = 1
else:
  for i in range(K):
    if ( A + i ) <= B:
      if ( A + i ) % K == 0:
        print("OK")
        c = 1
        break
if c == 0:
  print("NG")

Measured memory_bytes: 9192
import math
N = int(input())
tmin = 1
amin = 1
for i in range(N):
    t, a = map(int, input().split())
    multiple = max((tmin -  1) // t, (amin - 1) // a) + 1
    tmin = t * multiple
    amin = a * multiple
print(tmin + amin)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main()
{
	fast;
	ll k,n; cin>>k>>n; ll arr[n];
	for(ll i = 0; i < n; i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	ll ans = LLONG_MIN;
	for(ll i = 1; i < n; i++)
		ans = max(ans,arr[i]-arr[i-1]);
	ans = max(ans,(k-arr[n-1]) + arr[0]);
	cout << k - ans << endl;
	return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  vector<int> x(3);
  cin >> x[0];
  cin >> x[1];
  cin >> x[2];

  int ret = 0;
  while (true) {
    if (x[0] == x[1] && x[1] == x[2])
      break;

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

    if (x[0] < x[1])
      x[0] += 2;
    else {
      ++x[0];
      ++x[1];
    }
    ++ret;
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
l = list(map(int,input().split()))
min_ = 100*100000
ret=0
for i in range(n):
    x = l[i]
    if min_ > abs(a-t+x*0.006):
        ret = i+1
        min_ = min(min_,abs(a-t+x*0.006))

print(ret)


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

int main(void) {
    int year, month, date;
    int heisei = 2019*365+3*30+30;
    if (scanf("%4d/%2d/%2d", &year, &month, &date) != EOF) {
        if (year*365+(month-1)*30+date <= heisei) {
            printf("Heisei");
        } else {
            printf("TBD");
        }
    } else {
        return 1;
    }
    return 0;
}

Measured memory_bytes: 128
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int mod2 = 998244353;
  const int N = 20005;
  const int INF = 1e16;
  const double PI = acos(-1);



int binarysearch(vector<int> arr,int low,int high,int t)
{
  while(low <= high)
  {
    int mid = low + (high-low)/2;

    if(arr[mid] <= t)
    {
      low = mid + 1;
    }
    else
    {
      high = mid - 1;
    }

  }
  return low;
}
int32_t main()
{
       

    IOS



    int n;
    cin >> n;

    vector<int> v(n);

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

    sort(all(v));
    int ans = 0;

    for(int i = 0; i < n; i++)
    {
      for(int j = i + 1; j < n; j++)
      {
        ans += binarysearch(v,j,v.size()-1,v[i] + v[j] - 1) - j - 1;
      }
    }

    cout << ans;

  return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

class Program {
    static void Main(string[] args) {
        char c;
        Input(out c);
        Console.WriteLine((char)(c + 1));
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    string s; cin>>s;
    vi ans;
    for(int i=n; i>0; i--){
        int reach = i;
        for(int j=max(0,i-m); j<i; j++){
            if (s[j]=='0'){
                reach = j;
                break;
            }
        }
        if (i==reach){
            cout << "-1\n";
            return 0;
        }
        ans.pb(i-reach);
        i = reach+1;
    }
    RITR(itr, ans){
        cout << *itr << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1096
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  invec<ll> A(N);
  
  in<ll> Q;
  static ll nums[130000] = {0};
  ll r = 0;
  
  for (auto i : A) {
    nums[i]++;
    r += i;
  }
  
  REP(i,Q) {
    in<ll> B, C;
    nums[C] += nums[B];
    r = r - B * nums[B] + C * nums[B];
    nums[B] = 0;
    cout << r << endl;
  }


}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 4836
#include <bits/stdc++.h>
#include <iostream> 
#include <iterator>
#include <vector>
#include <string>
using namespace std;


int main(int argc, char const *argv[])
{
	string s;
	bool flag = false;
	cin >> s;
	int alphabet[122] = {0};
	for(int i = 0; (size_t)i < s.size(); i++ ){
		int k = (int)s[i];
		alphabet[k]++;
	}
	for(int j = 0; j < 122; j++){
		if(alphabet[j] == 0){
			continue;
			}
		if(alphabet[j]%2 != 0 ){
			flag = true;
			break;
			}
		
		}
		if(flag){
			cout << "No" << "\n";
			}else{
				cout << "Yes" << "\n";
				}
	return 0;
}


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

s = list(input())

odd = ["R","U","D"]
even = ["L","U","D"]

isEasy = True
for i in range(len(s)):
    if i%2 == 1:
        if s[i] in even:
            continue
        else:
            isEasy = False
    else:
        if s[i] in odd:
            continue
        else:
            isEasy = False

if isEasy:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N, P; cin>>N>>P;
  string S; cin>>S;

  if (10%P == 0) { assert(P==2 || P==5);
    ll ans = 0;
    REP(r, N) {
      // 部分文字列の末尾の数字で判定
      if ((S[r] - '0') % P == 0) {
        ans += r + 1; // r を固定して l を [0,r] の r+1 箇所から選ぶ
      }
    }
    cout << ans << endl;
    return 0;
  }

  // 各桁の数を P で割った余り md を求める
  // md[i] := (S[i] * 10^i) % P 
  vi md(N, 0);
  ll ten = 1;
  REP(i, N) {
    int d =  (S[N-1-i] - '0');
    md[N-1-i] = (d * ten) % P;
    ten *= 10;
    ten %= P; // 10 と P は互いに素
  }

  // md の mod P の塁積和を求める
  vl sum(N+1, 0);
  sum[N] = md[N-1];
  FOR(i, 1, N) {
    sum[N-i] = (sum[N+1-i] + md[N-1-i])%P;
  }

  // mod P の塁積和の数字が同じ区間は、差が 0 なので P の倍数となる
  ll ans = 0;
  vl cnt(P, 0);
  REP(i,N+1) {
    ans += cnt[sum[i]];
    cnt[sum[i]] += 1;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 2964
// https://atcoder.jp/contests/abc165/tasks/abc165_d

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 1000000005


int main() {
	ll a,b,n;
	cin >> a >> b >> n;
	ll x = min(b-1,n);
	ll ans = (a * x) / b - a * (x / b);
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3608
/*
[abc113] C - ID
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;
const int MAX_M = 100000;

int N, M;
int P[MAX_M], Y[MAX_M];
int cnt[MAX_N];

void solve(vector<string>& ans) {
    vector<pii> ym;
    for (int i = 0; i < M; i++) {
        ym.push_back(pii(Y[i], i));
    }
    sort(ym.begin(), ym.end());

    ans.resize(M);
    for (pii& p : ym) {
        int m = p.second;
        char code[13];
        sprintf(code, "%06d%06d", P[m] + 1, cnt[P[m]] + 1);
        ans[m] = code;
        cnt[P[m]]++;
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        P[i]--;
    }

    vector<string> ans;
    solve(ans);

    for (string& code : ans) {
        cout << code << endl;
    }

    return 0;
}


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

using namespace std;

const int MOD = 998244353; 

int main() {

  string s;
  cin >> s;

  bool all_same = true;
  for (int i = 1; i < s.size(); ++i) if (s[i] != s[0]) { all_same = false; break; }
  
  if (all_same) { cout << "1" << endl; return 0; }

  if (s.size() <= 3) {
    set<string> S;
    S.insert(s);
    while (true) {
      vector<string> to_add;
      for (auto i = S.begin(); i != S.end(); ++i) {
        for (int j = 0; j < s.size() - 1; ++j) {
          if ((*i)[j] != (*i)[j + 1]) {

            bool flag[3] = { false, false, false };
            flag[(*i)[j] - 'a'] = flag[(*i)[j + 1] - 'a'] = true;
            char ch;
            for (int k = 0; k < 3; ++k) if (!flag[k]) { ch = 'a' + k; break; }

            string new_s = "";
            if (j > 0) new_s += i->substr(0, j);
            new_s += ch;
            new_s += ch;
            if (j + 2 < s.size()) new_s += i->substr(j +  2);
            to_add.push_back(new_s);
          }
        }
      }
      int pre = S.size();
      for (auto i = to_add.begin(); i != to_add.end(); ++i) S.insert(*i);
      int cur = S.size();
      if (pre == cur) break;
    }
    cout << S.size() << endl;
    return 0;
  }

  int mod = 0;
  for (int i = 0; i < s.size(); ++i) {
    mod = (mod + s[i] - 'a') % 3;
  }
 
  long long f[2][3][3][2];
  memset(f, 0x00, sizeof(f));
  int x = 0, y = 1;

  for (int d = 0; d < 3; ++d) f[x][d][d][0] = 1;

  for (int i = 1; i < s.size(); ++i, swap(x, y)) {
    for (int m = 0; m < 3; ++m) {
      for (int d = 0; d < 3; ++d) {
        for (int t = 0; t < 2; ++t) {
          f[y][m][d][t] = 0;
        }
      }
    }
 
    for (int m = 0; m < 3; ++m) {
      for (int d = 0; d < 3; ++d) {
        for (int t = 0; t < 2; ++t) {
          for (int n_d = 0; n_d < 3; ++n_d) {
            int n_m = (m + n_d) % 3;
            int n_t = (t == 1 || n_d == d) ? 1 : 0;
            f[y][n_m][n_d][n_t] = (f[y][n_m][n_d][n_t] + f[x][m][d][t]) % MOD;
          }
        }
      }
    }

  }

  long long ans = 0;
  for (int d = 0; d < 3; ++d) ans = (ans + f[x][mod][d][1]) % MOD; 

  bool all_diff = true;
  for (int i = 1; i < s.size(); ++i) if (s[i] == s[i - 1]) { all_diff = false; break; }

  if (all_diff) ans = (ans + 1) % MOD;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;


signed main(){
  int a, b;
  cin >> a >> b;
  double c1, c2;
  double d1, d2;
  c1 = 12.5 * a;
  c2 = c1 + 12.5;
  d1 = 10 * b;
  d2 = d1 + 10;
  if (not (c1 > d2 or d1 > c2)){
    int ans = (int)ceil(max(d1, c1));
    if (ans >= d2 or ans >= c2)
      cout << -1;
    else 
      cout << ans;
  }
  else
    cout << -1;
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;
int n;
long long li[300005],d = 1,ans;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++) scanf("%lld",&li[i]);
  for(int i = 0;i < 61;i++){
    long long m = 0;
    for(int j = 1;j <= n;j++){
      if(li[j]&1) m++;
      li[j] >>= 1;
    }
    ans += (((m*(n-m))%mod)*d)%mod;
    d <<= 1;
    d %= mod;
  }
  cout<<ans%mod<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int n,m,x,y,mini=2000000000,maxi=-2000000000,c;
int main()
{ cin>>n>>m>>x>>y;
  for(int i=1;i<=n;i++)
  { cin>>c;
    if(c>maxi)
       maxi=c;
  }
  for(int i=1;i<=m;i++)
  { cin>>c;
    if(c<mini)
       mini=c;
  }
  if(maxi>=mini)
  { cout<<"War";
    return 0;
  }
  if(x>=mini)
  { cout<<"War";
    return 0;
  }
  if(y<=maxi)
  { cout<<"War";
    return 0;
  }
  cout<<"No War";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int insertion_sort(int xs[], int n, int g){
    int cnt = 0;
    for(int i = g; i < n; ++i){
        //int v = xs[i];
        for(int j = i-g; j >= 0 && xs[j+g] < xs[j]; j-=g){
            ++cnt;
            swap(xs[j+g], xs[j]);
        }
    }
    return cnt;
}

vector<int> gen_g(int n){
    auto vec = vector<int> {};
    while(n > 1){
        n /= 2;
        vec.push_back(n);
    }
    if(!vec.size()) vec.push_back(1);
    return vec;
}

int shell_sort(int xs[], int n, vector<int> g){
    int cnt = 0;
    vector<int>::iterator it;
    for(it = g.begin(); it != g.end(); ++it){
        cnt += insertion_sort(xs, n, *it);
    }
    return cnt;
}

template <class T>
void print_array(T xs[], int n){
    for(int i = 0; i < n; ++i){
        printf("%d\n", xs[i]);
    }
}

void print_vector(vector<int> vec){
    vector<int>::iterator it;
    for(it = vec.begin(); it != vec.end(); ++it){
        if(it != vec.begin()) cout << ' ';
        cout << *it;
    }
    cout << '\n';
}

int main(){
    int n;
    cin >> n;
    int xs[n];
    for(int i = 0; i < n; ++i){
        scanf("%d", &xs[i]);
    }
    vector<int> g = gen_g(n);
    int cnt = shell_sort(xs, n, g);

    cout << g.size() << '\n';
    print_vector(g);
    cout << cnt << '\n';
    print_array(xs, n);
}

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

int     main() {
        int n;
        cin >> n;
        vector<int> p(n);
        for (int i=0; i<n; i++) {
                cin >> p.at(i);
        }
        int s=0;
        vector<int> q(3);
        int ss;
        for (int i=0; i<n-2; i++){
                q.at(0)=p.at(i);
                q.at(1)=p.at(i+1);
                q.at(2)=p.at(i+2);
                ss=q.at(1);
                sort(q.begin(), q.end());
                if (ss==q.at(1)) s++;
        }
        cout << s << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=INT_MAX;
const long long LLINF=LONG_MAX;
typedef long long ll;
const ll mod=998244353;
const int MX=4e5+7;
ll qpow(ll a ,ll b,int MOD=mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=ans*a%MOD;
        }
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll ans=0;
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=b;i++)
    {
        int c;
        cin>>c;
        ans+=c;

    }
    if(ans<a)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    vi sumb(n + 1);
    vi sumw(n + 1);
    REP(i, n) {
        if (s[i] == '.') {
            sumw[i + 1] = sumw[i] + 1;
            sumb[i + 1] = sumb[i];
        } else {
            sumw[i + 1] = sumw[i];
            sumb[i + 1] = sumb[i] + 1;
        }
    }
    int ans = INF;
    REP(i, n + 1) {
        chmin(ans, sumb[i] - sumb[0] + sumw[n] - sumw[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>

using namespace std;
using LL = long long;
LL sum = 0;
int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i)
		for (int j = i; j <= n; j += i)
			sum += j;

	printf("%lld\n", sum);

	return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int inf = 1e9;
int a, b, c, d;

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	cin>>a>>b>>c>>d;
	for(int i = 0; ; ++i){
		if(i % 2 == 0){
			c -= b;
		}
		else{
			a -= d;
		}
		if(a <= 0){cout<<"No"<<endl;break;}
		if(c <= 0){cout<<"Yes"<<endl;break;}
	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;
const long long MOD = 1000000007; 

int H, W;
ll dp[1100][1100];

int main(){
  cin >> H >> W;
  vector<string> field(H);
  rep(i, H) cin >> field[i];

  dp[0][0] = 1;
  rep(i, H){
    rep(j, W){
      if(field[i][j] == '#') continue;
      if(i>0) dp[i][j] += dp[i-1][j];
      if(j>0) dp[i][j] += dp[i][j-1];
      dp[i][j] %= MOD;
    }
  }

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

  return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define inf 1000000000
#define sz(x) (ll)x.size()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef  double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair< int , pii> piii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
typedef pair<ld , ld> pdd;
typedef vector<pdd> vdd;
typedef vector<ld> vd;
const int MOD = 1e9 + 7; //998244353;

int dp[100005];
vvi graph;
int dfs(int x){
    if(dp[x] != -1)return dp[x];
    for(int i : graph[x]){
        dp[x] = max(dp[x] , dfs(i) + 1);
    }
    dp[x] = max(dp[x] , 0);
    return dp[x];
}
int main(){
    boost;
    int n , m ;
    cin >> n >>m ;
    memset(dp , -1 , sizeof dp);
    graph.resize(n);
    while(m--){
        int x , y;
        cin >> x >> y;
        x--;y--;
        graph[y].pb(x);
    }
    for(int i = 0;i<n;i++){
        dfs(i);
    }
    int x = 0;
    for(int i = 0;i<n;i++)x = max(x , dp[i]);
    cout << x;
}


Measured memory_bytes: 13440
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int interval_num,money;
  while(~scanf("%d %d",&interval_num,&money)){
    if(interval_num == 0) break;

    int encounter_freq[11];
    memset(encounter_freq,0,sizeof(encounter_freq));

    int total = 0;
    for(int i=0;i<interval_num;i++){
      int dist,encounter_num;
      scanf("%d %d",&dist,&encounter_num);
      total += dist * encounter_num;
      encounter_freq[encounter_num]+=dist;
    }

    for(int freq=10;freq>=0;freq--){
      while(encounter_freq[freq] > 0 && money > 0){
	total -= freq;
	money--;
	encounter_freq[freq]--;
      }
    }

    printf("%d\n",total);
  }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 4e5 + 5;

int a,b,k;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  //cout << fixed << setprecision(6);

  cin>>a>>b>>k;
  vector<int> ans;
  for (int i=1; i<=min(a,b); i++) {
    if (a%i==0 && b%i==0) {
      ans.push_back(i);
    }
  }

  sort(ans.begin(), ans.end());
  // for (auto x: ans) cout<<x<<" ";
  // cout<<endl;
  int n=ans.size();
  out(ans[n-k]);

  return 0;
}


Measured memory_bytes: 256
Tiles=input()

N_len=len(Tiles)
type1 = sum( 1 if int(Tiles[i]) == (i%2) else 0 for i in range(N_len))
type2 = sum( 0 if int(Tiles[i]) == (i%2) else 1 for i in range(N_len))
print(min(type1,type2))

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =
		new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int num = Integer.parseInt(str);
		int x = num * num * num;
		System.out.println(x);
	}
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    int a1, b1, c1, a2, b2, c2, d, dx, dy;
    while(cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2){
        d = a1*b2 - a2*b1;
        dx = c1*b2 - c2*b1;
        dy = a1*c2 - a2*c1;
        if(d != 0){
            float x = (float)dx/d;
            float y = (float)dy/d;
            if (x == 0.0) x = abs(x);
            if (y == 0.0) y = abs(y);
            cout <<fixed << setprecision(3)<< x <<' '<< y <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef unsigned long long ull;

int main(){
	const int MAX_N = 50;
	ull v = 0;
	int X1[MAX_N], Y1[MAX_N], D1[MAX_N], X2[MAX_N], Y2[MAX_N], D2[MAX_N];
	int N, K;

	cin >> N >> K;

	vector<int> X(2 * N), Y(2 * N), D(2 * N);

	for (int i = 0; i<N; i++){
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
		X[i]     = X1[i];
		X[i + N] = X2[i];
		Y[i]     = Y1[i];
		Y[i + N] = Y2[i];
		D[i]     = D1[i];
		D[i + N] = D2[i];
	}

	// 並び替え
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	sort(D.begin(), D.end());

	// 重複する値を消去
	X.erase(unique(X.begin(), X.end()), X.end());
	Y.erase(unique(Y.begin(), Y.end()), Y.end());
	D.erase(unique(D.begin(), D.end()), D.end());

	// 3次元配列
	vector<vector<vector<int> > > num(X.size()-1, vector<vector<int> >(Y.size()-1, vector<int>(D.size()-1, 0)));

	for (int n = 0; n < N; n++){

		// n番目の種類の生息範囲を取り出す
		// iterator同士の引き算によってiterator -> intに変換できる
		// lower_boundは二分木探索（要ソート）、findは線形探索（ソート不要）
		int xl = lower_bound(X.begin(), X.end(), X1[n]) - X.begin();
		int xr = lower_bound(X.begin(), X.end(), X2[n]) - X.begin();
		int yl = lower_bound(Y.begin(), Y.end(), Y1[n]) - Y.begin();
		int yr = lower_bound(Y.begin(), Y.end(), Y2[n]) - Y.begin();

		//std::distanceでもできる
		int dl = distance(D.begin(), lower_bound(D.begin(), D.end(), D1[n]));
		int dr = distance(D.begin(), lower_bound(D.begin(), D.end(), D2[n]));

		for (int i = xl; i < xr; i++){
		for (int j = yl; j < yr; j++){
		for (int k = dl; k < dr; k++){
			num[i][j][k] ++;
		}}}

	}

	for (int i = 0, nx = X.size() - 1; i<nx; i++){
	for (int j = 0, ny = Y.size() - 1; j<ny; j++){
	for (int k = 0, nd = D.size() - 1; k<nd; k++){
		if (num[i][j][k] >= K) v += (ull)(X[i+1] - X[i]) * (Y[j+1] - Y[j]) * (D[k+1] - D[k]);
	}
	}
	}

	cout << v << endl;
	return 0;
}

Measured memory_bytes: 5468
import queue

N, M = map(int, input().split())
path = [0]*(N+1)

for i in range(N+1):
    path[i] = []

paths = []

for _ in range(M):
    a, b = map(int, input().split())
    path[a].append(b)
    path[b].append(a)
    paths.append((a, b))


ans = 0
for none in paths:
    dp = [False]*(N+1)
    dp[0] = True
    
    q = queue.Queue()
    q.put(1)
    while not q.empty():
        now = q.get()
        for e in path[now]:
            if not none in [(now, e), (e, now)]:
                if not dp[e]:
                    dp[e] = True
                    q.put(e)

    if False in dp:
        ans += 1

print(ans)


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n;
	cin >> n;
	vector<ll> a(n);
	ll m = 1000, stonks = 0;
	int tobuy = 0, tosell = -1;
	loop(n) {
		cin >> a[i];
		if (i) {
			if (a[i] < a[i - 1]) {
				if (stonks) {
					m += stonks * a[tosell];
					stonks = 0;
				}
				tobuy = i;
			}
			else if (a[i] > a[i - 1]) {
				ll x = m / a[tobuy];
				m -= x * a[tobuy];
				stonks += x;
				tosell = i;
			}
		}
	}
	if (stonks) m += stonks * a[tosell];
	cout << m << endl;
	return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;
const int N=2e4+10;
int a[N],b[N],ans[N];
int n,h;
int main(){
	cin>>h>>n;
	int f=0;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		f=max(a[i],f);
	}
	memset(ans,0x3f,sizeof(ans));
	ans[0]=0;
	for(int i=0;i<n;i++){
		for(int j=a[i];j<=h+a[i];j++){
			ans[j]=min(ans[j],ans[j-a[i]]+b[i]);
		}
	}
	int as=INT_MAX;
	for(int i=h;i<=h+f;i++) as=min(as,ans[i]);
	cout<<as;
	return 0;
}


Measured memory_bytes: 384
# 120_a
A, B, C = map(int, input().split())
if (1<=A&A<=100)&(1<=B&B<=100)&(1<=C&C<=100):
    C_price=A*C
    if B<C_price:
        B_count=int(B/A)
    elif B>=C_price:
        B_count=C
    print(B_count)

Measured memory_bytes: 9180
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >>c;
	if(a>=b && a>=c){cout << b+c <<endl;}
	else if(b>=a && b>=c){cout << a+c <<endl;}
	else if(c>=a && c>=b){cout << a+b <<endl;}
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    if(S[0]=='S'){
        cout << "Cloudy" << endl;
    }else if(S[0]=='C'){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const int maxn = 1e5+7;
int main(){
	fast_io;
	string s;
	cin>>s;
	if(s[0] =='7' ||s[1]=='7' ||s[2] =='7'){
		cout<<"Yes";
	}else cout<<"No";


	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;

int main(void){
  string s;
  int i,odd=0,even=0,ans=0;
  cin >> s;
  REP(i,s.length()){
    if(s[i] == '1'){
      odd+=(i+1)%2;
      even+=i%2;
    }
  }
  if(s.length()%2==0){
    ans = min(odd,even);  
    ans += s.length()/2 - max(odd,even);
  }else{
    if(odd>even){
      ans = even;
      ans += s.length()/2+1 - odd;
    }else{
      ans = odd;
      ans += s.length()/2 - even;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define pb          push_back
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323


void solve()
{
       ll n; cin>>n;
       ll a[n];
       rep(i,0,n) cin>>a[i];
       ll ans=0;
       for(ll i=1; i<n-1; i++)
       {
              ll j=i-1, k=i+1;
                            if((a[j] > a[i]  && a[k] < a[i]) || (a[j]<a[i] && a[k]>a[i]))
                            {
                                   ans++;
                            }
       }
       cout<<ans<<endl;
}


int main() {
	int T = 1;
//     pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  string s = to_string(N);
  int fx = 0;
  rep(i,sz(s)) {
    fx += s[i]-'0';
  }
  if(N%fx==0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    vector<int> num(n + 1, 0);
    for (int i = 0; i < n; i++) {
        num.at(a.at(i))++;
    }

    sort(num.begin(), num.end());
    reverse(num.begin(), num.end());

    int ans = 0;
    int c = 0;
    while (num.at(c) != 0) {
        if (c >= k) {
            ans += num.at(c);
        }
        c++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s,t; cin >> s >> t;
    int ans = n;
    REP(i,n) {
        if(s.substr(i,n-i)==t.substr(0,n-i)) break;
        else ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	puts(n==3||n==5||n==7?"YES":"NO");
}

Measured memory_bytes: 128
#include <memory>
#include <map>
#include <cassert>
#include <array>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <numeric>

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
      int a, b, c, d;
      in >> a >> b >> c >> d;
      if (b < c || d < a)
        return void (out << "0\n");
      out << std::min (b, d) - std::max (a, c) << '\n';
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}

#include <iostream>

int main ()
{
  solve (std::cin, std::cout);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long power(long long x, long long y, long long p) 
{ 
    long long res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
long long modInverse(long long n, long long p) 
{ 
    return power(n, p-2, p); 
} 
      long long fac[2005];
long long ncr(long long n, long long r, long long p) 
{ 

   if (r==0) 
      return 1; 
    if(r>n)	return 0;
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
    fac[0] = 1; 
    ll n,i,k,mod=1e9+7;
    for (i=1 ; i<=2000; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
     
     cin>>n>>k;
     for(i=1;i<=k;i++){
         //cout<<n-k+1;
     	cout<<(ncr(n-k+1,i,mod)*(ncr(k-1,i-1,mod)))%mod<<"\n";
     }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
string s;
ll n;
ll done[2*MAX][3],dp[2*MAX][3];
ll solve(ll i,ll j,char _1,char _2){
	if(i == n){
		return 0;
	}
	if(done[i][j])return dp[i][j];
	ll ans = -INF;
	if(j == 2){
		ans=max(ans,1+solve(i+1,1,s[i],'.'));
		if(i<n-1 and (s[i]!=_1 or s[i+1]!=_2)){
			ans=max(ans,1+solve(i+2,2,s[i],s[i+1]));
		}
	}
	else{
		if(s[i]!=_1){
			ans=max(ans,1+solve(i+1,1,s[i],'.'));
		}
		if(i<n-1){
			ans=max(ans,1+solve(i+2,2,s[i],s[i+1]));
		}
	}
	done[i][j]=1;
	return dp[i][j] = ans;
}
int main(){FAST;
cin>>s;
n = s.length();
ll ans = 1+solve(1,1,s[0],'.');
if(n>=2){
	ans=max(ans,1+solve(2,2,s[0],s[1]));
}
cout<<ans;
return 0;
}

Measured memory_bytes: 22036
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
long long mod = 1e9 + 7;
const int N = 3e5 + 500;

long long n, m, u, v, k, t, q, a, h;

string str;

vector <int> adj[N];
vector <int> cost[N];
int color[N];

void dfs(int v, int par) {
   for (int i = 0; i < adj[v].size(); ++i) {
      if (adj[v][i] == par) continue;
      if (cost[v][i] % 2 == 1) color[adj[v][i]] = 1 - color[v];
      else color[adj[v][i]] = color[v];
      dfs(adj[v][i], v);
   }
}

int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   
   cin >> n;
   
   for (int i = 1; i <= n - 1; ++i) {
      cin >> u >> v >> k;
      adj[u].push_back(v);
      adj[v].push_back(u);
      cost[u].push_back(k);
      cost[v].push_back(k);
   }
   
   dfs(1, 0);
   
   for (int i = 1; i <= n; ++i) {
      cout << color[i] << '\n';
   }
}






Measured memory_bytes: 24576