akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}


const int MOD = 1e9 + 7;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool dp[100001];
int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int x;
    cin >> x;
    dp[0] = true;
    REP(i, 100, x + 1) {
      if(i == 100){
        if(dp[i - 100]) dp[i] = true;
        continue;
      }
      if(i == 101){
        if(dp[i - 101]) dp[i] = true;
        continue;
      }
      if(i == 102){
        if(dp[i - 102]) dp[i] = true;
        continue;
      }
      if(i == 103){
        if(dp[i - 103]) dp[i] = true;
        continue;
      }
      if(i == 104){
        if(dp[i - 104]) dp[i] = true;
        continue;
      }
      if(i == 105){
        if(dp[i - 105]) dp[i] = true;
        continue;
      }
        if(dp[i - 100]) dp[i] = true;
        if(dp[i - 101]) dp[i] = true;
        if(dp[i - 102]) dp[i] = true;
        if(dp[i - 103]) dp[i] = true;
        if(dp[i - 104]) dp[i] = true;
        if(dp[i - 105]) dp[i] = true;
    }
    if(dp[x]) {
      print(1);
    }
    else {
      print(0);
    }
}

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

public class Main {
    FastScanner in;
    PrintWriter out;

    void solve() {
        for (int i = 1; i <= 5; i++) {
            if (in.nextInt() == 0) {
                out.println(i);
                break;
            }
        }
    }


    final int mod = 988244353;

    int mul(int x, int y) {
        return (int) ((x * 1L * y) % mod);
    }

    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}

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

using ll = long long;

ll dp[100002];

int main() {
  int N;
  ll W, res = 0;
  scanf("%d%lld", &N, &W);
  while (N--) {
    ll w;
    int v;
    scanf("%lld%d", &w, &v);
    for (int i = W - w; i >= 0; --i) {
      if (!i || dp[i]) {
        dp[i + w] = max(dp[i + w], dp[i] + v);
        res = max(res, dp[i + w]);
      }
    }
  }

  printf("%lld\n", res);
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef vector<ll> vl;
typedef pair<vl,vl> t;
int n,k,r,s,p;
string str;
int dp[1000005][3];
int solve(string str){
	int n = str.size();
	rep(i,n+3) rep(j,3) dp[i][j] = 0;
	rep(i,n){
		rep(j,3){
			int add = 0;
			if(str[i] == 's' && j == 0) add = r;
			if(str[i] == 'p' && j == 1) add = s;
			if(str[i] == 'r' && j == 2) add = p;
			int hoge = 0;
			rep(k,3) if(j != k) hoge = max(hoge,dp[i][k]);
			dp[i+1][j] = max(dp[i+1][j],add+hoge);
		}
	}
	return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main(){
	cin>>n>>k>>r>>s>>p>>str;
	int ans = 0;
	rep(i,k){
		string S = "";
		int j = i;
		while(j < n) { S.pb(str[j]); j += k; }
		
		ans += solve(S);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll a, b;
    cin >> a >> b;
    ll tmp = a, i = 0;
    while(tmp <= b){
        tmp *= 2;
        i++;
    }
    cout << i<< endl;

    return 0;
}


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

const double eps = 0.0000000001;

bool eq(double a,double b){
  return ( fabs(a-b) < eps );
}

struct Point{
  double x,y,z;
  
  Point operator + (Point p){
    return (Point){x+p.x,y+p.y,z+p.z};
  }
  Point operator - (Point p){
    return (Point){x-p.x,y-p.y,z-p.z};
  }
  Point operator * (double k){
    return (Point){x*k,y*k,z*k};
  }
};
typedef Point Vector;

struct Segment{
  Point p, v;
};
typedef Segment Line;

bool isIntersect(Segment a,Point b,double r){
  double X=a.p.x-b.x;
  double Y=a.p.y-b.y;
  double Z=a.p.z-b.z;
  double A=(a.v.x*a.v.x+a.v.y*a.v.y+a.v.z*a.v.z);
  double B=(X*a.v.x+Y*a.v.y+Z*a.v.z)*2.0;
  double C=X*X+Y*Y+Z*Z-r*r;
  double K=B*B-4.0*A*C;
  if( K < -eps )return false;
  if( eq(K,0) )K=0;
  double t =  (-B + sqrt(B*B-4.0*A*C)) / (2.0*A);
  double t2 =  (-B - sqrt(B*B-4.0*A*C)) / (2.0*A);
  if( 0 < t && t < 1)return true;
  if( 0 < t2 && t2 < 1)return true;
  return false;
}

int N,Q;
Point A[50];
double B[50];
long long C[50];

int main(){
  cin>>N>>Q;
  for(int i=0;i<N;i++){
    cin>>A[i].x>>A[i].y>>A[i].z;
    cin>>B[i]>>C[i];
  }
  for(int i=0;i<Q;i++){
    long long ans=0;
    Segment s;
    cin>>s.p.x>>s.p.y>>s.p.z;
    cin>>s.v.x>>s.v.y>>s.v.z;
    s.v = s.v - s.p;
    for(int j=0;j<N;j++)
      if(isIntersect(s,A[j],B[j]))ans+=C[j];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	set<int> s;
	for(int i = 0,j; i<n; i++) {cin>>j; s.insert(j);}
		cout<<s.size()<<endl;
	return 0;
}

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

using namespace std;

double p[3005];
int n;
double dp[3005][3005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i=1;i<=n;i++)cin >> p[i];
    for (int i=n/2+1;i<=n;i++)dp[n][i] = 1.0;
    for (int i=n-1;i>=0;i--)
    {
        double q = 1.0 - p[i + 1];
        for (int j=0;j<=n;j++)
        {
            dp[i][j] = (dp[i + 1][j] * q + dp[i + 1][j + 1] * p[i + 1]);
        }
    }
    cout << fixed << setprecision(9) << dp[0][0] << endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 70656
#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;
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; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

struct RH {
    vector<unsigned long long> p,hash;
    void init(const string s) {
        unsigned long long m=1000000007,q=1,n=s.size();
        p.resize(n+1);hash.resize(n+1);p[0]=q;hash[0]=0;
        for(int i=0;i<n;i++){p[i+1]=p[i]*m;hash[i+1]=s[i]+hash[i]*m;}
    }
    unsigned long long h(int i)const{return hash[i];}
    unsigned long long h(int i,int j)const{return h(j)-h(i)*p[j-i];}
};

void solve(){
    string T,P; cin >> T >> P;
    if(T.length() < P.length()) return;
    RH hashT,hashP;
    hashT.init(T); hashP.init(P);
    for(int i = 0; i <= T.length()-P.length();i++){
        if(hashT.h(i,i+P.length()) == hashP.h(P.length())) cout << i << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 19724
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string O, E;
  cin >> O >> E;
  const int64_t L = static_cast<int64_t>(O.length());
  for (int64_t i = 0; i < L; ++i) {
    cout << O[i];
    if (i < static_cast<int64_t>(E.length())) {
      cout << E[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll gcd(ll a,ll b){
    ll r=a%b; 
    while(r!=0){a=b;b=r;r=a%b;}
    return b;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll ans;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    if(i==0)ans=a;
    else ans=gcd(ans,a);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 200005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll n;
	cin >> n;
	ll val = 2000 - n;
	if (val % 200 == 0)
		cout << val / 200 << END;
	else
		cout << val / 200 + 1 << END;





// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 3648
#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 ull unsigned long long
#define f(a, b) for (ll i = a; i < b; i++)
#define mod 1000000007
#define pb push_back
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define ld long double
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    os << "]";
    return os;
}
template <class T>
ostream &operator<<(ostream &os, set<T> S)
{
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
    return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream &operator<<(ostream &os, map<L, R> M)
{
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}

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

    ll a, b, m;
    cin >> a >> b >> m;
    ll aa[a], bb[b];
    f(0, a) cin >> aa[i];
    f(0, b) cin >> bb[i];
    ll ans = 1e18;
    f(0, m)
    {
        ll x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, aa[x] + bb[y] - c);
    }
    sort(aa, aa + a);
    sort(bb, bb + b);
    ans = min(ans, aa[0] + bb[0]);
    cout << ans;

    return 0;
}

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

struct SegTree{
    vector<int> data;
    int data_num;
    char my_c;
    SegTree(): data(){
    }
    void init(int n,char c){
        data_num=1;
        while(n!=0){
            n = n/2;
            data_num*=2;
        }
        data_num*=2;
        data_num--;
        my_c = c;
        rep(i,data_num) data.push_back(0); 
    }

    void update(int i, int x){
        i = (data_num+1)/2 -1 + i;
        data[i] = x;
        while(i>0){
            i = (i-1)/2;
            data[i]=max(data[i*2+1],data[i*2+2]);
        }
    }

    int find(int s, int t){
        int res = 0;
        s=(data_num+1)/2 -1 + s; t=(data_num+1)/2 -1 + t;
        res = max(res,data[s]); res = max(res,data[t]);
        while(t-s>1){
            s++; t--;
            t=(t-1)/2; s=(s-1)/2;
            res = max(res,data[s]); res = max(res,data[t]);
        }
        //if(res==1)  cout << "find " << my_c << endl;
        //else cout << "none " << my_c << endl;
        return res;
    }

    void show_one(int k){
        cout<< "my: " << my_c;
        cout << data[(data_num+1)/2 - 1 + k] << endl;
    }
};


int main(){
    int n; string S;
    cin >> n; cin >> S;
    int q;
    cin >> q;
    vector<int> res;
    SegTree sg[26];
    char my='a';
    rep(i,26){
        sg[i].init(n,my);
        my++;
    }
    rep(i,S.size()){
        sg[int(S[i]-'a')].update(i,1);
    }

    /*
    rep(i,S.size()){
        sg[int(S[i]-'a')].show_one(i);
    }*/



    rep(i,q){
        int com;
        cin >> com;
        if(com==1){
            int x; char c,del_c;
            cin >> x >> c;
            x--;
            del_c = S[x];
            sg[int(S[x]-'a')].update(x,0);
            sg[int(c-'a')].update(x,1);
            //cout << "del " << S[x] << " ";
            //sg[int(S[x]-'a')].show_one(x);
            //cout << "add " << c << " ";
            //sg[int(c-'a')].show_one(x);
            S[x]=c;
        }
        else{
            int l,r;
            cin >> l >> r;
            l--; r--;
            int temp=0;
            rep(i,26){
                if(sg[i].find(l,r)) temp++;
            }
            cout << temp << endl;
        }
        /*
        rep(i,S.size()){
        sg[int(S[i]-'a')].show_one(i);
        }*/
    }
    
}

Measured memory_bytes: 111348
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,s);
  REP(i,n){
    if(s[i]=='I') x++;
    else if(s[i]=='D') x--;
    z = max(x,z);
  }
  OUT(z);
}

Measured memory_bytes: 256
# editorialを参考にした
# M個の目的地があると、そこには(M-1)個の区間がある。N個のコマを使うことで(N-1)個の区間を訪れなくてもよくなる。
# つまり、長い区間を(N-1)個除いて、それ以外の区間の和が移動回数の最小値
N, M = map(int, input().split())
X = [int(x) for x in input().split()]
X = sorted(X)
sa = [0] * (M - 1)
for i in range(M - 1):
    sa[i] = X[i + 1] - X[i]
sa = sorted(sa)
numofmove = 0
if N >= M:
    numofmove = 0
else:
    for j in range(M - N):
        numofmove += sa[j]

print(numofmove)


Measured memory_bytes: 13840
#include <cstdio>
using namespace std;

int a[4];
int c[8];
int k;

int calc(){
	int op = c[k++];
	int ret = 0;
	if(op >= 0){
		ret = op;
	}
	else if(op >= -3){
		int x = calc();
		int y = calc();
		if(op == -1){
			ret = x + y;
		}
		else if(op == -2){
			ret = x - y;
		}
		else{
			ret = x * y;
		}
	}
	else{
		throw 0;
	}
	return ret;
}

void print(){
	int op = c[k++];
	if(op >= 0){
		printf("%d", op);
	}
	else{
		char ch;
		if(op == -1){ ch = '+'; }
		else if(op == -2){ ch = '-'; }
		else{ ch = '*'; }

		putchar('(');
		print();
		printf(" %c ", ch);
		print();
		putchar(')');
	}
}

void solve(int i, int S, int oprem, int numrem){
	if(i == 6){
		for(int j = 0; j < 4; ++j){
			if(S >> j & 1){
				c[6] = a[j];
			}
		}
		try{
			k = 0;
			if(calc() == 10 && k == 7){
				k = 0;
				print();
				puts("");
				throw "";
			}
		}catch(int){}
		return;
	}

	if(oprem > 0){
		for(int op = -1; op >= -3; --op){
			c[i] = op;
			solve(i + 1, S, oprem - 1, numrem + 1);
		}
	}

	if(numrem > 0){
		for(int j = 0; j < 4; ++j){
			if(S >> j & 1){
				c[i] = a[j];
				solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
			}
		}
	}
}

int main(){
	while(1){
		for(int i = 0; i < 8; ++i){
			c[i] = -9;
		}
		for(int i = 0; i < 4; ++i){
			scanf("%d", &a[i]);
		}
		if(a[0] == 0){ break; }
		try{
			solve(0, 15, 3, 0);
			puts("0");
		}catch(...){}
	}
}

Measured memory_bytes: 1128
def act(t,m,l):
    t = (t+m) % len(l);
    del l[t-1]
    return (t-1) % (len(l)+1)

while True:
    i = raw_input().split()

    n = int(i[0])
    m = int(i[1])

    if n == 0 and m == 0:
        break
    else:
        l = range(1,n+1)
        t = 0
        for i in range(n-1):
            tt = act(t,m,l);
            t = tt;
        print l[0]

Measured memory_bytes: 6404
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,
        s: chars, // Vec<char>
    }
    if s.len() <= k {
        let ss: String = s.into_iter().collect();
        println!("{}", ss);
    } else {
        let ss: String = s[0..k].into_iter().collect();
        println!("{}...", ss);
    }
}

Measured memory_bytes: 2116
lists=[]
for i in range(3):
    a=list(map(int,input().split()))
    lists.append(a)
bingo=[[0 for i in range(3)] for j in range(3)]
n=int(input())
for i in range(n):
    x=int(input())
    for i in range(3):
        for j in range(3):
            if x==lists[i][j]:
                bingo[i][j]=1
flag=False
for i in range(3):
    if sum(bingo[i])==3:
        flag=True
for j in range(3):
    c=0
    for i in range(3):
        c+=bingo[i][j]
    if c==3:
        flag=True
if bingo[0][0]+bingo[1][1]+bingo[2][2]==3:
    flag=True
if bingo[0][2]+bingo[1][1]+bingo[2][0]==3:
    flag=True
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define N 1000000
vi s(N + 1, 1);
void eli(int p)
{
    for (int i = p + p; i <= N; i = i + p)
    {
        s[i] = 0;
    }
}
void eratos(){
    s[0] = s[1] = 0;
    rep(i, N + 1)
    {
        if (s[i] == 1)
        {
            eli(i);
        }
    }
}
int main(){
    eratos();
    vi sum(N + 1, 0);
    rep(i,N){
        sum[i + 1] = sum[i] + s[i + 1];
    }
    int n;
    while(cin>>n){
        cout << sum[n] << endl;
    }

    return 0;
}


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

int main(){
  int n; cin >> n;
  int minus = 0, absmin = numeric_limits<int>::max();

  int a;
  long long ans = 0;
  for(int i=0; i<n; ++i){
    cin >> a;
    minus += a < 0;
    absmin = min(absmin, abs(a));
    ans += abs(a);
  }

  if(minus & 1) ans -= 2*absmin;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long mod = 1e9 + 7;

int n, x;
int arr[MAXN];
void solve(){
    int mn = MAXN, val = MAXN;
    int i = 0;
    set<int> present;
    for(i = 0; i < n; i++)
        present.insert(arr[i]);
    for(i = -1; i <= 105; i++){
        if(present.find(i) != present.end())
            continue;
        if(abs(x - i) < mn){
            mn = abs(x - i);
            val = i;
        }
        else if(abs(x - i) == mn){
            val = min(val, i);
        }
    }
    cout << val << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> x >> n;
    int i = 0;
    for(i = 0; i < n; i++)
        cin >> arr[i];
    solve();
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
int main() {
	ll num = 1;
	cin >> N;
	for (i = 1; i <= N; i++) {
		ll k = i;
		ll pre = 0;
		while (k % 2 == 0) {
			k /= 2;
			pre++;
		}
		if (pre > ans) {
			num = i;
			ans = pre;
		}
	}
	cout << num;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		List<Integer> from1 = new ArrayList<>();
		List<Integer> toN = new ArrayList<>();
		for(int i=0;i<m;i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			if(a==1) from1.add(b);
			if(b==n) toN.add(a);
		}
		from1.sort(Comparator.naturalOrder());
		toN.sort(Comparator.naturalOrder());
		int fmax = from1.size();
		int tmax = toN.size();
		int fidx = 0;
		int tidx = 0;
		while(fidx<fmax && tidx<tmax) {
			int f = from1.get(fidx);
			int t = toN.get(tidx);
			if(f==t) break;
			else if(f<t) fidx++;
			else tidx++;
		}
		
		if(fidx==fmax || tidx==tmax) System.out.println("IMPOSSIBLE");
		else System.out.println("POSSIBLE");
		in.close();
	}

}


Measured memory_bytes: 95028
Max = 1500000
A, B, C = (0...3).to_a
From, To = 1, 0

until (n,m=gets.split.map(&:to_i)).all?(&:zero?) do
  tray = Array.new
  3.times do
    tray.push([-1] + gets.split.slice(1...$_.split.size).map(&:to_i))
  end
  answer = Max + 1
  [[A,B], [B,C]].each do |move|
    t = tray.map(&:dup)
    for depth in 0..m do
      if t[A].size==n+1 || t[C].size==n+1
        answer = [answer, depth].min
        break
      end
      move.sort!{|a,b|t[a].last<=>t[b].last}
      t[move[To]].push( t[move[From]].pop )
      move = move.include?(C) ? [A,B] : [B,C]
    end
  end
  p answer<=Max ? answer : -1
end

Measured memory_bytes: 6120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%10==3){
		cout<<"bon"<<"\n";
	}
	else{
		if(n%10==0 || n%10==1|| n%10==6 || n%10==8){
			cout<<"pon"<<"\n";
		}
		else{
			cout<<"hon"<<"\n";
		}
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main() {
    int t=1;
    //cin >> t;
    while(t--){
        int n;
        cin >> n;
        int a,b,i,j;
        int cnt=0;
        bool f=0;
        for(i=0;i<n;i++){
            cin >> a >> b;
            if(a==b){
                cnt++;
            }
            if(cnt==3){
                f=1;
            }
            if(a!=b){
                cnt=0;
            }
        }
        cout << (f==1?"Yes":"No");
    }
}

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

using namespace std;

const int N = 212, B = 61;

char s[N];

long long val[B];

int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    vector<long long> a(n);
    for (int i = 0; i < n; ++i)
      scanf("%lld", &a[i]);
    scanf("%s", s);
    if (s[n-1] == '1') {
      puts("1");
      continue;
    }
    memset(val, 0, sizeof val);
    bool ok = true;
    for (int i = n-1; i >= 0; --i) {
      if (s[i] == '0') {
        long long x = a[i];
        for (int j = B-1; j >= 0; --j) {
          if (((x >> j) & 1) == 0) continue;
          if (val[j] == 0) continue;
          x ^= val[j];
        }
        if (x) {
          int pos = 63 - __builtin_clzll(x);
          val[pos] = x;
          for (int j = 0; j < B; ++j) {
            if (j == pos) continue;
            if ((val[j] >> pos) & 1) {
              val[j] ^= x;
            }
          }
        }
      } else {
        long long x = a[i];
        for (int j = B-1; j >= 0; --j) {
          x = min(x, x^val[j]);
        }
        if (x) {
          ok = false;
          break;
        }
      }
    }
    puts(ok ? "0" : "1");
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;
using Int = int64_t;
int main() {
    Int N;
    cin >> N;
    string s;
    unordered_map<string, Int> um;
    for (Int i {}; i < N; i++) {
        cin >> s;
        sort(s.begin(), s.end());
        um[s]++;
    }
    Int ans {};
    for (const auto& p : um) ans += p.second * (p.second - 1) / 2;
    cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size() - 1;
  int64_t sum = 0;
  rep(bit, (1 << n)) {
    string ns = s;
    int idx = 1;
    rep(j, n) {
      if ((bit >> j & 1) == 1) {
        ns.insert(j+idx, "+");
        idx++;
      }
    }
    string num_s;
    rep(c, ns.size()) {
      if (ns.at(c) != '+') {
        num_s += ns.at(c);
      }
      else {
        sum += stoll(num_s);
        num_s.clear();
      }
    } 
    sum += stoll(num_s);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int f(int n) {
    int ans = 0;
    while(n > 0) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    cout << (n % f(n) ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

		if (a <= b && b <= c) {
			cout << a <<" "<< b <<" "<< c << endl;
		}
		else if(b <= a && a <= c){
			cout << b << " " << a << " " << c << endl;
		}
		else if(a <= c && c <= b) {
			cout << a << " " << c << " " << b << endl;
		}
		else if(b <= c && c <= a) {
			cout << b << " " << c << " " << a << endl;
		}
		else if(c <= a && a <= b) {
			cout << c << " " << a << " " << b << endl;
		}
		else if(c <= b && b <=a ){
			cout << c << " " << b << " " << a << endl;
		}





    return 0;
}





 


Measured memory_bytes: 3084
using System;

namespace B___Card_Game_for_Three__ABC_Edit_
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = new string[3];
            for (var i = 0; i < 3; i++)
            {
                s[i] = Console.ReadLine ();
            }
            var n = 0;
            var o = 'a';
            while (s[n] != "")
            {
                o = s[n][0];
                s[n] = s[n].Remove (0, 1);
                n = o - 97;
            }
            Console.WriteLine (Char.ToUpper (o));
        }
    }
}

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

using namespace std;

const int INF = 1001001001;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> key;
    for(int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        int s = 0;
        for(int j=0;j<b;j++){
            int c;
            cin >> c;
            --c;
            s |= (1 << c);
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1 << N, INF); // 2^n
    // 空集合
    dp[0] = 0;
    for(int s=0;s<(1<<N)-1;s++){
        for(int i=0;i<M;i++){
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if(ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define LINF LLONG_MAX
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define P pair<int,int>
#define prique priority_queue
#define F first
#define S second
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	f(i,a){
		f(j,b){
			string s;
			cin>>s;
			if(s=="snuke"){
				cout<<(char)('A'+j)<<i+1<<endl;
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
n=int(input())
dic={}

for i in range(n):
    s=input()
    if s not in dic:
        dic[s]=1
    else:
        dic[s]+=1
#print(dic)

m=int(input())
for i in range(m):
    t=input()
    if t in dic:
        dic[t]-=1
    
ans_list=sorted(dic.items(),key=lambda x:x[1],reverse=True)
#print(ans_list)

if ans_list[0][1]<0:
    print(0)
else:
    print(ans_list[0][1])


Measured memory_bytes: 9040
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int w, h;
void dfs(int y, int x, char c, vector<string> &vs) {
  if(y < 0 || y >= h || x < 0 || x >= w) return;
  if(vs[y][x] == 'W' || vs[y][x] == 'B') return;
  if(vs[y][x] == c || vs[y][x] == '3') return;
  if(vs[y][x] == '.') vs[y][x] = c;
  else if(vs[y][x] != c) vs[y][x] = '3';
  dfs(y+1,x,c,vs);
  dfs(y-1,x,c,vs);
  dfs(y,x+1,c,vs);
  dfs(y,x-1,c,vs);
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin>>w>>h,w||h) {
    vector<string> vs(h);
    FOR(i,0,h) cin >> vs[i];
    FOR(y,0,h) {
      FOR(x,0,w) {
        if(vs[y][x] == 'W' || vs[y][x] == 'B') {
          dfs(y + 1, x, vs[y][x] == 'B' ? '1' : '2', vs);
          dfs(y - 1, x, vs[y][x] == 'B' ? '1' : '2', vs);
          dfs(y, x + 1, vs[y][x] == 'B' ? '1' : '2', vs);
          dfs(y, x - 1, vs[y][x] == 'B' ? '1' : '2', vs);
        }
      }
    }
    int ans[2]; CLR(ans);
    FOR(y,0,h) {
      FOR(x,0,w) {
        if(vs[y][x] == '1') ans[0]++;
        if(vs[y][x] == '2') ans[1]++;
      }
    }
    cout << ans[0] << " " << ans[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3192
(stdin => {
  // Define Function

  // Declare Variable
  const inputs = stdin.toString().trim().split(' ')
  const x = parseInt(inputs[0], 10)
  const jikan = Math.floor(x/3600)
  const hun = Math.floor((x%3600)/60)
  const byo = Math.floor(x%60)



  console.log(`${jikan}:${hun}:${byo}`)
})(require('fs').readFileSync('/dev/stdin', 'utf8'))


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


int main() {
  string s;
  cin >> s;
  ll n;
  n = s.size();
  ll sum = 0;
  rep(i,n){
    ll a;
    a=s[i]-'0';
    
    sum = (sum + a) % 9;
  }
  if(sum % 9 == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
 
  
  return 0;
}






Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a==1 || b==1){
        if(a==1 && b==1)cout<<"Draw";
        else if(a<b)cout<<"Alice";
        else if(a>b)cout<<"Bob";

    }
    else {
        if(a>b)cout<<"Alice";
        else if(a==b)cout<<"Draw";
        else if(a<b)cout<<"Bob";
    }



    return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; ++i) {
		string str = std::to_string(i);
		string str2 = str;
		reverse(str2.begin(), str2.end());
		if (str == str2) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    q.push(a);
  }
  for (int i = 0; i < m; i++) {
    int now = q.top();
    q.pop();
    q.push(now / 2);
  }
  long long ans = 0;
  while (!q.empty()) {
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
#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
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using vi = vector<int>;

const int LIM = 111;

int calc(int n, const vi &r, const vector<vi> &u, int p)
{
    int ng=0,ok=LIM;
    while(ok-ng>1)
    {
        int M = (ng+ok)/2;
        vector<vi> U(u);

        U[0][p]+=M;

        vi s(n);
        rep(i,3)
        {
            vi a(n);
            rep(j,n) a[j] = -U[j][i];
            sort(all(a));
            rep(j,n)
            {
                int idx = lower_bound(all(a),-U[j][i])-a.begin();
                s[j]-=r[idx];
            }
        }

        int score = s[0];
        sort(all(s));
        int rank = lower_bound(all(s),score)-s.begin()+1;
        if(rank<=8) ok=M;
        else ng=M;
    }
    return ok;
}

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

    vi r(n);
    rep(i,n) cin >>r[i];

    vector<vi> u(n,vi(3));
    rep(i,n)rep(j,3) cin >>u[i][j];

    int ans = LIM;
    rep(i,3) ans = min(ans,calc(n,r,u,i));

    cout << (ans==LIM?"Saiko":to_string(ans)) << endl;
    return 0;
}

Measured memory_bytes: 3212
from operator import itemgetter
N = int(input())
red = [list(map(int,input().split())) for i in range(N)]
blue = [list(map(int,input().split())) for i in range(N)]
blue.sort()
red2=sorted(red,key=itemgetter(1))
red3=[]
for x in red2[::-1]:
  red3.append(x)
count=0
for i in range(N):
  redlen=len(red3)
  j=0
  for j in range(redlen):
    if red3[j][0]<blue[i][0] and red3[j][1]<blue[i][1]:
      count+=1
      del red3[j]
      break
print(count)

Measured memory_bytes: 3064
a, b = map(int, input().split())
if a <= 0 and b >= 0:
  print('Zero')
else:
  if a > 0 and b > 0:
    print('Positive')
  elif a < 0 and b < 0:
    if (b - a) % 2:
      print('Positive')
    else:
      print('Negative')


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
  char s[2][4];
  scanf("%s%s",s[0],s[1]);
  puts((s[0][0]==s[1][2])&&(s[0][1]==s[1][1])&&(s[0][2]==s[1][0])?"YES":"NO");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int n;
vector<vector<PII> > v;

bool judge(int bit){
  rep(i,n){
    if(!(bit&(1<<i))) continue;
    for(PII xy : v[i]){
      int x = xy.first, y = xy.second;
      // if(y==1 &&!(bit&(1<<x))) return false;
      // if(y==0 && (bit&(1<<x))) return false;
      if(((bit>>x)&1)^y) return false;
    }
  }
  return true;
}

signed main(){
  cin>>n;
  v.resize(n);
  rep(i,n){
    int a; cin>>a;
    v[i].resize(a);
    rep(j,a){
      cin >> v[i][j].first >> v[i][j].second;
      v[i][j].first--;
    }
  }

  int res = 0;
  rep(bit,1<<n){
    if(judge(bit)){
      int count = 0;
      rep(i,n){
        if(bit&(1<<i)) count++;
      }
      res = max(res,count);
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256