akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int X;
    cin >> X;
    set<int> p;
    p.insert(1);
    for (int i = 2; i <= 31; i++) {
        int tmp = i * i;
        while (tmp <= X) {
            p.insert(tmp);
            tmp *= i;
        }
    }
    cout << *p.rbegin() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  ll n;cin>>n;
  ll ans=0;
  ans+=(n/500)*1000;
  n=n%500;
  ans+=(n-n%5);
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
ans = ''
ans += 'U'*(ty-sy) + 'R'*(tx-sx) + 'D'*(ty-sy) + 'L'*(tx-sx)
ans += 'L' + 'U'*(ty-sy+1) + 'R'*(tx-sx+1) + 'D' + 'R' + 'D'*(ty-sy+1) + 'L'*(tx-sx+1) + 'U'
print(ans)

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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define vll vector<ll>
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
#define MOD 1000000007
const ll N = 2e5;

int main()
{
    speed;
    ll x;
    cin>>x;
    ll ans = 0;
    ll val = x%500;
    cout<<(x/500)*1000 + (val/5)*5<<endl;
    return 0;
}


Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const D = Number(input[0][0]);

  const T = [...Array(D)].map((_, i) => (i % 26) + 1);

  return T.join("\n");
};

console.log(main(read()));


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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

void printV(vector<int> &v);
void printVV(vector<vector<int>> &vv);


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

  vector<int> a(N);
  int maxD = 0;
  cin >> a.at(0);
  for(int i = 1; i < N; i++) {
    cin >> a.at(i);
    maxD = max(maxD, a.at(i) - a.at(i-1));
  }

  maxD = max(maxD, a.at(0) + (K - a.at(N-1)));

  cout << K - maxD << endl;
}


// ベクターの中身を全部出力
void printV(vector<int> &v) {
  cout << "  [ ";
  for(int i = 0; i < (int)v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << "]" << endl;
}

void printVV(vector<vector<int>> &vv) {
  cout << "{" << endl;
  for(int i = 0; i < (int)vv.size(); i++) {
    cout << "  [ ";
    for(int j = 0; j < (int)vv.at(i).size(); j++) {
      cout << vv.at(i).at(j) << " ";
    }
    cout << "]," << endl;
  }
  cout << "}" << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

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

int main() {
    INIT;
    string S;
    cin >> S;

    vector<ll> cnt(3, 0);
    rep(i, SZ(S)) { cnt[S[i] - 'a']++; }

    if (cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    int N, M, K;
    std::cin >> N >> M >> K;

    int64_t A, B;
    int64_t sum_A[N+1] = {0};
    int64_t sum_B[M+1] = {0};
    for (int i = 0; i < N; ++i) {
        std::cin >> A;
        sum_A[i+1] = sum_A[i] + A;
    }

    for (int i = 0; i < M; ++i) {
        std::cin >> B;
        sum_B[i+1] = sum_B[i] + B;
    }
    
    int ans = 0;
    int cur = 0;
    for (int i = N; i >= 0; --i) {
        if (sum_A[i] > K) {
            continue;
        }

        for (int j = cur; j <= M; ++j) {
            if ((sum_A[i] + sum_B[j]) > K) {
                break;
            }

            ans = std::max(i + j, ans);
            cur = j;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 6744
n = input()
A = input().split(' ')
A.sort()
A.reverse()
q = input()
M = input().split(' ')

A = list(map(int,A))
M = list(map(int,M))
A.sort()

A_sum = [0]
for a in A:
    A_sum.append(a+A_sum[-1])
A_sum.pop(0)

A.reverse()
A_sum.reverse()


#memo = [True]*(len(A))

def search(base, m, n):
    if base == m:
        return True
    if len(A)-1 < n or m - base > A_sum[n]:
        return False
    result = False
    for i in range(len(A)-1,n-1,-1):
        if base + A[i] <= m: # and memo[i]:
#           memo[i] = False
#           print(str(A[i]) + ',' + str(base+A[i]) + ',')
            if search(base+A[i], m, i+1):
                return True
#           memo[i] = True
    return result

def print_yn(result):
    if result:
        print('yes')
    else:
        print('no')

for m in M:
#   print(str(m)+':')
    print_yn(search(0,m,0))

Measured memory_bytes: 7800
#include <map>
#include <set>
#include <cmath>
#include <ctime> 
#include <queue>
#include <stack>
#include <bitset> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

template <class T>
inline void rd(T &x) {
    char c = getchar(), f = 0; x = 0;
    while (!isdigit(c)) f = (c == '-'), c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    x = f ? -x : x;
}

int main() {
    int k, n;
    rd(k);
    if (k == 1) { puts("1\n1"); return 0; }
    printf("%d\n", n = (k + 3) / 4 * 2);
    rep(i, 0, n - 1) {
        rep(j, 0, n - 1) {
            int gx = (i + j) % n + 1 + (i & 1) * n;
            if (gx > k) gx -= n;
            printf("%d ", gx);
        }
        puts("");
    }
    return 0;
}

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

using namespace std;

signed main() {
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	vector <int> a;
	int x;
	while (cin >> x) a.push_back(x);

	int n = a.size();
	sort(a.begin(), a.end());

	int ans = 0;
	for (int i = 1; i < n; ++i) {
		ans += a[i] - a[i - 1];
	}

	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [float(x) for x in input().split()]

A.sort(reverse=True)

sum = 0.0
for a in A:
    sum += a

ret = 'Yes'
for i in range(M):
    if (A[i] < (sum / (4 * M))):
        ret = 'No'
        break

print(ret)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

const int INF = 1e9 + 5;
int main() {
	int n; cin >> n;
	vi dp1(3);
	cin >> dp1[0] >> dp1[1] >> dp1[2];

	for (int i = 0; i < n - 1; i++){
		vi tmp(3);
		vi dp2(3);
		for (auto &it : tmp) cin >> it;
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 3; k++){
				if (j != k){
					dp2[j] = max(dp2[j], dp1[k] + tmp[j]);
				}
			}
		}
		dp1 = dp2;
	}
	int mx = 0;
	for (int i = 0; i < 3; i++) mx = max(mx, dp1[i]);
	cout << mx << endl;
}


Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            N %= 10;
            if ((N == 0) || (N == 1) || (N == 6) || (N == 8)) Console.WriteLine("pon");
            else if (N == 3) Console.WriteLine("bon");
            else Console.WriteLine("hon");
        }
    }
}


Measured memory_bytes: 27540
def main():
    import sys
    from operator import itemgetter
    input = sys.stdin.readline

    N = int(input())
    if N == 1:
        print(0)
        exit()
    xy = []
    ymax = 0
    ymin = 10**9+7
    for _ in range(N):
        x, y = map(int, input().split())
        if x > y:
            x, y = y, x
        if y > ymax:
            ymax = y
        if y < ymin:
            ymin = y
        xy.append((x, y))
    xy.sort(key=itemgetter(0))

    xmin = xy[0][0]
    xmax = xy[-1][0]
    ymax_idx = []
    for i in range(N):
        if xy[i][1] == ymax:
            ymax_idx.append(i)

    ans = (xmax - xmin) * (ymax - ymin)
    xmin_tmp = 10**9+7
    xmax_tmp = 0
    for i in range(ymax_idx[0]):
        if xy[i][1] < xmin_tmp:
            xmin_tmp = xy[i][1]
        if xy[i][1] > xmax_tmp:
            xmax_tmp = xy[i][1]
        ans_new = (ymax - xmin) * (max(xmax, xmax_tmp) - min(xmin_tmp, xy[i+1][0]))
        if ans_new < ans:
            ans = ans_new
    xmin_tmp = 10 ** 9 + 7
    xmax_tmp = 0
    for i in range(N-1, ymax_idx[-1], -1):
        if xy[i][1] < xmin_tmp:
            xmin_tmp = xy[i][1]
        if xy[i][1] > xmax_tmp:
            xmax_tmp = xy[i][1]
        ans_new = (ymax - xmin) * (max(xmax_tmp, xy[i-1][0]) - min(xmin_tmp, xmin))
        if ans_new < ans:
            ans = ans_new

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72412
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N;
  cin >> N;
  double p;
  if (N % 2 == 0){
    p = 0.5;
    cout << p << endl;
  } else {
    p = (N/2 + 1.0) / N;
    cout << p << endl;
  }
}


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


void solve(long long N){
    while (N > 10) {
        N %= 10;
    }
    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        printf("hon\n");
    } else if (N == 3) {
        printf("bon\n");
    } else {
        printf("pon\n");
    }
    
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
        int n;
        cin >> n;
        while(n){
                int sum = 0;
                for(int i  = 1; i <= n; i++){
                        int k = i;
                        while(!(k%5)){
                                k /= 5;
                                sum++;
                        }   
                }   
                cout << sum << endl;
                cin >> n;
        }   
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#define MAXN (100000 + 5)
using namespace std;
bool isp[MAXN];
vector<int> prime;
void init()
{
	memset(isp, true, sizeof(isp));
	isp[1] = false;
	for (int i = 2; i < MAXN; i++)
	{
		if (isp[i])
			prime.push_back(i);
		for (int j = 0; j < prime.size() && prime[j] * i < MAXN; j++)
		{
			isp[i * prime[j]] = false;
			if (i % prime[j] == 0)
				break;
		}
	}
}
int main()
{
	init();
	int n;
	scanf("%d", &n);
	int last = 0;
	for (int i = 1; i <= n; i++)
	{
		for (; last < prime.size(); last++)
			if (prime[last] % 10 == 1)
			{
				printf("%d ", prime[last]);
				++last;
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, const char* argv[]) {
  int N, M;
  int ACcount = 0;
  int WAcount = 0;
  cin >> N >> M;
  vector<int> p(M);
  vector<int> WAC(M);
  vector<int> WA(N);
  vector<int> status(N);
  string S;

  for (int i = 0; i < M; i++) {
    cin >> p[i] >> S;
    if(S.compare("AC") == 0){
      WAC[i] = 1;
    }else{
      WAC[i] = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    status[i] = 0;
    WA[i] = 0;
  }

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

  for (int i = 0; i < M; i++) {
    if (status[p[i]-1] == 0) {
      if (WAC[i] == 1) {
        status[p[i] - 1] = 1;
        WAcount += WA[p[i] - 1];
        ACcount++;
      }else{
        WA[p[i] - 1]++;
      }
    }
  }

  printf("%d %d\n", ACcount, WAcount);
  return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, sum, carryOver int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := make([]int, n+1)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	b := make([]int, n)
	for i := range b {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
	}

	for i := 0; i <= n; i++ {
		m := a[i]
		if carryOver >= m {
			sum += m
			m = 0
		} else {
			sum += carryOver
			m -= carryOver
		}

		if i == n {
			break
		}

		if b[i] >= m {
			sum += m
			carryOver = b[i] - m
		} else {
			sum += b[i]
			carryOver = 0
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 5120
#include<stdio.h>
 
int main(void){
  int N,i;
  long int sum;
  scanf("%d", &N);
  sum = 0;
  for(i=0;i<=N;i++){
    if(i%3!=0 && i%5!=0)
      sum += i;
  }
  printf("%ld", sum);
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9+7;

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	int west = count(str.begin(), str.end(),  'W');
	int east = 0;
	int ans = INF;
	rep(i, n){
		int change = i-east;
		if(str.at(i) == 'W'){
			change += n-(west+east);
		}else{
			change += n-1-(west+east);
		}
		ans = min(ans, change);
		if(str.at(i) == 'E') east++;
	}
	cout << ans << endl;

}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

vi exps(ll x) {
  vi cnts;
  for (ll i = 2; i*i <= x; ++i) {
    int c1 = 0;
    if (x%i==0) {
      while (x%i==0) {
        x/=i;
        ++c1;
      } 
    }
    cnts.pb(c1);
  }
  if (x != 1) cnts.pb(1);
  return cnts;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  auto fnd = [&](int x) {
    ll ans = 0;
    per(j,0,20) {
      while ((ans+(1<<j))*(ans+(1<<j)+1) / 2 <= x) {
        ans += 1<<j;
      }
    }
    return ans;
  };

  ll n;
  cin >> n;
  vi res = exps(n);
  ll ans = 0;
  for (auto x: res) {
    ans += fnd(x);
  }

  cout << ans << '\n';
}

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

int main(){
sp;
double t,x;
cin>>t>>x;
cout<<fixed<<setprecision(12)<<(1.0*t/x);
return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1 << 19;
const int W_MAX = 1000;
const int N_MAX = 1000;

int v[N_MAX + 1], w[N_MAX + 1];
int N,W;
int dp[N_MAX + 1][W_MAX +1];//N個目までで、Wを超えないように選んだ時の最大値

int main()
{
	int c = 1;
	while(cin >> W,W){
		cin >> N;
		for(int i = 0; i < N; ++i){
			cin >> v[i]; cin.ignore(1,','); cin >> w[i];
		}
		
		for(int i = 0; i < N; ++i){
			for(int j = 0; j <= W; ++j){
				if(j < w[i]){
					dp[i + 1][j] = dp[i][j];
				}else {
					dp[i + 1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
				}
			}
		}
		cout << "Case " << c++ << ':' << endl;
		int max_v = -1, min_w = INF;
		for(int i = 0; i <= W; ++i){
			if(dp[N][i] > max_v){
				max_v = dp[N][i];
				min_w = i;
			}
		}
		cout << max_v << endl << min_w << endl;
	}
}

Measured memory_bytes: 5084
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  cin >> A;
  vector<int> cnt(N + 1);
  for (int i = 0; i < N; i++) {
    cnt[A[i]]++;
  }
  debug(cnt);
  int64 ans = 1;
  if (N % 2 == 0) {  // even
    for (int i = 1; i < N; i += 2) {
      debug(i, cnt[i]);
      if (cnt[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
    }
    for (int i = 1; i <= N / 2; i++) {
      ans *= 2;
      ans %= (int64)1e9 + 7;
    }
  } else {  // odd
    if (cnt[0] != 1) {
      cout << 0 << endl;
      return 0;
    }
    for (int i = 2; i < N; i += 2) {
      if (cnt[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
    }
    for (int i = 1; i <= (N - 1) / 2; i++) {
      ans *= 2;
      ans %= (int64)1e9 + 7;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4024
#pragma GCC diagnostic error "-std=c++14"
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
void print(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)print(x/10);
	putchar(x%10+48);
}
int main()
{
	int n=read(n);
    long long ans=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 1596
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>

int solve(int n, const std::vector<std::string>& gifts)
{
  std::unordered_set<std::string> set;
  for (const auto& s : gifts) {
    set.insert(s);
  }
  return set.size();
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<std::string> gifts(n);
  for (auto& s : gifts) {
    std::cin >> s;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(n, gifts) << std::endl;
}


Measured memory_bytes: 24044
from collections import defaultdict
import sys
input = sys.stdin.readline

def main():
    H, W, N = map(int, input().split())
    j = [0] * 10
    ans = [0] * 10
    ans[0] = (H - 2) * (W - 2)
    d = defaultdict(int)
    dt = [-1,0,1]
    for i in range(N):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        for i in dt:
            if 0 <= a + i <= H - 1:
                for j in dt:
                    if 0 <= b + j <= W - 1:
                        tmp = d[(a + i, b + j)]
                        d[(a + i, b + j)] += 1
                        if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2:
                            ans[tmp] -= 1
                            ans[tmp + 1] += 1
    
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 151928
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

struct VectorItem
{
  uint64_t a, b, c, d;
  VectorItem(uint64_t a = 0, uint64_t b = 0, uint64_t c = 0, uint64_t d = 0)
    : a(a), b(b), c(c), d(d) {}

  bool operator>(const VectorItem &item) const
  {
    return d > item.d;
  }
  bool operator<(const VectorItem &item) const
  {
    return b < item.b;
  }
};

istream& operator>>(istream &is, VectorItem &item)
{
  is >> item.a >> item.b >> item.c >> item.d;
  --item.a; --item.b;
  return is;
}

struct QueueItem
{
  uint64_t n;
  vector<uint64_t> v;

  QueueItem(uint64_t n, const vector<uint64_t> &v) : n(n), v(v) {}
};

int main()
{
  uint64_t N, M, Q;
  cin >> N >> M >> Q;

  vector<VectorItem> v(Q);
  N_TIMES(q, Q) { cin >> v[q]; }
  
  auto calc_score = [&](const vector<uint64_t> &A) {
    uint64_t score = 0;
    N_TIMES(q, Q) {
      if (A[v[q].b] - A[v[q].a] == v[q].c) {
        score += v[q].d;
      }
    }
    return score;
  };

  uint64_t max_score = 0;
  queue<QueueItem> q;
  q.emplace(1, vector<uint64_t>(N, 1));
  while (!q.empty()) {
    QueueItem item = q.front(); q.pop();
    
    if (item.n == N) { 
      max_score = max(max_score, calc_score(item.v));
      continue;
    }

    for (uint64_t x = item.v[item.n - 1]; x <= M; ++x) {
      vector<uint64_t> u(item.v);
      u[item.n] = x;
      q.emplace(item.n + 1, u);
    }
  }
  cout << max_score << endl;

  return 0;
}

Measured memory_bytes: 9268
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i,m){
		cin >> a[i] >> b[i];
		--a[i];
		--b[i];
	}
	int ans = 0;
	rep(i,m){
		union_find uf(n);
		rep(j,m){
			if(i == j) continue;
			uf.unite(a[j], b[j]);
		}
		bool ok = false;
		rep(i,n){
			if(!uf.same(0, i)) ok = true;
		}
		if(ok) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if (a > b) {
        swap(a, b);
    }
    cout << max(b - a - W, 0) << endl;
    return 0;
}


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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQMIN(...) std::priority_queue<__VA_ARGS__,Arr<__VA_ARGS__>,greater<__VA_ARGS__>>
template<class... A>
auto ARR(auto n, A&&...a){
	if constexpr(sizeof...(a)==0) return n;
	else return vector(n,ARR(a...));
}

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
auto cinint(){i64 x;cin>>x;return x;}
auto cinchr(){char x;cin>>x;return x;}
auto cinints(int n){Arr<i64> a(n);for(auto&i:a)cin>>i;return a;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int n; cin>>n;
	int a[n];
	rep(i,n)
		cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	int ans=a[0];
	rep(i,n-2)
		ans+=a[i/2+1];
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 5208
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

int H, W;
char grid[1000][1001];
int m[1000][1000];

bool ok(int t)
{
  static bool visited[1000][1000];
  for (int i = 0; i < H; i++) {
    fill_n(visited[i], W, false);
  }
  visited[0][0] = true;
  queue<pair<int,int> > q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    const int x = q.front().first;
    const int y = q.front().second;
    q.pop();
    if (grid[x][y] == 't') {
      return true;
    }
    for (int d = 0; d < 4; d++) {
      static const int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
      const int z = x + dx[d], w = y + dy[d];
      if (0 <= z && z < H && 0 <= w && w < W
          && !visited[z][w]
          && (grid[z][w] != '#' || m[z][w] <= t)) {
        visited[z][w] = true;
        q.push(make_pair(z, w));
      }
    }
  }
  return false;
}

int main()
{
  scanf("%d %d", &W, &H);
  for (int i = 0; i < H; i++) {
    scanf("%s", grid[i]);
  }
  int N;
  scanf("%d", &N);
  static const int INF = 10000000;
  for (int i = 0; i < H; i++) {
    fill_n(m[i], W, INF);
  }
  for (int i = 0; i < N; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    m[y][x] = i+1;
  }

  if (!ok(N)) {
    puts("-1");
    return 0;
  }

  int lo = 0, hi = N;
  while (lo < hi) {
    const int mid = (lo + hi)/2;
    if (ok(mid)) {
      hi = mid;
    } else {
      lo = mid+1;
    }
  }
  printf("%d\n", lo);
  return 0;
}

Measured memory_bytes: 6656
#include <iostream>
using namespace std;
int main(){
	const string TABLE[] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	int n;
	cin >> n;
	for(int i=0;i<n;++i){
		string s;
		string ans;
		int k=0,l=-1;
		bool in = false;
		cin >> s;
		for(int j=0;j<s.size();++j){
			if(s[j]=='0'){
				if(in){
					ans+=TABLE[k][l];
				}
				in = false;
				k=0;
				l=-1;
			}else{
				in = true;
				l++;
				k=s[j]-'1';
				l%=TABLE[k].size();
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream
#include <bitset>
#include <iomanip>
#include <functional>
#include <set>


#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;
const long long INF = 1LL << 60;

#define OUTPUT_DEBUG_LOG

template <typename T>
void DisplayAnswer(const T& v) {
	cout << v << endl;
}
template <typename T>
void DisplayAnswers(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << endl;
	}
}

template <typename T>
void DisplayAnswerOneLine(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << ' ';
	}
	cout << endl;
}


std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



template<class T>
void chmin(T& a, T b) {
	if (a > b) {
		a = b;
	}
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

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

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}


void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}



struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

void FuncA() {
	ll m;
	cin >> m;

	while (m > 0) {
		m -= 1000;
	}
	DisplayAnswer(-m);
}

void FuncB() {
	unordered_map<string, int> map;

	map["AC"]=0;
	map["WA"] = 0;
	map["TLE"] = 0;
	map["RE"] = 0;

	ll n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		map[str]++;
	}

	cout << "AC x " << map["AC"] << endl;
	cout << "WA x " << map["WA"] << endl;
	cout << "TLE x " << map["TLE"] << endl;
	cout << "RE x " << map["RE"] << endl;
}

int main(void) {

	FuncB();

	return 0;
}


Measured memory_bytes: 3636
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

A,B,C = read().decode().split()

A = list(A)
B = list(B)
C = list(C)

def can_match(x,y):
    return x == '?' or y == '?' or x == y

M = 2020

def solve(A,B,C,LA,LB,LC):
    B_from_A = [True] * (M+1)
    for i in range(M+1):
        B_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],B))
    C_from_A = [True] * (M+M+1)
    for i in range(M+M+1):
        C_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],C))
    C_from_B = [True] * (M+1)
    for i in range(M+1):
        C_from_B[i] = all(can_match(x,y) for x,y in zip(B[i:],C))
    for i in range(M):
        if not B_from_A[i]:
            continue
        for j in range(M):
            if not C_from_B[j]:
                continue
            if not C_from_A[i+j]:
                continue
            yield max(LA, LB+i, LC+i+j)
            break

answer = 10 ** 9
for A,B,C in itertools.permutations([A,B,C]):
    LA = len(A)
    LB = len(B)
    LC = len(C)
    x = min(solve(A,B,C,LA,LB,LC))
    if answer > x:
        answer = x
print(answer)

Measured memory_bytes: 90204
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    string K;
    int D;
    cin >> K >> D;

    const ll MOD = 1e9+7;
    Vvec<ll> dp(D, vector<ll>(2));
    Vvec<ll> next(D, vector<ll>(2));
    dp[0][1] = 1;

    for(int i=0; i<K.size(); i++){
        int n = K[i] - '0';
        for(int j=0; j<D; j++){
            for(int k=0; k<10; k++){
                int r = (j+k) % D;
                next[r][0] += dp[j][0];
                next[r][0] %= MOD;
            }
            for(int k=0; k<n; k++){
                int r = (j+k) % D;
                next[r][0] += dp[j][1];
                next[r][0] %= MOD;
            }
            int r = (j+n) % D;
            next[r][1] += dp[j][1];
            next[r][1] %= MOD;
        }

        for(int j=0; j<D; j++){
            dp[j][0] = next[j][0];
            dp[j][1] = next[j][1];
            next[j][0] = 0;
            next[j][1] = 0;
        }
    }

    ll ans = dp[0][0] + dp[0][1] - 1;
    if(ans < 0) ans += MOD;
    cout << ans % MOD << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long A,B,N;
	scanf("%lld%lld%lld",&A,&B,&N);
	if(N>=B-1ll) printf("%lld",(A*(B-1ll))/B);
	else printf("%lld",(A*N)/B);
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<bool> flg(8, false);
    int all_num = 0;
    rep(i, n) {
        int tmp_num = 0;
        cin >> tmp_num;
        if ( tmp_num <= 399 ) flg[0] = true;
        else if ( tmp_num <= 799 ) flg[1] = true;
        else if ( tmp_num <= 1199 ) flg[2] = true;
        else if ( tmp_num <= 1599 ) flg[3] = true;
        else if ( tmp_num <= 1999 ) flg[4] = true;
        else if ( tmp_num <= 2399 ) flg[5] = true;
        else if ( tmp_num <= 2799 ) flg[6] = true;
        else if ( tmp_num <= 3199 ) flg[7] = true;
        else                        ++all_num;
    }
    int cnt = 0;
    rep(i, 8) {
        if ( flg[i] ) ++cnt;
    }
    if ( all_num == 0 ) cout << cnt << " " << cnt << endl;
    else                cout << max(1, cnt) << " " << cnt+all_num << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

const int maxn = 205;

int deg[5];

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

	int M = 3;
	while (M--){
		int u, v;
		cin >> u >> v;
		deg[u]++; deg[v]++;
	}
	int res = 0;
	for (int i=1; i<=4; ++i)
		if (deg[i] == 1) ++res;
	if (res <= 2) cout << "YES";
	else cout << "NO";
}


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

int main(){
int a,b,c;
cin >> a >> b >>c;
int first_remainder=a%b;
string ans="NO";
int i=1;
do{ 
    if(a*i % b ==c)
    {ans="YES";}
    i++;
}
while(first_remainder!=a*i%b);//iが1以外の時にあまりが一周したら終了
cout << ans << endl;
return 0;
}
//

Measured memory_bytes: 256
s = list(input())
cnt0 = 0
cnt1 = 0
for i, ss in enumerate(s):
    if i % 2 == 0 :
        if ss == '0':
            cnt1 += 1
        else:
            cnt0 += 1
    else:
        if ss == '1':
            cnt1 += 1
        else:
            cnt0 += 1
print(min(cnt0,cnt1))


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

void print_array(const int a[], int n) {
  for (int i = 0; i < n; ++i) {
    if (i > 0)
      std::cout << " ";
    std::cout << a[i];
  }
  std::cout << std::endl;
}

void insertion_sort(int a[], int n) {
  for (int i = 0; i < n; ++i) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    print_array(a, n);
  }
}

int main() {
  int n;
  std::cin >> n;
  int a[100];
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];

  insertion_sort(a, n);
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long  n,count,a;
	cin>>n;
	int c=sqrt(n);
	for(int i=c;;i--){
		if(n%i==0){count=i;goto loop;}
	}
	loop:;
	count=max(count,n/count);
	for(int i=0;;i++){
		if(count/10==0){a=i;goto loop2;}
		count/=10;
	}
	loop2:;
	cout<<a+1<<endl;
}


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

int main(){
  int N;
  cin >> N;
  
  set<int> st;
  

  for (int i=0; i<N; i++){
    int a;
    cin >> a;
    st.insert(a);
  }
  
  for(auto itr = st.begin(); itr != st.end(); ++itr) {
    //cout << *itr << "\n";
  }
  
  cout << st.size() << endl;
}

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

using T = tuple<int, int, int>;

int main() {
    int n;
    cin >> n;
    int p[3];
    set<T> st;
    for (int i = 0; i < n; i++) {
        cin >> p[0] >> p[1] >> p[2];
        sort(p, p + 3);
        T t = make_tuple(p[0], p[1], p[2]);
        st.insert(t);
    }
    cout << n - st.size() << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll f(ll a, ll b) {
    return (a * a * a * a) + (a * a * a * b) + (a * a * b * b)+ (a * b * b * b) + (b * b * b * b);
}

vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i) {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void solve() {
    ll X;
    cin >> X;
    auto divisors = divisor(X);
    for (ll d : divisors) {
        ll ano = X / d;
        rep2(a, -140 , 140 + 1) {
            ll b = a - d;
            if (f(a, b) == ano) {
                cout << a << " " << b << '\n';
                return;
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int n, x[100001], p[100000], d[100000], np[100000], tp[100000];
ll an[100001];

int main(){
	scanf("%d", &n);
	f(i, 1, n + 1)scanf("%d", x + i);
	f(i, 1, n)d[i] = x[i + 1] - x[i];
	f(i, 1, n)p[i] = i, np[i] = i;
	int m;
	ll k;
	scanf("%d%lld", &m, &k);
	f(i, 0, m){
		int t;
		scanf("%d", &t);
		swap(p[t - 1], p[t]);
	}
	while (k){
		if (k & 1){
			f(i, 1, n)tp[i] = np[p[i]];
			f(i, 1, n)np[i] = tp[i];
		}
		f(i, 1, n)tp[i] = p[p[i]];
		f(i, 1, n)p[i] = tp[i];
		k >>= 1;
	}
	an[1] = x[1];
	f(i, 2, n + 1)an[i] = an[i - 1] + d[np[i - 1]];
	f(i, 1, n + 1)printf("%lld\n", an[i]);
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

typedef vector<ll> vl;

const int mod = 998244353, root = 3;

ll pot (ll b, ll p) {
	if (p < 0) p += mod - 1;
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

int nearestPowerOfTwo (int n) {
	int ans = 1;
	while (ans < n)
		ans <<= 1;
	return ans;
}

void ntt (vi &x, int inv) {
	int n = x.size();

	for(int i = 1, j = 0; i < n - 1; i++){
		for(int k = n >> 1; (j ^= k) < k; k >>= 1);
		if(i < j)
			swap(x[i], x[j]);
	}
	
	vl wp(n >> 1, 1);
	for(int k = 1; k < n; k <<= 1){
		ll wk = pot(root, inv * (mod - 1) / (k << 1));
		
		for (int j = 1; j < k; ++j)
			wp[j] = wp[j - 1] * wk % mod;
		
		for (int i = 0; i < n; i += k << 1) {
			for (int j = 0; j < k; ++j) {
				int u = x[i + j], v = x[i + j + k] * wp[j] % mod;
				x[i + j] = u + v < mod ? u + v : u + v - mod;
				x[i + j + k] = u - v < 0 ? u - v + mod : u - v;
			}
		}
	}

	if (inv == -1) {
		ll nrev = pot(n, mod - 2);
		for(int i = 0; i < n; i++)
			x[i] = x[i] * nrev % mod;
	}
}

void mul (vi &a, vi &b) {
	int sz = a.size() + b.size() - 1;
	int size = nearestPowerOfTwo(sz);
	
	a.resize(size), b.resize(size);
	ntt(a, 1), ntt(b, 1);
	
	for(int i = 0; i < size; i++)
		a[i] = 1ll * a[i] * b[i] % mod;
	
	ntt(a, -1);
	a.resize(sz);
}

const int MX = 100005;
int n, h[MX], cn[MX];
ll fac[MX], inv[MX], f[MX];
vi p[MX];
priority_queue<ii, vii, greater<ii>> pq;

ll comb (int n, int k) {
	return fac[n] * inv[k] % mod * inv[n - k] % mod;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	fac[0] = inv[0] = 1;
	for (int i = 1; i < MX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = pot(fac[i], mod - 2);
	}

	cin >> n;
	forn (i, 2 * n) {
		int a;
		cin >> a;
		cn[a]++;
	}

	f[0] = f[1] = 1;
	for (int i = 2; i < MX; i++)
		f[i] = f[i - 1] * (2 * i - 1) % mod;

	forn (i, MX) {
		p[i].resize(cn[i] / 2 + 1);

		p[i][0] = 1;
		for (ll j = 1; j <= cn[i] / 2; j++)
			p[i][j] = comb(cn[i], 2 * j) * f[j] % mod;

		if (p[i].size() > 1) pq.emplace(p[i].size(), i);
	}

	while (pq.size() > 1) {
		int x = pq.top().se; pq.pop();
		int y = pq.top().se; pq.pop();

		mul(p[x], p[y]);
		p[y].clear();

		pq.emplace(p[x].size(), x);
	}

	ll res = 0;

	if (pq.size()) {
		int i = pq.top().se;

		for (int j = 0, s = 1; j < p[i].size(); j++, s *= -1)
			(res += s * p[i][j] * f[n - j]) %= mod;

		cout << MOD(res, mod) << endl;
	} else {
		cout << f[n] << endl;
	}

	return 0;
}


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

int main() {
int a,b,c,x,answer;
  answer=0;
  cin >> a >> b >> c >> x;
  for(int i=0;i<a+1; i++){
    for(int j=0;j<b+1; j++){
      for(int k=0;k<c+1; k++){
        if(500*i+100*j+50*k==x){
          answer++;
        }
      }
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1*1e5+5;

int dp[5][(1<<21)+5];

void add_self(int &a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
}

int32_t main() {

	
	int n;
	cin >> n;
	vector<int> m(n, 0);
	
	
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++) {
			int x;
			cin >> x;
			if(x) m[i] |= (1<<j);
		}

	for(int i = 0; i <= (1 << n); i++)
		dp[n & 1][i] = 1;
	
	for(int i = n-1; i >= 0; i--)
		for(int j = (1<<n)-1; j >= 0; j--) {
			
			dp[i & 1][j] = 0;
			int kappa = m[i] ^ (m[i] & j);
		
			while(kappa > 0) {
				add_self(dp[i & 1][j], dp[~i & 1][j | (kappa & -kappa)]);
				kappa -= (kappa & -kappa);
			}
			
			
		}
	
	cout << dp[0][0] << endl;
			
}


Measured memory_bytes: 35072