akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

	private static void execute() {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();

			int num = a /100;
			int remain = a % 100;
			
			for(int i=0; i<num; i++) {
				if(remain <= 5) {
					System.out.println("1");
					return;
				}
				remain = remain - 5;
			}
			System.out.println("0");

		}
	}
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    int N;
    std::cin >> N;
    std::vector<pair<int, int>> A(N);
    REP(i, N) {
        int a;
        std::cin >> a;
        A[i] = make_pair(a, i + 1);
    }

    SORT(A);

    REP(i, N) {
        std::cout << A[i].second << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 1664
n, m, x = map(int, input().split(" "))
nums = list(map(int, input().split(" ")))
lefts = [t for t in nums if t < x]
rights = [t for t in nums if t > x]

if len(lefts) > len(rights):
	print(len(rights))
else:
	print(len(lefts))

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

int main() {
    int N; cin >> N;
    int counter = 0;
    int now = 1;
    rep(i, N){
        int a; cin >> a;
        if (a == now){
            now++;
        } else {
            counter++;
        }
    }
    if (counter == N){
        cout << -1 << endl;
    } else {
        cout << counter << endl; 
    }
    return 0;
}

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

#define int long long

using namespace std;

signed main(){
//	int t;
//	cin >> t;
//	while(t--){
		int n,k;
		cin >> n >> k;
		int a[n];
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		for(int i=k;i<n;i++){
			if(a[i]>a[i-k]){
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
//	}
}

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

int n;
long long a[52], u, l;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	u = *std::max_element(a, a + n);
	l = *std::min_element(a, a + n);
	if(abs(u) >= abs(l)) {
		printf("%d\n", 2 * n - 2);
		printf("%d %d\n", std::max_element(a, a + n) - a + 1, n);
		printf("%d %d\n", std::max_element(a, a + n) - a + 1, n);
		a[n - 1] += u * 2;
		for(int i = 1; i + 1 < n; ++i) {
			printf("%d %d\n", n, i + 1);
			a[i] += a[n - 1];
			printf("%d %d\n", n, n);
			a[n - 1] += a[n - 1];
		}
	} else {
		printf("%d\n", 2 * n - 2);
		printf("%d %d\n", std::min_element(a, a + n) - a + 1, 1);
		printf("%d %d\n", std::min_element(a, a + n) - a + 1, 1);
		a[0] += l * 2;
		for(int i = n - 1; i >= 2; --i) {
			printf("%d %d\n", 1, i);
			a[i - 1] += a[0];
			printf("%d %d\n", 1, 1);
			a[0] += a[0];
		}
	}
	return 0;
}


Measured memory_bytes: 256
void main(){
	int n, a, b;
	int ans;
	readf("%d %d %d", &n, &a, &b);
	foreach(i; 1..n+1){
		string s = i.to!string();
		int all=0; // 各桁の合計
		foreach(c; s)all += c.to!(int)-'0';
		if(a<= all && all<=b)ans+=i;
	}
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[100002], b[100002];
    vector<int> v[100002];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    int q;
    cin >> q;
    int near[100002];
    int col[100002] {0};
    fill(near, near + n, -1);
    int w[100002], d[100002], c[100002];
    for(int i = q - 1; i >= 0; i--){
        cin >> w[i] >> d[i] >> c[i];
        w[i]--;
    }
    for(int i = 0; i < q; i++){
        queue<int> que;
        if(near[w[i]] == -1) col[w[i]] = c[i];
        near[w[i]] = d[i];
        que.push(w[i]);
        while(que.size()){
            int now = que.front();
            que.pop();
            if(near[now] == 0) continue;
            for(int next : v[now]){
                if(near[next] < near[now] - 1){
                    if(near[next] == -1) col[next] = c[i];
                    near[next] = near[now] - 1;
                    que.push(next);
                }
            }
        }
    }
    for(int i = 0; i < n; i++) cout << col[i] << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 1; i <= n; i++) {
    a[i-1] = i;
  }

  vector<int> p(n), q(n);
  rep(i, n) {
    cin >> p[i];
  }
  rep(i, n) {
    cin >> q[i];
  }
  int ra, rb;
  int count = 1;
  do {
    bool pm = true;
    bool qm = true;
    rep(i, n) {
      if (p[i] != a[i]) pm = false;
      if (q[i] != a[i]) qm = false;
    }

    if (pm) ra = count;
    if (qm) rb = count;
    count++;
  } while (next_permutation(begin(a), end(a)));

  cout << abs(ra - rb);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(;;){
        string s;
        cin >> s;
        if(s == ".")
            return 0;

        int n = s.size();
        string ans;
        stack<int> stk;
        int d = 0;
        for(int i=0; i<n; ++i){
            switch(s[i]){
                case '+':
                    ++ d;
                    break;

                case '-':
                    -- d;
                    break;

                case '[':
                    stk.push(ans.size());
                    break;

                case ']':
                    reverse(ans.begin() + stk.top(), ans.end());
                    stk.pop();
                    break;

                case '?':
                    ans += 'A';
                    d = 0;
                    break;

                default:
                    char c = ((s[i] - 'A' + d) % 26 + 26) % 26 + 'A';
                    ans += c;
                    d = 0;
                    break;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N;
	long long A[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	long long min = llabs(A[1]), sum = 0, parity = 0;
	for (i = 1; i <= N; i++) {
		sum += llabs(A[i]);
		if (llabs(A[i]) < min) min = llabs(A[i]);
		if (A[i] < 0) parity ^= 1;
	}
	
	if (parity == 0) printf("%lld\n", sum);
	else printf("%lld\n", sum - min * 2);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    num_list = [0] * n  # 各番号が書かれたボールが何個あるか
    method_list = [0] * n  # 同じ番号が書かれた異なる2つのボールを選ぶ方法

    for a in a_list:
        num_list[a - 1] += 1

    for i in range(n):
        b = num_list[i]
        if b >= 2:
            method_list[i] = b * (b - 1) // 2

    total_method = sum(method_list)

    for k in range(n):
        c = a_list[k]  # k番目のボールに書かれている数字
        ans = total_method - method_list[c - 1]
        d = num_list[c - 1]
        if d >= 3:
            e = (d - 1) * (d - 2) // 2
        else:
            e = 0
        ans += e
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 100832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int h, w;
    cin >> h >> w;
    VI a(h), b(h);
    rep(i, h) {
        cin >> a[i] >> b[i];
        a[i]--;
    }
    multiset<int> num;
    rep(i, w) num.insert(0);
    VI dp(w);
    set<int> alive;
    rep(i, w) alive.insert(i);
    rep(i, h) {
        while(1) {
            auto it = alive.lower_bound(a[i]);
            if(it == alive.end() || *it >= b[i]) break;
            int k = *it;
            assert(num.find(dp[k]) != num.end());
            alive.erase(k);
            num.erase(num.find(dp[k]));
            if (b[i] == w) {
                ;
            } else if (alive.count(b[i]) == 0) {
                alive.insert(b[i]);
                dp[b[i]] = dp[k] + b[i] - k;
                num.insert(dp[k] + b[i] - k);
            } else {
                if (dp[k] + b[i] - k < dp[b[i]]) {
                    num.erase(num.find(dp[b[i]]));
                    num.insert(dp[k] + b[i] - k);
                    dp[b[i]] = dp[k] + b[i] - k;
                }
            }
            a[i] = k + 1;
        }
        if (num.empty()) cout << -1 << endl;
        else cout << *num.begin() + i + 1 << endl;
    }
}

Measured memory_bytes: 24264
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

struct SegTree{
	int size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = 0;
	}
	
	void update(int i, llint val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = (seg[i*2]+seg[i*2+1]) % mod;
		}
	}

	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return 0;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return (lval+rval)%mod;
	}
	llint query(int a, int b)
	{
		if(a > b) return 0;
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint fact[2005], fact_inv[2005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 2005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 2005; i++){
		fact_inv[i] = pow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint N, K;
SegTree seg[2] = {SegTree(12), SegTree(12)};

int main(void)
{
	make_fact();
	cin >> N >> K;
	if(N == 1){
		cout << 1 << endl;
		return 0;
	}
	
	seg[0].update(0, 1);
	for(int i = 1; i <= K-1; i++){
		seg[i%2].init();
		for(int j = 0; j <= N-1; j++){
			llint tmp = 0;
			tmp += seg[(i+1)%2].query(j+1, j+1);
			if(N-(i+j) > 0) tmp += seg[(i+1)%2].query(j, j), tmp %= mod;
			if(j <= N-1-i) tmp += seg[(i+1)%2].query(0, j-1), tmp %= mod;
			seg[i%2].update(j, tmp);
		}
	}
	
	llint ans = 0;
	for(int i = 0; i <= N-1; i++){
		ans += seg[(K-1)%2].query(i, i) * pow(2, max(N-K-1, 0LL)) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=200005;

void solve()
{
    
    int n;
    cin>>n;
    map<int,int>mp;
    int a[n];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i];
        mp[a[i]]++;
    }
    int q;
    cin>>q;
    int b,c;
    while(q--)
    {
        cin>>b>>c;
        mp[c]+=mp[b];
        ans+=(c-b)*mp[b];
        mp[b]=0;
        cout<<ans<<endl;
        
        
    }
    
    
    
    
    
}
int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






Measured memory_bytes: 10248
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,ans;
int main()
{
	cin>>n;
	if(n%2==1)
	{
		cout<<0<<endl;
	}
	else
	{
		n/=2;
		while(n)
		{
			ans+=n/5;
			n/=5;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]
 
sys.setrecursionlimit(1000000)
mod = 1000000007
 
def solve():
  x,y,z = map(int,input().split())
  print(z,x,y)
  return
 
#Solve
if __name__ == "__main__":
    solve()

Measured memory_bytes: 38292
#include<iostream>
#include<cstring>
using namespace std;

int w,h;
int data[20][20]; //y,x
int memo[20][20]; //y,x

int solve(int y, int x){

  if(x < 0 || y < 0 || x == w || y == h) return 0;
  if(memo[y][x] > 0) return memo[y][x];
  if(data[y][x] == 1) return 0;
  if(data[y][x] == 0 && y == h-1) return 1;
  if(data[y][x] == 2 && (y == h-2 || y == h-1)) return 1;

  if(data[y][x] == 2) return memo[y][x] = solve(y+2,x);

  if(x > 0 && !data[y+1][x-1] && !data[y+1][x+1])
    return memo[y][x] = solve(y+1,x-1) + solve(y+1,x) + solve(y+1,x+1);

  else if(x > 0 && !data[y+1][x-1])
    return memo[y][x] = solve(y+1,x-1) + solve(y+1,x);

  else if(!data[y+1][x+1])
    return memo[y][x] = solve(y+1,x) + solve(y+1,x+1);

  else return memo[y][x] = solve(y+1,x);
}

int main(){

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++) cin >> data[i][j]; //y,x
    }

    int ans = 0;
    for(int i=0;i<w;i++){
      memset(memo,0,sizeof(memo));
      ans += solve(0,i); //y,x
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1164
from decimal import *
while True:
    try:
        a,b,c,d,e,f=map(float, input().split())
    except:
        break
    m=(c*e-b*f)
    n=(a*e-b*d)
    if m == 0.0:
        x=0.0
    else:
        x=m/n
    m=(c*d-a*f)
    n=(b*d-a*e)
    if m == 0.0:
        y=0.0
    else:
        y=m/n
    print(Decimal(str(x)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP),Decimal(str(y)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP))




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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    long long int sum = 0;
    vector<int>a;
    for(int i = 0; i < m; i++){
        int p;
        cin >> p;
        a.push_back(p);
        sum = sum + p;
    }
    if(sum > n) cout << -1 << endl;
    else cout << n - sum << endl;
    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main(void){
    string o, e;
    cin >> o >> e;
    for(int i =0; i < e.size(); i++){
        cout << o[i] << e[i];
    }
    if(o.size() != e.size()){
        cout << o[o.size() - 1];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
x, n = map(int,input().split())
l = list(map(int,input().split()))
a = 0
ab = 0
for i in range(100):
    if x - i not in l:
        ans = x - i
        a = i + 1
        break
for i in range(100):
    if x + i not in l:
        ansb = x + i
        ab = i + 1
        break
if a > ab:
    print(ansb)
else:
    print(ans)


Measured memory_bytes: 9000
#include <iostream>
#include <stdio.h>
#include <map>
#include <algorithm>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI=3.14159265358979323846;

int main(){
  int n;
  cin >> n;  
  map<string, int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s] += 1;
  }
  int ma = 0;
  for(auto &p:mp){
    int now = p.second;
    if(now>ma) ma = now;
  }
  for(auto &p:mp){
    if(p.second == ma) cout << p.first << endl;
  }
}


Measured memory_bytes: 25216
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int E = in.nextInt();
		int F = in.nextInt();
		double maxConcentration = -1;
		int water = 0;
		int sugar = 0;
		for (int i = 0; 100 * A * i <= F; i += 1) {
			int a = 100 * A * i;
			for (int j = 0; a + 100 * B * j <= F; j += 1) {
				int b = 100 * B * j;
				int maxSugar = Math.min(F - a - b, (a + b) / 100 * E);
				for (int k = 0; C * k <= maxSugar; k += 1) {
					int c = C * k;
					for (int l = 0; c + D * l <= maxSugar; l += 1) {
						int d = D * l;
						if (a + b + c + d == 0) {
							continue;
						}
						double concentration = (double) (c + d)
								/ (a + b + c + d);
						if (maxConcentration >= concentration) {
							continue;
						}
						maxConcentration = concentration;
						water = a + b;
						sugar = c + d;
					}
				}
			}
		}
		out.println((water + sugar) + " " + sugar);
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}


Measured memory_bytes: 23124
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  ll n;
  string s;
  bool a,b;
  cin >> n >> s;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      string tmp;
      tmp += (i==0)?'S':'W';
      tmp += (j==0)?'S':'W';
      for(int k=2;k<n;k++){
        if(tmp[k-1]=='S'){
          if(s[k-1]=='o'){
            tmp+=tmp[k-2];
          }else{
            tmp+=(tmp[k-2]=='W')?'S':'W';
          }
        }else{
          if(s[k-1]=='x'){
            tmp+=tmp[k-2];
          }else{
            tmp+=(tmp[k-2]=='W')?'S':'W';
          }
        }
      }
      if(tmp[0]=='S'){
        a =((s[0]=='o'&&tmp[1]==tmp[n-1])
            ||(s[0]=='x'&&tmp[1]!=tmp[n-1]));
      }else{
        a =((s[0]=='x'&&tmp[1]==tmp[n-1])
            ||(s[0]=='o'&&tmp[1]!=tmp[n-1]));
      }
      if(tmp[n-1]=='S'){
        b =((s[n-1]=='o'&&tmp[n-2]==tmp[0])
            ||(s[n-1]=='x'&&tmp[n-2]!=tmp[0]));
      }else{
        b =((s[n-1]=='x'&&tmp[n-2]==tmp[0])
            ||(s[n-1]=='o'&&tmp[n-2]!=tmp[0]));
      }
      if(a&&b){
        cout << tmp<<endl;
        return 0;
      }
    }
  }
  cout <<"-1\n";
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std


int main()
{
	string S, T;
	bool flag = false;

	IN >> S >> T;

	LEP(i, S.length())
	{
		flag = false;
		LEP(j, S.length())
		{
			if (S[(i + j) % S.length()] != T[(j) % T.length()])
			{
				flag = true;
				break;
			}
		}
		if (flag == false)
		{
			puts("Yes");
			return 0;
		}
	}


	puts("No");

	return 0;
}

Measured memory_bytes: 256
s = list(input())

if s == s[::-1]:
    n = len(s)
    kai_1 = s[:(n-1)//2]
    kai_2 = s[(n + 3) // 2 - 1:]
    if (kai_1 == kai_1[::-1]) and (kai_2 == kai_2[::-1]):
        print("Yes")
        exit(0)

print("No")

Measured memory_bytes: 61692
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define sf scanf
#define pf printf
#define pb push_back
#define lb lower_bound
#define forr(i,x,y) for(int i=x;i<=y;i++)
#define ford(i,x,y) for(int i=x;i>=y;i--)

const int inf=0x7f7f7f,mod=100000000;

inline void read(int &input) {
	int value=0,sign=1;
	char ch;
	do {
		ch=getchar();
		if(ch=='-') sign*=-1;
	}while(ch<'0'||ch>'9');
	while(ch>='0'&&ch<='9') {
		value=value*10+ch-'0';
		ch=getchar();
	}
	input=value*sign;
}

inline void read(int *input,int begin,int end) {
	for(int i=begin;i<=end;i++)
		read(input[i]);
}

inline void read(int &input1,int &input2) {
	read(input1),read(input2);
}

inline void read(int &input1,int &input2,int &input3) {
	read(input1,input2),read(input3);
}

inline void read(int &input1,int &input2,int &input3,int &input4) {
	read(input1,input2),read(input3,input4);
}

int h,w,n,ans;
char mp[1008][1008];
bool passed[1008][1008];
struct node{
    int r,c,res;
}que[1000000];
int head=0,tail=1;
int x[]={0,0,1,-1};
int y[]={1,-1,0,0};

void bfs(char ch) {
	head=0,tail=1;
	que[0].res=0;
    passed[que[0].r][que[0].c]=1;
    while(head!=tail) {
        node Head=que[head];
        forr(i,0,3) {
            node Tail=Head;
            Tail.r+=x[i];
            Tail.c+=y[i];
            Tail.res++;
            if(Tail.r<=0||Tail.c<=0||Tail.r>h||Tail.c>w) continue;
            if(mp[Tail.r][Tail.c]=='X'||passed[Tail.r][Tail.c]) continue;
            que[tail++]=Tail;
            passed[Tail.r][Tail.c]=1;
            if(mp[Tail.r][Tail.c]==ch) {
                ans+=Tail.res;
                que[0].r=Tail.r;
                que[0].c=Tail.c;
            }
        }
        head++;
    }
}

int main() {
	read(h,w,n);
	forr(i,1,h) {
		sf("%s",mp[i]+1);
		forr(j,1,w)
			if(mp[i][j]=='S')
				que[0].r=i,que[0].c=j;
	}
	forr(i,1,n)
        memset(passed,0,sizeof passed),
		bfs('0'+i);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 10172
N=int(input())
minT=pow(10,5)
for i in range(1,N):
  tmp = 0
  for x in range(len(str(i))):
    tmp += int(str(i)[x])
  for y in range(len(str(N-i))):
    tmp += int(str(N-i)[y])
  minT = min(minT,tmp)
print(minT)

Measured memory_bytes: 3060
n = int(input())
arr = [int(s) for s in input().split()]
dp = [-1]*n
dp[0] = 0
dp[1] = abs(arr[0]-arr[1])
for i in range(2,n):
    dp[i] = min(abs(arr[i-1]-arr[i])+dp[i-1],abs(arr[i-2]-arr[i])+dp[i-2])
print(dp[n-1])


Measured memory_bytes: 52464
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	ll sum = 1e9;
	for (int i = -100; i <= 100 ; ++i){
		ll tmp = 0;
		rep(j, n){
			tmp += pow((i - v[j]), 2);
		}
		sum = min(tmp, sum);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 15:28:11
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int e[n], w[n];
    int prev = 0;
    for (int i = 0; i < n; i++) {
        e[i] = prev;
        if (s[i] == 'E') prev++;
    }
    prev = 0;
    for (int i = n-1; i > -1; i--) {
        w[i] = prev;
        if (s[i] == 'W') prev++;
    }

    int m = 0;
    for (int i = 0; i < n; i++) {
        int sum = e[i] + w[i];
        if (m < sum) m = sum;
    }

    int ans = n - m - 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3076
N=int(input())
P = []
# 26進数で表していこう
for _ in range(N):
    prize = input()
    prize_num = 0
    for i,p in enumerate(prize[::-1]):
        prize_num += 26**i * ord(p)
    P.append(prize_num)

P.sort()
now=-1
count = 0
for p in P:
    if not p==now:
        now=p
        count+=1

print(count)



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

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

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

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

Measured memory_bytes: 256
//
// ABC067B: Snake Toy
// dfsよりsortが簡単
//

#include <iostream>
#include <algorithm>
using namespace std;


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

	int a[N];
	for(int i=0; i<N; i++) cin >> a[i];

	sort(a, a+N, greater<int>()); //逆順ソート

	// 長いほうからK本選んだ時の合計長さを求める。
	int sum=0;
	for(int i=0; i<K; i++) {
		sum += a[i];
	}
	cout << sum <<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++)


int main() {
    int K,X;
    cin >> K >> X;
    if(500*K>=X) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

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

  int ans = 0;
  
  for (int i = 0; i < K+1; i++) {
    for (int j = 0; j < K+1; j++) {
      if (S - i - j >= 0 && S -i - j <= K) {
        ans++;
      }
      
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b;
  cout <<(a-1)*(b-1)<<'\n';
  return (0);
}


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

int main() {
    int N, X, M=0;
    cin >> N >> X;
    int m[110];
    int min = 1100;
    for(int i = 0; i < N; ++i) {
        cin >> m[i];
        M += m[i];
        if(m[i] < min) min = m[i];
    }

    int res = (X - M) / min;
    cout << res + N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
}

Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int d[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &d[i]);
    }
    sort(d, d + n);
    int ans = 0;
    int num = 0;
    for(int i = 0; i < n; i++){
        if (d[i] != num) {
            ans++;
            num = d[i];
        } 
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  double r;
  cin>>r;
  cout<<fixed<<setprecision(20)<<2*pi*r<<"\n";
  return 0;
}

Measured memory_bytes: 3820
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    long long n;
    cin>>n;
    long long a[n];
    bool ok = false;
    for(long long i=0;i<n;i++){
        cin>>a[i];
        if(a[i] == 0) ok = true;
    }
    if(ok){
        cout<<0<<endl;
        return 0;
    }

    long long ans = 1;
    long long maxans = 1e18;
    for(long long i=0;i<n;i++){
        if(ans > maxans / a[i]){
            cout<<-1<<endl;
            return 0;
        }
        ans *= a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int D;
    cin >> D;
    vector<int> C(26);
    rep(i, 26) cin >> C[i];
    Graph S(D, vector<int>(26));
    rep(i, D){
        rep(j, 26) cin >> S[i][j];
    }
    
    vector<int> T(D, 0), last(26, -1);

    ll sum = 0;

    rep(i, D){
        ll max_sum;

        rep(j, 26){ // i+1日目に選ぶコンテストの番号がj+1
            ll tmp_sum = sum;
            tmp_sum += S[i][j];
            rep(k, 26){
                if(j == k) continue;
                sum -= C[k] * (i - last[k]);
            }

            if(j == 0 || max_sum < tmp_sum){
                max_sum = tmp_sum;
                T[i] = j;
            }
        }
        last[T[i]] = i;
    }

    // cout << max(1000000 + sum, 0LL) << endl;

    rep(i, D){
        cout << T[i] + 1 << endl;
    }
}

Measured memory_bytes: 3704
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<cstring> 
#include<climits>  
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define INF 1000000000000000
#define MAXN 100000
#define LL long long
LL read(){ 
    LL f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
LL n,m,Min=1,Max=INF,val[MAXN+5],vis[MAXN+5];
struct edge{
	LL v,w;
	edge(){}
	edge(LL V,LL W){v=V,w=W;}
};
vector<edge> G[MAXN+5];
void DFS(LL x,LL u,LL fa,LL f){
	if(x<=0){
		if(f){
			printf("0\n");
			exit(0);
		}
		Min=max(Min,-x+2);
	}
	if(f) Max=min(Max,x);
	vis[u]=f+1,val[u]=x;
	LL v,w,siz=G[u].size();
	for(int i=0;i<siz;i++){
		v=G[u][i].v,w=G[u][i].w;
		if(v==fa) continue;
		if(vis[v]){
			if(vis[u]==vis[v]){
				if(((val[u]+val[v])%2+4)%2!=w%2){
					printf("0\n");
					exit(0);
				}
				if(vis[u]==1){
					if(Min>1+(w-(val[u]+val[v]))/2||Max<1+(w-(val[u]+val[v]))/2){
						printf("0\n");
						exit(0);
					}
					Max=Min=1+(w-(val[u]+val[v]))/2;
				}
				else{
					if(Min>1+((val[u]+val[v])-w)/2||Max<1+((val[u]+val[v])-w)/2){
						printf("0\n");
						exit(0);
					}
					Max=Min=1+((val[u]+val[v])-w)/2;
				}
			}else{
				if(val[u]+val[v]!=w){
					printf("0\n");
					exit(0);
				}
				if(val[v]<=0){
					if(vis[v]-1){
						printf("0\n");
						exit(0);
					}
					Min=max(Min,-val[v]+1);
				}
			}
			continue;
		}
		DFS(w-x,v,u,(f+1)%2);
	}
	return ;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		LL u=read(),v=read(),w=read();
		G[u].push_back(edge(v,w));
		G[v].push_back(edge(u,w));
	}
	DFS(1,1,-1,0);
	printf("%lld\n",max(0ll,Max-Min+1));
    return 0;
}

Measured memory_bytes: 17152
#include<iostream>

using namespace std;

int main(){
  int i, n, m, x, y, ans;
  bool check;

  cin >> n >> m;
  for(i=0, ans=m, check=true; i<n; ++i){
    cin >> x >> y;
    if(!check) continue;
    m += x;
    m -= y;
    if(m < 0) check = false;
    if(ans < m) ans = m;
  }

  if(check) cout << ans << endl;
  else cout << "0" << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){

    int n,m;
    I2(n,m);
    int ar[n+2];
    for(int i = 1;i<=n;i++)I(ar[i]);
    vector<int>v[n+2];

    for(int i = 1;i<=m;i++){

        int x,y;
        I2(x,y);
        v[x].push_back(y);
        v[y].push_back(x);
    }

    int ans = 0;
    for(int i = 1;i<=n;i++){
        bool fl = 0;

        for(int j = 0;j<v[i].size();j++){
            int x = v[i][j];
            if(ar[x]>=ar[i])fl = 1;
        }
        ans += (fl==0);

    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 9164
///**Bismillahir Rahmanir Rahim.**

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(tmp, v)           tmp.assign(v.begin(), v.end())
#define rep(i, l, r)          for (int i = l; i < r; i++)
#define rep2(i, l, r)         for (int i = l-1; i >= r; i--)
#define sf(n)                 scanf("%d", &n)
#define sff(n, m)             scanf("%d %d",&n,&m)
#define sfl(n)                scanf("%lld", &n)
#define sfu(n)                scanf("%llu", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfff(n, m, o)         scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld", n)
#define pfu(n)                printf("%llu", n)
#define pb                    push_back
#define pii                   pair<int,int>
#define mp                    make_pair
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters
{
    bool operator()(const long& a, const long& b) const
    {
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//


typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 200050;
const int mod = 1e9+7;


int main()
{
    //freopen("test.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;
    int tcase = 1, cas = 0;
    while(tcase--)
    {
        int m, d;
        cin >> m >> d;

        int cnt = 0;
        for(int i = 4; i <= m; i++)
        {
            for(int j = 22; j <= d; j++)
            {
                int x = j;
                int a = x%10;
                x /= 10;
                int b = x%10;
                if(a >= 2 and b >= 2 and (a*b) == i)
                {
                    cnt++;
                }
            }
        }
        cout << cnt;

        ///printf("Case %d: %lld\n", ++cas, ans);
    }
    return 0;

}

//-----------------------------------***********************----------------------------------------------//



Measured memory_bytes: 256
if __name__ == '__main__':
    S = str(input())
    
    N = len(S)
    S_0 = '01'*N
    S_0 = S_0[:N]
    S_1 = '10'*N
    S_1 = S_1[:N]
    
    count_0 = 0
    count_1 = 0
    for i in range(N):
        if S[i] != S_0[i]:
            count_0 += 1
        if S[i] != S_1[i]:
            count_1 += 1
    print(min(count_0, count_1))

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
//{
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

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

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);
//}

lint maxi[2000005];
lint maxi2[2000005];



int main() {
	make(n);
	makev(v, n+1);

	if (n == 0) {
		if (v[0] == 1) printf("1\n");
		else printf("-1\n");
		return 0;
	}
	if (v[0] > 0) {
		printf("-1\n");
		return 0;
	}
	maxi[0] = 1;
	lint INF = 1e16;
	FOR(i,1,n+1) {
		maxi[i] = min(2*maxi[i-1]-v[i], INF);
		if (maxi[i] < 0) {
			printf("-1\n");
			return 0;
		}
	}
	maxi2[n] = 0;
	FORD(i,n-1,0) {
		maxi2[i] = min(maxi[i], maxi2[i+1]+v[i+1]);
	}
	lint ans = 0;
	FOR(i,0,n+1) ans += (v[i]+maxi2[i]);
	printf("%lld\n", ans);
}


Measured memory_bytes: 5476
N = int(input())
S = input()

import collections
c = 0
m = 0
for i in range(N):
  S1 = S[:i]
  S2 = S[i:]
  C1 = collections.Counter(S1)
  C2 = collections.Counter(S2)
  c = 0
  for c1 in C1.keys():
    if c1 in C2.keys():
      c += 1
  m = max(m,c)
print(m)

Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int main()
{
    int N, D, X;
    cin >> N >> D >> X;
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        sum += (D - 1) / A + 1;
    }
    cout << sum + X << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A;
    A.resize(N + 2);
    A[0] = 0;
    int max = -5000;
    int min = 5000;
    for (int i = 1; i < N + 1; i++)
    {
        cin >> A[i];
        if (A[i] > max) max = A[i];
        if (A[i] < min) min = A[i];
        
    }
    A[N + 1] = 0;

    int p = 0;
    for (int i = 1; i < N + 2; i++)
    {
        p += abs(A[i] - A[i - 1]);
    }
    
    int ans;
    for (int i = 1; i < N + 1; i++)
    {
        ans = p - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + (abs(A[i + 1] - A[i - 1]));
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define x1 xxx
#define y1 yyy
#define x2 xx
#define y2 yy
#define pb push_back
#define F first
#define S second
#define P push
#define T top

using namespace std;
const long long MOD=1000000007;
typedef long long ll;
ll ar[100009];
bool bo[100009];
int main(){
    ll n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        ar[i+1]=1;
    }
    bo[1]=1;
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        ar[a]--;
        ar[b]++;
        if(bo[a]==1)bo[b]=1;
        if(ar[a]==0)bo[a]=0;
    }
    ll res=0;
    for(int i=1;i<=n;i++)if(bo[i])res++;
    cout<<res;
      return 0;
}



Measured memory_bytes: 1152
import java.lang.Math
import java.math.BigDecimal

fun main(args: Array<String>) {
    val (a, b, x) = readLine()!!.split(" ").map { it.toDouble() }

    val half = a * a * b / 2
    when {
        half == x -> {
            val ans = Math.atan(b / a)
            println(Math.toDegrees(ans))
        }
        half < x -> {
            // 1/2 * a * a* tan = (aab-x)/a
            // tan = 2(aab-x)/aaa
            val ans = Math.atan(2 * (a * a * b - x) / (a * a * a))
            println(Math.toDegrees(ans))
        }
        else -> {
            val ans = Math.atan(2 * x / (b * b * a))
            println(90 - Math.toDegrees(ans))

        }
    }
}


Measured memory_bytes: 37812
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,w,b;
using Edge = pair<int,bool>;
vector<Edge> G[610];
bool used[610],dp[610][610];
vector<vector<int>> wvec,bvec;

void dfs(int v,bool c){
	used[v] = true;
	(c ? bvec : wvec).back().push_back(v);
	for(auto e : G[v]){
		if(!used[e.first]) dfs(e.first,e.second ^ c);
	}
}

void solve(){
	wvec.clear(); bvec.clear();
	for(int i = 0;i < w + b;i++){
		G[i].clear();
		used[i] = false;
	}
	for(int i = 0;i < n;i++){
		int x,y;
		string s;
		cin >> x >> y >> s; x--;y--;
		G[x].emplace_back(y,s == "no");
		G[y].emplace_back(x,s == "no");
	}
	for(int i = 0;i < w + b;i++){
		if(!used[i]){
			wvec.emplace_back(); bvec.emplace_back();
			dfs(i,false);
		}
	}
	int m = wvec.size();
	for(int i = 0;i <= m;i++){
		for(int j = 0;j <= w;j++) dp[i][j] = false;
	}
	dp[0][0] = true;
	for(int i = 0;i < m;i++){
		for(int j = 0;j <= w;j++){
			if(j + wvec[i].size() <= w) dp[i + 1][j + wvec[i].size()] |= dp[i][j];
			if(j + bvec[i].size() <= w) dp[i + 1][j + bvec[i].size()] |= dp[i][j];
		}
	}
	if(!dp[m][w]){
		cout << "no" << endl;
		return;
	}
	vector<int> ans;
	for(int i = m - 1;i >= 0;i--){
		int x = wvec[i].size(),y = bvec[i].size();
		if(x == y || (w >= max(x,y) && dp[i][w - x] && dp[i][w - y])){
			cout << "no" << endl;
			return;
		}
		if(w >= x && dp[i][w - x]){
			w -= x;
			ans.insert(ans.end(),wvec[i].begin(),wvec[i].end());
		}else{
			w -= y;
			ans.insert(ans.end(),bvec[i].begin(),bvec[i].end());
		}
	}
	sort(ans.begin(),ans.end());
	for(int v : ans) cout << v + 1 << endl;
	cout << "end" << endl;
}

signed main(){
	while(cin >> n >> w >> b,w + b) solve();
}


Measured memory_bytes: 3244
import java.awt.*

inline fun str() = readLine()!!
inline fun int() = str().toInt()
inline fun long() = str().toLong()

inline fun read(d:String = " ") = str().split(d)
inline fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
inline fun list() = list {toInt()}

inline fun <T> T.print() = this.also(::println)

fun main() {
	abc000X()
}

fun abc000X() {
	println(str().replace('?','D'))
}


Measured memory_bytes: 40560