akhauriyash/Code-Regression huggingface dataset:
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

void solve(int n, int d, int x, vector<int> &a){
    vector<int> eat(d+1, 0);
    REP(i, n){
        int day = 1;
        for (int j = day; j <= d; j += a[i]){
            eat[day]++;
        }
    }
    lint sum = x;
    REP(i, d+1){
        sum += eat[i];
    }
    cout << sum << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    REP(i, n){
        cin >> a[i];
    }
    solve(n, d, x, a);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

struct UnionFind{
    vector<int> d;
    UnionFind(int n = 0): d(n, -1){}
    int find(int x){
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x){return -d[find(x)];}
};

VVI g;

int main(){
    int n;
    cin >> n;
    g.resize(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> q;
    VI parent(n, inf);
    q.push(0);
    parent[0] = -1;
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int d: g[v]){
            if (parent[d] != inf) continue;
            parent[d] = v;
            q.push(d);
        }
    }

    VI gg;
    int i = n-1;
    while(parent[i] != -1){
        gg.push_back(i);
        i = parent[i];
    }
    gg.push_back(0);
    reverse(all(gg));

    int p1, p2;
    if (sz(gg) % 2 == 1){
        p1 = gg[sz(gg) / 2];
        p2 = gg[sz(gg) / 2 + 1];
    }else{
        p1 = gg[sz(gg) / 2 - 1];
        p2 = gg[sz(gg) / 2];
    }

    g[p1].erase(remove(all(g[p1]), p2), g[p1].end());
    g[p2].erase(remove(all(g[p2]), p1), g[p2].end());

    UnionFind uf(n);
    rep(i,n){
        for(int d: g[i]){
            uf.unite(i, d);
        }
    }

    int cnt1 = uf.size(0);
    int cnt2 = uf.size(n-1);

    if (cnt1 > cnt2) view("Fennec");
    else view("Snuke");

    return 0;
}

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

typedef long long lint;
lint arr[55];

int main(void){
    lint k;
    scanf("%lld",&k);
    lint n=50;
    lint a,b,c;
    a=k/n;
    b=k%n;
    c=n-b;
    for(int i=1;i<=n;i++)
        arr[i]=n-1+a;
    for(int i=1;i<=c;i++)
        arr[i]=n-1+a-b;
    for(int i=c+1;i<=n;i++)
        arr[i]=n-1+a-b+1+n;
    printf("%lld\n",n);
    for(int i=1;i<=n;i++)
        printf("%lld ",arr[i]);
    printf("\n");
    return 0;
}


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

int main(){
    for(int j=1;j<=9;j++)
	for(int i=1;i<=9;i++)
	    cout<<j<<'x'<<i<<'='<<j*i<<'\n';
	    //printf("%dx%d = %d",j,i,j*i);
    return 0;
}

Measured memory_bytes: 1112
n,p = map(int,input().split())
import math
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n //= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
so = factorization(p)
ans = 1
for i,j in so:
    ans *= i**(j//n)
print(ans)

Measured memory_bytes: 39280
n = int(input())
data = [map(int, input().split()) for i in range(n)]
ans = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
for b,f,r,v in data:
    ans[b-1][f-1][r-1] += v
    
ans = [[[' '+str(ans[b][f][r]) for r in range(10)] for f in range(3)] for b in range(4)]
for b in range(4):
    for f in range(3):
        ans_str = ''.join(ans[b][f])
        print(ans_str)
    if b<3:
        print('#'*20)


Measured memory_bytes: 5644
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N,K; cin >> N >> K;
    int A[N]; REP(i,N) cin >> A[i];
    map<int,int> m;
    REP(i,N){
        if(m.find(A[i]) == m.end()) m[A[i]] = 1;
        else m[A[i]]++;
    }
    priority_queue<P, vector<P>, greater<P>> q;
    for(auto p : m) q.push(P(p.second, p.first));
    int ans = 0;
    while(q.size() > K){
        auto p = q.top(); q.pop();
        ans += p.first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12536
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

ll a[100001] = {};

//initial : call init_uf();
//unite x and y : p[uf(x)] = uf(y)
//same x and y : uf(x) == uf(y)
static const ll MAX_N = 200001;
ll p[MAX_N] = {};
ll uf(ll i) { return (p[i] == i) ? i : p[i] = uf(p[i]); }
void init_uf() { rep(i, 1, MAX_N)p[i] = i; }

ll q[MAX_N] = {};
ll uf2(ll i) { return (q[i] == i) ? i : q[i] = uf2(q[i]); }
void init_uf2() { rep(i, 1, MAX_N)q[i] = i; }

int main() {
	init_uf();
	init_uf2();
	ll n, k, l; cin >> n >> k >> l;
	rep(i, 0, k) {
		ll x, y; cin >> x >> y;
		if (uf(x) != uf(y)) p[uf(x)] = uf(y);
	}
	rep(i, 0, l) {
		ll x, y; cin >> x >> y;
		if (uf2(x) != uf2(y)) q[uf2(x)] = uf2(y);
	}

	map<pair<ll, ll>, ll> m;
	repe(i, 1, n)m[{uf(i), uf2(i)}]++;
	repe(i, 1, n)cout << m[{uf(i), uf2(i)}] << endl;
	return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> p(N); // Male = 1, Female = 2;
    string response;
    auto ask = [&](int pos) {
        cout << pos << endl;
        cin >> response;
        if (response == "Vacant") return -1;
        else if (response == "Male") return 1;
        else return 2;
    };
    p[0] = ask(0);
    if (p[0] == -1) return 0;
    p[N-1] = ask(N-1);
    if (p[N-1] == -1) return 0;
    int left = 0;
    int right = N-1;
    while (right - left > 1){
        int mid = (right + left)/2;
        p[mid] = ask(mid);
        if (p[mid] == -1) return 0;
        if ((right - mid)%2 == 0 && p[mid] != p[right]) left = mid;
        else if ((right - mid)%2 == 1 && p[mid] == p[right]) left = mid;
        else if ((mid - left)%2 == 0 && p[mid] != p[left]) right = mid;
        else if ((mid - left)%2 == 1 && p[mid] == p[left]) right = mid;
    }
    return 0;
}

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


int main() {
  int n, a;
  cin >> n >> a;
  string ans = "No";
  if((n%500) <= a) ans = "Yes";  
  cout << ans << endl;
  return 0;
  
}

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

int main(){
  int H, W;
  cin >> H >> W;
  //char S[H][W];
  string S[100];
  int result[100][100];
  for(int i=0;i<H;i++) for(int j=0;j<W;j++) {
	result[i][j]=0;
  }
  //for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> S[i][j];
  for(int i=0;i<H;i++) cin >> S[i];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
	  if(S[i][j]=='#'){
	    if(i>0){
	      result[i-1][j]++;
		  if(j>0){
		    result[i-1][j-1]++;
		  }
		  if(j<W){
			result[i-1][j+1]++;
		  }
		}
		if(j>0){
		  result[i][j-1]++;
		  if(i<H){
		    result[i+1][j-1]++;
		  }
		}
		if(i<H){
		  result[i+1][j]++;
		  if(j<W){
		    result[i+1][j+1]++;
		  }
		}
		if(j<W){
		  result[i][j+1]++;
		}
	  }
	}
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
	  if(S[i][j]=='#'){
		cout << '#';
	  }else{
		cout << result[i][j];
	  }
	}
	cout << endl;
  }
  return 0;
}


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

int main() {
  int D;
  cin >> D;
  if(D==22)
    cout << "Christmas Eve Eve Eve" << endl;
  else if(D==23)
    cout << "Christmas Eve Eve" << endl;
  else if(D==24)
    cout << "Christmas Eve" << endl;
  else
    cout << "Christmas" << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  bool ok = false;
  for (int i = 0; i <= x; i++) {
    if ((x - i)*4 + i*2 == y) {
      ok = true;
    }
  }
  if (ok) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; ++i) cin >> v[i];

  for (int b = 0; b < 1 << 3; ++b) {
    int child1 = 0;
    int child2 = 0;
    for (int i = 0; i < 3; ++i) {
      if (b >> i & 1)
        child1 += v[i];
      else
        child2 += v[i];
    }
    if (child1 == child2) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
  return 0;
}

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

int const MOD = 1e9+5;

#define  pi acos(-1.00)
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define newLine printf("\n")
#define start_p int main()
#define end_p return 0
#define test_IO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;


start_p{
    #ifndef ONLINE_JUDGE
    //test_IO;
    #endif // ONLINE_JUDGE
    int n,m;
    cin>>n>>m;
    int sum = 0;
    for(int i = 0; i < m; i++){
        int t; cin>>t;
        sum += t;
    }
    if(sum > n) cout<<-1<<endl;
    else cout<<n-sum<<endl;

    end_p;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  ll n,a,b,c,d;
  string s;
  cin>>n>>a>>b>>c>>d>>s;

  if(c<d){
    bool dame=false;
    for(int i=b-1;i<d-1;i++){
      if(s[i]=='#' && s[i+1]=='#') dame=true;
    }
    for(int i=a-1;i<c-1;i++){
      if(s[i]=='#' && s[i+1]=='#') dame=true;
    }
  cout << (dame?"No":"Yes") << endl;
  }

  if(c>d){
    bool dame=false;
    for(int i=b-1;i<d-1;i++){
      if(s[i]=='#' && s[i+1]=='#') dame=true;
    }
    for(int i=a-1;i<c-1;i++){
      if(s[i]=='#' && s[i+1]=='#') dame=true;
    }

    bool oasis=false;
    for(int i=b-2;i<=d-2;i++){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') oasis=true;
    }
    if(!oasis) dame=true;
    cout << (dame?"No":"Yes") << endl;
  }

}


Measured memory_bytes: 640
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;

int main(){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a <= c && d <= b) printf("%d\n",d-c);
	else if(b <= c) printf("0\n");
	else if(c >= a && c <= b && d >= b) printf("%d\n",b-c);
	else if(a >= c && b <= d) printf("%d\n",b-a);
	else if(a >= c && a <= d && b >= d) printf("%d\n",d-a);
	else if(a >= d) printf("0\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1)
using namespace std;
int main()
{
    int n,a;
    cin>>n;
    int b[n+10]={0};
    int m=n-1;
    while(m--)
    {
        cin>>a;
        b[a]++;
    }
    for(int i=1; i<=n; i++)
    {
        cout<<b[i]<<"\n";
    }
}

Measured memory_bytes: 4408
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int x[13],p[13],n,m,ans=0;
vector <int> o[13];
bool vis[13];
void dfs(int x){
	vis[x]=0;
	if (x==n){
		bool ok=1;
		for (int i=0;i<m;i++){
		int res=0;for (int j=0;j<o[i].size();j++) if (vis[o[i][j]]) res++;
		if (res%2!=p[i]) ok=0;
		} if (ok)ans++;
	}else dfs(x+1);
	vis[x]=1;
	if (x==n){
		bool ok=1;
		for (int i=0;i<m;i++){
		int res=0;for (int j=0;j<o[i].size();j++) if (vis[o[i][j]]) res++;
		if (res%2!=p[i]) ok=0;
		} if (ok)ans++;
	}else dfs(x+1);
}
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int k;
		cin>>k;
		while (k--){
			int t;
			cin>>t;
			o[i].push_back(t); 
		}
	}
	for (int i=0;i<m;i++) cin>>p[i];
	dfs(1);
	cout<<ans;
}

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

int main()
{
    double N, ans = 0;
    cin >> N;
    if ((int)N % 2 != 0)
    {
        ans = (double)(((N + 1) / 2) / N);
        cout << fixed << ans << endl;
    }
    else
    {
        ans = (double)((N / 2) / N);
        cout << fixed << ans << endl;
    }
}

Measured memory_bytes: 256
def main():
    n = int(input())
    S = list(map(int,input().split()))
    q = int(input())
    T = list(map(int,input().split()))

    T.sort()
    S.sort()
    cnt = 0
    for i in range(n):
        if (i != 0) and (S[i] == S[i-1]):
            continue
#ここから二分探索
        left = 0
        right = q
        mid = 0
        while True:
            #print(left,right,mid,cnt)
            mid = int( (left+right)/2 )
            if T[mid] == S[i]:
                cnt += 1
                break
            elif S[i] < T[mid]:
                right = mid
            elif S[i] > T[mid]:
                left = mid + 1


            if left == right:
                break
    return cnt

print(main())



Measured memory_bytes: 16712
h, w, k = map(int, input().split())
board = [input() for _ in range(h)]
cnt = 0
for redlines in range(2**h):
    redlines_bin = format(redlines, 'b').zfill(h)
    for redclms in range(2**w):
        redclms_bin = format(redclms, 'b').zfill(w)
        
        rem_black = 0
        for i in range(h):
            for j in range(w):
                if redlines_bin[i] == '0' and redclms_bin[j] == '0' and board[i][j] == '#':
                    rem_black += 1
        
        if rem_black == k:
            cnt += 1

print(cnt)

Measured memory_bytes: 9064
A, B = list(map(int,input().split()))

if A % 2 == 0 and B % 2 == 0:
    diff = (B - A + 1) // 2
    if diff % 2 == 1:
         print(1 ^ B)
    else :
        print(0 ^ B)
elif A % 2 == 0 and B % 2 == 1:
    diff = (B - A + 1) // 2
    if diff % 2 == 1:
        print(1)
    else :
        print(0)
elif A % 2 == 1 and B % 2 == 0:
    diff = (B - A) // 2
    if diff % 2 == 1:
        print(A ^ 1 ^ B)
    else :
        print(A ^ 0 ^ B)
else :
    diff = (B - A) // 2
    if diff % 2 == 1:
        print(A ^ 1)
    else :
        print(A ^ 0)

Measured memory_bytes: 3064
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

NUM = 20005

table = [""]*NUM


while True:

    T = str(input())
    if T == '-':
        break

    left = 0
    right = 0
    #長い配列にパターン文字列を転記
    for i in range(len(T)):
        # print(T[right])
        table[left+right] = T[right]
        right += 1

    num_suffle = int(input())

    for loop in range(num_suffle):
        pick_num = int(input())
        #先頭からpick_num文字を末尾に転記し、論理削除
        for i in range(pick_num):
            table[right+i] = table[left+i]
        left += pick_num
        right += pick_num

    for i in range(left,right):
        print("%s"%(table[i]),end = "")
    print()



Measured memory_bytes: 5740
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<=b)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state();auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}
#define SHOWQUEUE(a) {std::queue<decltype(a.front())> tmp(a);std::cout << #a << "\t:";for(int i=0; i<static_cast<int>(a.size()); ++i){std::cout << tmp.front() << "\n";tmp.pop();}std::cout << "\n";}

//#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000000001;
constexpr int MOD = 1000000007;

ll gcd(ll a, ll b) {
	return b != 0 ? gcd(b, a % b) : a;
}

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

int main() {
	INIT;
	ll a, b;
	while (std::cin >> a >> b) {
		OUT(gcd(a, b))SP OUT(lcm(a, b))BR;
	}
	return 0;
}

Measured memory_bytes: 3100
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200, mod = 1e9 + 7;

set <int> S;
vector <int> g;
int n, m, k;
int a[N], d[3000][3000], b[N];
string ss;

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for (int j = 1; j <= m; j++){
		cin >> b[j];
	}
	int res = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (a[i] == b[j]){
				(res += d[i - 1][j - 1] + 1) %= mod;
				d[i][j] = (d[i - 1][j] + d[i][j - 1] + 1) % mod;
			}
			else{
				d[i][j] = (d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + mod) % mod;
			}
			//cout << d[i][j] << " ";
		}
		//cout << endl;
	}
	cout << (res + 1) % mod;
	return 0;
}












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

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> result;
  int ex[5], max, min, n;
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    max = 0;
    min = 500;
    for (int i = 0; i < n; i++) {
      int tmp, sum = 0;
      for (int j = 0; j < 5; j++) {
        cin >> tmp;
        sum += tmp;
      }
      if (sum > max)
        max = sum;
      if (sum < min)
        min = sum;
    }
    result.push_back(max);
    result.push_back(min);
  }

  for (int i = 0; i < result.size(); i += 2)
    cout << result[i] << ' ' << result[i+1] << endl;
  return 0;
}

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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;


void solve()
{
    ll n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    ll ct = 0;
    ll overseas = 0;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'c')
            cout << "No";
        else if(s[i] == 'a')
        {
            if(ct < a+b)
            {
                cout << "Yes";
                ct++;
            }
            else
                cout << "No";
        }
        else
        {
            if(ct < a+b && overseas < b)
            {
                cout << "Yes";
                ct++;
                overseas++;
            }
            else
                cout << "No";
        }
        cout << "\n";
    }

    
}

int main()
{
    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <cstring>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int t[100005];
	memset(t, 0, sizeof t);
	
	int k;
	cin >> k;
	for (int i = 1; i <= k; ++i) {
		int s;
		cin >> s;
		t[s] = i;
	}	
	
	for (int i = 1; i <= k; ++i) {
		cout << t[i];
		if (i == k) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	
  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		while(in.hasNext())new AOJ0127().doIt();
	}
	
	class AOJ0127{
		String hyou = "abcdefghijklmnopqrstuvwxyz.?! ";
		void doIt(){
			String input = in.next();
			if(input.length()%2==1){
				System.out.println("NA");return;
			}
			StringBuffer result = new StringBuffer("");
			try {
				for(int i=0;i<input.length();i+=2){
					if(isOK(input.charAt(i))||isOK(input.charAt(i+1))){
						System.out.println("NA");return;
					}
					int a = Integer.parseInt(input.charAt(i)+"")-1;
					int b = Integer.parseInt(input.charAt(i+1)+"")-1;
//					if(5*a+b>=hyou.length()||5*a+b<0){
//						System.out.println("NA");return;
//					}
					if(0<=a&&a<6&&0<=b&&b<5)result.append(hyou.charAt(5*a+b));
					else{
						System.out.println("NA");return;
					}
				}
				System.out.println(result);
			    } catch (java.lang.ArrayIndexOutOfBoundsException e) {
			      System.out.println("NA");
			    }
			
		}
		
		boolean isOK(char a){
			return (a=='0'||a=='1'||a=='2'||a=='3'||a=='4'||a=='5'||a=='6'||a=='7'||a=='8'||a=='9')==false;
		}
		
	}
	
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 2e5 + 5;

int arr[maxr];
int32_t main()
{
	GO;
	int n;
	cin >> n;
	if ((n & 1))
		cout << 0 << endl;
	else {
		int count = 10, ans = 0;
		while ((n / count) > 0) {
			ans += (n / count);
			count *= 5;
		}
		cout << ans << endl;
	}
	return 0;
}

//!

Measured memory_bytes: 3652
n, k = map(int, input().split())
d = list(map(int, input().split()))

use_list = []
for i in range(10):
    if i not in d:
        use_list.append(str(i))

for a in use_list:
    if int(a) >= n:
        print(int(a))
        exit()

for a in use_list:
    for b in use_list:
        if int(a+b) >= n:
            print(int(a+b))
            exit()

for a in use_list:
    for b in use_list:
        for c in use_list:
            if int(a+b+c) >= n:
                print(int(a+b+c))
                exit()

for a in use_list:
    for b in use_list:
        for c in use_list:
            for d in use_list:
                if int(a+b+c+d) >= n:
                    print(int(a+b+c+d))
                    exit()

for a in use_list:
    for b in use_list:
        for c in use_list:
            for d in use_list:
                for e in use_list:
                    if int(a+b+c+d+e) >= n:
                        print(int(a+b+c+d+e))
                        exit()


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

using namespace std;

int N, M, Q;
vector<int> a, b, c, d;
int ans = 0;

void calc(vector<int> A){
	if (A.size() == N){
		int temp = 0;
		for (int i = 0; i < Q; i++){
			if(A[b[i]] - A[a[i]] == c[i]){
				temp += d[i];
			}
		}
		ans = max(ans, temp);
		return;
	}
	A.push_back(A.back());
	while(A.back() <= M){
		calc(A);
		A.back()++;
	}
}

int main(){
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; i++){
		int ta, tb, tc, td;
		cin >> ta >> tb >> tc >> td;
		a.push_back(ta - 1);
		b.push_back(tb - 1);
		c.push_back(tc);
		d.push_back(td);
	}

	for (int i = 1; i <= M; i++){
		calc({1, i});
	}
	cout << ans << endl;
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << ((H2 * 60 + M2) - (H1 * 60 + M1) - K) << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a,A=0,B=0,O=0,AB=0;
    char c[10]={0};
    while(scanf("%d,%s",&a,c) != EOF )
    {
        if(strlen(c)==2)AB++;
        else if(c[0]=='B')B++;
        else if(c[0]=='O')O++;
        else A++;
    }
    cout<<A<<endl<<B<<endl<<AB<<endl<<O<<endl;
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXK = 100 * 1000 + 10;
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAXN = 101;
int nbPossibles[MAXN][MAXK];
int32_t main()
{
	int N , K;
	cin >> N >> K;
	nbPossibles[0][0] = 1;
	for (int i = 1 ; i <= N ; i++)
	{
		int actu;
		cin >> actu;
		int tot = 0;
		for (int j = 0 ; j <= K ; j++)
		{
			tot = (tot + nbPossibles[i - 1][j]) % MOD;
			if (j > actu)
				tot = (tot - nbPossibles[i - 1][j - actu - 1] + MOD) % MOD;
			nbPossibles[i][j] = tot;			
		}
	}
	cout<<nbPossibles[N][K]<<endl;

}

Measured memory_bytes: 78336
N,M=map(int,input().split())

lists = [[] for _ in range(N)]
items = [list(map(int, input().split())) for _ in range(M)]
for p, y in items:
  lists[p-1].append(y)

dic = {}

for n in range(N):
  lists[n].sort()  

for n in range(N):
  l = lists[n]
  count = 1
  for i in l:
    dic[i] = count
    count+=1

for p, y in items:
  print("{:06g}{:06g}".format(p,dic[y]))

Measured memory_bytes: 47332
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  int r, g, b;
  cin >> r >> g >> b;

  int x = 100 * r + 10 * g + b;
  if (x % 4 == 0) {
	cout << "YES" << endl;
  }
  else {
	cout << "NO" << endl;
  }

  return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<pair<ll, int>> vv(A+B+C);
  rep(i, A) {
    int p; cin >> p;
    vv[i] = mp(p, 1);
  }
  rep(i, B) {
    int p; cin >> p;
    vv[A+i] = mp(p, 2);
  }
  rep(i, C) {
    int p; cin >> p;
    vv[A+B+i] = mp(p, 3);
  }
  
  sort(all(vv));
  reverse(all(vv));
  
  ll arem = X;
  ll brem = Y;
  ll ccoms = 0;
  ll sum = 0;
  rep(i, A+B+C) {
    pair<ll,ll> p = vv[i];
    if(p.second == 1) {
      if(arem > 0 && arem + brem - ccoms > 0) {
        sum += p.first;
        arem--;
      }
      //残なしは追加しない
    } else if(p.second == 2 && arem + brem - ccoms > 0) {
      if(brem > 0) {
        sum += p.first;
        brem--;
      }
    } else {
      if(arem + brem - ccoms > 0) {
        ccoms++;
        sum += p.first;
      }
    }
  }
  fin(sum);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main()
{
	cin >> s >> n;
	string t;
	REP(i, s.size())
	{
		if (n == 0) {
			continue;
		} else {
			if (26 - s[i] + 'a' <= n) {
				if (s[i] != 'a') {
					n -= 26 - s[i] + 'a';
				}
				s[i] = 'a';
			}
		}
	}
	if (n != 0) {
		if (s[s.size() - 1] + n > 'z') {
			ll b = (s[s.size() - 1] + n - 'a');
			b %= 26;
			if (b == 0) {
				s[s.size() - 1] = 'a';
			} else {
				s[s.size() - 1] = 'a' + b;
			}
		} else {
			ll b = (s[s.size() - 1] + n - 'a');
			b %= 26;
			if (b == 0) {
				s[s.size() - 1] = 'a';
			} else {
				s[s.size() - 1] = 'a' + b;
			}
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 512
N=int(input())
S1=list(input())
S2=list(input())
mod=1000000007

ty=[]
i=0
while i<N:
  if S1[i]==S2[i]:
    ty.append(1)
    i+=1
  else:
    ty.append(0)
    i+=2
    
if ty[0]==0:
  ans=6
else:
  ans=3
  
for i in range(1,len(ty)):
  if ty[i-1]==0:
    if ty[i]==0:
      ans=(ans*3)%mod
  else:
    ans=(ans*2)%mod
    
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug cout<<"!"<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
//#define int long long


signed main(){
  string s;
  int k;
  cin>>s>>k;
  int cnt=0;
  vector<string> ans;
  ans.push_back("");
  rep(i,s.size() ){
    repi(j,1,k+1){
      if(i+j > s.size() ) break;
      ans.push_back(s.substr(i,j) );
    }
  }
  sort(ans.begin(),ans.end() );
  rep(i,ans.size()){
    if(ans[i]!=ans[i+1]) cnt++;
    //cout<<ans[i+1]<<endl;
    if(cnt==k){cout<<ans[i+1]<<endl;break;}
  }
  return 0;
}


Measured memory_bytes: 1660
s=str(input())
if s=='RRR':
    print(3)
if s=='RRS':
    print(2)
if s=='RSR':
    print(1)
if s=='SRR':
    print(2)
if s=='RSS':
    print(1)
if s=='SRS':
    print(1)
if s=='SSR':
    print(1)
if s=='SSS':
    print(0)


Measured memory_bytes: 9104
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<vector<pair<int, int>>> vt;
int n, m;
int visited[100010];
int check[100010];
int indegree[100010];
int update = 0;
void dfs(int here, int cst)
{
	visited[here] = 1;
	check[here] = cst;
	for (int i = 0; i < vt[here].size(); i++)
	{
		int next = vt[here][i].first;
		int ncst = vt[here][i].second;
		if (!visited[next])
			dfs(next, cst + ncst);
		else
		{
			if (check[next] != check[here] + ncst)
				update = 1;
		}
	}
}
int main()
{
	scanf("%d %d", &n, &m);
	vt.resize(n + 1);
	for (int i = 0; i < m; i++)
	{
		int q, w, e;
		scanf("%d %d %d", &q, &w, &e);
		vt[q].push_back({ w,e });
		indegree[w]++;
	}
	for (int i = 1; i <= n; i++)
	{
		if (!indegree[i])
			dfs(i, 0);
	}
	for (int i = 1; i <= n; i++)
	{
		if (!visited[i])
			dfs(i, 0);
	}
	if (update)
		puts("No");
	else
		puts("Yes");
}

Measured memory_bytes: 11520
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    cin >> x;
    for (ll i = -1000; i <= 1000; i++) {
        for (ll j = -1000; j <= 1000; j++) {
            if (i * i * i * i * i - j * j * j * j * j == x) {
                cout << i << ' ' << j;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>>
using namespace std;

long long a[200005];
int main()
{
    int n;
    scanf("%d",&n);
    long long s=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        s+=a[i];
    }
    long long ss=0;
    ss+=a[1];
    s-=a[1];
    long long x=fabs(ss-s);
    for(int i=2;i<=n-1;i++)
    {
        ss+=a[i];
        s-=a[i];
        if(fabs(ss-s)<x)
                x=fabs(ss-s);
    }
        printf("%lld\n",x);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n;
  	cin>>n;
  	int i,a[n];
  	for(i=0;i<n;i++)
  	{
  		cin>>a[i];
	}
	int ans=0;
	for(i=0;i<n;)
	{
		int j=i+1;
		while(j<n && a[j]<=a[j-1])
		{
			j++;
		}
		//cout<<j<<" "<<i<<" "<<j-i<<endl;
		ans=max(ans,j-i-1);
		i=j;
	}
	cout<<ans;
  	return 0;
}

Measured memory_bytes: 640
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<ll> I;
    char b = S[0];
    I.pb(0);
    rep (i, N) {
        if (b != S[i]) {
            b = S[i];
            I.pb(i);
        }
    }
    I.pb(N);

    ll ans = 0;
    rep (i, I.size()) {
        if (S[I[i]] == '0') {
            ans = max(ans, I[min((ll)I.size() - 1, i + 2 * K)] - I[i]);
        } else {
            ans = max(ans, I[min((ll)I.size() - 1, i + 2 * K + 1)] - I[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1528
import java.util.Arrays;
import java.util.Scanner;

class Main {
	double[][] p = new double[2][6];

	void run() {
		Scanner sc = new Scanner(System.in);
		int Na = sc.nextInt();
		int Nb = sc.nextInt();
		long[] xa = new long[Na];
		long[] ya = new long[Na];
		long[] xb = new long[Nb];
		long[] yb = new long[Nb];
		for (int i = 0; i < Na; ++i) {
			xa[i] = sc.nextLong();
			ya[i] = sc.nextLong();
		}
		for (int i = 0; i < Nb; ++i) {
			xb[i] = sc.nextLong();
			yb[i] = sc.nextLong();
		}

		double ans = Double.MAX_VALUE / 3;
		for (int t = 0; t < 2; ++t) {
			for (int i = 0; i < Na; ++i) {
				for (int j = 0; j < Na; ++j) {
					if (cross(xa[0], ya[0], xa[i], ya[i], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[i], ya[i], xa[j], ya[j], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					ans = Math.min(ans, dist(xa[0], ya[0], xa[i], ya[i]) + dist(xa[i], ya[i], xa[j], ya[j])
							+ dist(xa[j], ya[j], xa[1], ya[1]) + dist(xb[0], yb[0], xb[1], yb[1]));
				}
			}
			Na ^= Nb;
			Nb ^= Na;
			Na ^= Nb;
			long[] tmp = new long[Na];
			tmp = Arrays.copyOf(xa, xa.length);
			xa = Arrays.copyOf(xb, xb.length);
			xb = Arrays.copyOf(tmp, tmp.length);
			tmp = Arrays.copyOf(ya, ya.length);
			ya = Arrays.copyOf(yb, yb.length);
			yb = Arrays.copyOf(tmp, tmp.length);
		}
		System.out.println(ans >= Double.MAX_VALUE / 4 ? "-1" : ans);
	}

	double dist(long xa, long ya, long xb, long yb) {
		long dx = xa - xb;
		long dy = ya - yb;
		return Math.sqrt(dx * dx + dy * dy);
	}

	boolean cross(long xa1, long ya1, long xb1, long yb1, long xa2, long ya2, long xb2, long yb2) {
		long v = f(xa1, ya1, xb1, yb1, xa2, ya2) * f(xa1, ya1, xb1, yb1, xb2, yb2);
		long u = f(xa2, ya2, xb2, yb2, xa1, ya1) * f(xa2, ya2, xb2, yb2, xb1, yb1);
		return v <= 0 && u <= 0;
	}

	long f(long xa, long ya, long xb, long yb, long x, long y) {
		return (ya - yb) * (x - xa) - (y - ya) * (xa - xb);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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


Measured memory_bytes: 36188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
  cin>>a>>b>>c;
  if(max({a,b,c})==a+b+c-max({a,b,c})){
    cout<<"Yes"<<endl;    
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if a[len(a) - 1] == b[0] && b[len(b) - 1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512