akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <queue>
std::queue<long long> q;
main(){
    int k;scanf("%d",&k);for(register int i=1;i<=9;i++) q.push(i+0ll);
    while(--k){long long x=q.front();q.pop();if(x%10) q.push(10*x+x%10-1);q.push(10*x+x%10);if(x%10!=9) q.push(10*x+x%10+1);}
    return printf("%lld\n",q.front()),0;
}

Measured memory_bytes: 1792
n,k,q = map(int,input().split())
l = []
for i in range(q):
    l.append(int(input()))
s = []
d = {}
for i in l:
    if(i in d):
        d[i]+=1
    else:
        d[i]=1
for i in range(1,n+1):
    if (i in d):
        continue
    else:
        d[i] = 0
for i in range(1,n+1):
    if(k+d[i]-q)>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 19084
#include <iostream>

using namespace std;

int main(){
    int N, M;
    bool red[100000];
    int cnt[100000];
    cin >> N >> M;
    red[0] = true;
    cnt[0] = 1;
    for(int i = 1; i < N; i++){
        red[i] = false;
        cnt[i] = 1;
    }
    bool flag = false;
    for(int i = 0; i < M; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cnt[x]--;
        cnt[y]++;
        if(red[x]) red[y] = true;
        if(cnt[x] == 0) red[x] = false;
        if(x == 0 && !flag) red[x] = false;
        if(y == 0) flag = true;
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(red[i] && cnt[i] > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N,T;
	SCD2(N,T);
	
	static int A[100002];
	
	ARSCD1(A,N);
	
	int buy = A[1];
	int profit = 0;
	int Tc = T/2;
	
	FORq(i,2,N){
		if (buy < A[i]){
			profit = max(profit,(A[i] - buy));
		}else{
			buy = A[i];
		}
	}
	
	set<int> flg;
	
	buy = A[1];
	int buyin = 1;
	
	FORq(i,2,N){
		if (buy < A[i]){
			if ((A[i] - buy) == profit){
				flg.insert(i);
				flg.insert(buyin);
			}
		}else{
			buy = A[i];
			buyin = i;
		}
	}
	
	if (flg.size() % 2 == 0){
		PRINTD(flg.size() / 2);
	}else{
		PRINTD((flg.size() / 2) + 1);
	}
	

	
    
   	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
using namespace std;
int greatest_divisor(int a,int b){
    if(a > b){
        while((a % b) !=0){
            int t = a%b;
            a = b;
            b = t;
        }
        return b;
    }else{
       while((b % a) !=0){
            int t = b%a;
            b = a;
            a = t;
        }
        return a; 
    }
}

int main(){
    int a,b;
    cin>>a>>b;
    
    int res = greatest_divisor(a,b);
    cout<<res<<endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int p[n];
    rep(i, n) { cin >> p[i]; }
    int counter = 0;

    rep(i, n) {
        if (p[i] != i + 1) {
            counter++;
        }
    }

    if (counter == 2 | counter == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    long long int H;
    cin >> N >> H;
    
    vector<long long int> A(N);
    vector<long long int> B(N);
    
    for(int n=0; n<N; n++) {
        cin >> A[n] >> B[n];
    }
    
    sort(A.begin(), A.end(), greater<long long int>());
    sort(B.begin(), B.end(), greater<long long int>());
    
    long long int counter=0;
    for(int bi=0; bi<N; bi++) {
        if(B[bi]<A[0]) break;
        H -= B[bi];
        counter++;
        if(H<=0) {
            cout << counter << endl;
            return 0;
        }
    }

    counter += H/A[0];
    if(H%A[0]!=0) counter++;
    cout << counter << endl;

    return 0;
    
}

Measured memory_bytes: 1792
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<bitset>
#include<queue>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
const int N = 5 * 100*1000 + 7;

int test;

int a,b;

void solve()
{
    cin >> a >> b;

    if (a%b==0){
        cout << -1;
        return;
    }

    for(int i = a; ; i += a){
        if (i%b!=0){
            cout << i;
            return;
        }
    }

    return;
}

int32_t main()
{
    boost

    test=1;

    while(test--)
    {
        solve();
    }

  return 0;
}


Measured memory_bytes: 764
c = [list(map(int,input().split())) for i in range(3)]
if c[0][1]-c[0][0] == c[1][1]-c[1][0] == c[2][1]-c[2][0] and c[0][2]-c[0][1] == c[1][2]-c[1][1] == c[2][2]-c[2][1] and c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2] and c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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 N1, N2, N3, N4;
    cin >> N1 >> N2 >> N3 >> N4;
    vector<bool> b(10, false);
    b[N1] = true;
    b[N2] = true;
    b[N3] = true;
    b[N4] = true;

    if (b[1] && b[9] && b[7] && b[4]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
program main
   integer, allocatable :: i(:, :)
   read(*, *)n
   allocate(i(3, 0:n))
   i(:, 0) = (/0, 0, 0/)
   read(*, *)i(:, 1:n)
   do k = 1, n
      jx = abs(i(2, k) - i(2, k - 1)) + abs(i(3, k) - i(3, k - 1)) 
      jt = i(1, k) - i(1, k - 1)
      if(jx > jt .or. ibits(jx, 0, 1) /= ibits(jt, 0, 1))then
         write(*, *) "No"
         stop
      endif
   enddo
   write(*, *)"Yes"
end


Measured memory_bytes: 1920
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N,K = getNM()
ans = 0
rec = [0] * (K + 1)

for X in range(K, 0, -1):
    rec[X] = pow(K//X, N, mod)
    for i in range(2, K // X + 1):
        rec[X] -= rec[i * X] % mod
    ans += (X * rec[X]) % mod
print(ans % mod)

Measured memory_bytes: 79296
x,y=map(int,input().split())
x_=-x
y_=-y
ans=10**9+6
if x<=y:
  ans=min(ans,y-x)
if x_<=y:
  ans=min(ans,y-x_+1)
if x_<=y_:
  ans=min(ans,y_-x_+2)
if x<=y_:
  ans=min(ans,y_-x+1)
print(ans)  

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

struct Combination{
    vector<ll> fac,finv,inv;
    Combination(int mx){init(mx);}
    void init(int mx){
        fac.resize(mx+1);
        finv.resize(mx+1);
        inv.resize(mx+1);
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for(int i=2;i<=mx;i++){
            fac[i]=fac[i-1]*i%MOD;
            inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
            finv[i]=finv[i-1]*inv[i]%MOD;
        }
    }
    ll calc(int n,int k){
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
    }
};

int main(){
    ll n,m;
    cin>>n>>m;
    ll ans=1;
    Combination comb(1e5+50);
    for(ll i=2;i*i<=m;i++){
        if(m%i==0){
            int cnt=0;
            while(m%i==0){
                cnt++;
                m/=i;
            }
            ans=(ans*comb.calc(cnt+n-1,cnt))%MOD;
        }
    }
    if(m!=1)ans=(ans*n)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=200010;

ll h[N],a[N];

ll sgt[4*N];

void build(ll st,ll en,ll pos)
{
    if(st==en){
        sgt[pos]=0;
        return;
    }
    ll mid=(st+en)/2;
    build(st,mid,2*pos+1);
    build(mid+1,en,2*pos+2);
    sgt[pos]=max(sgt[2*pos+1],sgt[2*pos+2]);
}

void update(ll st,ll en,ll pos,ll idx,ll val)
{
    if(st==en){
        sgt[pos]=val;
        return;
    }
    ll mid=(st+en)/2;
    if(idx>=st&&idx<=mid){update(st,mid,2*pos+1,idx,val);}
    else{update(mid+1,en,2*pos+2,idx,val);}
    sgt[pos]=max(sgt[2*pos+1],sgt[2*pos+2]);
}

ll query(ll st,ll en,ll pos,ll l,ll r)
{
    if(st>r||en<l){return 0;}
    if(st>=l&&en<=r){return sgt[pos];}
    ll mid=(st+en)/2;
    return max(query(st,mid,2*pos+1,l,r),query(mid+1,en,2*pos+2,l,r));
}

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

    ll n;
    cin>>n;
    for(ll i=0;i<n;++i){cin>>h[i];--h[i];}
    for(ll i=0;i<n;++i){cin>>a[i];}
    build(0,n-1,0);

    ll dp[n];
    dp[0]=a[0];
    update(0,n-1,0,h[0],a[0]);

    for(ll i=1;i<n;++i)
    {
        ll lol=0;
        if(h[i]!=0)
        {
            lol=query(0,n-1,0,0,h[i]-1);
        }
        dp[i]=lol+a[i];
        update(0,n-1,0,h[i],dp[i]);
    }

    ll ans=*max_element(dp,dp+n);

    cout<<ans<<endl;

    return (0);
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	double l;
	cin >> l;
	cout << fixed << setprecision(10);
	double res = 1;
	res *= (l / 3);
	l = l * 2 / 3;
	res *= (l / 2) * (l - l / 2);
	cout << res << endl;
	
    return 0;
}



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

using namespace std;
#define ll long long
const int N=2e5+5;
ll cnt[N];
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    ll ans=0;
    for(int i=0;i<N;i++) ans+=cnt[i]*(cnt[i]-1)/2;
    for(int i=0;i<n;i++)
    {
        ans-=cnt[a[i]]*(cnt[a[i]]-1)/2;
        cnt[a[i]]--;
        ans+=cnt[a[i]]*(cnt[a[i]]-1)/2;
        cout<<ans<<'\n';
        ans-=cnt[a[i]]*(cnt[a[i]]-1)/2;
        cnt[a[i]]++;
        ans+=cnt[a[i]]*(cnt[a[i]]-1)/2;
    }
    return 0;
}


Measured memory_bytes: 3968
from itertools import product
from string import digits


def is_producible(s, digit3):
    curr = 0
    for c in s:
        if c == digit3[curr]:
            curr += 1
            if curr == 3:
                return True
    return False


n = int(input())
s = input()

ret = 0
for digit3 in product(digits, repeat=3):
    if is_producible(s, digit3):
        ret += 1
print(ret)

# 問題を分割する
# この番号は作れるのか？


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

typedef long long ll;

int main() {
  
  int n; cin >> n;
  vector<int> parr(n);
  vector<int> qarr(n);
  rep(i, 0, n) cin >> parr[i];
  rep(i, 0, n) cin >> qarr[i];

  vector<int> perm(n);
  rep(i, 0, n) perm[i] = i + 1;

  int pvalue = 0;
  int qvalue = 0;
  int permvalue = 1;

  do{

    bool pflag = true;
    rep(i, 0, n){
      if(parr[i] != perm[i]){
        pflag = false;
      }
    }
    if(pflag) pvalue = permvalue;

    bool qflag = true;
    rep(i, 0, n){
      if(qarr[i] != perm[i]){
        qflag = false;
      }
    }
    if(qflag) qvalue = permvalue;

    permvalue++;

  }while(next_permutation(perm.begin(), perm.end()));

  cout << abs(pvalue - qvalue) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{

  int N,K;cin>>N>>K;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  vector<vector<int> > DP (N+1,vector<int>(K+1,0));
  DP[0][0] = 1;//数え上げ
  for (int i = 0; i < N; i++)
  {
    vector<int> SUM (K+2,0);

    for (int j = 0; j <= K; j++)
    {
      SUM[j+1] = (SUM[j] + DP[i][j] )%MOD;
    }
    for (int j = 0; j <= K; j++)
    {
      DP[i+1][j] = (SUM[j+1] - SUM[max(0LL,j - vec[i])] +MOD)%MOD;
    }
    
  }
  cout<<DP[N][K]<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 80256
import sys
A,B,C=map(int,input().split())
if A==B and B==C and A%2==0:
  print('-1')
  sys.exit()
if A==B and B==C and A%2==1:
  print(0)
  sys.exit()
i = 0
a = [A]
b = [B]
c = [C]
while a[i]%2==0 and b[i]%2==0 and c[i]%2==0:
  a.append((b[i]+c[i])/2)
  b.append((a[i]+c[i])/2)
  c.append((a[i]+b[i])/2)
  i += 1
print(i)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

string toUpperCase (string word) {
    for (int i = 0; i < word.size(); i++) {
        word[i] = toupper(word[i]);
    }
    return word;
}

int main () {
    string keyword;
    cin >> keyword;
    string s;
    cin >> s;
    long long result = 0;
    
    while(s != "END_OF_TEXT") {
        if (toUpperCase(keyword) == toUpperCase(s)) {
            result++;
        }
        cin >> s;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x; cin >> x;
    if(x==1){cout<<1<<endl; return 0;}
    int res=-1*INF;
    for(int i=2; i*i<=x; i++){
        for(int j=2; pow(i,j)<=x; j++){
            chmax(res,(ll)pow(i,j));
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4004
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstdlib>
#include<queue>
#include<map>
using namespace std;
int a,pos,ans;
char c;
int main()
{
    cin>>a;
    for(int s=0;s<a;s++)
    {
        cin>>c;
        if(c=='I')
		pos++;
        else
        pos--;
        ans=max(ans,pos);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int first[4001], second[4001];
    for (int i = 0; i <= 4000; ++i) {
        first[i] = i * i * i * i * i;
    }
    for (int i = 0; i <= 4000; ++i) {
        second[i] = -1 * first[i];
    }
    int x;
    cin >> x;
    for (int i = 0; i <= 4000; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (first[i] - first[j] == x) {
                cout << i << " " << j;
                return 0;
            }
        }
        for (int j = 0; j <= 4000; ++j) {
            if (first[i] - second[j] == x) {
                cout << i << " " << -1 * j;
                return 0;
            }
        }
    }
    for (int i = 0; i <= 4000; ++i) {
        for (int j = 0; j <= 4000; ++j) {
            if (second[i] - first[j] == x) {
                cout << -1 * i << " " << j;
                return 0;
            }
        }
        for (int j = 0; j <= 4000; ++j) {
            if (second[i] - second[j] == x) {
                cout << -1 * i << " " << -1 * j;
                return 0;
            }
        }
    }
    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

const int N = 200007, M = 1e9 + 7;

ll memo[N];
ii v[N];

ll fat[N];

ll fast_pow(ll a, ll b) {
	ll ans = 1;
	while(b) {
		if(b&1) ans = ans * a % M;
		b >>= 1;
		a = a * a % M;
	}
	return ans;
}

ll calc(ll L, ll R) {
	return fat[L + R] * fast_pow(fat[L] * fat[R] % M, M - 2) % M;
}

int n;

ll solve(int pos) {
	ll & st = memo[pos];
	if(st == -1) {
		int r, c; tie(r, c) = v[pos];
		st = calc(r-1, c-1);
		for(int i = 0; i < n; i++) {
			if(i == pos) continue;
			int p, q; tie(p, q) = v[i];
			if(p <= r and q <= c) {
				st = (st - (solve(i) * calc(r - p, c - q) % M) + M)%M;
			}
		}
	}
	return st;
}

int main() {
	memset(memo, -1, sizeof memo);
	ios::sync_with_stdio(0); cin.tie(0);

	fat[0] = 1;
	for(int i = 1; i < N; i++) {
		fat[i] = fat[i-1] * i % M;
	}

	int h, w; cin >> h >> w >> n;

	for(int i = 0; i < n; ++i) {
		int r, c; cin >> r >> c;
		v[i] = ii(r, c);
	}

	ll ans = calc(h-1, w-1);
	for(int i = 0; i < n; i++) {
		int p, q; tie(p, q) = v[i];
		ans = (ans - (solve(i) * calc(h - p, w - q) % M) + M)%M;

	}
	cout << ans << endl;
}

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

int main(){
  int R0, W0, C, R;
  while(cin >> R0 >> W0 >> C >> R && R0*W0*C*R>0){
    int n=(C*W0-R0)/R;
    if(n<0) cout << 0 << endl;
    else{
      if(C*W0>R0+n*R) cout << (n+1) << endl;
      else cout << n << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 12, TT = 5000;
bool dp[1<<N];
int len[1<<N];
bool match[N][TT];

int main(){
    int n,m;
    while(cin >>n >>m,n){
        vector<string> s(n);
        rep(i,n) cin >>s[i];

        string t="";
        while(m--){
            string tmp;
            cin >>tmp;
            t += tmp;
        }

        vector<int> sz(n);
        int S = 0;
        rep(i,n){
            sz[i] = s[i].size();
            S += sz[i];
        }
        int T = t.size();
        // S <= 240, T <= 5000

        rep(mask,1<<n){
            len[mask] = 0;
            rep(i,n)if(mask>>i&1) len[mask] += sz[i];
        }

        fill(match[0], match[N], false);
        rep(i,n){
            rep(j,T-sz[i]+1){
                match[i][j] = (s[i] == t.substr(j,sz[i]));
            }
        }

        int ans = 0;
        rep(i,T-S+1){
            fill(dp,dp+(1<<N),false);
            dp[0] = true;
            rep(mask,1<<n)if(dp[mask]){
                rep(j,n)if(!(mask>>j&1)){
                    int nx = mask | (1<<j);
                    if(match[j][i+len[mask]]) dp[nx] = true;
                }
            }

            if(dp[(1<<n)-1]) ++ans;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  string s; cin >> s;
  int a = s[0] - '0', b = s[2] - '0';
  a *= 10; b *= 10;
  a += s[1] - '0'; b += s[3] - '0';

  if(0 < a && a <= 12){
    if(0 < b && b <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }else{
    if(0 < b && b <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}


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

int N, M;
vector<string> u;

int main() {
  u.push_back(" ");
  
  cin>>N;
  string s[N+1];
  for(int i=1;i<=N;i++){
    cin>>s[i];
    u.push_back(s[i]);
  }
  
  cin>>M;
  string t[M+1];
  for(int i=1;i<=M;i++){
    cin>>t[i];
    u.push_back(t[i]);
  }
  
  int Max=0;

  for(int i=0;i<=N+M;i++){
    int a=0;
    for(int j=1;j<=N;j++){
      if(u[i]==s[j]) a++;
    }
    for(int j=1;j<=M;j++){
      if(u[i]==t[j]) a--;
    }
    Max=max(a, Max);
  }
  
  cout<<Max<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b;
    cin>>a>>b;
    if(a<b)
    {
        while(b--)
        {
            cout<<a;
        }
        cout<<endl;
    }
    else
    {
        while(a--)
        {
            cout<<b;
        }
        cout<<endl;
    }
    return 0;
    
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  ll ss;
  cin >> s;
  ss = toInt(s);
  int n = s.size();
  ll ans = 0;
  rep(i, n) { ans += s[i] - '0'; }

  if( ss % ans == 0) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Grup = new Grouping();
			Grup.Exec();
		}
	}

	public class Grouping
	{
		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int x = array[0];
			int y = array[1];
			List<int> g1 = new List<int>() { 1, 3, 5, 7, 8, 10, 12 };
			List<int> g2 = new List<int>() { 4, 6, 9, 11 };
			List<int> g3 = new List<int>() { 2 };

			bool contains = false;
			if ((g1.Contains(x) && g1.Contains(y))
				|| (g2.Contains(x) && g2.Contains(y))) {
				contains = true;
			}

			Console.WriteLine(contains ? "Yes" : "No");

			Console.Out.Flush();

			Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13408
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> v(n);
    for(auto &a : v) cin>>a;
    ll ret = 1ll*accumulate(v.begin(),v.end(),0ll);
    for(int i=1;i<n;++i){
        int tmp = v[n-1];
        for(int j=n-1;j>0;j--){
            v[j] = min(v[j-1],v[j]);
        }
        v[0] = min(v[0],tmp);
        ret = min(ret,1ll*accumulate(v.begin(),v.end(),0ll)+1ll*i*x);
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = []
count = 0
for i in range(N):
  a = np.array(list(map(int, input().split())))
  if np.sum(a * B) + C > 0:
    count += 1
print(count)
  

Measured memory_bytes: 12432
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
	int N;
	string A,B,C;
	int ANS=0;
	cin>>N>>A>>B>>C;
	for(int i=0;i<N;i++){
		int count=0;
		if(A.at(i)==B.at(i)){
			count++;
		}
		if(C.at(i)==B.at(i)){
			count++;
		}		
		if(A.at(i)==C.at(i)){
			count++;
		}
		if(count==1){
		ANS++;
		}else if(count==0){
			ANS+=2;
		}
	}
	cout<<ANS<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);    	
    	int a = scan.nextInt();
    	int b = scan.nextInt();
    	int ans = a + b;
    	if (ans < (a-b)) ans = a - b;
    	if (ans < (a*b)) ans = a * b;
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21716
class node():
    def __init__(self, id, parent, child, depth, type_t, sibling, height=0):
        self.id = id
        self.parent = parent
        self.child = child
        self.depth = depth
        self.type_t = type_t
        self.sibling = sibling
        self.height = height


def add(t, d, i, parent, depth, sibling):
    type_t = 'internal node'
    if d[i][1] == -1 and d[i][2] == -1:
        type_t = 'leaf'
    if depth == 0:
        type_t = 'root'
    child = d[i][1:]
    new_node = node(i, parent, child, depth, type_t, sibling)
    t.append(new_node)
    if child[0] >= 0:
        sib = child[1] if child[1] >= 0 else -1
        add(t, d, child[0], i, depth + 1, sib)
    if child[1] >= 0:
        sib = child[0] if child[0] >= 0 else -1
        add(t, d, child[1], i, depth + 1, sib)


def calc_height(t, i):
    if t[i].child[0] == -1 and t[i].child[1] == -1:
        return 0
    max_h = -1
    if t[i].child[0] >= 0:
        max_h = max(max_h, calc_height(t, t[i].child[0]))
    if t[i].child[1] >= 0:
        max_h = max(max_h, calc_height(t, t[i].child[1]))
    return max_h + 1

def preorder(t, a, i):
    l, r = -1, -1
    l = t[i].child[0]
    r = t[i].child[1]
    a.append(i)
    if not l == -1:
        preorder(t, a, l)
    if not r == -1:
        preorder(t, a, r)


def inorder(t, a, i):
    l, r = -1, -1
    l = t[i].child[0]
    r = t[i].child[1]
    if not l == -1:
        inorder(t, a, l)
    a.append(i)
    if not r == -1:
        inorder(t, a, r)


def postorder(t, a, i):
    l, r = -1, -1
    l = t[i].child[0]
    r = t[i].child[1]
    if not l == -1:
        postorder(t, a, l)
    if not r == -1:
        postorder(t, a, r)
    a.append(i)

N = int(input())
tree = []
data = [[] for i in range(N)]
for i in range(N):
    data[i] = [int(i) for i in input().split()]

data.sort(key=lambda x: x[0])
root = [True for i in range(N)]
for d in data:
    for c in d[1:]:
        if c == -1:
            continue
        root[c] = False

root_index = root.index(True)
add(tree, data, root_index, -1, 0, -1)

tree.sort(key=lambda x: x.id)

for i in range(N):
    h = calc_height(tree, i)
    tree[i].height = h

a = []
preorder(tree, a, root_index)
print('Preorder')
print('', ' '.join(map(str, a)))
a = []
inorder(tree, a, root_index)
print('Inorder')
print('', ' '.join(map(str, a)))
a = []
postorder(tree, a, root_index)
print('Postorder')
print('', ' '.join(map(str, a)))



Measured memory_bytes: 5744
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

double calc(int[][] a) {
    double ans = 0;
    int n = 0;
    foreach (e; permutations(a)) {
        for (int i = 1; i < e.length; i++) {
            double x1 = e[i - 1][0];
            double y1 = e[i - 1][1];
            double x2 = e[i][0];
            double y2 = e[i][1];
            ans += sqrt((x1 - x2) ^^ 2 + (y1 - y2) ^^ 2);
        }
        n++;
    }
    return ans / n;
}

double calc2(int[][] a) {
    double d = 0;
    for (int i = 0; i < a.length; i++) {
        for (int j = i + 1; j < a.length; j++) {
            double x1 = a[i][0];
            double y1 = a[i][1];
            double x2 = a[j][0];
            double y2 = a[j][1];
            d += sqrt((x1 - x2) ^^ 2 + (y1 - y2) ^^ 2);
        }
    }
    return d * 2 / a.length;
}

void main() {
    int n = readint;
    int[][] a;
    foreach (_; 0..n) {
        a ~= readints;
    }

    auto ans = calc(a);
    // auto ans = calc2(a);
    writefln("%.8f", ans);
}


Measured memory_bytes: 256
n=int(input())
t=[int(input())for i in range(n)]
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
ans=1
for i in range(n):
    ans=lcm(ans,t[i])
print(ans)



Measured memory_bytes: 3060
#include <stdio.h>

int dp[50];

int fib(int n) {
  if ( n == 0 || n == 1 ) return dp[n] = 1;
  if ( dp[n] != -1 ) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main() {
  int n, i;
  for ( i = 0; i < 50; i++ ) dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll left = 0, right = inf;
  while (right- left > 1) {
    ll mid = (left + right) / 2;
    ll cnt = 0;
    rep(i, n) cnt += (a[i] - 1) / mid;
    if (cnt > k) left = mid;
    else right = mid;
  }
  ll ans = right;
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 4776
import sys
sys.setrecursionlimit(10**4)
def input():
	return sys.stdin.readline()[:-1]

n, m = map(int, input().split())
adj = [[] for _ in range(n)]
edges = []
for i in range(m):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	edges.append((a-1, b-1))

seen = [False for _ in range(n)]
visited = [False for _ in range(n)]
begin = -1
hist = []

def dfs(x):
	global begin, hist
	if begin >= 0:
		return
	seen[x] = True
	hist.append(x)
	for v in adj[x]:
		if visited[v]:
			continue
		if seen[v] == True and visited[v] == False:
			begin = v
			return
		dfs(v)
		if begin >= 0:
			return
	visited[x] = True
	hist.pop()
	return

for i in range(n):
	if begin < 0:
		dfs(i)
	if begin >= 0:
		break

if begin < 0:
	print(-1)
	sys.exit()
else:
	cycle = []
	included = [False for _ in range(n)]
	included[begin] = True
	while hist and hist[-1] != begin:
		cycle.append(hist[-1])
		included[hist[-1]] = True
		hist.pop()
	cycle.append(begin)
	hist.pop()

	while True:
		meets = True
		l = len(cycle)
		ind = [-1 for _ in range(n)]
		for i in range(l):
			ind[cycle[i]] = i
		for i in range(l):
			if meets == False:
				break
			for v in adj[cycle[(i+1)%l]]:
				if included[v] == True and v != cycle[i]:
					meets = False
					new_start_id, new_end_id = ind[v], (i+1)%l
					break

		if meets:
			print(len(cycle))
			print(*[c+1 for c in cycle], sep="\n")
			break
		else:
			new_cycle = []
			included = [False for _ in range(n)]
			cur = new_end_id
			while cur != new_start_id:
				new_cycle.append(cycle[cur])
				included[cycle[cur]] = True
				cur = (cur+1)%l
			new_cycle.append(cycle[new_start_id])
			cycle = new_cycle

Measured memory_bytes: 40432
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

s = list(input())
t = list(input())

ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans+= 1
print(ans) 

Measured memory_bytes: 76688
import sys

def solve():
    N = int(input())
    S, T = map(str, input().split())
    Ans = [None] * (2 * N)
    for i in range(N):
        Ans[2 * i] = S[i]
        Ans[2 * i + 1] = T[i]
    print("".join(map(str, Ans)))
    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
s = int(input())
s1 = s//100
s2 = s%100

if (0 <= s1 <= 99 and 1 <= s2 <= 12) and (0 <= s2 <= 99 and 1 <= s1 <= 12):
    print("AMBIGUOUS")
elif 0 <= s2 <= 99 and 1 <= s1 <= 12:
    print("MMYY")
elif 0 <= s1 <= 99 and 1 <= s2 <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
n=int(input())
s=input()

r = 0
r_l = []
g = 0
g_l = []
b = 0
b_l = []

for i in range(n):
    if s[i] == "R":
        r += 1
        r_l.append(i)
    if s[i] == "G":
        g += 1
        g_l.append(i)
    if s[i] == "B":
        b += 1
        b_l.append(i)
        
ans = r*g*b

for i in r_l:
    for j in g_l:
        tmp = abs(i-j)
        if 0 <= i-tmp and s[i-tmp] == "B":
            ans -= 1
        if 0 <= j-tmp and s[j-tmp] == "B":
            ans -= 1
        if i+tmp < n and s[i+tmp] == "B":
            ans -= 1
        if j+tmp < n and s[j+tmp] == "B":
            ans -= 1

        if (tmp / 2).is_integer():
            if s[max(i,j)-(tmp//2)] == "B":
                ans -= 1
            if max(i,j)-(tmp//2) != min(i,j)+(tmp//2) and s[min(i,j)+(tmp//2)] == "B":
                ans -= 1

print(ans)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ld ans=inf;
ld x[100],y[100];
ld lx,rx;
ll n;
ld find(ld x1,ld y1)
{
	ld ma=0;
	for(ll i=0;i<n;i++)
	{
		ld r=((x1-x[i])*(x1-x[i]))+((y1-y[i])*(y1-y[i]));
		r=sqrt(r);
		ma=max(r,ma);
	}
	return ma;
}
ld check(ld x)
{
	ld l=0,u=1000;
	while((u-l)>eps)
	{
		ld ly=((u-l)/3)+l;
		ld ry=(2*(u-l)/3)+l;
		ld p1=find(x,ly),p2=find(x,ry);
		if(p1<p2)
		{
			u=ry;
		}
		else
		{
			l=ly;
		}
	}
	return find(x,l);
}
int main()
{
	FAST
	#ifdef ayk_16
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
	}
	ld l=0,u=1000;
	while((u-l)>eps)
	{
		lx=((u-l)/3)+l;
		rx=(2*(u-l)/3)+l;
		ld p1=0,p2=0;
		p1=check(lx);p2=check(rx);
		if(p1<p2)
		{
			u=rx;
		}
		else
		{
			l=lx;
		}
		ans=min(ans,check(lx));
	}
	cout<<stp<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int n;
	int i=1;
	int x;
	
	scanf("%d", &n);

	do
	{
		int x = i;
			if (x % 3 == 0) {
				printf(" %d", i);
				continue;
		}
			
			do{
				if (x % 10 == 3) {
					printf(" %d", i);
					break;
				}
				else {
					x /= 10;
				}
			
			} while (x);
			
	} while (++i <= n);

	printf("\n");

	return(0);
}


Measured memory_bytes: 2104
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

bool prime(int a) {
    if (a <= 1) return false;
    for (int i = 2; i * i <= a; i++)
        if (a % i == 0) return false;
    return true;
}

int main() {
    int x; cin >> x;
    while (!prime(x)) x++;
    cout << x << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> score(N);
  
  for (int i=0; i<N; i++) {
    cin >> score.at(i);
  }
  
  sort(score.begin(),score.end());
  reverse(score.begin(),score.end());
  
  int sa=0,sb=0;
  
  for (int i=0; i<N; i++) {
    if (i%2==0) {
      sa += score.at(i);
    }
    else {
      sb += score.at(i);
    }
  }
 
  cout << sa-sb << endl;
}

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

int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s;
	int x,y,i,j,k;
	cin>>s>>x>>y;
	
    vector<unordered_set<int>>prev(2);
    vector<unordered_set<int>>nex(2);
	int t=0;
	bool flag=0;
	map<int,map<int,int>>mp;
	prev[0].insert(0);
	prev[1].insert(0);
	j=0;
	for(i=0;i<s.length();i++)
	{
	    if(s[i]=='F')
	    {
	        j++;
	        
	    }
	        
	    else
	    {
	        if(flag==0)
	        {
	            for(auto a : prev[t])
	            {
	    //            cout<<t<<" : "<<a<<endl;
	                nex[t].insert(a+j);
	            }
	            prev[t]=nex[t];
	            nex[t].clear();
	        }
	        else
	        {
	            for(auto a : prev[t])
	            {
	   //             cout<<t<<" : "<<a<<endl;
	                nex[t].insert(a+j);
	                nex[t].insert(a-j);
	            }
	            prev[t]=nex[t];
	            nex[t].clear();
	            
	        }
	        
	        j=0;
	        
	        t^=1;
//	        cout<<t<<endl;
	        flag=1;
	    }
	}
	if(flag==0)
	        {
	            for(auto a : prev[t])
	            {
	   //             cout<<t<<" : "<<a<<endl;
	                nex[t].insert(a+j);
	            }
	            prev[t]=nex[t];
	            nex[t].clear();
	        }
	        else
	        {
	            for(auto a : prev[t])
	            {
	 //               cout<<t<<" : "<<a<<endl;
	                nex[t].insert(a+j);
	                nex[t].insert(a-j);
	            }
	            prev[t]=nex[t];
	            nex[t].clear();
	            
	        }
	
    flag=0;
    bool flag1=0;    
    for(auto a: prev[0])
    {
       // cout<<"ans x : "<<a<<endl;
        if(x==a)
        flag++;
    }
	for(auto a:prev[1])
	{
	  //  cout<<"ans y : "<<a<<endl;
	    if(y==a)
	    flag1++;
	}

	if(flag&&flag1)
	cout<<"Yes";
	else
	cout<<"No";
	
	return 0;
}


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

int main(int argc, char const* argv[])
{
    int n, k;
    cin >> n >> k;

    if (k == 2) {
        cout << n-1 << endl;
    }else{
        cout << ( ( n / (k-1) ) + (n % (k-1) >= 2 ) ) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    vector<ll> V(7);
    rep(i,0,7)cin >> V[i];
    ll ans = 0;
    int a = V[0] % 2 + V[3] % 2 + V[4] % 2;
    if(a >= 2 && min({V[0], V[3], V[4]}) >= 1){
        ans += 3;
        V[0]--,V[3]--,V[4]--;
    }
    ans += V[0] / 2 * 2;
    ans += V[1];
    ans += V[3] / 2 * 2;
    ans += V[4] / 2 * 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (ll i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

const int MAX_ROW = 110;
const int MAX_COL = 110000;
struct BitMatrix {
  int H, W;
  bitset<MAX_COL> val[MAX_ROW];
  BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
  inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

void GaussJordan(BitMatrix &A, bool is_extended = false) {
  vector<bool> used(A.H, 0);
  for (int col = 0; col < A.W; ++col) {
    if (is_extended && col == A.W - 1) break;
    int pivot = -1;
    for (int row = 0; row < A.H; ++row) {
      if (used[row]) continue;
      if (A[row][col]) {
        pivot = row;
        break;
      }
    }
    if (pivot == -1) continue;
    for (int row = 0; row < A.H; ++row) {
      if (row != pivot && A[row][col]) A[row] ^= A[pivot];
    }
    used[pivot] = true;
  }
}

const int MD = 60;

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

  ll res = 0;
  BitMatrix B(MD + 1, n + 1);
  vector<bool> cannot(MD + 1, 0);
  repr(d, MD) {
    ll num = 0;
    rep(i, n) {
      if (a[i] & (1LL << d)) num++;
    }
    if (num == 0) {
      cannot[d] = 1;
      continue;
    }
    else if (num & 1) {
      cannot[d] = 1;
      res += (1LL << d);
      continue;
    }
    rep(i, n) {
      if (a[i] & (1LL << d)) B[MD - d][i] = 1;
    }
    B[MD - d][n] = 1;
  }
  GaussJordan(B, true);

  repr(d, MD) {
    if (cannot[d]) continue;
    bool ok = false;
    rep(i, n) {
      if (B[MD - d][i]) ok = true;
    }
    if (!B[MD - d][n]) ok = true;
    if (ok) res += (2LL << d);
  }
  cout << res << endl;


}

Measured memory_bytes: 2560