akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int MAX = 101010;
	vector<int> is_prime(MAX, 1);
	is_prime[0] = 0, is_prime[1] = 0;

	for (int i = 2; i < MAX; i++)
	{
		if (!is_prime[i]) continue;
		for (int j = i * 2; j < MAX; j += i) is_prime[j] = 0;
	}

	vector<int> a(MAX);
	for (int i = 0; i < MAX; i++)
	{
		if (i % 2 == 0) continue;
		if (is_prime[i] && is_prime[(i + 1) / 2]) a[i] = 1;
	}

	vector<int> s(MAX + 1);
	for (int i = 0; i < MAX; i++) s[i + 1] = s[i] + a[i];

	int Q; cin >> Q;
	for (int q = 0; q < Q; ++q) {
		int l, r;
		cin >> l >> r;
		++r;

		cout << s[r] - s[l] << endl;
	}
}

/*
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

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

	vector<int> a(n);
	for (int i = 0; i < a.size(); i++) cin >> a[i];

	// 累積GCD
	vector<int> left(n + 1), right(n + 1);
	for (int i = 0; i < n; i++) left[i + 1] = GCD(left[i], a[i]);
}
*/

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

int main()
{
	int a, b;
	string S;

	cin >> a >> b >> S;

	int count_haihun = 0;
	int count_to_haihun = 0;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '-')
		{
			count_haihun++;
		}

	}

	if (count_haihun > 1 || count_haihun == 0)
	{
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; S[i] != '-'; i++)
	{
		count_to_haihun++;
	}

	if (count_to_haihun != a)
	{
		cout << "No" << endl;
		return 0;
	}

	if (S.size() != a + b + 1)
	{
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes";
}

Measured memory_bytes: 256
import math

n, k = map(int, input().split())
ans = 0.0

for i in range(n):
    if i + 1 >= k:
        e = 0
    else:
        e = int(math.log2((k - 1) / (i + 1))) + 1
    ans += 0.5 ** e

print(ans / n)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);

  int a,b,c;
  cin >> a >> b >> c;
  cout << (a<=c && c<=b ? "Yes" : "No") << LF;

  return 0;
}



Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void add(ll &a, ll b) {
    a += b;
    if(a >= mod) a %= mod;
}

void solve() {
	string s; cin >> s;
    int n = (int)s.size();
    string t = s;
    reverse(all(t));
    vector<vector<int>> ns(n + 1, vector<int>(26, n));
    vector<vector<int>> nt(n + 1, vector<int>(26, n));
    for(int i = n - 1; i >= 0; --i) {
        rep(j, 26) ns[i][j] = ns[i + 1][j];
        ns[i][s[i] - 'a'] = i;
    }
    for(int i = n - 1; i >= 0; --i) {
        rep(j, 26) nt[i][j] = nt[i + 1][j];
        nt[i][t[i] - 'a'] = i;
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, n) {
            rep(k, 26) {
                int ni = ns[i][k] + 1;
                int nj = nt[j][k] + 1;
                if(ni + nj <= n) add(dp[ni][nj], dp[i][j]);
            }
        }
    }
    ll res = 0;
    for(int i = 0; i <= n; ++i) {
        set<int> se;
        for(int j = n - i; j >= 0; --j) {
            add(res, ((int)se.size() + 1) * dp[i][j]);
            if(j - 1 >= 0) se.insert(t[j - 1] - 'a');
            //cerr << i << " " << j << " " << ((int)se.size() + 1) * dp[i][j] << endl;
        }
    }
    cout << (res + mod - 1) % mod << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 35368
#include <stdio.h>
int N = 200;

int main(){
  int line[N][N];
  int n,u,k,v,x,y;

  scanf("%d",&n);

  for(x = 0;x < n;x++)
    {
      for(y = 0;y < n;y++)
	line[x][y] = 0;
    }

  for(x = 0;x < n;x++)
    {
      scanf("%d %d",&u, &k);
      for(y = 0;y < k;y++)
	{
	  scanf("%d",&v);
	  line[u-1][v-1] = 1;
	}
    }

  for(x = 0;x < n;x++)
    {
      for(y = 0;y < n;y++)
	{
	  if(y > 0)printf(" ");
	  printf("%d", line[x][y]);
	}
       printf("\n");
    }

  return 0;
}



Measured memory_bytes: 2024
#include<iostream>
using namespace std;
int main()
{
   int x;
   cin>>x;
   if(x>=400&&x<=599)
   {
       cout<<"8"<<endl;
   }
   else if(x>=600&&x<=799)
   {
       cout<<"7"<<endl;
   }
   else if(x>=800&&x<=999)
   {
       cout<<"6"<<endl;
   }
   else if(x>=1000&&x<=1199)
   {
       cout<<"5"<<endl;
   }
   else if(x>=1200&&x<=1399)
   {
       cout<<"4"<<endl;
   }
   else if(x>=1400&&x<=1599)
   {
       cout<<"3"<<endl;
   }
   else if(x>=1600&&x<=1799)
   {
       cout<<"2"<<endl;
   }
   else if(x>=1800&&x<=1999)
   {
       cout<<"1"<<endl;
   }
 return 0;
}


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

int main() {

	int n;
	cin >> n;

	int c1 = n/1000;
	n = n - c1*1000;

	int c2 = n/100;
	n = n - c2*100;

	int c3 = n/10;
	n = n - c3*10;

	int c4 = n;

	if ((c1 == c2 && c2 == c3) || (c2 == c3 && c3 == c4)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

std::string s;

int main(){
    std::cin >> s;
    std::cout << s.substr(0, s.length() - 8) << std::endl;
}


Measured memory_bytes: 256
from copy import deepcopy

S = input()
N = len(S)
two = deepcopy(S[:int((N-1)/2):1])
three = deepcopy(S[int((N+3)/2)-1:N:1])

if S == S[::-1] and two == two[::-1] and three == three[::-1]:
  print("Yes")
  exit()
print("No")

Measured memory_bytes: 3444
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(fibonacci(n));
    }

    public static int fibonacci(int n) {
        if (n == 0 || n == 1) return 1;

        int result = 0;
        int preOldResult = 1;
        int oldResult = 1;

        for (int i = 2; i <= n; i++) {
            result = preOldResult + oldResult;
            preOldResult = oldResult;
            oldResult = result;
        }

        return result;
    }
}

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

int main() {
  int A, B, K,count = 0;
  bool baisu = false;
  cin >> K >> A >> B;
  int i = 1;
  
  while(K*i <= B){
    
    if(baisu) break;
    
    if(K*i <= B && K*i >= A){
      count = 1;
      baisu = true;
    }
    
    ++i;

  }
  
  if(count>=1){
  	cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3592
#include <stdio.h>

int main()
{
	int i, N;
	long long a[10001], b[10001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(a[i]));
	for (i = 1; i <= N; i++) scanf("%lld", &(b[i]));
	
	long long sum = 0;
	for (i = 1; i <= N; i++) {
		if (a[i] < b[i] && a[i] % 2 != b[i] % 2) {
			a[i] += 2;
			b[i]++;
		}
		sum += (a[i] > b[i])? b[i] - a[i]: (b[i] - a[i]) / 2;
	}
	if (sum >= 0) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
// clang-format off
  #include <bits/stdc++.h>
  #include<string>
      #define rep(i, n) for(int i = 0; i < (n); i++)
      using namespace std;

// clang-format on
int main() {
  int x, y;
  cin >> x >> y;
  if (x == 2 || y == 2) {
    cout << "No" << endl;
  } else if (x == 4) {
    if (y == 6) {
      cout << "Yes" << endl;
    } else if (y == 9) {
      cout << "Yes" << endl;
    } else if (y == 11) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

  } else if (x == 6) {
    if (y == 9) {
      cout << "Yes" << endl;
    } else if (y == 11) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (x == 9) {
    if (y == 11) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (x == 11) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

int main() {
    vector<vector<int>> c(3, vector<int>(3, 0));

    for(auto &row: c) {
        for(auto &x: row) {
            cin >> x;
        }
    }
    vector<int> a(3, 0);
    a[0] = c[0][0];
    a[1] = c[1][0];
    a[2] = c[2][0];

    bool isCreate = false;
    // 差が等しければb2を足すことで[c12, c22, c32]^T を生成できる
    if ((c[0][1] - a[0] == c[1][1] - a[1]) && (c[1][1] - a[1] == c[2][1] - a[2])) {
        isCreate = true;
    }
    if (!isCreate) {
        cout << "No" << endl;
        return 0;
    }
    
    isCreate = false;
    // 差が等しければb3を足すことで[c13, c23, c33]^T を生成できる
    if ((c[0][2] - a[0] == c[1][2] - a[1]) && (c[1][2] - a[1] == c[2][2] - a[2])) {
        isCreate = true;
    }
    if (!isCreate) {
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>());

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
		
	string S, T;
	vector<char> s, t;
	cin >> S >> T;
	for(int i = 0; i < S.length(); i++) {
		s.push_back(S[i]);
	}

	for(int i = 0; i < T.length(); i++) {
		t.push_back(T[i]);
	}
	vsort(s);
	vsort_reverse(t);
	S = "";
	T = "";

	for(int i = 0; i < s.size(); i++) {
		S += s[i];
	}

	for(int i = 0; i < t.size(); i++) {
		T += t[i];
	}
	if(S.compare(T) < 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	string s;
    cin >> s;
  	if((s[0] == s[1] && s[1]==s[2]) || (s[1] == s[2] && s[2]==s[3]))
      cout<<"Yes";
  	else
      cout<<"No";
	return 0;
	// BYE BYE 
}


Measured memory_bytes: 384
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int r;
  cin >> r;

  if(r < 1200){
    cout << "ABC" << endl;
  }
  else if(r < 2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int Check(int x){
    char s[10];
    sprintf(s+1,"%d",x);
    int len=strlen(s+1);
    for(int i=1;i<=len/2;i++)
        if(s[i]!=s[len-i+1])
            return 0;
    return 1;
}

int main(){
    int A,B,Ans=0;
    scanf("%d%d",&A,&B);
    for(int i=A;i<=B;i++)
        Ans+=Check(i);
    printf("%d",Ans);
}
/**/

Measured memory_bytes: 128
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int n, m;
string a;
int dp[N], par[N];
pii d[N * 4];
pii uu;
pii merge (pii f, pii s) {
	if (f.F != -1 && s.F != -1) {
		if (f.F == s.F) {
			return (s.S < f.S ? s : f);
		}
		else {
			return (f.F > s.F ? s : f);
		}
	}
	else if (f.F != -1) return f;
	else if (s.F != -1) return s;
	else return uu;
}
void build (int v, int l, int r) {
	if (l == r) {
		d[v].F = dp[l];
		d[v].S = l;
		return;
	}
	int mid = l + r >> 1;
	build (v * 2, l, mid);
	build (v * 2 + 1, mid + 1, r);
	d[v] = merge (d[v * 2], d[v * 2 + 1]);
}
pii get (int v, int l, int r, int nl, int nr) {
	if (l > nr || nl > r) return uu;
	if (nl <= l && r <= nr) return d[v];
	int mid = l + r >> 1;
	return merge (get (v * 2, l, mid, nl, nr), get (v * 2 + 1, mid + 1, r, nl, nr));	
}
void update (int v, int l, int r, int pos, int x) {
	if (l == r) {
		d[v].F = x;
		d[v].S = l;
		return;
	}
	int mid = l + r >> 1;
	if (pos <= mid) update (v * 2, l, mid, pos, x);
	else update (v * 2 + 1, mid + 1, r, pos, x);
	d[v] = merge (d[v * 2], d[v * 2 + 1]);
}
void solve () {
	uu.F = -1, uu.S = -1;	
	cin >> n >> m >> a;
	for (int i = 0; i <= n; i ++) dp[i] = -1, par[i] = -1;
	if (a[0] == '1' || a[n] == '1') {
		cout << -1;
		return;
	}
	dp[n] = 0;	
	par[n] = -1;
	build (1, 0, n);
	for (int i = n - 1; i >= 0; i --) {
		if (a[i] == '0') {
			pii o = get (1, 0, n, i + 1, min (n, i + m));
			if (o.F != -1) {
				dp[i] = o.F + 1;
				par[i] = o.S;
				update (1, 0, n, i, dp[i]);
			}
		}
	}
	if (dp[0] == -1) {
		cout << -1;
		return;
	}
	int pos = 0;
	while (par[pos] != -1) {	
		cout << par[pos] - pos << " ";
		pos = par[pos];	
	}
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

int32_t main(){
  int n,m;
  
  cin>>n>>m;
  
  int arr[m];
  int s=0;
  for(int i=0;i<m;i++)
  {
    cin>>arr[i];
    s+=arr[i];
  }
  if(s>n)
  cout<<-1<<"\n";
  else 
    cout<<n-s<<"\n";
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int a,b,c;
    cin>>a>>b>>c;;
    int k;
    cin>>k;
    
    int cc;
    cc=a+b+c+max(max(a,b),c)*(pow(2,k)-1);
    cout<<cc<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>                   
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vlli vector<long long int>
#define pb push_back
#define mp make_pair
#define ll long long
#define all(c)  ((c).begin()), ((c).end())
#define dbg(x) cout<<#x<<" = "<<x<<"\n"
#define FOREACH(i,t) for (auto &i:t)

const ll MOD = 1e9+7;

using namespace std;

int main(void) {
    int n,k;
    cin>>n>>k;                                                                                                                          
    vi a(n);
    FOREACH(it,a) cin>>it;
    vi dp(n);
    //FOR(i,0,n) dp[i] = 1e6;
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    FOR(i,2,n) {
        dp[i] = dp[i-1] + abs(a[i] - a[i-1]);
        for(int j=2; j <= min(k,i) ; ++j) {
            dp[i] = min( dp[i-j] + abs(a[i] - a[i-j]) , dp[i] );
        }
    }
    cout<<dp[n-1]<<endl;
}                              


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

string s,t;
ll pos[30][N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
   // freopen(task".inp","r",stdin);
  //  freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>s>>t;
    int n=s.length(),m=t.length();
    s=' ' + s;
    t=' ' + t;
    for (int i=0;i<=n+1;i++)
        for (int j=0;j<=25;j++) pos[j][i]=inf;
    for (int i=n;i>=0;i--) {
        for (int j=0;j<26;j++) pos[j][i]=min(pos[j][i],pos[j][i+1]);
        if (i) pos[s[i]-'a'][i-1]=i;
    }
    ll j=0,res=0;
    for (int i=1;i<=m;i++) {
        if (pos[t[i]-'a'][j]==inf) {
            j=pos[t[i]-'a'][0];
            if (j==inf) {
                cout<<-1;
                return 0;
            }
            res++;
        }
        else j=pos[t[i]-'a'][j];
    }
    cout<<res*n+j;
    return 0;
}


Measured memory_bytes: 21100
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N; cin >> N;
    int ans = 0;
    for(int a = 1; a < N; a++){
        for(int b = 1; a*b < N; b++){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
def solve
  n = gets.to_i
  s = gets.split('')
  s.pop
  cnt = 0
  x = s.count('R') * s.count('G') * s.count('B')

  (0..(n - 1)).each do |i|
    (i + 1..(n - 1)).each do |j|
      k = 2 * j - i
      next if k > n - 1

      next unless s[i] != s[j] && s[i] != s[k] && s[j] != s[k]

      cnt += 1 if j - i == k - j
    end
  end
  print x - cnt
end
solve


Measured memory_bytes: 14604
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  char c;
  cin >> c;
  c++;
  cout << (char)c << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr int MAXN = 1e5 + 5;
constexpr long long M = 998244353;
constexpr double EPS = 1e-7;
using namespace std;
template <typename T> inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
struct segTree {
    using Node = segTree *;
    Node lson, rson;
    int l, r;
    long long mul;
}Tree[MAXN << 1];
using uLL = unsigned long long;
uLL n, m;
int main() {
    //freopen("test.in", "r", stdin);
    vector<int> vec{999, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    //sort (vec.begin(), vec.end());
    cin >> n >> m;
    uLL x = m % 2 == 0 ? m / 2 : m / 2 + 1;
    uLL x2 = m / 2;
    uLL y = n % 2 == 0 ? n / 2 : n / 2 + 1;
    uLL y2 = n / 2;
    if (n == 1 || m == 1) cout << 1 << endl;
    else cout << x * y + x2 * y2 << endl;
    return 0;
}

Measured memory_bytes: 256
# Vicfred
# https://atcoder.jp/contests/abc154/tasks/abc154_c
# sorting
n = int(input())
a = list(map(int, input().split()))

a.sort()

repeated = False
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        repeated = True
        break

if repeated:
    print("NO")
else:
    print("YES")



Measured memory_bytes: 26808
#include<stdio.h>
int a[110000];
int main(){
	int n,n4=0,n2=0;
	int flag=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]%4==0)n4++;
		else if(a[i]%2==0)n2++;
	}
	int nn=n-n2-n4;
	if(n2==0){
		if(nn>n4+1)flag=0;
	}else{
		if(nn>n4)flag=0;
	}
	
	if(flag)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DGatheringChildren solver = new DGatheringChildren();
        solver.solve(1, in, out);
        out.close();
    }

    static class DGatheringChildren {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            char[] S = in.next().toCharArray();
            int n = S.length;
            int[] ans = new int[n];

            for (int i = 0; i < 2; i++) {
                int cnt = 0;
                for (int j = 0; j < n; j++) {
                    if (S[j] == 'R') {
                        cnt++;
                    } else {
                        ans[j] += cnt / 2;
                        ans[j - 1] += (cnt + 1) / 2;
                        cnt = 0;
                    }
                }
                reverse(S);
                reverse(ans);
                for (int j = 0; j < n; j++) {
                    if (S[j] == 'L') S[j] = 'R';
                    else S[j] = 'L';
                }
            }


            for (int i = 0; i < n; i++) {
                out.printf("%d ", ans[i]);
            }
            out.printf("\n");
        }

        void reverse(char[] array) {
            for (int i = 0; i < array.length / 2; i++) swap(array, i, array.length - i - 1);
        }

        void reverse(int[] array) {
            for (int i = 0; i < array.length / 2; i++) swap(array, i, array.length - i - 1);
        }

        void swap(int[] array, int i, int j) {
            int tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
        }

        void swap(char[] array, int i, int j) {
            char tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
        }

    }
}



Measured memory_bytes: 89248
class BinaryTree:
    def __init__(self, node, children):
        self.node = node
        for i in range(2):
            try:
                children.remove(-1)
            except:
                pass
            
        self.children = children
        self.parent = -1
        try:
            self.sibling = self.parent.children.remove(self.node)[0]
        except:
            self.sibling = -1
        
        self.degree = len(children)
        self.depth = 0
        self.height = 0
        if len(children) == 0:    #子が両方とも-1の場合
            self.status = "leaf"
        else:
            self.status="root"
    
    def display(self):
        print("""node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s"""
             %(self.node, self.parent, self.sibling, self.degree, self.depth, self.height, self.status))

n = int(input())
NODE_DICT = {}
root_search = {}
for loop in range(n):
    tmp_input = list(map(int, input().split()))
    tmp = BinaryTree(tmp_input[0], tmp_input[1:])
    NODE_DICT[tmp_input[0]] = tmp
    root_search[tmp_input[0]] = True
    
for loop in range(n):
    for element in NODE_DICT[loop].children:
        root_search[element] = False

for element in range(n):
    if root_search[element]:
        root = element

def Process(NODE_DICT, node, depth):
    
    NODE_DICT[node].depth = depth
    
    if len(NODE_DICT[node].children) != 0:
        if depth != 0:
            NODE_DICT[node].status = "internal node"
        height_list = []
        if len(NODE_DICT[node].children) == 2:
            NODE_DICT[NODE_DICT[node].children[0]].sibling, NODE_DICT[NODE_DICT[node].children[1]].sibling \
            = NODE_DICT[node].children[1], NODE_DICT[node].children[0]
        
        for child in NODE_DICT[node].children:
            NODE_DICT[child].parent = NODE_DICT[node].node
            Process(NODE_DICT, child, depth+1)
            height_list.append(NODE_DICT[child].height+1)
            
        NODE_DICT[node].height = max(height_list)
        
    else:
        if depth == 0:
            NODE_DICT[node].status = "root"
        NODE_DICT[node].height = 0
    
Process(NODE_DICT, root, 0)

for loop in range(len(NODE_DICT)):
    NODE_DICT[loop].display()


Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
using namespace std;
#define MAX 100000
vector<int>G[MAX];
int n;
bool visited[MAX];
int premium[MAX];
int parent[MAX];
int lowest[MAX];
int timer;
void dfs(int current,int prev){
  premium[current]=lowest[current]=timer;
  timer++;
  visited[current]=true;
  int next;
  for(int i=0;i<G[current].size();i++){
    next=G[current][i];
    if(!visited[next]){
      parent[next]=current;
      dfs(next,current);
      lowest[current]=min(lowest[current],lowest[next]);
    }else if(next!=prev){
      lowest[current]=min(lowest[current],premium[next]);
    }
  }
}
void art_points(){
  for(int i=0;i<n;i++) visited[i]=false;
  timer=1;
  dfs(0,-1);
  set<int>ap;
  int np=0;
  for(int i=1;i<n;i++){
    int p=parent[i];
    if(p==0) np++;
    else if(premium[p]<=lowest[i]) ap.insert(p);
  }
  if(np>1) ap.insert(0);
  for(set<int>::iterator it=ap.begin();it!=ap.end();it++) cout<<*it<<endl;
}
int main(){
  int m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    int s,t;
    scanf("%d%d",&s,&t);
    G[s].push_back(t);
    G[t].push_back(s);
  }
  art_points();
  return 0;
}



Measured memory_bytes: 7000
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

int cday[1024][16][32];

int main(void){
  int n, y, m, d;
  int cnt = 0;
  reps(i,1,1000){
    reps(j,1,10){
      reps(k,1,20){
        if(i%3 != 0 && j%2 == 0 && k > 19)break;
        cday[i][j][k] = ++cnt;
      }
    }
  }
  cin >> n;
  rep(l,n){
    cin >> y >> m >> d;
    cout << cday[1000][1][1] - cday[y][m][d] << endl;
  }

  return 0;
}

Measured memory_bytes: 5044
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
void solve(void)
{
  int N;
  cin>>N;
  int X = N;
  int A = X - N/100*100;
  int B = (X - A)/100;
  if((A)*(13 - A)> 0 && (B)*(13 - B)> 0)
  {
    cout<<"AMBIGUOUS"<<endl;
  }
  else if((B)*(13 - B)> 0)
  {
    cout<<"MMYY"<<endl;
  }
  else if((A)*(13 - A)> 0)
  {
    cout<<"YYMM"<<endl;
  }
  else
  {
    cout<<"NA"<<endl;
  }
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

int main(int argc, char const *argv[]) {
  int n,s,m;
  s = 0;
  scanf("%d",&n );
  m = n;
  for (; n > 0; n /= 10) {
    s += n % 10;
  }
  if (m % s == 0) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f

struct sf
{
    int x,y;
    int t;
};

int vis[30][30];
char s[30][30];
int d[4][2]={1,0,-1,0,0,-1,0,1};
int h,w;
int ans=0;
void bfs(int x,int y)
{
    memset(vis,0,sizeof(vis));
    queue<sf>q;
    sf now,nex;
    now.x=x;now.y=y;now.t=0;
    vis[x][y]=1;
    q.push(now);
    while(q.size())
    {
        now=q.front();q.pop();
        nex=now;
        for(int i=0;i<4;i++)
        {
            nex.x=now.x+d[i][0];
            nex.y=now.y+d[i][1];
            nex.t=now.t+1;
            if(nex.x>=0&&nex.x<h&&nex.y>=0&&nex.y<w&&!vis[nex.x][nex.y]&&s[nex.x][nex.y]=='.')
            {
                vis[nex.x][nex.y]=1;
                ans=max(ans,nex.t);
                q.push(nex);
            }
        }
    }
}


int main()
{
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
    {
        scanf("%s",s[i]);
    }
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
            if(s[i][j]=='.')
                bfs(i,j);
        }
    printf("%d\n",ans);
}


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

#define int long long 
#define S second
#define F first
typedef pair <int, int> pii;
const int INF = 1ll << 60, MN = 2010;
vector <int> adj[MN];
int mz[MN], sz[MN];

pii mrg(pii a, pii b) {
//	cerr << a.F << '&' << a.S << " + " << b.F << ' ' << b.S << " = ";
	if (a.S > b.S)
		swap(a, b);
	int x = b.S - a.S;
	int y = min(x / 2, a.F);
//	cerr << x << ' ' << y << endl;
	a.S += 2 * y;
	a.F -= y;
//	cerr << a.F + b.F + a.S << ' ' << b.S - a.S << endl;
	return {a.F + b.F + a.S, b.S - a.S};
}

pii dfs(int v, int p = -1) {
	vector <pii> gaff;
	for (int u: adj[v]) {
		if (u == p)
			continue;
		gaff.push_back(dfs(u, v));
		gaff.back().S += sz[u];
		sz[v] += sz[u];
	}
	pii my(0, 0);
	for (pii p: gaff)
		my = mrg(my, p);
//	cerr << v << '!' << endl;
//	cerr << my.F << ' ' << my.S << endl;
	return my;
}

int32_t main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char ch;
		cin >> ch;
		mz[i] = ch - '0';
	}
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int ans = INF;
	for (int i = 0; i < n; i++) {
		for (int i = 0; i < n; i++)
			sz[i] = mz[i];
		pii p = dfs(i);
		if (p.S == 0) 
			ans = min(ans, p.F);
//		for (int i = 0; i < n; i++)
//			cerr << sz[i] << ' ';
//		cerr << endl;
	}
	cout << (ans == INF? -1: ans);
}


Measured memory_bytes: 3964
#include <unistd.h>
#include <stdlib.h>

void writing(int ans)
{
    char c;
    if (ans < 10)
    {
        c = ans + '0';
        write(1, &c, 1);
    }
    else
    {
        writing(ans / 10);
        writing(ans % 10);
    }
}

int get_num(char *s)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i] != 10)
    {
        if (s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                    
            }
            return (num);
        }
    }  
}

void get_nums(int *array, char *s, int count)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i])
    {
        if (s[i] != 10 && s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                if (!s[i])
                {
                    array[count] = num;
                    return ;                    
                }
            }
            array[count++] = num;
            i--;
        }
    }  
}

void get_num_plus(int *tab, char *tmp, int pass_flag, int count)
{
    int i;
    
    i = -1;
    while (count < pass_flag)
    {
        while (tmp[++i] != 10)
            ;
        count++;
    }
    get_nums(tab, &tmp[++i], 0);
}

void get_ans(int n, char *tmp)
{
    int i;
    int j;
    int tab[n];
    int count;
    
    get_num_plus(tab, tmp, 1, 0);
    count = 0;
    j = 0;
    i = -1;
    while (++i < n)
    {
        count++;
        if (tab[j] == 2)
        {
            writing(count);
            return ;
        }
        j = tab[j] - 1;
    }
    write(1, "-1", 2);
}

char *create_array(char *s, char *new_arr, char *t, int size)
{
    int i;
    int j;
    
    i = -1;
    while (s[++i])
        new_arr[i] = s[i];
    free(s);
    j = 0;
    while (j < size)
        new_arr[i++] = t[j++];   
    new_arr[i] = 0;
    return (new_arr);
}

char *get_data(char *s)
{
    int size;
    int sum_size;
    char t[100000];
    char *new_arr;
    
    sum_size = 0;
    while ((size = read(0, t, 100000)))
    {
        if (size == -1)
            return (NULL);
        sum_size += size;
        if (!(new_arr = (char*)malloc(sum_size + 1)))
            return (NULL);
        s = create_array(s, new_arr, t, size);
    }
    return (s);
}

int main(void){
    int num;
    char *s;
    
    s = malloc(1);
    s = get_data(s);
    num = get_num(s);
    get_ans(num, s);
    free(s);
    return (0);
}


Measured memory_bytes: 1292
#include "bits/stdc++.h"
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=100005;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

int main()
{
    //read("in.txt"),write("out.txt");
    int n;
    ini(n);
    if(n==3||n==5||n==7)
        outs("YES"),nl;
    else
        outs("NO"),nl;
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
int H, W, K;
vector<string> s;

template <typename T> void print_vec(vector<T> &v) {
  for (auto i : v)
    cout << i << " ";
  cout << "\n";
}

vector<int> cnt_whi(vector<int> &a, int w, int I) {
  int idx = 0;
  vector<int> res(__builtin_popcount(I) + 1, 0);
  for (int i = 0; i < H; i++) {
    if (s[i][w] == '1')
      a[idx]++, res[idx]++;
    if ((I & (1 << i)) != 0)
      idx++;
  }
  return res;
}

int op_count(int I) {
  int n = __builtin_popcount(I);
  int res = n;
  vector<int> cnt(n + 1, 0);
  for (int i = 0; i < W; i++) {
    auto v = cnt_whi(cnt, i, I);
    // print_vec(cnt);
    for (auto it : v)
      if (it > K)
        return 1 << 29;
    bool d = false;
    for (auto it : cnt)
      if (it > K)
        d = true;
    if (d) {
      res++;
      swap(v, cnt);
    }
  }
  return res;
}

int main() {
  cin >> H >> W >> K;
  s.resize(H);
  for (int i = 0; i < H; i++)
    cin >> s[i];
  int ans = 1 << 29;
  for (int i = 0; i < (1 << (H - 1)); i++) {
    int r = op_count(i);
    ans = min(ans, r);
  }
  assert(ans != 1 << 29);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> g[100005];
bool d[100005];
int p[100005];
vector<int> t;
void tpsort(int v)
{
	d[v]=true;
	for(int i=0;i<g[v].size();i++)
		if(!d[g[v][i]]) 
			tpsort(g[v][i]);
	t.push_back(v);
}
int main()
{
	cin>>n>>m;
	int u,v;
	for(int i=0;i<m;i++)
	{
		cin>>u>>v;
		g[u].push_back(v);
	}
	for(int i=1;i<=n;i++) 
		if(!d[i]) 
			tpsort(i);
	reverse(t.begin(),t.end());
	for(int i=0;i<t.size();i++)
	{
		int v=t[i];
		for(int j=0;j<g[v].size();j++)
			p[g[v][j]]=max(p[g[v][j]],p[v]+1);
	}
	int ans=0;
	for(int i=1;i<=n;i++) 
		ans=max(ans,p[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8056
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K, S, T;
vector<int> A;

i64 dp[2][55];
i64 C[55][55];

int main()
{
	C[0][0] = 1;
	for (int i = 1; i <= 50; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= 50; ++j) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
	scanf("%d%d%d%d", &N, &K, &S, &T);
	if ((S & T) != S) {
		puts("0");
		return 0;
	}
	vector<int> rels;
	for (int i = 0; i < 18; ++i) {
		if (((S >> i) & 1) == 0 && ((T >> i) & 1) != 0) {
			rels.push_back(i);
		}
	}
	for (int i = 0; i < N; ++i) {
		int x;
		scanf("%d", &x);
		if ((x & S) == S && (x & T) == x) {
			int x2 = 0;
			for (int j = 0; j < rels.size(); ++j) {
				x2 |= ((x >> rels[j]) & 1) << j;
			}
			A.push_back(x2);
		}
	}

	int B = rels.size();
	N = A.size();

	//printf("%d\n", N);
	//for (int i = 0; i < N; ++i) printf("%d ", A[i]);
	//puts("");
	i64 ret = 0;
	for (int m = 0; m < (1 << B); ++m) {
		map<int, int> grps;
		for (int i = 0; i < N; ++i) {
			if (grps.count(A[i] & m) == 0) grps[A[i] & m] = 1;
			else grps[A[i] & m] += 1;
		}
		/*
		int t = 0;
		for (int i = 0; i <= K; ++i) {
			dp[t][i] = 0;
		}
		dp[t][0] = 1;
		for (auto e : grps) {
			int w = e.second;
			for (int i = 0; i <= K; ++i) dp[1 - t][i] = dp[t][i] + (i >= w ? dp[t][i - w] : 0);
			t = 1 - t;
		}
		*/

		i64 tmp = 1;
		//for (int i = 0; i <= K; ++i) tmp += dp[t][i];
		for (auto e : grps) {
			int w = e.second;
			for (int i = 1; i <= K; ++i) tmp += C[w][i];
		}

		int pop = __builtin_popcount(m) % 2;
		if (pop == 1) tmp = -tmp;
		// printf("%d: %lld\n", m, tmp);
		ret += tmp;
	}
	printf("%lld\n", ret);
	return 0;
}


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

const long long MOD = 1000000007;

int main() {
	long long n, k, result = 0;
	cin >> n >> k;
    long long factorial[n + 1], ifactorial[n + 1], inv[n + 1], a[n];
    factorial[0] = 1;
    ifactorial[0] = 1;
    inv[1] = 1;
    factorial[1] = 1;
    ifactorial[1] = 1;
    for (long long i = 2; i < n; i++) {
        factorial[i] = factorial[i - 1] * i % MOD;
        inv[i] = (-MOD / i + MOD) * inv[MOD % i] % MOD;
        ifactorial[i] = ifactorial[i - 1] * inv[i] % MOD;
    }
    auto C = [&](long long n, long long k)->long long {
    	if (k > n) {
    		return 0;
    	}
    	return factorial[n] * ifactorial[n - k] % MOD * ifactorial[k] % MOD;
    };
	for (int i = 0; cin >> a[i]; i++) {
	}
	sort(a, a + n);
	for (long long i = 0; i < n; i++) {
		result = (result + a[i] * C(i, k - 1)) % MOD;
		result = (result - a[i] * C(n - i - 1, k - 1) % MOD + MOD) % MOD;
	}
	cout << result;
	return 0;
}

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

int main(){
string S;
  cin>>S;
  
 int ans1=0, ans2=0;
  for(int i=0; i<S.size(); i++){  // パターンは010101...か101010...の2通りしかない
   if(S[i]-'0'==i%2){ans1++;} // 010101...との共通点があったらans1++
    else{ans2++;}             // 010101...との相違点があったらans2++
  }
  cout<<min(ans1, ans2);      // 010101...と101010...のどちらのパターンで
}                             // タイルを張れば、より少ない数に抑えられるかを表示


Measured memory_bytes: 512
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1138&lang=jp
using namespace std;
const double inf = 1e5;

struct edge {
	int from, to, cost;
	edge() {}
	edge(int from,int to,int cost):from(from),to(to),cost(cost){}
};

int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int n, m, p, a, b;
	while (cin >> n >> m >> p >> a >> b, n | m | p | a | b) {
		a--;b--;
		vector<double> t(n);
		for (int i = 0; i < n;i++)cin >> t[i];
		vector<vector<edge>> G(m);
		for (int i = 0; i < p;i++) {
			int x, y, z; cin >> x >> y >> z;
			x--;y--;
			G[x].push_back(edge(x, y, z));
			G[y].push_back(edge(y, x, z));
		}

		// dist[i][j] := ??????i??§????????¬?????????j(?????????)???????????????
		// j???k??????????????????????????£??????????????????k???????????´???????????¨???
		vector<vector<double>> dist(m, vector<double>(1 << n,inf));
		using key = tuple<int, int>;
		queue<key> q;

		// initialize
		q.push(key(a,0));
		dist[a][0] = 0;

		while(!q.empty()){
			int city, ticket;
			tie(city, ticket) = q.front(); q.pop();
			for (int i = 0; i < G[city].size();i++) {
				int next_city = G[city][i].to;
				int cost = G[city][i].cost;

				for (int k = 0; k < n;k++) {
					//k???????????¬??????????????¨?????§????????°
					if ((ticket >> k) & 1) continue;
					if (dist[next_city][ticket | (1 << k)] > dist[city][ticket] + cost / t[k]) {
						dist[next_city][ticket | (1 << k)] = dist[city][ticket] + cost / t[k];
						q.push(key(next_city, ticket | (1 << k)));
					}
				}
			}
		}

		double ans = inf;
		for (int j = 0;j < (1 << n);j++) {
			ans = min(ans, dist[b][j]);
		}
		if (ans == inf) { cout << "Impossible" << endl; continue; }
		cout << fixed << setprecision(4) << ans << endl;
	}
}

Measured memory_bytes: 3436
#include <stdio.h>

int main(void){
  char s[100000];
  int i, success = 0;

  scanf("%s", s);

  if(s[0] == 'Y') success++;
  if(s[1] == 'A') success++;
  if(s[2] == 'K') success++;
  if(s[3] == 'I') success++;

  if(success == 4){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

A, B, K = MAP()

for _ in range(K//2):
	B += A//2
	A //= 2
	A += B//2
	B //= 2

if K%2:
	B += A//2
	A //= 2

print(A, B)

Measured memory_bytes: 10520