akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
  int H, W; cin >> H >> W;
  vector<vector<int>> s(H, vector<int> (W, -1));
  int wset = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      char c; cin >> c;
      if(c == '#') s[i][j] = 0;
      else if(i != 0 || j != 0)wset++;
    }
  }
  queue<pair<int, int>> que;
  que.push(make_pair(0, 0));
  s.at(0).at(0) = 0;
  vector<int> dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
  while(!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    for(int i = 0; i < 4; i++) {
      int px = p.first + dx.at(i);
      int py = p.second + dy.at(i);
      if(px >= 0 && px < H && py >= 0 && py < W) {
        if(s.at(px).at(py) == -1) {
          s.at(px).at(py) = s.at(p.first).at(p.second) + 1;
          que.push(make_pair(px, py));
        }
      }
    }
  }
  if(s.at(H - 1).at(W - 1) == -1) cout << -1 << endl;
  else cout << wset - s.at(H - 1).at(W - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
double h[1005];
 
int main() {
  int n;
  cin >> n;
  double t, a;
  cin >> t >> a;
  int ans = 0;
  double ansd = 1e9;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    double d = abs(t - h[i] * 0.006 - a);
    if (d < ansd)
      ansd = d, ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)1e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int a[NAX][26];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    string s[n];
    vector<string> v;
    for(int i=0; i<n; ++i) {
      cin >> s[i];
      sort(all(s[i]));
      v.push_back(s[i]);
    }
    sort(all(v), [&](const string a, const string b){
          return (a < b);
        });
    ll res = 0;
    for(int i=0; i<v.size()-1; ++i){
      ll c = 1;
      int p = i;
      while(p+1<n && v[p] == v[p+1]) {
        ++c; 
        ++p;
      }
      if(c > 1)
        i = p -1;
      res += c*(c-1)/2;
    }
    //v.resize(unique(all(v)) - v.begin());
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 11252
N = int(input())
A = list(map(int,input().split()))
answer = 0
for i in range(N) :
    A[i]-= i+1
A = sorted(A)
if N % 2 != 0 :
    a = A[N//2]
else :
    a = (A[N//2]+A[N//2-1])//2
for j in range(N) :
    A[j] -= a
    answer += abs(A[j])
print(answer)


Measured memory_bytes: 25196
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first<y.first)
        return true;
    else if(x.first==y.first)
        return x.second>y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}

void solve()
{   
    int n,a,b,c;
    string ans="";
    string s;
    cin>>n>>a>>b>>c;
    map<char,int> m;
    m['A']=a;
    m['B']=b;
    m['C']=c;
    string s1="";
    for(int i=0;i<n;i++){
        if( s1=="")
            cin>>s;
        else
        {
            s=s1;
            s1="";
        }
        if(m[s[0]]>m[s[1]]){
            m[s[0]]--,m[s[1]]++;
            ans+=s[1];
        }
        else if(m[s[0]]==m[s[1]]){
            s1;
            if(i<n-1){
                cin>>s1;
                if(s==s1){
                    m[s[0]]--,m[s[1]]++;
                    ans+=s[1];
                }
                else
                {
                    if(s[0]==s1[0] || s[0]==s1[1]){
                        m[s[0]]++,m[s[1]]--;
                        ans+=s[0];
                    }
                    else{
                        m[s[0]]--,m[s[1]]++;
                        ans+=s[1];
                    }
                }
            }
            else{
                m[s[0]]--,m[s[1]]++;
                ans+=s[1];
            }
        }
        else{
            m[s[1]]--,m[s[0]]++;
            ans+=s[0];
        }
        if(m['A']<0 || m['B']<0 || m['C']<0){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes"<<'\n';
    for(char c: ans)
        cout<<c<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 3744
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br

sys.setrecursionlimit(100000000)

ii     =lambda: int(input())
si     =lambda: input()
jn     =lambda x,l: x.join(map(str,l))
sl     =lambda: list(map(str,input().strip()))
mi     =lambda: map(int,input().split())
mif    =lambda: map(float,input().split())
lii    =lambda: list(map(int,input().split()))

ceil   =lambda x: int(x) if(x==int(x)) else int(x)+1
ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1

flush  =lambda: stdout.flush()
stdstr =lambda: stdin.readline()
stdint =lambda: int(stdin.readline())
stdpr  =lambda x: stdout.write(str(x))

mod=1000000007


#main code
d,t,s=mi()
if d/s<=t:
    print('Yes')
else:
    print('No')


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

using namespace std;

#define ll long long

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

    int k, a, b;
    cin >> k >> a >> b;
    int flag = 0;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            flag = 1;
            break;
        }
    }
    if (flag) cout << "OK\n";
    else cout << "NG\n";
    return 0;
}

Measured memory_bytes: 3652
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ii, null_type, less<ii>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n, k;
    cin >> n >> k;
    vi arr(n);
    for (auto &it : arr) {
        cin >> it;
    }

    vi s(n, 0);
    for (int i = 0; i < k; i++) {
        ll curr = 0;
        for (int j = n - 1; j >= 0; j--) {
            s[max(0ll, j - arr[j])]++;
            if (j + arr[j] + 1 < n) {
                s[j + arr[j] + 1]--;
            }
        }

        bool fin2 = true;
        for (int j = 0; j < n; j++) {
            curr += s[j];
            s[j] = 0;
            arr[j] = curr;
            if (arr[j] != n) {
                fin2 = false;
            }
        }

        if (fin2) {
            break;
        }
    }

    for (auto it : arr) {
        cout << it << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 6348
n, m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n #いい展望台のところは1にする
li = []
for i in range(m):
    li.append(list(map(int,input().split())))

for x in li:
    y = h[x[0]-1]
    z = h[x[1]-1]
    if y <= z:
        ans[x[0]-1] = 0
    if z <= y:
        ans[x[1]-1] = 0

print(ans.count(1))

Measured memory_bytes: 93200
#include<stdio.h>
 
int main(void)
 
 
{
 
 
int a,b;
 
 
scanf("%d %d",&a,&b);
 
 
printf("%d %d %lf\n",a/b,a%b,(double)a/b);
 
 
return 0;
 
 
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {
	
	public static int ComputeMaxProfit(int n, int[] r) {
		int maxProfit = Integer.MIN_VALUE;
		int minE = Integer.MAX_VALUE;
		for(int i=0;i<n-1;i++) {
			if(minE>r[i]) {
				minE=r[i];
			}
			maxProfit = Math.max(maxProfit, r[i+1] - minE);
		}
		return maxProfit;
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] r = new int[n]; 
		for(int i=0;i<n;i++) {
			r[i] = scan.nextInt();
		}
		scan.close();
		System.out.println(ComputeMaxProfit(n,r));
		

	}

}


Measured memory_bytes: 101004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    scanf(" %d", &n);
    vector<ll> v(n);
    rep(i,n) scanf(" %lld", &v[i]);

    ll ans = LLONG_MAX;
    rep(head,2)
    {
        ll ct=0;
        ll s=0;

        vector<ll> a(v);
        rep(i,n)
        {
            if((head+i)%2==0)
            {
                // s>0にしたい
                if(s+a[i]<=0)
                {
                    ct += 1-(s+a[i]);
                    a[i] = 1-s;
                }
                s += a[i];
            }
            else
            {
                // s<0にしたい
                if(s+a[i]>=0)
                {
                    ct += s+a[i]+1;
                    a[i] = -s-1;
                }
                s += a[i];
            }
        }
        ans = min(ans,ct);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1804
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;

int main(){
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        vector<int> sa;
        for (int j=0; j<3; j++) {
            int inp;
            cin >> inp;
            sa.push_back(inp);
        }
        sort(sa.begin(), sa.end());
        if (sa[0]*sa[0]+sa[1]*sa[1]==sa[2]*sa[2]) {
            cout << "YES"<<endl;
        }else{
            cout << "NO"<<endl;
        }
    }
    
}

Measured memory_bytes: 1208
-module('Main').
-export([main/1]).

calc2(N, I, Ai, Arr) ->
    length(lists:filter(fun (J) ->
        Aj = maps:get(I - J, Arr),
        Ak = maps:get(I + J, Arr),
        Ai =/= Aj andalso Ai =/= Ak andalso Aj =/= Ak
    end, lists:seq(1, min(I - 1, N - I)))).

calc(N, Arr) ->
    lists:sum([calc2(N, I, maps:get(I, Arr), Arr) || I <- lists:seq(1, N)]).

solve() ->
    [N, S] = input("~d~s"),
    Arr = maps:from_list(lists:zip(lists:seq(1, N), S)),
    [R, G, B] = [length(lists:filter(fun (X) -> X =:= Chara end, S)) || Chara <- "RGB"],
    io:format("~B~n", [R * G * B - calc(N, Arr)]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


Measured memory_bytes: 24236
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N;
  while(cin >>N && N){
    map<int, int> m;
    REP(i, N){
      int n; cin >>n;
      m[n] += 1;
    }
    int ans = -1;
    for(auto v : m) if(v.second > N / 2.0) ans = v.first;
    if(ans == -1) cout <<"NO COLOR" <<endl;
    else cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 2736
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()

int main() {
    ll N,M; scanf("%lld%lld",&N,&M);
    ll a[100010];
    ll b[100010];
    rep(i,N) scanf("%lld%lld",&a[i],&b[i]);
    pair<ll,ll> data[100010];
    rep(i,N) {
        data[i].first = a[i];
        data[i].second = b[i];
    }
    sort(data,data+N);
    ll sum = 0;
    ll rem = M;
    ll idx = 0;
    while(rem > 0){
        ll dif = min(data[idx].second,rem);
        sum += data[idx].first*dif;
        rem -= dif;
        idx ++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cstring>

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

const int INF = (1<<28);

using namespace std;

struct edge {
	int to, c, h, r;
};

struct node {
	int v, c, h;
	bool operator<(const node &u) const {
		if(c != u.c) return c > u.c;
		return h > u.h;
	}
};

int N, M, H, K, S, T, P;
int pass[256], done[128][32], ps[256];
vector<edge> G[128];

int dijkstra(int f, int ub) {
	if( pass[f] == INF ) return INF;
	priority_queue<node> q;
	q.push((node){S, pass[f], 0});
	memset(done, 0, sizeof(done));
	while(!q.empty()) {
		node u = q.top(); q.pop();
		//cout << u.v << " " << u.c << " " << u.h << endl; 
		if(u.v == T || u.c >= ub) return u.c;
		if(done[u.v][u.h]) continue;
		done[u.v][u.h] = 1;
		rep(i, G[u.v].size()) {
			if(u.h + G[u.v][i].h > H) continue;
			if(f & (1 << G[u.v][i].r)) q.push((node){G[u.v][i].to, u.c, u.h+G[u.v][i].h});
			else {
				//cout << "kita " << G[u.v][i].to << " " << u.c+G[u.v][i].c << " " << u.h+G[u.v][i].h << endl;
				q.push((node){G[u.v][i].to, u.c+G[u.v][i].c, u.h+G[u.v][i].h});
			}
		}
	}
	return INF;
 }

int main(){
	while(cin >> N >> M >> H >> K && N) {
		rep(i, 128) G[i].clear();
		rep(i, 256) pass[i] = INF; 
		rep(i, M) {
			int a, b, c, h, r;
			cin >> a >> b >> c >> h >> r;
			a--; b--; r--;
			G[a].push_back((edge){b, c, h, r});
			G[b].push_back((edge){a, c, h, r});
		}
		cin >> S >> T >> P;
		S--; T--;
		rep(i, P) {
			int l, d, k;
			cin >> l >> d;
			int idx = 0;
			rep(j, l) {
				cin >> k;
				idx |= (1 << (k-1));
			}
			pass[idx] = d; 
		}
		rep(i, (1<<K)) rep(j,i) rep(h,i){
			if( (i&j) == j && (i&h) == h && (j|h) == i ){
				pass[i] = min( pass[i], pass[j] + pass[h] );
			}
		}
		pass[0] = 0;
		
		int res = INF;
		rep(i, 1 << K) res = min(res, dijkstra(i, res));
		if(res == INF) cout << -1 << endl;
		else cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    long int H[N];
    for(int i=0; i<N; i++) {
        cin >> H[i];
    }
    
    int max=0, right=0;
    
    for(int left=0; left<N; left++) {
        // cout << "left: " << left << endl;
        right = left;
        while(H[right+1]<=H[right] && right<N) {
            right++;
            // cout << "right: " << right << endl;
        }
        if(max<right-left) max = right-left;
        left = right;
    }
    
    cout << max << endl;

    return 0;
    
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String[] inArray = in.split(" ");
		int count5 = 0;
		int count7 = 0;
		for (int i = 0; i < inArray.length; i++) {
			if (inArray[i].equals("5")) {
				count5++;
			} else if (inArray[i].equals("7")) {
				count7++;
			}
		}
		if ((count5 == 2) && (count7 ==1)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		sc.close();
	}
	

}


Measured memory_bytes: 8788
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
 
#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s
 
using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
 
 
 
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::string s, t = "CODEFESTIVAL2016";
	std::cin >> s;
	uint32 c = 0;
	rep(i, 0, s.length()) {
		if (s[i] != t[i])
			++c;
	}
	std::cout << c<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define all(a) (a).begin(), (a).end()
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)
int n,m;
map<int,int> available;
map<int,int> numb;

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>n>>m;
  available[1]=1;
  FOR(i,1,n+1) numb[i]++;
  REP(i,m)
  {
    int x,y; cin>>x>>y;
    if (available[x]) available[y]=1;
    numb[x]--;
    numb[y]++;
    if (numb[x]==0) available[x]=0;
  }

  int cnt=0;
  FOR(i,1,n+1)
  {
    if (available[i]) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	ll n, ans = 0, k = 1;
	cin >> n;
	while (n > 0) {
		ans += k;
		n >>= 1;
		k <<= 1;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,x,y,t;

vi zsan(200);
vi osan(200);


ll zw=0;
ll ow=0;




ll cbit(ll i){
  ll tmp=0;
  for(tmp=0;i>0;i/=2){
    tmp++;
  }
  return tmp;
}





ll kensyo(ll aj)
{
  if (aj==0){
    return 0;
  }
  if (zw==0){
    return 1;
  }
  

  ll caj=cbit(aj);
  ll myno=0;
  vi zdmy(zw);
  ll maxno=0;
  for(int i=0;i<zw;i++){
    zdmy[i]=zsan[i];
    maxno=max(maxno,zsan[i]);
  }

  ll mcbit=cbit(maxno);//maxnoは1<<(mcbit-1)以上～1<<mcbit未満
  if (aj>=(1LL<<mcbit))return 2;

  ll newmaxno=0;
  for(int i=0;i<64;i++){
    mcbit=cbit(maxno);//maxnoは1<<(mcbit-1)以上～1<<mcbit未満
    if (aj>=(1LL<<mcbit))return 3;
    if ((1LL<<(mcbit-1))<=aj)
    {
      aj^=maxno;//これで最上位がきえた
    }
    //cout<<"aj"<<aj<<" ";

    newmaxno=0;
    for(ll j=0;j<zw;j++){
      if ((1LL<<(mcbit-1))<=zdmy[j]) zdmy[j]^=maxno;
      newmaxno=max(newmaxno,zdmy[j]);
    }
    maxno=newmaxno;
    if (maxno==0)break;
  }

  if (aj!=0){
    return 4;
  }
  return 0;
}





int main(){
  
  

  
  cin>>t;
  vi ans(t);
  for(ll i=0;i<t;i++){
    cin >> n;
    vi a(n);
    REP(j,200) zsan[j]=0;
    REP(j,200) osan[j]=0;

    REP(j,n) cin>>a[j];
    string s;cin>>s;
    ll leng=s.length();
    zw=0;
    ow=0;
    ans[i]=0;
    for(int j=leng-1;j>=0;j--){
      if (s[j]==48){//0さん
        zsan[zw]=a[j];
        zw++;
      }else{//1さん
        osan[ow]=a[j];
        ow++;
        //ここで検証。どうやっても0が勝てないなら1を出力
        ans[i]+=kensyo(a[j]);
      }
    }
    if (ans[i]!=0)ans[i]=1;
    
  }
  

  for(ll i=0;i<t;i++){
    cout<<ans[i]<<endl;
  }
  
  return 0;

}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc147/tasks/abc147_d>
 問題文============================================================
 D - Xor Sum 4
 =================================================================
 解説=============================================================
 
 
 https://atcoder.jp/contests/abc147/submissions/9121242
 ================================================================
 */

const ll MOD = 1e9+7;
template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    
    for(ll b = 0; b <= 60; b++){
        ll x[2] = {0};
        for(int i = 0; i < N;i++){
            x[(A[i]>>b)&1]++;
        }
        res += (x[0]*x[1])%MOD*((1LL<<b)%MOD)%MOD;
        res %= MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  
  if (N[0] == N[1] && N[1] == N[2]) {
    cout << "Yes" << endl;
  }
  
  else if (N[1] == N[2] && N[2] == N[3]) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}  
  
  


Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main()
{
	int x, y;

	while(1){
		cin >> x >> y;

		if(x == 0 && y == 0)
			break;

		for(int i = 0; i < x; i++){
			for(int j = 0; j < y; j++){
				if(i == 0 || i == x - 1 || j == 0 || j == y - 1)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[9][9][9],q[2];main(n,m,p,I,x,y,z,j,c,d){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,I=0,sizeof(M)),c=1;I++<p;c*=-1){
		for(scanf("%d%d",&x,&y),z=1;;z++)if(!M[x][y][z]){M[x][y][z]=c;break;}
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(q[j]=0;q[j]<m;q[j]+=2*j-1)if(M[x+D[d][0]*q[j]][y+D[d][1]*q[j]][z+D[d][2]*q[j]]!=c)break;
			if(q[1]-q[0]-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I++<p;)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
use std::io::stdin;

fn read_ints() -> Vec<i32> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|token| token.parse().unwrap()).collect()
}

fn main () {
    let ints = read_ints();
    let n = *ints.get(0).unwrap();
    let m = *ints.get(1).unwrap();

    let ans = if n % m == 0 {
        0
    } else {
        1
    };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.size() % 2 != 0) {
    puts("No");
    return 0;
  }

  for (int i = 0; i < s.size(); ++i) {
    if (i % 2 == 0 && s.at(i) != 'h') {
      puts("No");
      return 0;
    }
    if (i % 2 == 1 && s.at(i) != 'i') {
      puts("No");
      return 0;
    }
  }

  puts("Yes");

  return 0;
}

Measured memory_bytes: 256
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : 04 September, 2k20
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc177/tasks/abc177_c
|   Algorithm   :
|
\**============================================================================**/

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

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

const int MOD = 1e9 + 7;

void test_case()
{
    int n;
    cin >> n;

    vector <ll> vc(n+1), cum(n+1, 0);
    for(int i = 1; i <= n; ++i)
    {
        cin >> vc[i];
        cum[i] = cum[i-1] + vc[i];
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        ans = ( (ans % MOD) + ( ( ( cum[n] - cum[i] ) % MOD ) * vc[i] ) % MOD ) % MOD;
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < (int)(N); ++i) cin >> A[i];

  int S = accumulate((A).begin(), (A).end(), 0);
  int c = 0;
  for (int i = 0; i < (int)(N); ++i) c += (S <= 4 * M * A[i]);
  cout << (c >= M ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
import statistics
num = int(input())
aList = []
bList = []
for x in range(num):
    a, b = map(int, input().split())
    aList.append(a)
    bList.append(b)
a_median = statistics.median(aList)
b_median = statistics.median(bList)
if num % 2 == 1: print(b_median - a_median + 1)
else: print(int((b_median - a_median) * 2) + 1)


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

int main()
{
	int n, m, x;
	std::cin >> n >> m;
	std::vector<std::vector<int>> A(n, std::vector<int>(m, 0));
	std::vector<int> b(m);


	// fill the matrix
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			std::cin >> A.at(i).at(j);	
		}
	}

	// fill the vector b
	for (int i = 0; i < m; i++) {
		std::cin >> b[i];
	}

	// A x b, then sum each row
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			A.at(i).at(j) *= b[j];
			sum += A.at(i).at(j);
			//printf("%d ", A.at(i).at(j));
		}
		printf("%d\n", sum);
	}


	return 0;
}


Measured memory_bytes: 3252
#include <iostream>


int main()
{
    std::ios_base::sync_with_stdio(0);

    int M1,D1,M2,D2;
    std::cin>>M1>>D1>>M2>>D2;

    if(D2==1) std::cout<<1<<'\n';
    else std::cout<<0<<'\n';
  
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    var N = sc.nextInt
    while (N != 0) {
      if (N % 2 == 0) (System.gc)
      var z = true
      var sum = 0
      for (_ <- 0 until N) {
        val x = sc.nextInt
        if (x > 1) (z = false)
        if (x > 0) (sum += 1)
      }
      println(if (z) ("NA") else (sum + 1))

      N = sc.nextInt
    }
  }


  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 91228
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int num[100][100], sum1[100] = {0}, sum2 = 0, SUM = 0;
    int i, j, r, c;

    scanf("%d %d", &r, &c);
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            scanf("%d", &num[i][j]);
            sum1[i] += num[i][j];
        }
    }

    for(i = 0; i < r; i++){
        for(j = 0; j < c + 1; j++){
            if(j >= 0 && j < c)
                printf("%d ", num[i][j]);
            if(j == c)
                printf("%d", sum1[i]);
        }
        putchar('\n');
    }
    for(i = 0; i < c; i++){
        for(j = 0; j < r; j++){
            sum2 += num[j][i]; 
        }
        printf("%d ", sum2);
        sum2 = 0;
    }

    for(i = 0; i < r; i++)
        SUM += sum1[i];
    printf("%d\n", SUM);

    return 0;
} 


Measured memory_bytes: 3252
using System;
using System.Collections.Generic;

namespace ABC142
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var An = Console.ReadLine().Split(' ');

            var revAn = new int[N];

            for (int i = 0; i < N; i++)
            {
                revAn[int.Parse(An[i]) - 1] = i + 1;
            }

            foreach (var item in revAn)
            {
                Console.Write(item);
                Console.Write(' ');
            }
        }
    }
}


Measured memory_bytes: 24028
#!/usr/bin/env python3
s = input()
t = input()

ans = 'No'

if len(t) == len(s) + 1:
    for i in range(len(s)):
        if s[i] == t[i]:
            if i == len(s) - 1:
                ans = 'Yes'
        else:
            break
print(ans)


Measured memory_bytes: 8796
x,y,z=list(map(int, input().split()))
ans=0

if (y-x)//z==0:
	if x%z > y%z:
		ans=ans+1
	if x%z==0 or y%z==0:
		print(1)
	else:
		print(ans)
else:
	ans=((y//z)-((x-1)//z))
	if x==0:
		ans=ans
	print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

  for (int i = 0; i < 26; i++) {
    for (int j = 0; i * 4 + j * 7 <= n; j++) {
      if (i * 4 + j * 7 == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#define LL long long
using namespace std;
const int MAX=1e5+3;
LL a[MAX];
LL add[MAX];
inline bool myru(LL x,LL y){return x>y;}
LL rin()
{
	LL s=0;
	char c=getchar();
	bool bj=0;
	for(;(c>'9'||c<'0')&&c!='-';c=getchar());
	if(c=='-')bj=1,c=getchar();
	for(;c>='0'&&c<='9';c=getchar())s=(s<<1)+(s<<3)+(c^'0');
	if(bj)return -s;
	return s;
}
int main()
{
	//以下规则有先后判定，优先满足靠前的规则 
	//1.如果从大到小排序后a[p]-a[i]>m 则a[i]绝对无法入选
	//2.如果从p到i-1这些数不选时能凑够v个选票，则a[i]可以入选
	//3. ∑j=i-1 To p a[i]+m-a[j] >= (v-n+(i-p))*m ,则a[i]可以入选 
	int i,j;
	LL n,m,v,p;
	n=rin();m=rin();v=rin(),p=rin();
	for(i=1;i<=n;i++)a[i]=rin();sort(a+1,a+n+1,myru);
	
	add[0]=0;for(i=1;i<=n;i++)add[i]=add[i-1]+a[i];
	int ans=p;
	for(i=p+1;i<=n&&a[i]==a[p];i++)ans++;
	for(;i<=n;i++)
	{
		if(a[p]-a[i]>m)continue;
		if(n-(i-p)>=v){ans++;continue;}
		LL sum=a[i]+m;
		sum*=(i-p);
		sum-=add[i-1]-add[p-1];
		if(sum>=m*(v-(n-(i-p))))ans++;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 4796
n, m = map(int, input().split(" "))

list = [[1,int(i)] for i in input().split(" ")]
result = n
for i in range(m):
    a,b = map(int, input().split(" "))
    if list[a-1][1] <= list[b-1][1] and list[a-1][0] == 1:
        list[a-1][0] = 0
        result -= 1
    if list[b-1][1] <= list[a-1][1] and list[b-1][0] == 1:
        list[b-1][0] = 0
        result -= 1

print(result)




Measured memory_bytes: 28056
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ct, ans = 0;
	cin >> n;
	for (i = 1; i <= n; i+=2) {
		ct = 0;
		for (j = 1; j <= i; j++) {
			if ((i % j) == 0) ct++;
		}
		if (ct == 8) ans++;
	}
	cout << ans << "\n";


	return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int h, w;
vector<string> c;

int f[12];
int g[12];

inline bool same(int i, int j) {
    inc(k, 0, h){
        if(c[f[k]][i] != c[f[h-k-1]][j]) return false;
    }
    return true;
}

bool dfs2(int cnt, int flag) {
    if(cnt == w){
        return true;
    }

    bool res = false;

    inc(i, 0, w){
        if(g[i] == 0){
            inc(j, i+1, w){
                if(g[j] == 0){
                    if(same(i, j)){
                        g[i] = 1;
                        g[j] = 1;
                        return dfs2(cnt+2, flag);
                    }
                }
            }
            if(flag == 0 && same(i, i)){
                g[i] = 1;
                res |= dfs2(cnt+1, flag+1);
                g[i] = 0;
            }
            break;
        }
    }

    return res;
}

bool dfs1(int idx, int bit) {
    bool res = false;
    int cnt = 0;
    inc(i, 0, h){
        if((bit & (1 << i)) != 0) cnt++;
    }

    if(cnt == h){
        inc(i, 0, w){
            g[i] = 0;
        }
        return dfs2(0, 0);
    }

    if(cnt == 0 && h%2 == 1){
        inc(i, 0, h){
            f[h/2] = i;
            res |= dfs1(0, bit | (1 << i));
            f[h/2] = -1;
        }
    }else{
        inc(i, 0, h){
            if((bit & (1 << i)) == 0){
                inc(j, i+1, h){
                    if((bit & (1 << j)) == 0){
                        f[idx] = i;
                        f[h-idx-1] = j;
                        res |= dfs1(idx+1, bit | (1 << i) | (1 << j));
                        f[idx] = -1;
                        f[h-idx-1] = -1;
                    }
                }
                break;
            }
        }
    }

    return res;
}

int main() {
    cin >> h >> w;
    inc(i, 0, h){
        string s;cin >> s;
        c.pb(s);
    }

    inc(i, 0, h) f[i] = -1;

    bool ans = dfs1(0, 0);

    cout << (ans ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for c in range(C+1):
    for b in range(B+1):
        for a in range(A+1):
            s = 500 * a + 100 * b + 50 * c
            if s == X:
                ans += 1
print(ans)

Measured memory_bytes: 9176
from sys import stdin, stdout
import math,sys,heapq
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import bisect as bi
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    #------------------Sublime--------------------------------------#
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    #------------------PYPY FAst I/o--------------------------------#
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))

def dict(a):
    d={}
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:            
        return -1

def main():
    try:
        n,k=In()
        l=list(In())   
        ans=[]
        t=1
        last=1
        for x in range(k,n):
            if l[x-k]>=l[x]:
                print('No')
            else:
                print('Yes')


    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    #for _ in range(I()):main()
    for _ in range(1):main()




Measured memory_bytes: 32592
#include<iostream>

using namespace std;

#define N 100

int M[N][N];

int main(){
    int n,u,k,v;
  
    cin >> n;
    for(int i = 0;i < n;++i){
        cin >> u >> k;
        // 頂点を移動する
        u--;
        // 頂点の数だけ回す
        for(int j = 0;j < k;++j){
            cin >> v;
            --v;    // ずらす
            M[u][v] = 1;
        }
    }
    
    for(int i = 0;i < n;++i){
        for(int j = 0;j < n;++j){
            // 2個目からは空白が必要
            if(j){
                cout << " ";
            }
            cout << M[i][j];
        }
        cout << endl;
    }
    
    return 0;}


Measured memory_bytes: 3108
N = int(input())
if N < 10:
    print(N)
else:
    str_N = str(N)
    ### 最上位以外すべて9 の場合はその値が最大値
    for n in str_N[1:]:
        if n != '9':
            ### それ以外は最上位の桁を一つ下げてあと全部9 が一番最大
            print(int(str_N[0]) - 1 + (len(str_N) - 1) * 9)
            break
    else:
        print(int(str_N[0]) + (len(str_N) - 1) * 9)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){

  ll N;
  cin>>N;
  string S;
  vector<char> date(N+1);
  cin>>S;
  ll R=0;
  ll G=0;
  ll B=0;
  
  rep(i,N){
    date[i+1]=S[i];
if(S[i]=='R'){
R++;
}
else if(S[i]=='G'){
G++;
}
    else{
if(S[i]=='B'){
  B++;
}
    }
  }
  
  ll sub=0;
for(ll j=1;j<N+1;j++){
  for(ll k=j+1;k<N+1;k++){
        if(2*j-k>=1&&j>2*j-k){
if(date[j]!=date[k]&&date[j]!=date[2*j-k]&&date[2*j-k]!=date[k]){
  sub++;
}
        }
  }
}

  
  
  cout<<R*G*B-sub<<endl;
}



Measured memory_bytes: 3648
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)

int main() {
    int n, k; cin >> n >> k;
    vi a(n, 0);
    int sum = n;
    loop(i, k) {
        int d; cin >> d;
        loop(j, d) {
            int aij; cin >> aij;
            a[aij - 1]++;
        }
    }
    loop(i, n) {
        if (a[i] > 0) sum--;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//union-find
#define UFLIMIT (1<<17)
int unicnt[UFLIMIT+10];//正ならcnt、非正なら根のindex
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int root(int x){return unicnt[x]<=0?-(unicnt[x]=-root(-unicnt[x])):x;}
int same(int x,int y){return root(x)==root(y);}
void uni(int x,int y){if((x=root(x))==(y=root(y)))return;if(unicnt[x]<unicnt[y]){int t=x;x=y;y=t;}unicnt[x]+=unicnt[y];unicnt[y]=-x;}
#undef UFLIMIT

ll a[100010],b[100010];
ll ans[100010];
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m)scanf("%lld%lld",a+i,b+i);
	
	ufinit(n+5);
	ans[m-1]=n*(n-1)/2;
	for(int i=m-1;i>=1;i--){
		ans[i-1]=ans[i];
		if(!same(a[i],b[i]))ans[i-1]-=unicnt[root(a[i])]*unicnt[root(b[i])];
		uni(a[i],b[i]);
	}
	rep(i,0,m)printf("%lld\n",ans[i]);
}


Measured memory_bytes: 3968
@n = gets.split(' ').map(&:to_i)
q = gets.chomp.to_i

def throw(a, b)
    temp = @n[0]
    @n[0] = @n[a]
    @n[a] = @n[5]
    @n[5] = @n[b]
    @n[b] = temp
end

q.times{|i|
    face = gets.split(' ').map(&:to_i)
    while (face[1] != @n[0])
        throw(4, 1)
        break if face[1] == @n[0]
        throw(2, 3)
    end
    throw(4, 1)
    while (face[0] != @n[0])
        throw(2, 3)
    end
    puts @n[2]
}

Measured memory_bytes: 8624
#include<stdio.h>

int main(){
	int x1,y1,x2,y2;
	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
	printf("%d %d %d %d",x2+y1-y2,y2+x2-x1,y1-y2+x1,x2-x1+y1);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s;
	cin >> s;
	vi c;
	
	REP(i, s.size()) {
		if (s[i] == 'C')c.push_back(i);
	}
	vl v(c.size() + 1);
	v[0] = 0;
	int j = 0, cnt = 0;
	REP(i, s.size()) {
		if (s[i] == 'M')cnt++;
		else if (s[i] == 'C') {
			v[j + 1] = cnt;
			j++;
		}
	}
	REP(i, c.size())v[i + 1] += v[i];

	int q;
	cin >> q;
	REP(adfa, q) {
		int k; cin >> k;
		ll cnt = 0;
		ll ans = 0;
		int d = 0;
		REP(i, s.size()) {
			if (s[i] == 'M')cnt++;
			else if (s[i] == 'D') {
				int e = lower_bound(ALL(c), i + k) - c.begin();
				ans += v[e] - v[d] - cnt * (e - d);
			}
			else if (s[i] == 'C')d++;
		}
		cout << ans << endl;
	}
}

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

int main()
{
  int n;
  int sum = 100000;
  cin >> n;
  for(int i=0; i<n; i++){
    sum = sum*1.05;
    if( sum%1000 != 0 ){
      sum = ((sum/1000)+1)*1000;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

using ll = long long int;

int main(){
    
    ll N, K;
    array<pair<ll, ll>, 100000> X;
    cin >> N >> K;
    ll cnt = 0;
    for(ll i = 0; i < N; ++i){
        cin >> X[i].first >> X[i].second;
    }
    sort(X.begin(), X.begin() + N, [](const auto& a, const auto& b)->bool{
        return a.first < b.first;
    });
    for(ll i = 0; i < N; ++i){
        K -= X[i].second;
        if(K <= 0){
            cout << X[i].first << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  vector<vector<bool>> edge(n, vector<bool>(n, false));
  for (int i = 0; i < m; i++)
  {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    edge[a[i]][b[i]] = true;
    edge[b[i]][a[i]] = true;
  }
  int ans = 0;
  for (int i = 0; i < m; i++)
  {
    edge[a[i]][b[i]] = false;
    edge[b[i]][a[i]] = false;

    vector<bool> vis(n, false);
    vis[0] = true;
    queue<int> que;
    que.push(0);
    while (que.size())
    {
      int now = que.front();
      que.pop();
      for (int j = 0; j < m; j++)
        if (edge[now][j] && !vis[j])
        {
          vis[j] = true;
          que.push(j);
        }
    }
    bool ok = false;
    for (int j = 0; j < n; j++)
      if (!vis[j])
        ok = true;
    if (ok)
      ans++;

    edge[a[i]][b[i]] = true;
    edge[b[i]][a[i]] = true;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a>b){
			System.out.println("a > b");
		}else if(a<b){
			System.out.println("a < b");
		}else{
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 17200
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void solve5(int N, int M) {
    int p[M];
    REP(i,M) p[i] = 0;
    REP(i,N) {
        REP(j,M) {
            int k;
            cin >> k;
            p[j] += k;
        }
    }
    vector<pair<int, int> > v;
    REP(i,M) {
        v.push_back(make_pair(p[i], M-i));
    }
    sort(v.begin(), v.end(), greater<pair<int, int> >());
    REP(i,M-1) {
        cout << M - v[i].second + 1 << " ";
    }
    cout << M - v[M-1].second + 1 << endl;
}

int main() {
    int N, M;
    while(cin >> N >> M, N + M) {
        solve5(N, M);
    }
    return 0;
}

Measured memory_bytes: 1200