akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
vector<int> adj[100001];
int memo[100001];
int dfs(int i)
{
    if(memo[i]==-1)
    {
    int j;
    int ans=0;
    for(j=0;j<adj[i].size();j++)
    {
        ans=max(ans,dfs(adj[i][j])+1);
    }
    memo[i]=ans;
    return memo[i];
    }
    return memo[i];
}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input1.txt", "r", stdin);
//     freopen("output1.txt", "w", stdout);
// #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    int i;
    int u,v;
    for(i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].push_back(v);
    }
    for(i=0;i<=n;i++)
    {
        memo[i]=-1;
    }
    int l=0;
    for(i=1;i<=n;i++)
    {
        l=max(l,dfs(i));
        //cout<<dfs(i)<<"\n";
    }
    cout<<l<<"\n";
}

Measured memory_bytes: 8192
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

A,B =inpl()
if A==B:
    print(A+B)
else:
    print(max(A,B)*2-1)


Measured memory_bytes: 6624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
int main()
{
    fast;
    int n; cin>>n;
    int ans=0;
    vector<int> v;
    for(int i=0;i<2*n;i++)
    {
        int x; cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(auto i=v.begin();i!=v.end();i=i+2)
    {
       // cout<<*i<<endl;
        ans+=*i;
    }
   cout<<ans<<endl;
}


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

int main(){
	string a,b;
	
	cin >> a >> b;
	int al = a.size(),bl = b.size();
	
	if(al > bl) cout << "GREATER";
	else if(al < bl) cout << "LESS";
	else{
		if(a > b) cout << "GREATER";
		else if(a==b) cout << "EQUAL";
		else cout << "LESS";
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vp = vector<Pii>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

class UnionFind {
private:
    const int n;
    vector<int> uni;
public:
    UnionFind(int _n) : n(_n), uni(_n, -1) {}
    int root(int x) {
        if (uni[x] < 0) return x;
        return uni[x] = root(uni[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (uni[x] > uni[y]) swap(x, y);
        uni[x] += uni[y];
        uni[y] = x;
        return true;
    }
    void print() {
        for (auto x : uni) cout << x << " ";
        cout << endl;
    }
};

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

  int n;
  cin >> n;
  vi x(n), y(n);
  const int W = 100000;
  vi id_x(W, -1), id_y(W, -1);
  UnionFind uf(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
    if (id_x[x[i]] != -1) {
      uf.unite(id_x[x[i]], i);
    }
    else {
      id_x[x[i]] = i;
    }

    if (id_y[y[i]] != -1) {
      uf.unite(id_y[y[i]], i);
    }
    else {
      id_y[y[i]] = i;
    }
  }

  vector<set<int>> st_x(n), st_y(n);
  vector<int> size_comp(n, 0);
  rep(i, n) {
    st_x[uf.root(i)].insert(x[i]);
    st_y[uf.root(i)].insert(y[i]);
    size_comp[uf.root(i)]++;
  }

  int ans = 0;
  rep(i, n) {
    if (size_comp[i] > 0) {
      ans += ((int)st_x[i].size() * (int)st_y[i].size() - size_comp[i]);
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 19072
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        long m = -1000000;
        long s = 1000000;
        long sum = 0;
        for( int i = 0; i < n; i++ ){
        	long a = sc.nextLong();
        	if( m < a )
        		m = a;
            if( s > a )
                s = a;
            sum += a;
        }
        
        System.out.println( s+" "+m+" "+sum );

        sc.close();
    }
} 



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

using namespace std;

int main()
{
    string N;
    cin>>N;
    string s ="07";
    if(N.length()==3 && N[0]!=s[0]){
    if(N[0]==s[1]||N[1]==s[1]||N[2]==s[1]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string a,b;
  cin>>a>>b;
  if(a.length()==b.length()){
    rep(i,0,a.length()){
      cout<<a[i]<<b[i];
    }
  }else{
    rep(i,0,b.length()){
      cout<<a[i]<<b[i];
    }
    cout<<a[a.length()-1];
  }

}

// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
from collections import deque

N = int(input())
edges = {i: [] for i in range(N)}
edgeind = {}
for i in range(N - 1):
    a, b = map(int, input().split(" "))
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
    edgeind[(a - 1, b - 1)] = i

# 使用する色数 K = 最大次数
K = 0
root = -1
for i in range(N):
    K = max(K, len(edges[i]))
    if K == len(edges[i]):
        root = i

# rootから彩色していく
que = deque()
que.append((root, -1, -1))  # vertex, parent, parent color
ans = [-1 for i in range(N - 1)]

while len(que) > 0:
    now, par, par_col = que.popleft()
    color = 1
    for edge in edges[now]:
        if edge == par:
            continue
        if color == par_col:
            color += 1
        if (now, edge) in edgeind:
            ans[edgeind[(now, edge)]] = color
        else:
            ans[edgeind[(edge, now)]] = color
        que.append((edge, now, color))
        color += 1

print(K)
print('\n'.join([str(a) for a in ans]))

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int N;
  if (a==b && b==c)
    N=1;
  else if (a==b || b==c || c==a)
    N=2;
  else
    N=3;
  cout << N << endl;
}

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

const ll MAX = 2e5 + 1;
ll MOD = 998244353;
ll INV[MAX] = {}, FACTORIAL[MAX] = {}, FACTORIAL_INV[MAX] = {};

void calc_init() {
  INV[1] = 1;
  FACTORIAL[0] = FACTORIAL[1] = 1;
  FACTORIAL_INV[0] = FACTORIAL_INV[1] = 1;

  for (int i = 2; i <= MAX; i++) {
    ll q = MOD / i, r = MOD % i;
    INV[i] = (-INV[r] * q) % MOD;
    INV[i] = (INV[i] + MOD) % MOD;
    FACTORIAL[i] = (i * FACTORIAL[i - 1]) % MOD;
    FACTORIAL_INV[i] = (INV[i] * FACTORIAL_INV[i - 1]) % MOD;
  }
}

ll nCk(ll n, ll k) {
  ll ans = FACTORIAL[n];
  ans = (ans * FACTORIAL_INV[k]) % MOD;
  ans = (ans * FACTORIAL_INV[n - k]) % MOD;
  return ans;
}


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

  ll N; cin >> N;
  ll M; cin >> M;
  ll K; cin >> K;

  calc_init();
  ll ex = 1;
  for (ll i = 0; i < (N - K - 1); i++) {
    ex = (ex * (M - 1)) % MOD;
  }
  ll ans = 0;
  for (ll i = K; i >= 0; i--) {
    ll nck = nCk(N - 1, i);
    ll temp = (nck * M) % MOD;
    ans = (ans + (temp * ex) % MOD ) % MOD;
    ex = (ex * (M - 1)) % MOD;
  }

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

Measured memory_bytes: 8372
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 998244353;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
char s[5005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
	cin >> a >> b;
	p(a + b / 2);




	//p(ans);
	

    return 0;
}


Measured memory_bytes: 27008
def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

mod = 10**9+7

N,K = input_multiple_number()

ans = 0

for i in range(N+1+1):
	if i < K:
		continue

	ans += ((N-i+1+N)*i//2-(0+i-1)*i//2+1)

print(ans%mod)

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

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

    if((a*b)<=c) cout << a*b;
    else cout << c;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define bs inline bool scan
ii(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
ii() {return in(gcu());}
bs(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bs(char &c){c=gcu();gcu();return c!=EOF;}
// bs(string &s){int c; s = "";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#undef bs
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
// vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int len(int a, int c) {
	return a / c + (bool) (a % c);
}

int main() {
	int l = in(), a = in(), b = in(), c = in(), d = in();
	out(l - max(len(a, c), len(b, d)), '\n');
}


Measured memory_bytes: 2452
N, C, K = map(int, input().split())
Ts = [int(input()) for _ in range(N)]
Ts.sort()
front = 0
now = 0
cnt = 0
ans = 0
for i in Ts:
    if cnt == 0:
        front = i
        now = i
        cnt += 1
    elif cnt == C:
        front = i
        now = i
        cnt = 1
        ans += 1
    elif now - front <= K:
        if i - front <= K:
            now = i
            cnt += 1
        else:
            front = i
            now = i
            cnt = 1
            ans += 1
if cnt:
    ans += 1
print(ans)
        

Measured memory_bytes: 7440
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<ll>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    vi sum(n+1);
    rep(i, n) {
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }

    sort(sum.begin(), sum.end());
    ll ans = 0LL;
    map<ll, ll> mp;
    rep(i, n+1) {
        mp[sum[i]]++;
    }

    for(auto x:mp) {
        ans += x.second*(x.second-1)/2;
    }

    cout << ans << endl; 
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

  ll dp[n+1][W+1];

  ll v[n+1];
  int w[n+1];

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

  for(int i=0; i<=W; i++) dp[0][i] = 0;

  for(int i=1; i<=n; i++){
    for(int j=0; j<=W; j++) dp[i][j] = dp[i-1][j];
    for(int j=0; j+w[i] <=W; j++){
        dp[i][j+w[i]] = max(dp[i][j+w[i]],dp[i-1][j]+v[i]);
    }
  }

//  for(int i=0; i<=n; i++)
//  {
//      for(int j=0; j<=W; j++) cout << dp[i][j] << " ";
//      cout << endl;
//  }

  ll res = dp[n][0];

  for(int i=1; i<=W; i++) res = max(res,dp[n][i]);

  cout << res;

  return 0;
}


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

typedef long long ll;
#define INF 10e9

using namespace std;

ll dp[200005];

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

	ll buf = 0;
	for (int i = 0; s[i] != 'B'; i++) {
		buf++;
	}
	for (int i = buf + 1; i < s.size(); i++) {
	    if (s[i] == 'W' && s[i - 1] == 'B') {
			dp[i] = dp[i - 1] + i - buf;
			s[i] = 'B';
			buf++;
		}
		else
			dp[i] = dp[i - 1];
	}
	cout << dp[s.size() - 1] << endl;
}


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

void reverse(string &s, int m, int n){
    int i;
    string tmp;
	for (i=m;i<=(m+n)/2;i++){
		tmp[0] = s[i];
		s[i] = s[m+n-i];
		s[m+n-i] = tmp[0];
	}
}

int main(){
    string s,t;
    cin>>s>>t;
    int ls,i=0,flag=0;
    ls=s.length();
    while(i<ls){
        if(s!=t){
            reverse(s,0,ls-2);
            reverse(s,0,ls-1);
        }
        else{
            cout<<"Yes";
            flag=1;
            break;
        }
        i++;
    }
    if(!flag){
        cout<<"No";
    }


    return 0;
}


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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define REP(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define INF 1e+18L

int main()
{
    FastIO
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    REP(i,0,n)
        cin >> w[i] >> v[i];
    int sum_val = 0;
    for(int x : v)
        sum_val += x;
    vector<ll> dp(sum_val+1, INF);
    dp[0] = 0;
    REP(item,0,n)
    {
        for(int val_already = sum_val - v[item]; val_already >= 0;  val_already--)
        {
            dp[val_already+v[item]] = min(dp[val_already+v[item]], dp[val_already] + w[item]);
        }
    }

    ll ans = 0;
    REP(i,0,sum_val+1)
    {
        if(dp[i] <= W)
            ans = max(ans, (ll) i);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll x[100004] = {};
	ll y[100004] = {};
	ll z[100004] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);

	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == '0')
			{
				a++;
			}
		}
		else
		{
			if (s[i] == '1')
			{
				a++;
			}
		}
	}
	
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == '1')
			{
				ans++;
			}
		}
		else
		{
			if (s[i] == '0')
			{
				ans++;
			}
		}
	}

	cout << min(ans,a) << endl;



	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//sort(x, x + a, std::greater<ll>());

//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in);) {
			
			while(true) {
				long H = sc.nextInt();
				long W = sc.nextInt();

				if (H == 0 && W == 0) break;

				StringBuilder sb = new StringBuilder();

				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						sb.append("#");
					}
					sb.append("\n");
				}

				System.out.println(sb.toString());
			}
		}
	}
}


Measured memory_bytes: 27692
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string s;
    cin>>s;
    REP(i,(long long int)s.size()){
        if(i%2){
            if(s[i]=='R'){
                cout<<"No"<<endl;
                return 0;
            }
        }else{

            if(s[i]=='L'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main(){
  int n,m; cin>>n>>m;
  vector<vector<int>> num(n+1);
  for(int i=0;i<m;i++){
    int a,b; cin>>a>>b;
    num[a].push_back(b);
  }
  for(int i=0;i<num[1].size();i++){
    if(!num[num[1][i]].empty()){
      for(int j=0;j<num[num[1][i]].size();j++){
        if(num[num[1][i]][j]==n){
          cout<<"POSSIBLE"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 8576
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        bool[,] b = new bool[N,N];
        bool[] b1 = new bool[N];
        bool[] b2 = new bool[N];
        for(int i=0;i<N;i++){
            b2[i] = true;
        }
        bool b3 = false;
        int[] c = new int[N];
        for(int i=0;i<N;i++){
            string s = Console.ReadLine();
            for(int j=0;j<N;j++){
                b[i,j] = s[j] == '#';
                b1[j] |= b[i,j];
                b2[j] &= b[i,j];
                b3 |= b[i,j];
                if(b[i,j]){
                    c[i]++;
                }
            }
        }
        int ans;
        if(b3){
            int ac = 0;
            for(int i=0;i<N;i++){
                if(b2[i]){
                    ac++;
                }
            }
            int min = 2*N;
            for(int i=0;i<N;i++){
                if(b1[i]){
                    min = Math.Min(N-c[i]+N-ac,min);
                }
                else{
                    min = Math.Min(N-c[i]+N-ac+1,min);
                }
            }
            ans = min;
        }
        else{
            ans = -1;
        }
        sb.Append(ans+"\n");
    }
}

Measured memory_bytes: 11192
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n, p = map(int, input().split())
c = Counter(prime_factorize(p))
ans = 1
for i in c.most_common():
    ans *= i[0] ** (i[1] // n)
print(ans)

Measured memory_bytes: 3444
while(1):
    n = int(input())
    if n == 0:
        break
    t = [[0] * (n + 1) for i in range(n + 1)]
    m = []
    for i in range(0,n):
        m.append(list(int(x) for x in input().split(" ")))
    sum = 0
    for i in range(0,n):
        sum1 = 0
        sum2 = 0
        for j in range(0,n):
            t[i][j] = m[i][j]
            sum1 += m[i][j]
            sum2 += m[j][i]
        t[i][n] = sum1
        t[n][i] = sum2
        sum += sum1
    t[n][n] = sum
    
    
    for i in range(0,n + 1):
        for j in range(0,n + 1):
            print("%5d" %(t[i][j]),end="")
        print()


Measured memory_bytes: 5628
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
  ll a=0,b=0;
  ll n,x;
  cin>>n;
  for(int i=0;i<n;i++){
      cin>>x;
      if(x%2==0)a++;
      else b++;
  }
  if(a==0||b==0){
      cout<<0<<endl;
  }
  else{
      cout<<(b-1)/2*2+a<<endl;
  }
  return 0;
}



Measured memory_bytes: 3092
import bisect,collections,copy,heapq,itertools,math,numpy,string
from fractions import gcd
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) # tupleも検討する。
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = S()
    L = [i for i in N]
    ans = []

    for i, num in enumerate(L):
        if(num != "B"):
            ans.append(num)
        if(ans != [] and num == "B"):
            ans.pop(-1)

    print("".join(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 27244
#include <cstdlib>
#include <cmath>
#include <iostream>

using namespace std;

bool binarySearch(int tgt,int array[],int length){
    int pointer;
    int right = length;
    int left = 0;
    while(left < right){
        pointer = (left + right) / 2;
        if(array[pointer] < tgt){
            left = pointer + 1;
        }else if(array[pointer] > tgt){
            right = pointer;
        }else{
            return true;
        }
    }

    if(array[pointer] == tgt){
        return true;
    }
    
    return false;
}

int main(){
   int n;
   int s[100000];
   int q;
   int t[50000];
   int count = 0;

   cin >> n;

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

   cin >> q;

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

   //探索
   for(int i=0; i<q; i++){
       if(binarySearch(t[i],s,n)){
           count++;
       }
   }

   cout << count << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
int main(void){
 char num[1010];
 int a;
 while(1){
     scanf("%s", &num);
     if(num[0]=='0')
     break;
     else{
     int sum = 0;
     for(int i=0; i<strlen(num); i++){
         sum+=num[i]-'0';
     }
     printf("%d\n", sum);
     }

 }
 return 0;

}


Measured memory_bytes: 2040
#include <iostream>
#include <cmath>

using namespace std;

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

  long long X;
  cin >> X;
  int n = (-2 + ceil(sqrt(1 + 8 * X))) / 2 + 1;
  cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <assert.h>
#include <numeric>

using namespace std;

int solve() {
    int A, B, C;
    cin >> A >> B >> C;
    
    vector<int> v;
    v.push_back(A);
    v.push_back(B);
    v.push_back(C);
    
    sort(v.begin(), v.end());
    v[2] -= v[0]; v[1] -= v[0]; v[0] = 0;
    
    if ((v[2]-v[1])%2 == 0 && v[2]%2 == 0) {
        cout << (v[2]-v[1])/2 + v[2]/2 << endl;
    }
    if ((v[2]-v[1])%2 == 0 && v[2]%2 == 1) {
        cout << 1+(v[2]-v[1])/2 + (v[2]+1)/2 << endl;
    }
    if (v[2]%2 == 1 && v[1]%2 == 0) {
        cout << 1+(v[1]/2)+(v[2]-v[1]-1)/2 << endl;
    }
    if (v[2]%2 == 0 && v[1]%2 == 1) {
        cout << 1+(v[2]/2)+(v[2]-v[1]+1)/2 << endl;
    }
    return 0;
}

int main() {
        solve();
#ifdef DEBUG
    while (1) {
        solve();
    }
#endif
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

int main()
{
    fast
   string s,t;
   cin>>s>>t;
 int ans=0;
   for(int i=0;i<s.size()-t.size()+1;i++)
   {
   	int tans=0;
   	for(int j=0;j<t.size();j++)
   	{
   		if(s[i+j]==t[j])
   		{
   			tans++;
   		}
   	}

   	ans=max(ans,tans);
   }


  cout<<t.size()-ans<<endl;

    bye
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s; cin >> s;
  ll ans = 0;

  ll cnt = 0;
  rep(i, si(s)) {
    if (s[i] == 'W') {
      ans += i - cnt;
      ++cnt;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    vector<pair<ll, ll> > pr(m);
    for(ll i=0;i<m;i++){
        ll b, c; cin >> b >> c;
        pr.push_back(make_pair(c, b));
    }

    sort(a.begin(), a.end());
    sort(pr.rbegin(), pr.rend());

    vector<ll> rep(n, 0LL);
    ll idx = 0;
    for(ll i=0;i<m;i++){
        for(ll j=idx;j<min(n, idx + pr[i].second);j++){
            rep[j] = pr[i].first;
        }
        idx += pr[i].second;
    }

    // for(ll r: rep) cout << r << endl;

    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(a[i] < rep[i]){
            ans += rep[i];
        }else{
            ans += a[i];
        }
    }
    cout << ans << endl;
}

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

int main(void){
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i<N; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    double tmp = (v.at(0) + v.at(1))/2;
    for(int i = 2;i<N;i++){
        tmp = (tmp + v.at(i))/2;
    }
    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll dp[maxn][3], n;
ll arr[maxn][3];

int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    dp[1][0] = arr[1][0];
    dp[1][1] = arr[1][1];
    dp[1][2] = arr[1][2];
    ll result = max(max(dp[1][0], dp[1][1]), dp[1][2]);
    for(int i=2;i<=n;i++) {
        dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][0], dp[i-1][1]);
        result = max(max(dp[i][0], dp[i][1]), dp[i][2]);
    }
    cout<<result<<"\n";
    return 0;
}


Measured memory_bytes: 4992
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if len(set([l[i],l[j],l[k]]))==3:
                if l[i]+l[j]>l[k] and l[i]<l[j]+l[k] and l[i]+l[k]>l[j]:
                    ans+=1
print(ans)


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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  int as[n];
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
  }
  std::cout << as[n - 1];
  for (int i = n - 3; i >= 0; i -= 2) {
    std::cout << " " << as[i];
  }
  for (int i = n % 2; i < n - 1; i += 2) {
    std::cout << " " << as[i];
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>

typedef struct {
	int group;
	int people_num;
	int waiting_time;
} wqueue_t;

int main(void) {
	int i,j,k,mode;
	int tennai[17]={0};
	int wqueue_start=0;
	int wqueue_end=0;
	wqueue_t wqueue[100]={0};
	int waiting_time_list[100]={0};
	int zikan;
	int query;
	for(zikan=0;zikan<=1000;zikan++) {
		if(zikan%5==0 && zikan/5<100) {
			wqueue[wqueue_end].group=zikan/5;
			wqueue[wqueue_end].people_num=((zikan/5)%5==1)?5:2;
			wqueue[wqueue_end].waiting_time=0;
			wqueue_end++;
		}
		for(i=0;i<17;i++) {
			if(tennai[i]>0)tennai[i]--;
		}
		for(i=wqueue_start,mode=1;i<wqueue_end;i++) {
			if(mode) {
				for(j=wqueue[i].people_num;j<=17;j++) {
					for(k=j-wqueue[i].people_num;k<j;k++) {
						if(tennai[k]>0)break;
					}
					if(k>=j)break;
				}
				if(j<=17) {
					for(k=j-wqueue[i].people_num;k<j;k++) {
						tennai[k]=17*(wqueue[i].group%2)+
							3*(wqueue[i].group%3)+19;
					}
					wqueue_start=i+1;
					waiting_time_list[wqueue[i].group]
						=wqueue[i].waiting_time;
				} else {
					wqueue[i].waiting_time++;
					mode=0;
				}
			} else {
				wqueue[i].waiting_time++;
			}
		}
	}
	while(scanf("%d",&query)==1)printf("%d\n",waiting_time_list[query]);
	return 0;
}

Measured memory_bytes: 0
from collections import defaultdict

class RollingHash(object):
    def __init__(self, S: str, MOD: int = 10 ** 9 + 7, BASE: int = 10 ** 5 + 7):
        self.S = S
        self.N = N = len(S)
        self.MOD = MOD
        self.BASE = BASE
        self.S_arr = [ord(x) for x in S]

        self.POWER = [1] * (N + 1)
        self.HASH  = [0] * (N + 1)
        p, h = 1, 0
        for i in range(N):
            self.POWER[i + 1] = p = (p * BASE) % MOD
            self.HASH[i + 1] = h = (h * BASE + self.S_arr[i]) % MOD

    def hash(self, l: int, r: int):
        # get hash for S[l:r]
        _hash = (self.HASH[r] - self.HASH[l] * self.POWER[r - l]) % self.MOD
        return _hash

def main():
    N = int(input())
    S = input()
    MOD = 998244353
    rs = RollingHash(S, MOD=MOD, BASE=37)
    h, p = rs.HASH, rs.POWER

    left, right = 0, N // 2 + 1

    while abs(right - left) > 1:
        mid = (left + right) // 2
        ok = False
        hash_to_left = defaultdict(list)
        L = mid
        for i in range(N - L + 1):
            _hash = (h[i+L] - h[i] * p[L]) % MOD
            # hashが衝突しても文字列が完全に一致するか分からないので、
            # 衝突した場合は文字列が完全に一致するか調べ、かつ
            # 文字列同士がSの中で重なるような範囲にない場合はOKとする
            for j in hash_to_left[_hash]:
                if j+L <= i and S[i:i+L] == S[j:j+L]:
                    ok = True
                    break
            if ok:
                break
            hash_to_left[_hash].append(i)

    
        if ok:
            left = mid
        else:
            right = mid

    print(left)
    # # 長さLの部分文字列同士が、範囲を重ねず同じ文字列となる場合はTrue,
    # # そうでない場合はFalseを返す関数
    # def isOK(L):
    #     if L == 0:
    #         return True
    #     hash_to_left = defaultdict(list)
    #     for i in range(N - L + 1):
    #         _hash = rs.hash(i, i + L)
    #         # hashが衝突しても文字列が完全に一致するか分からないので、
    #         # 衝突した場合は文字列が完全に一致するか調べ、かつ
    #         # 文字列同士がSの中で重なるような範囲にない場合はOKとする
    #         for j in hash_to_left[_hash]:
    #             if j+L <= i and S[i:i+L] == S[j:j+L]:
    #                 return True
    #         hash_to_left[_hash].append(i)

    #     return False
    # # 範囲が重ならないことが条件にあるので、答えは最大でもN // 2（文字列の長さの半分）となる。
    # # ただし、二分探索する上で絶対に答えとならない範囲を含めたいので、
    # # 探索範囲としてはN // 2 + 1 と、+1しておく。
    # ans = binary_search(0, N // 2 + 1, isOK, search_max=True)
    # print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
    string s;
    cin>>s;
    int i=0;
    int coun=0;
    int maxi=0;
    while(i!=s.size()){
        if(s[i]!='A' && s[i]!='T' && s[i]!='G' && s[i]!='C'){
            if(coun>=maxi)
            {
                maxi =coun;
                coun=0;
            }else coun=0;

        }else {++coun;}
        ++i;
    }
    maxi = maxi>coun?maxi:coun;
    cout<<maxi;
	return 0;
}


Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    AIN(string, C, 2);
    YES(C[0][0] == C[1][2] and C[0][1] == C[1][1] and C[0][2] == C[1][0], "YES", "NO");
}

Measured memory_bytes: 3616
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    cnt = 0
    for a in A:
        if a % 4 == 0:
            cnt += 1
        elif a % 2 == 0:
            cnt += .5
    print('Yes' if N // 2 <= int(cnt) else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 19736
#include<stdio.h>

int main(void){
    int n,m,l;
    int i,j,k;
    scanf("%d %d %d", &n, &m, &l);
    int a[n][m];
    int b[m][l];
    long int c[n][l];
    for ( i = 0 ; i < n ; i++ ){
        for ( j = 0 ; j < m ; j++ ){
            scanf("%d", &a[i][j]);
        }
    }
    for ( j = 0 ; j < m ; j++ ){
        for ( k = 0 ; k < l ; k++ ){
            scanf("%d", &b[j][k]);
        }
    }
    for ( i = 0 ; i < n ; i++ ){
        for ( k = 0 ; k < l ; k++ ){
            c[i][k] = 0;
        }
    }
    for ( i = 0 ; i < n ; i++ ){
        for ( k = 0 ; k < l ; k++ ){
            for ( j = 0 ; j < m ; j++ ){
                c[i][k]+=(a[i][j]*b[j][k]);
            }
        }
    }
    for ( i = 0 ; i < n ; i++ ){
        for ( k = 0 ; k < l ; k++ ){
            printf("%ld", c[i][k]);
            if ( k != l - 1 ) {
                printf(" ");
            } else {
                printf("\n");
            }
        }
    }
}


Measured memory_bytes: 2132
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int s = int.Parse(ReadLine());
        List<int> l = new List<int>();
        int num = 1;

        l.Add(s);

        while(true)
        {
            if (s % 2 == 0)
                s /= 2;
            else
                s = s * 3 + 1;
            num++;

            if (l.Contains(s))         
                break;
            else
                l.Add(s);
        }
            Console.WriteLine(num);
    }

}



Measured memory_bytes: 27776
def bubbleSort(c, n):
    flag = 1
    while(flag) :
        flag = 0
        for i in reversed(range(1,n)):
            if(c[i][1] < c[i-1][1]):
                c[i], c[i-1] = c[i-1], c[i]
                flag = 1
    return c

def selectionSort(c,n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if(c[j][1] < c[minj][1]):
                minj = j
        c[i], c[minj] = c[minj], c[i]
    return c

def isStable(c1, c2, n):
    for i in range(n):
        if(c1[i] != c2[i]):
            return False
    return True

n = int(input())
c = input().split(' ')
trump = [list(i) for i in c]
bubble = ["".join(s) for s in bubbleSort(trump, n)]
trump = [list(i) for i in c]
selection = ["".join(s) for s in selectionSort(trump, n)]
str_bubble = " ".join(bubble)
str_selection = " ".join(selection)
print(str_bubble)
print('Stable')
print(str_selection)
if isStable(bubble, selection, n):
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5612
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
        print((B- A) // 2)
else:
        tmp = (B - A) // 2
        pattern1 = min((N - B), (A - 1)) + (B - A)
        B = B - tmp
        A = A + tmp
        pattern2 = min((N - B), (A - 1)) + (B - A)
        print(min(pattern1, pattern2))

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

int main( void ){
	
	lint n;
	string str;
	double tmp, ret;
	
	ret = 0;
	
	cin >> n;
	
	rep(i,n){
		cin >> tmp >> str;
		if( str == "JPY" ){
			ret += tmp;
		}else if( str == "BTC" ){
			ret += tmp * 380000.0;
		}
	}
	
	cout << fixed << ret << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())

rect = [[1 for i in range(W)] for j in range(H)]
for n in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for i in range(H):
            for j in range(x):
                rect[i][j] = 0
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                rect[i][j] = 0
    elif a == 3:
        for i in range(y):
            for j in range(W):
                rect[i][j] = 0
    else:
        for i in range(y, H):
            for j in range(W):
                rect[i][j] = 0

ans = 0
for i in range(H):
    for j in range(W):
        ans += rect[i][j]

print(ans)

Measured memory_bytes: 3064
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Stack;

public class Main{
       
	public static void main(String[] args) {
		
            Scanner sdf = new Scanner(System.in);
            int t=1;
            next: while(t-->0){
                String s=sdf.next();
                if(s.equals("AAA")||s.equals("BBB")){
                    System.out.println("No");
                }
                else System.out.println("Yes");
                    
            }
        }

        
        
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int k,s; cin >>k >>s;
  ll res = 0;

  for (int x=0; x<=k; x++){
    for (int y=0; y<=k; y++){
      int z = s - x - y;
      if (z >= 0 && z <= k) res++;
    }
  }
  cout <<res <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
const int N = 1e5+10;
typedef long long LL;
const LL mod = 1e9+7;
int a[N];
 
int main()
{
    int n;
    while(scanf("%d", &n)!=EOF)
    {
        for(int i=2;i<=n;i++)
        {
            int x=i;
            for(int j=2;j<=x;j++)
            {
                while(x%j==0)
                {
                    a[j]++;
                    x/=j;
                }
            }
            if(x!=1) a[x]++;
        }
        LL ans=1;
        for(int i=1;i<=n;i++)
        {
            if(a[i]!=0) ans=(ans*(a[i]+1))%mod;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
string dir[8] = { "R","L","D","U","RD","RU","LD","LU" };
bool flag[201010];
ll ans[201010];

vector<vector<ll>>to;

void dfs(ll v) {
	flag[v] = true;
	for (auto nv : to[v]) {
		if (flag[nv] == false) {
			ans[nv] += ans[v];
			dfs(nv);
		}
	}
}

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll x;
	cin >> x;
	if (x == 0)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3632