akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
    int n,val;
    cin>>n;
    set<char> s;
    for(int i=n;;i++){
	  	string a=to_string(i);
	  	for(auto it:a)s.insert(it);
	  	if((int)s.size()==1){
		   val=i;
		   break;
		 }
		 s.clear();
	}
	cout<<val<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	long A,B,C,D,E,F;
	while(scanf("%ld%ld%ld%ld",&A,&B,&C,&D)!=EOF)
	{
	E=A*B;
	F=C*D;
	if(E>=F)
	printf("%ld\n",E);
	else
	printf("%ld\n",F);		
	}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  char mark[n];
  int num[n];
  int S[13];
  int H[13];
  int C[13];
  int D[13];
  for(int i = 0;i < 13;i++){
    S[i]=i+1;
    H[i]=i+1;
    C[i]=i+1;
    D[i]=i+1;
  }

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

  for(int i = 0;i < n;i++){
    if(mark[i] == 'S'){
      for(int j = 0;j < 13;j++){
        if(num[i]==S[j]){
          S[j]=0;
        }
      }
    }
    if(mark[i] == 'H'){
      for(int j = 0;j < 13;j++){
        if(num[i]==H[j]){
          H[j]=0;
        }
      }
    }
    if(mark[i] == 'C'){
      for(int j = 0;j < 13;j++){
        if(num[i]==C[j]){
          C[j]=0;
        }
      }
    }
    if(mark[i] == 'D'){
      for(int j = 0;j < 13;j++){
        if(num[i]==D[j]){
          D[j]=0;
        }
      }
    }
  }
  for(int i = 0;i < 13;i++){
    if(S[i]!=0){
      cout<<"S "<<S[i]<<endl;
    }
  }
  for(int i = 0;i < 13;i++){
    if(H[i]!=0){
      cout<<"H "<<H[i]<<endl;
    }
  }
  for(int i = 0;i < 13;i++){
    if(C[i]!=0){
      cout<<"C "<<C[i]<<endl;
    }
  }
  for(int i = 0;i < 13;i++){
    if(D[i]!=0){
      cout<<"D "<<D[i]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;
int main(){
    string a;
    cin>>a;
    bool ans = false;
    for(int i =0;i<3;i++){
        if(a[i]-'0'==7){
            ans = true;
        }
    }
    if(ans == true){
        cout<<"Yes"<<nl;
    }else{
    cout<<"No"<<nl;}
}


Measured memory_bytes: 3636
#! /usr/bin/env python


class NodeBintree:

    def __init__(self, key, parent=None):
        self.key = key
        self.left = None
        self.right = None

    def insert_node (self, n):
        if (self.key is None) or (self.key > n.key):
            if self.left is None:
                self.left = n
            else:
                self.left.insert_node(n)
        else:
            if self.right is None:
                self.right = n
            else:
                self.right.insert_node(n)
    def find (self, key):
        if self.key is None:
            return self.left.find(key)
        elif self.key == key:
            return "yes"
        elif self.key > key:
            if self.left is None:
                return "no"
            else:
                return self.left.find(key)
        else:
            if self.right is None:
                return "no"
            else:
                return self.right.find(key)

    def traverse_inorder (self):
        ret = ""

        if self.left is not None:
            ret += self.left.traverse_inorder()

        if self.key is not None:
            ret += " {0}".format(self.key)

        if self.right is not None:
            ret += self.right.traverse_inorder()

        return ret

    def traverse_preorder (self):
        ret = ""

        if self.key is not None:
            ret += " {0}".format(self.key)

        if self.left is not None:
            ret += self.left.traverse_preorder()

        if self.right is not None:
            ret += self.right.traverse_preorder()

        return ret

def proc_inputs ():
    num_inputs = int(input())
    inputs = [proc_command(input().split()) for i in range(num_inputs)]
    return inputs

def proc_command (l):
    if len(l) > 1:
        arg = l[1]
    else:
        arg = None
    return {"command": l[0], "arg": arg}

def execute_command (tree, command):
    if command["command"] == "insert":
        tree.insert_node(NodeBintree(int(command["arg"])))

    elif command["command"] == "find":
        print(tree.find(int(command["arg"])))

    elif command["command"] == "print":
        print(tree.traverse_inorder() )
        print(tree.traverse_preorder() )

    return


def main ():
    inputs = proc_inputs()
    tree = NodeBintree(None)
    for command in inputs:
        execute_command(tree, command)
    exit(0)


if __name__ == "__main__":
    main()



Measured memory_bytes: 274812
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	VE a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			if (i >= j)continue;
			if (a[i] > a[j]) {
				ans += k; ans %= MOD;
			}
		}
	}
	int tmp = 0;
	rep(i, n) {
		rep(j, n) {
			if (i == j)continue;
			if (a[i] > a[j])tmp++;
		}
	}
	ans += (tmp * ((k*(k - 1) / 2) % MOD)) % MOD;
	cout << ans % MOD << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

a_b = []
for i in A:
    this_b = []
    this_a = i
    for j in range(59,-1,-1):
        j2 = 2**j
        if this_a >= j2:
            this_b.append(1)
            this_a -= j2
        else:
            this_b.append(0)
    a_b.append(this_b)
    
#print(a_b)

count_a_b = []
for i in range(60):
    count_a_b.append(0)

    
for i in a_b:
    for j in range(len(i)):
        count_a_b[j] += i[j]
#print(count_a_b)

count = 0
for i in range(len(count_a_b)):
    count += (count_a_b[i] * (N-count_a_b[i])) *2**(59-i)
    
print(count%(10**9+7))

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll dp[62][2][2][2];

ll solve(ll L,ll R){
	dp[61][0][0][0]=1;
	for(int i=60;i>=0;i--)rep(j,2)rep(k,2)rep(t,2){
		int bit=R>>i&1;
		int lim=(k?1:bit);
		for(int l=0;l<=lim;l++){
			int bit2=L>>i&1;
			int lim2=(t?0:bit2);
			if(l==1&&j==0)lim2=1;
			for(int m=lim2;m<=l;m++){
				(dp[i][j||l][k||l<bit][t||bit2<m]+=dp[i+1][j][k][t])%=MOD;
			}
		}
	}
	ll ans=0;
	rep(j,2)rep(k,2)rep(t,2){
		(ans+=dp[0][j][k][t])%=MOD;
	}
	return ans;
}
int main(){
	ll l,r;cin>>l>>r;
	cout<<solve(l,r)<<endl;
}

Measured memory_bytes: 256
from collections import*
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
for v,w,c in zip(t[::3],t[1::3],t[2::3]):
  e[v-1].append((w-1,c))
  e[w-1].append((v-1,c))
q=deque([(0,0)])
f=[0]+[-1]*~-n
while q:
  v,c=q.pop()
  for w,d in e[v]:
    if-1<f[w]:continue
    d=(c+d)%2
    f[w]=d
    q.append((w,d))
print(*f,sep='\n')

Measured memory_bytes: 50284
using System;

namespace ABC100_3
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            string[] str = Console.ReadLine().Split();
            int slash2 = 0;
            foreach(string ai in str)
            {
                int i;
                for(i = 1; ; i++)
                {
                    if(Int32.Parse(ai) % Math.Pow(2,i) != 0)
                    {
                        break;
                    }
                }
                slash2 += (i - 1);
            }
            Console.WriteLine(slash2);
        }
    }
}

Measured memory_bytes: 13792
# include <bits/stdc++.h>
# define rr
# define int long long
const int N=100010,INF=0x3f3f3f3f;
int n;
int v[N],p[N],cnt;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
signed main(void){
	n=read();
	int m=n;
	for(rr int i=2;i*i<=n;++i){
		if(m%i==0){
			v[++cnt]=i;
			while(m%i==0){
				++p[cnt];
				m/=i;
			}
		}
	}
	if(m>1){
		v[++cnt]=m,p[cnt]=1;
	}
	int ans=0;
	for(rr int i=1;i<=cnt;++i){
		int l=0,r=p[i],tot;
		while(l<=r){
			int mid=(l+r)>>1;
			if((1+mid)*mid/2<=p[i]){
				tot=mid;
				l=mid+1;
			}else{
				r=mid-1;
			}
		}
		ans+=tot;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
map<char , int>m;
char c;
int n;
long long sum;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> c;
		m[c]++; 
	}
	sum = 1;
	for(char i = 'a' ; i <= 'z' ; i++){
		sum *= (m[i] + 1);
		sum %= mod;
	}
	cout << sum - 1 << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define mp make_pair
#define pb push_back
#define f first
#define s second
const ll mod=998244353;
const ll N=2e5+5;
unordered_map<ll,vector<ll>> adj;
vector<ll> vis(300005,0);
vector<ll> p(100005,0);
ll c[100005];
ll cnt;
ll n;
void dfs(ll node)
{
  if(vis[node])
    return;
  vis[node]=1;
  cnt++;
  for(auto i:adj[node])
    {
      dfs(i);
    }
}
struct range{
  ll l;
  ll r;
  ll index;
};
bool cmp(range& p1,range& p2)
{
     return p1.l<p2.l;
}
int main()
{
   ll i,n;
   cin>>n;
   ll temp=n-1;
   ll cnt=0;
   for(i=1;i<=n-1;i++)
   {
        cnt+=temp/i;
   }
   cout<<cnt;
}

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

int main() {
	ll n;
	cin>>n;
	vector<int>a(1);
	a[0]=1;
	if(n==1){
		cout <<1;
		return 0;
	}
	for(int i=1;a[i]<1000000000;i++){
		a.push_back( (i+1)+a[i-1] );
		if(a[i]>=n){
			cout<<i+1;
			return 0;
		}
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a, b, c;
  cin >> a >> b >> c;
  double y = b * sin(c * M_PI/180);
  double ans2 = a * y * 0.5;
  double x = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c * M_PI/ 180);
  double ans1 = pow(x, 0.5) + a + b;
  cout << fixed << setprecision(15) << ans2 <<' '<< fixed << setprecision(15) << ans1 << ' ';
  cout <<fixed << setprecision(15) <<y<<endl;
}


Measured memory_bytes: 3612
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;


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

    string n;
    cin >> n;
    cout << (n[n.size()-1] == 's'?(n+"es"):(n+"s"));

}


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

int main(){
	int n, k;
	double ans = 0.0;
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; ; j++){
			if((double)i * pow(2.0, (double)j) >= k) {
				ans += pow(0.5, (double)j);
				break;
			}
		}
	}
	
	ans /= (double)n;
	printf("%.12f\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define NOT_FREE 10
#define FREE -10
#define MAX 8

int col[MAX],dpos[MAX*2],dneg[MAX*2],N=MAX,row[MAX],R[MAX],finish=0;

void printBord()
{
  int i,j;

  for(i = 0 ; i < N ; i++)
    {
      for(j = 0 ; j < N ; j++)
	{
	  if(row[i] == j)
	    {
	      printf("Q");
	    }
	  else printf(".");
	}
      printf("\n");
    }
  
  finish = 1;
  
  return;
}

void putQueen(int i)
{
  int j;
  
  if(i == N)
    {
      printBord();
      return;
    }

  for(j = 0 ; j < N ; j++)
    {
      if(i != R[i] && (col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE)) continue;


      if(i != R[i])
	{
	  row[i] = j;
	  col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
	}
      
      putQueen(i+1);

      if(finish) return;
      
      if(i != R[i]) col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }

  return;
}

int main()
{
  int k,i,j,r,c;

  scanf("%d",&k);

  for(i = 0 ; i < N ; i++) //初期化
    {
      R[i] = row[i] = col[i] = FREE;

      for(j = 0 ; j < N ; j++)
	{
	  dpos[i+j] = dneg[i-j+N-1] = FREE;
	}
    }

  for(i = 0 ; i < k ; i++)
    {
      scanf("%d %d",&r,&c);

      R[r] = r;
      
      row[R[r]] = c;
      col[c] = dpos[R[r]+c] = dneg[R[r]-c+N-1] = NOT_FREE;
    }
 
  putQueen(0);

  return 0;
}



Measured memory_bytes: 2104
package main

import "fmt"

func main() {
	var n, t, c, tt int
	fmt.Scan(&n, &t)
	minc := 1001
	for i := 0; i < n; i++ {
		fmt.Scan(&c, &tt)
		if tt <= t && minc > c {
			minc = c
		}
	}
	if minc != 1001 {
		fmt.Println(minc)
		return
	}
	fmt.Println("TLE")
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int N;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    int sum = 0,a;
    REP(i,N){
        cin >> a;
        sum += a;
    }
    cout << sum - N  << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
string s;
long long k, a, b, c;
int main()
{
    cin >> s >> k;
    s += s+s;
    for(int i = 1; i < s.length(); i++) {
        if(s[i] == s[i-1]) {
            if(i < s.length() / 3) a++;
            else if(i < s.length() / 3 * 2) b++;
            else c++;
            i++;
        }
    }
    if(a == c) cout << (k+1)/2*a + k/2*b;
    else cout << a + (k-1)*b;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	int t = N % 10;
	if(t == 3) cout<<"bon"<<endl;
	else if(t == 0 || t == 1 || t == 6 || t == 8) cout<<"pon"<<endl;
	else cout<<"hon"<<endl;
}

Measured memory_bytes: 3628
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m,k=nii()

for i in range(n+1):
  for j in range(m+1):
    if m*i+n*j-i*j*2==k:
      print('Yes')
      exit()

print('No')

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;
constexpr int B = 18;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int n;
  cin >> n;
  vector<int> ts(n);  // Twos
  vector<int> fs(n);  // Fives
  for (int i = 0; i < n; i++) {
    long double d;
    cin >> d;
    d *= 1E9;
    int64 x = roundf64x(d);
    // cout << x << endl;
    while (x % 2 == 0) {
      x /= 2;
      ts[i]++;
    }
    while (x % 5 == 0) {
      x /= 5;
      fs[i]++;
    }
  }

  auto count_table = Make2DVector<int64>(B + 1, B + 1, 0LL);
  for (int i = 0; i < n; i++) {
    count_table[min(ts[i], B)][min(fs[i], B)]++;
  }
  auto c_sum_table = Make2DVector<int64>(B + 1, B + 1, 0LL);
  for (int i = B; i >= 0; i--) {
    for (int j = B; j >= 0; j--) {
      c_sum_table[i][j] += count_table[i][j];
      if (i + 1 <= B) c_sum_table[i][j] += c_sum_table[i + 1][j];
      if (j + 1 <= B) c_sum_table[i][j] += c_sum_table[i][j + 1];
      if (i + 1 <= B && j + 1 <= B) c_sum_table[i][j] -= c_sum_table[i + 1][j + 1];
    }
  }

  int64 ans = 0;
  for (int i = 0; i < n; i++) {
    int t = max(B - ts[i], 0);
    int f = max(B - fs[i], 0);
    ans += c_sum_table[t][f];
    if (ts[i] >= 9 && fs[i] >= 9) ans--;
  }
  ans /= 2;
  cout << ans << endl;
}

Measured memory_bytes: 4868
#include "bits/stdc++.h"
using namespace std;
const long long inf = 4e18;

long long w[100010];
int d[100010];
int n, k;
long long count(long long x) {
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		if(x >= w[i]) {
			ans += (x - w[i]) / d[i];
			ans += 1;
			if(ans >= k) return k;
		}
	}
	return ans;
}
long long search(long long b, long long e) {
	if(b == e) {
		return b;
	}
	long long m = (b + e) >> 1;
	if(count(m) >= k) return search(b, m);
	else return search(m + 1, e); 
}

int main(int argc, char const *argv[])
{
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++) {
		scanf("%lld %d", &w[i], &d[i]);
	}
	printf("%lld\n", search(0, inf));
	return 0;
}

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

using namespace std;
using i64 = __int128_t;

signed main(){
    vector<i64> p2;
    p2.push_back(1);
    for(i64 i = 0;i < 70;i++){
        p2.push_back(p2.back()*2);
    }
    long long n2;
    while(cin >> n2){
        if(n2 == 0)
            return 0;
        i64 n = n2;
        --n;
        i64 dig = 0;
        i64 sum = 0;
        for(dig = 1;sum <= n;dig++){
            sum += 81 * (p2.at(dig) - 1);
        }
        sum -= 81 * (p2.at(dig - 1) - 1);
        
        n -= sum;
        string ans(dig, '?');
        bitset<10> use;
        for(i64 i = dig - 1; i >= 0; --i){
            if(use.count() == 0){
                for(i64 j = 1; j < 10; ++j){
                    i64 cnt = 9 * (p2[i] - 1);
                    if(n < cnt){
                        ans[i] = j + '0';
                        use.set(j);
                        break;
                    }else{
                        n -= cnt;
                    }
                }
                assert(ans[i] != '?');
            }else if(use.count() == 1){
                for(i64 j = 0; j < 10; ++j){
                    i64 cnt;
                    if(use[j])
                        cnt = 9 * (p2[i] - 1);
                    else
                        cnt = p2[i];
                    if(n < cnt){
                        ans[i] = j + '0';
                        use.set(j);
                        break;
                    }else{
                        n -= cnt;
                    }
                }
                if(ans[i] == '?'){
                    reverse(ans.begin(), ans.end());
                }
                assert(ans[i] != '?');
            }else{
                if(n < p2[i]){
                    for(i64 j = 0; j < 10; ++j){
                        if(use[j]){
                            ans[i] = j + '0';
                            break;
                        }
                    }
                }else{
                    n -= p2[i];
                    bool f = false;
                    for(i64 j = 0; j < 10; ++j){
                        if(use[j]){
                            if(!f)
                                f = true;
                            else{
                                ans[i] = j + '0';
                                break;
                            }
                        }
                    }
                }
                assert(ans[i] != '?');
            }
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
 
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);
 
using namespace std;

const int mod=1e9+7;
const int maxn=100010;

int a[maxn],b[maxn];
 
int main()
{
	IOS;
	int n;
	cin>>n;
	for (int j=1;j<=n;++j)
		cin>>a[j];
	for (int j=1;j<=n;++j)
		cin>>b[j];
	LL ans=1;
	for (int j=1;j<=n;++j)
	{
		if (a[j]<a[j-1]||b[j]<b[j+1]) ans=0;
		else if (a[j]>a[j-1]&&b[j]>b[j+1]&&a[j]!=b[j]) ans=0;
		else if (a[j]>a[j-1]&&a[j]>b[j]) ans=0;
		else if (b[j]>b[j+1]&&b[j]>a[j]) ans=0;
		else if (a[j]==a[j-1]&&b[j]==b[j+1]) ans*=(LL)min(a[j],b[j]);
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7
#s=input().rstrip()
a,b,c,d=MI()
for i in range(1000):
    c-=b
    a-=d
    if c<=0:
        print("Yes")
        sys.exit()
    elif a<=0:
        print("No")
        sys.exit()

Measured memory_bytes: 9504
#include <iostream>
#include <cstdio>

using namespace std;

int n, m, cnt;
int a[100005];
int b[100005];

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
    {
        a[i] = 1;
    }
    b[1] = 1;
    for(int i = 1; i <= m; i++)
    {
        int t1, t2;
        scanf("%d%d", &t1, &t2);
        a[t1]--, a[t2]++;
        if(a[t1] == 0 && b[t1] == 1) b[t1] = 0, b[t2] = 1;
        else if(b[t1] == 1) b[t2] = 1;
    }
    for(int i = 1; i <= n; i++)
    {
        if(b[i]) cnt++;
    }
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 1024
# B - Nice Shopping
def main():
    A, B, M, *ABX = map(int, open(0).read().split())
    fridges, microwaves, X = ABX[:A], ABX[A : A + B], ABX[A + B :]
    with_tickets = min(
        fridges[x - 1] + microwaves[y - 1] - c for x, y, c in zip(*[iter(X)] * 3)
    )
    without_tickets = min(fridges) + min(microwaves)
    print(min(with_tickets, without_tickets))


if __name__ == "__main__":
    main()


Measured memory_bytes: 55940
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int N;
  ll a = 0;
  ci(N);
  ve<ll> A(N + 1), B(N);
  rep(i, N + 1){
    ci(A.at(i));
  }
  rep(i, N){
    ci(B.at(i));
  }
  rep(i, N){
    a += min(A.at(i) + A.at(i + 1), B.at(i));
    if(A.at(i) - B.at(i) < 0){
      if(A.at(i + 1) > B.at(i) - A.at(i)){
        A.at(i + 1) -= B.at(i) - A.at(i);
      }
      else if (A.at(i + 1) <= B.at(i) - A.at(i)){
        A.at(i + 1) = 0;
      }
    }
  }
  co(a);
}

Measured memory_bytes: 1792
from bisect import bisect

n=int(input())
a=[0]*n
for i in range(n):
    a[i]=-int(input())

def loopa():

    n=len(a)
    dp = [10**10]*(n+1)
    dp[0] = -10**10
    
    for i in range(n):
        idx = bisect(dp, a[i])
        dp[idx] = min(a[i], dp[idx])

    return dp

dp=loopa()        

print(bisect(dp, 10**10-1)-1)    



Measured memory_bytes: 13608
n = int(input())
table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    table[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" %s" % " ".join(map(str, table[i][j])))
    if i < 3:
        print("#"*20)



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

int main()
{
    long long int A;
    string B;
    cin >> A >> B;
    long long int B_100 = int(B[0]-'0')*100 + int(B[2]-'0')*10 + int(B[3]-'0');
    long long int ans = A * B_100 / 100;
    cout << ans << endl;
    return 0;
}

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

string q,b="CF"; //打表
int al,bl;

int main(){
    getline(cin,q);
    al=q.length();
    for(int i=0;i<al;i++)
        if(q[i]==b[bl]){ //当找到一个的时候加一
            bl++;
            if(bl==2)   //都找到的时候就退出
                break;
        }
    if(bl==2) cout<<"Yes"; //判断并且输出
    else cout<<"No";
    cout<<endl;//最后不要忘了打个换行
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A1,A2,A3;
    scanf("%d %d %d",&A1,&A2,&A3);
    A1+A2+A3;
    if(A1+A2+A3>=22)
        printf("bust\n");
    else
        printf("win\n");
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll binpow(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1)
            res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    cout<<binpow(n,3)<<endl;
    return 0;
}


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


public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println((n*(n+1))/2);
        
        
        
        
        
        
        //System.out.println()
        //for(int i=0;i<n;i++)
     }
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);

  ll ans=0;
  rep(i,n-1){
    ans += max(0ll, a[i]-a[i+1]);
    if(a[i]-a[i+1]>0){
      a[i+1] = a[i];
    }
  }
  prt(ans);
}


Measured memory_bytes: 4784
#include <stdio.h>

int main(void){
    int n=0;
    int i;
    int v;
    int persons[5][4][11];
    int b;
    int f;
    int r;

    for(b=0;b<5;b++){
        for(f=0;f<4;f++){
            for(r=0;r<11;r++){
                persons[b][f][r]=0;
            }
        }
    }

    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&b);
        scanf("%d",&f);
        scanf("%d",&r);
        scanf("%d",&v);
        persons[b][f][r]=persons[b][f][r]+v;
    }

    for(b=1;b<=4;b++){
        for(f=1;f<=3;f++){
            for(r=1;r<=10;r++){
                printf(" %d",persons[b][f][r]);
            }
            printf("\n");
        }
        if(b!=4){
            printf("####################\n");
        }
    }


    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    string S, T;
    cin >> S >> T;

    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        if (S[i] == T[i]) ++cnt;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,c,s=0,l,r,b[25];
    cin>>n>>m>>c;
    for(i=0;i<m;i++)
    {
        cin>>b[i];
    }
    for(i=0;i<n;i++)
    {
        ll ss=0;
        for(j=0;j<m;j++)
        {
            cin>>l;
            ss+=l*b[j];
        }
        ss+=c;
        if(ss>0)
        {
            s++;
        }
    }
    cout<<s<<"\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll h,w,k;cin>>h>>w>>k;
  char s[h][w];rep(i,0,h)rep(j,0,w)cin>>s[i][j];

  ll ans=m;

  rep(bit,0,(1<<(h-1))){
    bool can=true;
    ll cnt=0;//flg
    vector<ll>ord(h,0);
    rep(i,0,h-1){
      if(!(bit&(1<<i)))ord[i+1]=ord[i];
      else ord[i+1]=ord[i]+1,cnt++;
    }

    ll add=0;
    vector<ll>nums(cnt+1,0);
    rep(j,0,w){
      vector<ll>one(cnt+1,0);
      bool ok=true;
      rep(r,0,h){
        one[ord[r]]+=s[r][j]-'0';
        nums[ord[r]]+=s[r][j]-'0';
        if(one[ord[r]]>k)can=false;
        if(nums[ord[r]]>k)ok=false;

      }
      if(!ok)add++,nums=one;//切る(+1)
    }
    if(can)chmin(ans,cnt+add);
  }

  out(ans);


  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

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

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll t; cin >> t;
		if (t == ans + 1) {
			ans++;
		}
	}
	cout << (ans ? n - ans : -1) << endl;
	return 0;
}

/*

*/

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int n, a[112345];
int a_c[112345], same_num, l, r;

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL &x, LL &y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x%m) % m;
}

// 階乗
LL fact[112345];
void mod_fact(LL n, LL m)
{
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) { fact[i] = fact[i - 1] * i%m; }
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) { return 0; }
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

int main()
{
	in >> n;
	rep(i, n + 1) { in >> a[i]; }

	std::copy(a, a + n + 1, a_c);
	std::sort(a_c, a_c + n + 1);
	rep(i, n)
	{
		if (a_c[i] == a_c[i + 1])
		{
			same_num = a_c[i];
			break;
		}
	}
	l = -1; r = -1;
	rep(i, n + 1)
	{
		if (a[i] == same_num)
		{
			if (l == -1) { l = i; }
			else { r = i; }
		}
	}
	mod_fact(n + 4, MOD);

	for (int k = 1; k <= n + 1; ++k)
	{
		LL a = mod_comb(n + 1, k, MOD); LL b = mod_comb(l + n - r, k - 1, MOD);
		a -= b; a = (a%MOD + MOD) % MOD;
		out << a << std::endl;
	}
	return 0;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define sz(x) int((x).size())
#define fi first
#define se second

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))
#define mp(a,b) make_pair(a,b)

// useful bits
#define IN(i,l,r) (i >= l && i <= r);
#define relax(a,b) a = max(a,b);
#define relaxi(a,b) a = min(a,b);

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) 
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(0, i)(rng)



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
//	freopen("output.txt", "w" , stdout);
	/* freopen("in.txt" , "r" , stdin); */
	/* clock_t start = clock(); */
	#endif
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	for(int i = 0 ; i < n -1 ; i ++){
		char c  = s[i] == '0'? '1': '0';
		if(s[i] == s[i+1])
			s[i+1] = c, ans++;
	}
	cout << ans << endl;


	#ifndef ONLINE_JUDGE
	/* cout << setprecision(12) << ld(clock()-start) / CLOCKS_PER_SEC << endl; */
	#endif
	return 0;
}



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

using namespace std;
int main() {
	long long int a, b, c, d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	long long int ac, ad, bc, bd;
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;
	if (ac >= ad && ac >= bc && ac >= bd) {
		cout << ac << endl;
	} else if (ad >= ac && ad >= bc && ad >= bd) {
		cout << ad << endl;
	} else if (bc >= ac && bc >= ad && bc >= bd) {
		cout << bc << endl;
	} else {
		cout << bd << endl;
	}
}


Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using static System.Console;
using static System.Math;
class Simple {
    void Solve() {
        var A = io.Int;
        var B = io.Int;
        var K = io.Int;
        var ans = new List <int>();
        for(int i = A, cnt = 0; i < B && cnt < K; ++i,++cnt)
            ans.Add(i);
        for(int i = B, cnt = 0; i >= A && cnt < K; --i,++cnt)
            ans.Add(i);
        foreach(var VARIABLE in ans.Distinct().OrderBy(x => x)) {
            WriteLine(VARIABLE);
        }
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


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

#define int long long

#define For(i,a,b) for (int i = a; i <= (b); ++i)
#define For2(i,a,b) for (int i = a; i >= (b); --i)

#define test int _t; cin >> _t; while (_t--)

#define pii pair<int, int>
#define mpii map<int, int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define sz(a) (int)a.size()

#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define INF 2147483647
#define EPS 1e-9

//#define FILEOPEN

using namespace std;

int cntS[100005], cntT[100005];

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#ifdef FILEOPEN
		freopen("input.in", "r", stdin);
		freopen("input.out", "w", stdout);
	#endif
	string s, t;
	cin >> s >> t;
	cntS[0] = 0;
	For(i,1,sz(s)) cntS[i] = cntS[i - 1] + (s[i - 1] == 'B' ? 1 : 2); 
	For(i,1,sz(t)) cntT[i] = cntT[i - 1] + (t[i - 1] == 'B' ? 1 : 2); 
	int q;
	cin >> q;
	while (q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		// a--; b--; c--; d--;
		//cout << cntS[b] - cntS[a - 1] << endl;
		cout << ((cntS[b] - cntS[a - 1] - cntT[d] + cntT[c - 1]) % 3 == 0 ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 5260
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split('/');
        int y = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        int d = int.Parse(str[2]);
        if (y <=2019)
        {
            if (m <= 4)
            {
                if (d<=30)
                {
                    Console.WriteLine("Heisei");
                }
                else
                    Console.WriteLine("TBD");
            }
            else
                Console.WriteLine("TBD");
        }
        else
            Console.WriteLine("TBD");
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int n;cin>>n;
    vector<int>v;
    int sum=0;int k=0;
    for(int i=1;sum<n;i++){
        sum+=i;
        if(sum==n){
            cout<<"Yes"<<endl;k=i+1;cout<<k<<endl;
        }
        else if(sum>n){
            cout<<"No"<<endl;return 0;
        }
    }
    int used[114514]={};
    int maxi=0;
    rep(i,0,k){
        int count=i;
        cout<<k-1<<" ";
        rep(j,0,count){
            cout<<used[j]+1<<" ";used[j]++;
        }
        int use=0;
        while(count<k-1){
            if(!use)used[i]=maxi;
            use=true;
            count++;cout<<maxi+1<<" ";maxi++;
        }cout<<endl;
    }return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

vector<ll> prime_fac(ll n){
    vector<ll> res;
    for(ll i=2; i*i<=n; i++){
        bool ok=false;
        while(n%i == 0){
            n/=i;
            ok=true;
        }
        if(ok) res.push_back(i);
    }
    if(n != 1) res.push_back(n);
    return res;
}

int main(){
    ll A, B; cin >> A >> B;
    vector<bool> check(1001001, 0);
    vector<ll> fac;
    fac=prime_fac(A);
    ll res=0;
    for(auto &x : fac){
        if(B%x == 0) res++;
    }
    res++;
    cout << res << endl;
    return 0;   
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll cd = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll L, R;
    cin >> L >> R;

    constexpr int N = 60;
    vector<bool> Lbit(N), Rbit(N);
    rep(i, N) Lbit[i] = L >> (N - 1 - i) & 1;
    rep(i, N) Rbit[i] = R >> (N - 1 - i) & 1;
    int LM = 0, RM = 0;
    rep(i, N) {
        if (L >> i & 1) LM = N - 1 - i;
        if (R >> i & 1) RM = N - 1 - i;
    }

    vv<ll> dp = vvec(N, 4, 0LL);
    ll ans = 0;
    rep(m, RM, LM + 1) {
        rep(i, N) rep(r, 4) dp[i][r] = 0;
        dp[m][(m == RM) + 2 * (m == LM)] = 1;
        rep(i, m + 1, N) {
            rep(y, 2) rep(x, 2) rep(a, 2) rep(b, 2) rep(c, 2) rep(d, 2) {
                if (y < x) continue;
                if (a < c) continue;
                if (a != c && y >= Rbit[i]) continue;
                if (a == 1 && c == 1 && y != Rbit[i]) continue;
                if (b < d) continue;
                if (b != d && x <= Lbit[i]) continue;
                if (b == 1 && d == 1 && x != Lbit[i]) continue;
                dp[i][c + 2 * d] += dp[i - 1][a + 2 * b];
                dp[i][c + 2 * d] %= MOD;
            }
        }
        rep(r, 4) ans = (ans + dp[N - 1][r]) % MOD;
    }
    write(ans);
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;
 
using ll = long long;
 
//constant
const double EPS = 1e-10;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
 
//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
 
// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }
 
// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
 
// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
 
 
 
 
// ***************************************
 
 
int main() {
 
    ll N;
    string S;
    cin >> N >> S;

    ll r{}, g{}, b{};

    for(char& c: S){
        if (c == 'R') r++;
        else {
            if (c == 'G') g++;
            else b++;
        }
    }

    ll all = r * g * b;
    ll ans = 0;
    REP(i, N){
        FOR(j, i + 1, N){
            if (S[i] == S[j]) continue;
            int k = 2 * j - i;
            if (k >= N) continue;
            if (S[j] == S[k] || S[k] == S[i]) continue;
            ans++;
        }
    }

    cout << all - ans << endl;
    

    return 0;
}

Measured memory_bytes: 3600