akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7

n = int(input())
S = input()
W = [0]*(2*10**5+1)
B = [0]*(2*10**5+1)
for i in range(n):
    if S[i] == '.':
        W[i] = 1
    else:
        B[i] = 1
for i in range(1,2*10**5+1):
    W[i] += W[i-1]
    B[i] += B[i-1]
W = [0] + W
B = [0] + B
res = INF
for i in range(2*10**5+1):
    ans = W[-1]-W[i]+B[i]
    if ans <= res:
        res = ans
print(res)


Measured memory_bytes: 20712
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A;
    string b;
    cin >> A >> b;
    ll B = stoi(b.substr(0, 1)) * 100 + stoi(b.substr(2, 1)) * 10 + stoi(b.substr(3, 1));

    ll ans = ll((A * B) / 100);

    cout << setprecision(17) << ans << endl;

    return 0;
}


Measured memory_bytes: 3180
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] f=br.readLine().split(" ");
        int n=Integer.parseInt(f[0]);
        int m=Integer.parseInt(f[1]);
        int l=Integer.parseInt(f[2]);
        String[][] As=new String[n][m];
        String[][] Bs=new String[m][l];
        int[][] Ai=new int[n][m];
        int[][] Bi=new int[m][l];
        for(int ni=0;ni<n;ni++) As[ni]=br.readLine().split(" ");
        for(int mi=0;mi<m;mi++) Bs[mi]=br.readLine().split(" ");
    	StringBuilder sb = new StringBuilder();
        for(int ni=0;ni<n;ni++){
        	for(int li=0;li<l;li++){
        		long b=0;
            	for(int mi=0;mi<m;mi++){
            		if(Ai[ni][mi]==0) Ai[ni][mi]=Integer.parseInt(As[ni][mi]);
            		if(Bi[mi][li]==0) Bi[mi][li]=Integer.parseInt(Bs[mi][li]);
            		b+=Ai[ni][mi]*Bi[mi][li];
            	}
            	sb.append(b);
            	if(li!=l-1) sb.append(" ");
        	}
        	sb.append("\n");
        }
    	System.out.print(sb);
	}
}

Measured memory_bytes: 30888
N = int(input())
t_p = 0
h_p = 0

for i in range(N):
    t, h = input().split()
    if t < h:
        h_p += 3
    elif t == h:
        t_p += 1
        h_p += 1
    else:
        t_p += 3
print(t_p, h_p)


Measured memory_bytes: 5596
from collections import deque
K = int(input())

q = [1, 2, 3, 4, 5, 6, 7, 8, 9]
q = deque(q)

def next_n(n):
    if n == 0:
        return [0, 1]
    elif n == 9:
        return [8, 9]
    else:
        return [n-1, n, n+1]

for _ in range(K-1):
    now = q.popleft()
    for next_ in next_n(now%10):
        q.append(now*10 + next_)

print(q[0])

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

const int mod = 1e9 + 7;

int add( int a, int b ) {
	a += b;
	if ( a >= mod ) {
		a -= mod;
	}
	return a;
}

int mul( int a, int b ) {
	return 1ll * a * b % mod;
}

int main() {
	int n, ans = 0;
	cin >> n;

	vector < long long > a(n);

	for ( auto &i: a ) {
		cin >> i;
	}
	for ( int i = 0; i < 60; i++ ) {
		int cnt = 0;

		for ( auto j: a ) {
			cnt += ( ( j >> i ) & 1 );
		}
		ans = add( ans, mul( ( 1ll << i ) % mod, mul( cnt, n - cnt ) ) );
	}
	cout << ans << '\n';
}


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

struct Edge {
    ll to; // 行き先の番号
    ll a; // 運賃
    ll b; // かかる時間
};

struct Vertex {
    ll v; // 頂点番号
    ll s; // 所持金
    ll x; // そこまでかかった時間

    bool operator<(const Vertex& other) const
    {
        return x > other.x;
    }
};

const ll INF = 1e18;

void solve(long long N, long long M, long long S, std::vector<long long> U, std::vector<long long> V, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, std::vector<long long> D)
{
    vector<vector<Edge>> edges(N + 1);
    for (ll i = 0; i < M; i++) {
        edges[U[i]].push_back({ V[i], A[i], B[i] });
        edges[V[i]].push_back({ U[i], A[i], B[i] });
    }

    // dp[駅番号][銀貨所持枚数] = その状態までにかかった時間 →最小化する
    // A≦50 の制約より、銀貨所持枚数は高々(N-1×50)で十分
    vector<vector<ll>> dp(N + 1, vector<ll>(N * 50 + 1, INF));

    priority_queue<Vertex> que;

    auto que_push = [&que, &dp](ll v, ll s, ll x) {
        if (s >= 0 && dp[v][s] > x) {
            dp[v][s] = x;
            que.push({ v, s, x });
        }
    };

    // 駅1の初期状態
    que_push(1, min(S, N * 50), 0);

    while (!que.empty()) {
        auto a = que.top();
        que.pop();
        if (dp[a.v][a.s] < a.x) {
            continue;
        }

        // 両替して銀貨を増やす
        que_push(a.v, min(a.s + C[a.v - 1], N * 50), a.x + D[a.v - 1]);

        // 次の駅へ向かう
        for (auto&& e : edges[a.v]) {
            que_push(e.to, a.s - e.a, a.x + e.b);
        }
    }

    for (ll i = 2; i <= N; i++) {
        ll ans = *min_element(begin(dp[i]), end(dp[i]));
        cout << ans << "\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long S;
    scanf("%lld",&S);
    std::vector<long long> U(M);
    std::vector<long long> V(M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&U[i]);
        scanf("%lld",&V[i]);
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
    }
    solve(N, M, S, std::move(U), std::move(V), std::move(A), std::move(B), std::move(C), std::move(D));
    return 0;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    int N, M;
    cin >> N >> M;
    vector<int> vec (N,-1);
    for(int i = 0;i < M;i++){
        int a, b;
        cin >> a >> b;
        a--;
        if(vec[a] == -1 || vec[a] == b){
            vec[a] = b;
            if(N > 1 && a == 0 && b == 0){
                cout << -1 << endl;
                ED;
            }
        }
        else{
            cout << -1 << endl;
            ED;
        }
    }

    for(int i = 0;i < N;i++){
        if(i == 0 && N != 1 && vec[i] == -1){
            cout << 1;
        }
        else if(vec[i] == -1){
            cout << 0;
        }
        else{
            cout << vec[i];
        }
    }
    cout << endl;

}


Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define aint(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,w; cin >> h >> w;
    char arr[h][w];
    int visited[h][w];
    queue < pair < pair <int, int>, int > > q;

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cin >> arr[i][j];
            visited[i][j] = 0; 
            if (arr[i][j] == '#')
            {
                q.push({{i,j}, 1});
                visited[i][j] = 1;
            }
        }
    }

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

    while (!q.empty())
    {
        int i, j, code;
        tie(i,j) = q.front().F; code = q.front().S;
        q.pop();
        ans = max(ans, code);
        for (int k = 0; k < 4; ++k)
        {
            int x = i + dx[k], y = j + dy[k];
            if (!(x >= 0 and y >= 0 and x < h and y < w and visited[x][y] == 0))
                continue;
            visited[x][y] = code + 1;
            q.push({{x,y}, code+1});
        }
    }
    cout << ans-1;
    return 0;
}

Measured memory_bytes: 33204
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
const int Nmax = 1e5;
int V[Nmax];

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

    map<int, int> m1, m2;
    for(int i=0; i<N; i++){
        if(i%2) m1[V[i]]++;
        else m2[V[i]]++;
    }
    vector<pair<int, int> > v1, v2;
    for(auto p: m1) v1.push_back({p.second, p.first});
    for(auto p: m2) v2.push_back({p.second, p.first});
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    reverse(v1.begin(), v1.end());
    reverse(v2.begin(), v2.end());
    if(v1[0].second == v2[0].second){
        printf("%d\n", N-max(v1[0].first+v2[1].first, v1[1].first+v2[0].first));
    } else {
        printf("%d\n", N-v1[0].first-v2[0].first);
    }

    return 0;
}

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

int main(int argc, const char * argv[]) {
    char S[4];
    cin >> S;
    
    if ((S[0] == S[1]) ||
        (S[1] == S[2]) ||
        (S[2] == S[3])
        ) {
        cout << "Bad" << endl;
    }else {
        cout << "Good" << endl;
    }
    
    return 0;
}

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

map<char, string> table;

int charCount,codeCount;

class HuffmanNode
{
public: 
	char character;
	int frequency;

	HuffmanNode *left;
	HuffmanNode *right;

	HuffmanNode(char c, int f)
	{
		character = c;
		frequency = f;
		left = nullptr;
		right = nullptr;
	}
};

class Compare
{
public:
    bool operator() ( HuffmanNode* left, HuffmanNode* right)
    {
        return left->frequency > right->frequency;
    }
};

void generateHuffmanCode(HuffmanNode* node,int code[], int top)
{
    if(node->left)
    {
        code[top]=0;  // code[0] = 0;
        generateHuffmanCode(node->left,code,top+1);
    }

    if(node->right)
    {
        code[top]=1;
        generateHuffmanCode(node->right,code,top+1);
    }

    if(!node->left && !node->right)
    {
        char ch = node->character;
        string str="";

        codeCount += top;
        charCount += (top * node->frequency) + 8;

        for(int i=0; i<top; i++) {
            str += (code[i]+48);
        }

        table[ch]=str;
    }
}

void generateHuffmanTree(map<char,int>freq)
{
    map<char,int>::iterator it;
    priority_queue<HuffmanNode*, vector<HuffmanNode*>, Compare > PQ;

    for(it=freq.begin(); it!=freq.end(); it++)
    {
        HuffmanNode* newNode = new HuffmanNode(it->first,it->second);
        PQ.push(newNode);
    }

    while(PQ.size() != 1)
    {
        HuffmanNode* left = PQ.top();
        PQ.pop();
        HuffmanNode* right = PQ.top();
        PQ.pop();

        HuffmanNode* node = new HuffmanNode('*',left->frequency+right->frequency);
        node->left = left;
        node->right = right;
        PQ.push(node);
    }

    HuffmanNode* root = PQ.top();

    int a[10000];
    int top=0;

    generateHuffmanCode(root,a,top);
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string str;

    getline(cin,str);

    map<char,int> freq;

    for (int i = 0; str[i]; ++i)
    {
    	freq[str[i]]++;
    }
    int ans = 0;

    generateHuffmanTree(freq);

   // cout<<freq.size()<<endl;

   auto itr = freq.begin();

   if(freq.size()==1){
   		cout<<itr->second<<endl;
   }else{
   	for(auto it: table){
    	string t = it.second;
    	
        ans += t.size() * freq[it.first];
    }
    cout<<ans<<endl;
   }

    

   


}


Measured memory_bytes: 3376
k=int(input())
t=[2]+[3]*8+[2]
g=[[1]+[0for i in range(100000)]for j in range(10)]
def f(x,y):
    if g[x][y]!=0:
        return g[x][y]
    else:
        p=0
        for i in range(x-1,x+2):
            if 0<=i<10:
                p+=f(i,y-1)
        g[x][y]=p
        return p
c=0
for i in range(100000):
    for j in range(1,10):
        if c+f(j,i)>=k:
            p=str(j)
            po=j
            for h in range(i-1,-1,-1):
                for w in range(po-1,po+2):
                    if 0<=w<10:
                        if c+f(w,h)>=k:
                            p+=str(w)
                            po=w
                            break
                        c+=f(w,h)
            print(p)
            exit()
        c+=f(j,i)


Measured memory_bytes: 11680
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
struct Element
{
    int u,v,opt;
} p[N+3];
int fa[N+3];
ll n,q,c,m;

int find(int u) {return fa[u]==u?u:fa[u]=find(fa[u]);}

int main()
{
    cin>>n>>m>>q;
    for(int i=1; i<=n; i++) fa[i] = i;
    for(int i=1; i<=q; i++)
    {
        scanf("%d%d%d",&p[i].u,&p[i].v,&p[i].opt); p[i].u++; p[i].v++;
        if(p[i].opt==0)
        {
            int uu = find(p[i].u),vv = find(p[i].v);
            if(uu!=vv) {fa[uu] = vv;}
        }
    }
    ll huan = 0; c = 0;
    
    for(int i=1; i<=n; i++) {if(i==find(i)) c++;}
    for(int i=1; i<=q; i++){
        if(p[i].opt==1){
            huan++;
            int uu = find(p[i].u),vv = find(p[i].v);
            if(uu==vv) {puts("No"); return 0;}
        }
    }
    
    ll temp=m-(n-c);
    ll l,r;
    l = huan?max(3ll,(ll)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
    if(l<=temp&&temp<=r)
        printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,q,c=0,s,t;
    vector<int> S,T;

    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s;
        S.push_back(s);
    }

    cin>>q;
    for(int i=0; i<q; i++){
        cin>>t;
        T.push_back(t);
    }

    for(int i=0; i<q; i++){
        for(int j=0; j<n; j++){
            if(S[j]==T[i]){
                c++;
                break;
            }
        }
    }

    cout<<c<<endl;
}


Measured memory_bytes: 3216
from itertools import permutations

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]

cnt = [[0] * C for _ in range(3)]
for h in range(N):
    for w, c in enumerate(map(int, input().split())):
        cnt[(h + w) % 3][c - 1] += 1

ans = 10**18
for perm in permutations(range(C), r=3):
    cost = 0
    for c, ns in zip(perm, cnt):
        for fr in range(C):
            if fr == c:
                continue
            cost += D[fr][c] * ns[fr]
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 44380
c=0
i = 0
h = []
w = []
while c == 0:
    a = input().split()
    if int(a[0]) == 0:
        c = 1
    elif int(a[1]) == 0:
        c = 1
    else:
        h.append(a[0])
        w.append(a[1])
        i = int(i) + 1

for j in range(int(i)):
    for k in range(int(h[j])):
        for o in range(int(w[j])):
            if int(o) == int(w[j])-1:
                print('#')
            elif int(o) == 0:
                print('#',end='')                
            elif int(k) == 0:
                print('#',end='')       
            elif int(k) == int(h[j])-1:
                print('#',end='')     
            else:
                print('.',end='')

    print('')


Measured memory_bytes: 7012
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

char S[100001];

signed main()
{
	cin >> S;
	int n = strlen(S);

	stack<char> s;
	for (int i = 0; i < n; i++)
	{
		char ch = S[i];
		if (s.size() == 0)
		{
			s.push(ch);
		}
		else
		{
			if (s.top() != ch)
			{
				s.pop();
			}
			else
			{
				s.push(ch);
			}
		}
	}

	cout << (n - s.size()) << endl;
}









Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define Max 100007

using namespace std;

ll n, a, b;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;

    ll _min = min(a,b);
    ll _max = max(a + b - n, 0*1LL);

    cout << _min << " " << _max;


    return 0;
}


Measured memory_bytes: 256
n=input()
count=0
maxi=0
flag=0
for i in range(len(n)):
	if n[i]=='R':
		count+=1
		flag=1
	else:
		maxi=max(count,maxi)
		flag=0
		count=0

if flag==0:
	print(maxi)
else:
	print(max(count,maxi))


Measured memory_bytes: 61640
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int N,sum,D,X,A,t,total=0;
    cin>>N;

    cin>>D>>X;
    for (int i=0; i<N; i++)
    {
        cin>>A;
        sum=0;
       // total;
        for(int j=0; j<101; j++)
        {
            t=j*A+1;
            if(t>D)
                break;
            else
            sum++;

        }
       // cout<<sum<<endl;
        total+=sum;
       // cout<<total;
        //cout<<A;

    }
cout<<total+X;

}


Measured memory_bytes: 256
n = int(input())
h = input().split()
for i in range(n):
  h[i]=int(h[i])
a = [0]*n
j=0
for i in range(1,n):
  if h[i]>h[i-1]:
    j+=1
  else:
    a[j]+=1
print(max(a))

Measured memory_bytes: 11132
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n; cin>>n;
    set<int> s;
    REP(i,n) {
        int a;
        cin>>a;
        s.insert(a);
    }
    if(SZ(s)%2==1) cout<<SZ(s)<<endl;
    else cout<<SZ(s)-1<<endl;
    return 0;
}


Measured memory_bytes: 4992
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
ab = mylistinput(n)

ab = mysort(ab,1,False)
# print(ab)

t = 0
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    t += a
    if t<=b:
        pass
    else:
        print("No")
        exit()
print("Yes")
exit()

Measured memory_bytes: 89744
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int pp(int x){
  int res=0;
  while(x)res++,x/=10;
  return res;
}
main(){
  int n,a[10001],c=0,b[10001];
  cin>>n;
  r(i,n)cin>>a[i];
  r(i,n)b[i]=pp(a[i]);
  sort(a,a+n);
  vector<int>v;
  r(i,n)r(j,n)if(i!=j){
    int x=pp(a[j]);
    v.push_back(a[j]+pow(10,x)*a[i]);
    if(c&&c%10000==0){
      vector<int>t=v;
      v.clear();
      sort(t.begin(),t.end());
      r(k,100)v.push_back(t[k]);
    }c++;
  }
  sort(v.begin(),v.end());
  cout<<v[2]<<endl;
}

Measured memory_bytes: 3472
//会長のコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        vector<pair<double, string>> seeds;
        for (int i = 0; i < n; i++) {
            // 作物を育てるには種を買わなければならない．
            string l;   // 作物 i の種の名前
            int p;      // その値段 Pi
            cin >> l >> p;
            int a, b, c, d, e;  // 種を植えてから実が成るまでの時間
            cin >> a >> b >> c >> d >> e;
            int total = a + b + c + d + e;
            int sub = d + e;    // 実が成ったあと葉に戻る
            int f;      // 一つの種から Fi 個の実が成る
            int s;      // それらの実は一つあたり Si の価格で売れる
            int m;      // 部の作物は多期作であり，計 Mi 回実をつける
            cin >> f >> s >> m;
            // ある種に対する収入は，
            // その種から成った全ての実を売った金額から，種の値段を引いた値である．
            int profit = f * s * m - p;
            // その種の収入効率は，
            // その収入を，種を植えてから全ての実が成り終わるまでの時間で割った値である．
            int time = total + sub * (m - 1);
            seeds.emplace_back(-1.0 * profit / time, l);
        }
        // 時間あたりの収入効率にもとづいて並べる
        sort(seeds.begin(), seeds.end());
        for (int i = 0; i < n; i++) {
            cout << seeds[i].second << endl;
        }
        cout << "#" << endl;
    }
    return 0;
}




Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}


int main() {
  int N;
  cin>>N;
  vector<int>ans(1000005);
  for(int x=1;x<=100;x++){
    for(int y=1;y<=100;y++){
      for(int z=1;z<=100;z++){
        int sum=x*x+y*y+z*z+x*y+y*z+z*x;
        ans[sum]++;
      }
    }
  }
  for(int i=1;i<=N;i++){
      cout<<ans[i]<<endl;}
  return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, r = inf, res;
vector<pair<int,int> > a;

signed main() {
	cin >> n >> m;
	a.resize(m);
	rep(i,m) cin >> a[i].first >> a[i].second;
	sort(a.rbegin(), a.rend());
	rep(i,m) if (a[i].second<=r) res++, r = a[i].first;
	cout << res << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		int[][] dp = new int[a.length][b.length];
		int max = 0;
		for(int i = 0; i < a.length; i++) {
			for(int j = 0; j < b.length; j++) {
				if(a[i] == b[j]) {
					if(i != 0 && j != 0)
					dp[i][j] = Math.max(dp[i-1][j-1]+1, 1);
					else dp[i][j] = 1;
				}
				max = Math.max(dp[i][j], max);
				
				
			}
		}
		System.out.println(max);
		}
		
	}

	
}

Measured memory_bytes: 326036
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.size();
	int pos = 0;
	while (pos < n && k > 0) {
		if (s[pos] != 'a' && 'z' - s[pos] + 1 <= k) {
			k -= 'z' - s[pos] + 1;
			s[pos] = 'a';
		}
		pos++;
	}
	if (pos == n) {
		k %= ('z' - 'a' + 1);
		s[pos - 1] += k;
		if (s[pos - 1] > 'z')
			s[pos - 1] -= 'z' - 'a' + 1;

	}
	cout << s << endl;

	return 0;
}

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

using namespace std;

int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	
	
	cin >> a;
	cin >> b;
	cin >> c;
	
	int t = a + b;
	
	if (t >= c) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    int n;
    cin >> n;
    long long int a;
    int flag = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a%2 == 1){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout << "first" << endl;
    }else{
        cout << "second" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
const int Maxn=400000;
const int Mod=1000000007;
int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1){
			ans=1ll*ans*a%Mod;
		}
		a=1ll*a*a%Mod;
		b>>=1;
	}
	return ans;
}
int frac[Maxn+5],inv_f[Maxn+5];
void init(){
	frac[0]=1;
	inv_f[0]=1;
	for(int i=1;i<=Maxn;i++){
		frac[i]=1ll*frac[i-1]*i%Mod;
	}
	inv_f[Maxn]=ksm(frac[Maxn],Mod-2);
	for(int i=Maxn-1;i>0;i--){
		inv_f[i]=1ll*inv_f[i+1]*(i+1)%Mod;
	}
}
int C(int n,int m){
	return 1ll*frac[n]*inv_f[m]%Mod*inv_f[n-m]%Mod;
}
int f[Maxn+5];
int main(){
	init();
	int n,k;
	scanf("%d%d",&n,&k);
	if(k>=n-1){
		printf("%d\n",C(n+n-1,n));
	}
	else{
		f[0]=1;
		f[1]=1ll*n*(n-1)%Mod;
		for(int i=2;i<n;i++){
			f[i]=C(n,i);
			f[i]=1ll*f[i]*C(n-1,i)%Mod;
		}
		int ans=0;
		for(int i=0;i<=k;i++){
			ans=(ans+f[i])%Mod;
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 4096
from bisect import *
INF=10**18
n=int(input())
a=[int(input()) for i in range(n)]

dp=[INF]*(n+1)
dp[0]=-1
for i in range(n):
    b=bisect_left(dp,a[i])
    dp[b]=a[i]
ans=-1
for i in range(n+1):
    if dp[i]==INF:
        break
    ans=i
print(ans)


Measured memory_bytes: 10468
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int[] a = new int[6];
    
    for(int i = 0; i < 6; i++){
      a[i] = Integer.parseInt(br.readLine());
    }
    
    boolean flag = true;
    for(int i = 0; i < 5; i++){
      for(int j = 0; j < 5; j++){
        if(Math.abs(a[i] - a[j]) > a[5]){
          flag = false;
          break;
        }
      }
    }
    
    if(flag){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 21204
n,m = map(int,input().split())
ans = 0
K = [0]*m
S = [0]*m
for i in range(m):
    I = input().split()
    K[i],S[i] = int(I[0]), list(map(int,I[1:]))
P = list(map(int,input().split()))

for i in range(2**n):
    on = [0]*n
    j = 0
    while i > 0:
        if i&1:
            on[j] = 1
        i = i >> 1
        j += 1
    cnt = [0]*m
    flag = 1
    for j in range(m):
        for s in S[j]:
            cnt[j] += on[s-1]
        if (cnt[j]-P[j])&1:
            flag = 0
    ans += flag
print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] strs = br.readLine().split(" ");
		int[] inputData = new int[n];
		for (int i = 0; i < n; i++) {
			inputData[i] = Integer.parseInt(strs[i]);
		}
		int swapCnt = selectionSort(inputData);

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < inputData.length; i++) {
			sb.append(inputData[i]);
			if (i < inputData.length - 1) {
				sb.append(" ");
			}
		}
		sb.append("\n").append(swapCnt);
		System.out.println(sb.toString());
	}

	public static int selectionSort(int[] A) {
		int swapCnt = 0;
		for (int i = 0; i < A.length; i++) {
			int minIdx = i;
			for (int j = i + 1; j < A.length; j++) {
				if (A[minIdx] > A[j]) {
					minIdx = j;
				}
			}
			if (i == minIdx) continue;
			int temp = A[i];
			A[i] = A[minIdx];
			A[minIdx] = temp;
			swapCnt++;
		}
		return swapCnt;
	}
}

Measured memory_bytes: 24484
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

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

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int H, W, N;
vector<vector<int>> max_col;
map<pair<int, int>, bool> cache;

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

    cin >> H >> W >> N;
    max_col.resize(W);

    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;

        cache[{x, y}] = true;
        max_col[y].push_back(x);
    }

    for (int i = 0; i < W; i++) {
        max_col[i].push_back(H);
        sort(max_col[i].begin(), max_col[i].end());
    }

    int ans = H - 1;

    int r = 0, c = 0;
    int steps = 0;

    //debug() << "st: " << ans;
    vector<int> at(W);

    for (int i = 0; i < max(H + 1, W + 1); i++) {
        
        while (max_col[c][at[c]] < r)
            at[c]++;

        int obstacle = max_col[c][at[c]];

        ans = min(ans, steps + obstacle - r - 1);

        if (r == H - 1 || cache.count({r + 1, c})) {
            ans = min(ans, steps);
            //debug() << "end " << steps;
            break;
        }

        steps++;
        r++;

        if (c + 1 < W && !cache.count({r, c + 1})) {
            c++;
        }
    }

    cout << ans + 1 << "\n";

    return 0;
}


Measured memory_bytes: 24576
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)
#define DBG(x) cerr << #x << ": " << x << "\n"
#define INF 1000000000

using namespace std;
typedef long long lint;
const int MOD = 1000000007;


int main() {

	cin.tie(0);

	int N, M;
	cin >> N >> M;

	vector<int> a(M), b(M), c(M);
	FOR(i, 0, M)cin >> a[i] >> b[i] >> c[i];

	vector<vector<int>> dist(N, vector<int>(N, INF));
	FOR(i, 0, N) dist[i][i] = 0;

	FOR(i, 0, M) {
		dist[a[i] - 1][b[i] - 1] = c[i];
		dist[b[i] - 1][a[i] - 1] = c[i];
	}

	FOR(k, 0, N) {
		FOR(j, 0, N) {
			FOR(i, 0, N) {
			
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	int cnt = 0;
	FOR(i, 0, M) {

		if (c[i] > dist[a[i] - 1][b[i] - 1]) cnt++;
	}

	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5+5;
int ans[N];
int main() {
    int n;
    cin>>n;
    int h[n];
    for(int i = 0;i<n;i++){
        cin>>h[i];
    }
    ans[0] = 0;
    ans[1] = abs(h[1] - h[0]);
    for(int i = 2;i<n;i++){
        ans[i] = min( abs(h[i] - h[i-2])+ans[i-2]
                , abs(h[i] - h[i-1]) + ans[i-1]);
    }
    cout<<ans[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N;
string S, T;

int main(void){
	//IO("test.in", "test.out");
	cin >> S >> T;
	while(S != T && N < S.length()){
		S = S[S.length() - 1] + S.substr(0, S.length() - 1);
		N++;
	}
	if(S == T) printf("Yes\n");
	else printf("No\n");
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

void solve(){
  int32 n;
  cin >> n;
  vector<int64> a(n);
  REP(i,n)cin >> a[i];
  string s;
  cin >> s;
  vector<int64> bs;
  FORR(i,n-1,0){
    int64 v = a[i];
    for(auto b : bs){
      v = min(v,v^b);
    }
    if(s[i] == '0'){
      if(v != 0)bs.pb(v);
    }else{
      if(v != 0){
        ANS(1);
        return;
      }
    }
  }
  ANS(0);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 t;
  cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3632
h , w = map(int,input().split())
giri = [list(input()) for i in range(h)]
ans = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    sta = -1
    cou = 0
    for j in range(w):
        if sta == -1 and giri[i][j] == ".":
            sta = j
            cou += 1
        elif sta != -1 and giri[i][j] == ".":
            cou += 1
        elif sta != -1 and giri[i][j] == "#":
            for k in range(sta,j):
                ans[i][k] += cou
            cou = 0
            sta = -1
        if j == w-1 and sta != -1:
            for k in range(sta,w):
                ans[i][k] += cou

for i in range(w):
    sta = -1
    cou = 0
    for j in range(h):
        if sta == -1 and giri[j][i] == ".":
            sta = j
            cou += 1
        elif sta != -1 and giri[j][i] == ".":
            cou += 1
        elif sta != -1 and giri[j][i] == "#":
            for k in range(sta,j):
                ans[k][i] += cou
            cou = 0
            sta = -1
        if j == h-1 and sta != -1:
            for k in range(sta,h):
                ans[k][i] += cou

kotae = 0

for i in range(h):
    for j in range(w):
        kotae = max(kotae,ans[i][j]-1)

print(kotae)

Measured memory_bytes: 222216
#include <stdio.h>
long long int factorial(long long int num)
{
	if(num>0)
		return num*factorial(num-1);
	else
		return 1;
}
int main(void) {
	long long int n;
	scanf("%lld",&n);
	printf("%lld\n",factorial(n));
	return 0;
}


Measured memory_bytes: 2056
n,m=map(int,input().split())
p=[]
for i in range(m):
    a,b=map(int,input().split())
    p.append([i,a,b,0])
ps=sorted(p,key=lambda i:(i[1],i[2]))
cnt=1
for i in range(m):
    if i!=0:
        if ps[i][1]==ps[i-1][1]:
            cnt+=1
            ps[i][3]=cnt
        else:
            ps[i][3]=1
            cnt=1
    else:
        ps[i][3]=1
ps=sorted(ps,key=lambda i:i[0])
for i in range(m):
    print("{0:06d}".format(ps[i][1]),end='')#文末の改行取り消し
    print("{0:06d}".format(ps[i][3]))


Measured memory_bytes: 35104
import collections

n = int(input())
ls = list(map(int, input().split()))
counter = collections.Counter()
for a in ls:
    counter[a] += 1
ls = [(k, v) for k, v in counter.items() if v > 1]
ls.sort(reverse=True)
m = len(ls)
if m >= 1 and ls[0][1] >= 4:
    print(ls[0][0]**2)
elif m >= 2:
    print(ls[0][0] * ls[1][0])
else:
    print(0)

Measured memory_bytes: 18600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

const int MOD = 1000000007;

struct CumulativeSum {
  vector<long long> csum;
  template<typename T>
  CumulativeSum(vector<T> input) : csum(input.size() + 1, 0) {
    for(int i = 0; i < (int)input.size(); i++) csum[i+1] = csum[i] + input[i];
  }
  long long query(int l, int r) { /* 0-indexed, inclusive */ return csum[r+1] - csum[l]; }
};

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  CumulativeSum cs(a);


  ll ans = 0;
  rep(i,1,n) {
    ll q = cs.query(0, i-1) % MOD;
    ans += (a[i] * q) % MOD;
    ans = ans % MOD;
  }
  cout << ans << endl;
}


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

int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 3620
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

n = int(input())
n_2 = n%100
n_3 = n_2%10

if n_3 in hon: print('hon')
elif n_3 in pon: print('pon')
elif n_3 in bon: print('bon')

Measured memory_bytes: 9180
#include <iostream>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 10;
int nums[MAXN];
LL lft, rght;
bool solve(LL a) {
    LL tmp = lft / a * a;
    if (lft % a != 0) tmp += a;
    if (tmp > rght) return false;
    lft = tmp;
    tmp = rght / a * a;
    rght = tmp + a - 1;
    return true;
}
int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    lft = rght = 2;
    for (int i = n-1; i >= 0; i--) {
        if (!solve(nums[i])) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << lft << ' ' << rght << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int a,b,n; // n<=10^6

int main(){
	while(cin>>a>>b>>n){
		a%=b;
		int ans=0;
		rep(i,n){
			int x=a*10/b;
			ans+=x;
			a=a*10-x*b;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0