akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;


int main() {
	string board;
	cin >> board;

	int count = 0;

	for(int i = 0; i < board.size() - 1; i++) {
		if(board[i] != board[i + 1]) {
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

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

using namespace std;

int main(void){
	for (int h = 1; h <= 4;h++){
		int t, n, p;
		cin >> t >> n;
		switch (t){
		case 1: p = 6000; break;
		case 2: p = 4000; break;
		case 3: p = 3000; break;
		case 4: p = 2000; break;
		}
		cout << p*n << endl;
	}
}

Measured memory_bytes: 1160
N, M, X, Y = map(int, input().split())
*x, = map(int, input().split())
*y, = map(int, input().split())

if not X <= Y:
	print("War")
	exit()

if not max(x + [X]) < min(y + [Y]):
	print("War")
	exit()

print("No War")


Measured memory_bytes: 2940
import math
from functools import lru_cache, reduce


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def prefix_sum(arr, a):
    arr.append(arr[-1]+a)
    return arr


def solve():
    """
    OPT[i][j] = min(OPT[i][k]+OPT[k+1][j])+sum(A[i:j+1])    i <= k < j
    OPT[i][j] = 0 if i == j
    """
    N = read_int()
    A = read_ints()
    prefix = reduce(prefix_sum, A, [0])

    @lru_cache(None)
    def dp(i, j):
        if i == j:
            return 0
        return min(dp(i, k)+dp(k+1, j)+(prefix[j+1]-prefix[i]) for k in range(i, j))

    OPT = [[0]*N for _ in range(N)]
    for j in range(N):
        for i in range(j-1, -1, -1):
            OPT[i][j] = min(OPT[i][k]+OPT[k+1][j] for k in range(i, j))+(prefix[j+1]-prefix[i])

    return OPT[0][N-1]


if __name__ == '__main__':
    print(solve())


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  vector<int> a(4);
  for(int i=0;i<4;++i) {
    a[i] = (int)(s[i] - '0');
  }

  int b = 10 * a[0] + a[1];
  int c = 10 * a[2] + a[3];

  bool b1 = false, b2 = false;
  if(1 <= b && b <= 12) b1 = true;
  if(1 <= c && c <= 12) b2 = true;
  if(b1 && b2) {
    cout << "AMBIGUOUS" << endl;
  } else if(b1) {
    cout << "MMYY" << endl;
  } else if(b2) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

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

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

    // 素数である
    return true;
}

int main(){
    int a;
    cin >> a;
    int ans = 0;
    bool c = true;
    while(a <= 100003 && c){
        if(IsPrime(a)){
            ans = a;
            c = false;
            }
        a++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7

memo = dict()
memo[0] = 1
def pow3(n):
	if n in memo:
		return memo[n]
	if n%2 == 0:
		tmp = pow3(n//2)
		memo[n] = tmp*tmp%MOD
		return memo[n]
	memo[n] = 3 * pow3(n-1)%MOD
	return memo[n]

def cul(i, p):
	cur = (1<<i)%MOD
	cur *= pow3(p)
	return cur % MOD

def solve(L):
	n = len(L)
	if L == "0":
		return 1
	if not "0" in L:
		return pow3(n)

	num_1 = 0
	pos = []
	for i in range(n):
		if L[i] == "1":
			num_1 += 1
			pos.append(n-i-1)

	ans = (2**num_1)%MOD
	for i, p in enumerate(pos):
		ans += cul(i, p)
		ans %= MOD

	return ans

def main():
	L = input()
	print(solve(L))


if __name__ == '__main__':
	main()

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

int n, x, c, ans, now, dlt;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		dlt = 0;
		scanf("%d", &x);
		c = (int)log2(x);
		if(x != (1 << c)) dlt = 1;
		if(now < c) ans += c - now, now = c;
		if(now > c) now = c, dlt = 0;
		if(dlt) ++ans, ++now;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int a[200005];

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

  int ans = 0;
  int k = 1;
  for(int i = 0; i < n; i++) {
    while(i < n && k != a[i]) {
      i++;
      ans++;
    }
    k++;
  }

  if(ans == n) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;

}
    


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> ci(n);
    vector<int> diff(n);
    rep(i, n) {
        cin >> ci[i];
        diff[i] = abs(ci[i] - x);
    }
    int ans = 0;

    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans = diff[i];
            continue;
        }

        ans = gcd(diff[i], ans);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int a, b;
    cin >> a >> b;
    if (b % a == 0)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a<< endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
};

//istream& operator>>(istream& is, const mint& a){return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	if((x+y)%3 != 0){
		cout << 0 << endl;
		return 0;
	}
	mint ans = choose((x+y)/3, max(x,y)-(x+y)/3);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;

int n, m, f, s;
vector<pair<int, int>>u, v;
map<pair<int, int>, int>mp;

int main(){
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++){
        int p, y;
        scanf("%d%d", &p, &y);
        pair<int, int> a = make_pair(p, y);
        u.push_back(a);
        v.push_back(a);
    }
    sort(u.begin(), u.end());
    for (int i = 0; i < m; i++){
        if (f != u[i].first)f = u[i].first, s = 1;
        mp[u[i]] = s, s++;
    }
    for (int i = 0; i < m; i++)printf("%06d%06d\n", v[i].first, mp[v[i]]);
}

Measured memory_bytes: 9324
const main = (N,U) => {
    const result = U.sort((a,b) => a - b).slice(1).reduce((x,i) => {
        return x = (x + i)/2
    },U[0])
    return result
}

const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")
const N = Number(input[0])
const U = input[1].split(" ").map( x => Number(x))
console.log(main(N,U))

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &x : A) cin >> x;

    vector<int> dp(N, INT_MAX);
    for (int i = 0; i < N; ++i) {
        int pnt = lower_bound(dp.begin(), dp.end(), A.at(i)) - dp.begin();
        dp.at(pnt) = A.at(i);
    }

    cout << lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin() << endl;

    return 0;
}


Measured memory_bytes: 3636
from collections import deque
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
 
q=deque()
 
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append((i,j))
 
dx=[1,0,-1,0]            
dy=[0,1,0,-1]
ans=0
 
while q:
    nq=deque()
    while True:
        y,x=q.popleft()    
        for i in range(4):
            ny=y+dy[i]
            nx=x+dx[i]
            if 0<=ny<h and 0<=nx<w and a[ny][nx]!='#':
                a[ny][nx]='#'
                nq.append((ny,nx))

        if not q:
            ans+=1
            q=nq
            break
print(ans-1)

Measured memory_bytes: 115164
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,m;
    cin>>n>>m;
    int a[n],b[n],ci[m],cj[m];
    for (int i=0;i<n;i++) cin>>a[i]>>b[i];
    for (int i=0;i<m;i++) cin>>ci[i]>>cj[i];
    for (int i=0;i<n;i++){
        int d=100000000000,ith,ii=100000000000;
        for (int j=0;j<m;j++){
            int h= abs(a[i]-ci[j])+abs(b[i]-cj[j]);
            if (h<=d){
                if (h<d){
                    d=h; ith=j+1; ii = abs(a[i]);
                }
                else {
                    int dd=abs(a[i]);
                    if (dd<ii){
                        ii=dd;
                        ith=j+1;
                    }
                }
            }
        }
        cout << ith << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

L = [list(map(int,input().split())) for i in range(M)]
ans = 999

if N == 1:
    for i in range(10):
        jdg = True
        for k in range(M):
            l = str(i)
            if int(l[(L[k][0])-1]) != L[k][1]:
                jdg = False
        if jdg == True:
            print(i)
            break        
                
else:
    for i in range(10**(N-1),10**N):
        jdg = True
        for k in range(M):
            l = str(i)
            if int(l[(L[k][0])-1]) != L[k][1]:
                jdg = False
            
        if jdg == True:
            print(i)
            break
        
if jdg == False:
    print(-1)

Measured memory_bytes: 39408
MODC = 1000000007

n = gets.strip.to_i
ab = []
n.times { ab.append gets.strip.split.map(&:to_i) }
a,b = ab.transpose
a.sort!
b.sort!
if n%2 == 0
  p (b[n/2-1]+b[n/2])-(a[n/2-1]+a[n/2])+1
else  
  p b[(n-1)/2]-a[(n-1)/2]+1
end


Measured memory_bytes: 33436
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>


int main(int argc, char *argv[])
{
	int n,r;
	cin >> n>>r;
	
	if (n<10) r+=(100)*(10-n);

	cout<< r<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s, t;
  s.push_back(-1e12);
  t.push_back(-1e12);
  REP(i, a) {
    ll ss;
    cin >> ss;
    s.push_back(ss);
  }
  REP(i, b) {
    ll tt;
    cin >> tt;
    t.push_back(tt);
  }
  s.push_back(1e12);
  t.push_back(1e12);
  REP(i, q) {
    ll x;
    cin >> x;
    auto a = lower_bound(ALL(s), x);
    auto b = lower_bound(ALL(s), x);
    auto c = lower_bound(ALL(t), x);
    auto d = lower_bound(ALL(t), x);
    a--, c--;
    ll ans1 = x - min(*a, *c);
    ll ans2 = max(*b, *d) - x;
    ll ans3 = x - *c + *b - *c;
    ll ans4 = x - *a + *d - *a;
    ll ans5 = *b - x + *b - *c;
    ll ans6 = *d - x + *d - *a;
    ll mn1 = min(min(ans1, ans2), ans3);
    ll mn2 = min(min(ans4, ans5), ans6);
    cout << min(mn1, mn2) << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
	int T;
	cin >> T;
	while(T--){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int ans = a * c + b * d;
		ans = min(ans, (a * max(c, 5) + b * max(d, 2)) * 8 / 10);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=1e5+10;
int n,a[N],cnt,head[N],rt,rd[N];
struct edge{int to,nxt;}e[N<<1];

void adde(int x,int y){
	e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;
}

void dfs(int u,int par){
	int sum=0,mx=0,leaf=1;
	for (int i=head[u],v;i;i=e[i].nxt)
		if (v=e[i].to,v!=par)
			dfs(v,u),sum+=a[v],mx=max(mx,a[v]),leaf=0;
	if (leaf) return;
	if (a[u]>sum){puts("NO"); exit(0);}
	int t=min(sum-mx,sum>>1);
	if (sum-a[u]>t){puts("NO"); exit(0);}
	a[u]-=sum-a[u];
}

int main(){
	scanf("%d",&n);
	rep (i,1,n) scanf("%d",&a[i]);
	rep (i,1,n-1){int x,y; scanf("%d%d",&x,&y),adde(x,y),adde(y,x),rd[x]++,rd[y]++;}
	if (n==2) return puts(a[1]==a[2]?"YES":"NO"),0;
	rep (i,1,n) if (rd[i]>1){rt=i; break;}
	dfs(rt,0);
	puts(!a[rt]?"YES":"NO");
	return 0;
}

Measured memory_bytes: 9600
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int a[3001];
int dp[3001][3001];
int rec(int i, int j) {
    if (i == j) {
        return a[i];
    }
    if (j == i + 1)
        return max(a[i], a[j]);
    if (i > j) {
        return 0;
    }
    int &ans = dp[i][j];
    if (ans != -1)
        return ans;
    ans  = 0;
    ans  = max(a[i] + min(rec(i + 2, j), rec(i + 1, j - 1)), a[j] + min(rec(i + 1, j - 1),  rec(i, j - 2)));
    return ans ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;;
    int sum = 0 ;
    forr(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    ms(dp, -1);
    int X = rec(0, n - 1);
    int Y = sum - X;
    int ans = X - Y;
    cout << ans ;
    return 0;
}

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

using namespace std;

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

int solve(int H, vector<vector<int>>& b) {
    int retval = 0;
    for(;;) {
        bool update = false;
        rep(i, H) rep(j, 3) if (b[i][j]) {
            int k = 0;
            for (; j + k < 5 && b[i][j + k] == b[i][j]; ++k);
            if (k < 3) continue;
            while (0 <= --k) {
                retval += b[i][j + k];
                b[i][j + k] = 0;
            }
            update = true;
        }
        if (!update) break;
        for (int i = H - 1; i > 0; --i) rep(j, 5) if (!b[i][j]) {
            int k = 1;
            for (; 0 <= i - k && !b[i - k][j]; ++k);
            if (0 <= i - k) swap(b[i][j], b[i - k][j]);
        }
    }
    return retval;
}

int main() {
    for (int H; cin >> H, H;) {
        vector<vector<int>> board(H, vector<int>(5));
        rep(i, H) rep(j, 5) cin >> board[i][j];
        cout << solve(H, board) << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl; 

    return 0;
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int N;
int A[200001];



//---------- 1000000007 ----------
const int MOD = 1000000007;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_div(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}
int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_div(p, i);
	}
	return p;
}
int m_comb_with_rep(int n, int r)
{
	return m_comb(n + r - 1, r);
}
int m_perm(int n, int r)
{
	int a = 1;
	for (int i = n; i > n - r; i--)
	{
		a = m_mul(a, i);
	}
	return a;
}



signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	int ans = 0;

	int sum = 0;
	for (int i = N - 2; i >= 0; i--)
	{
		sum = m_add(sum, A[i + 1]);
		int n = m_mul(A[i], sum);
		ans = m_add(ans, n);
	}
	cout << ans << endl;
}



Measured memory_bytes: 4752
# coding: utf-8
# Your code here!
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if min(a,b,c,d,e)==a:
    if n%a!=0:
        print(n//a+1+4)
    else:
        print(n//a+4)
elif min(a,b,c,d,e)==b:
    if n%b!=0:
        print(n//b+1+4)
    else:
        print(n//b+4)
elif min(a,b,c,d,e)==c:
    if n%c!=0:
        print(n//c+1+4)
    else:
        print(n//c+4)
elif min(a,b,c,d,e)==d:
    if n%d!=0:
        print(n//d+1+4)
    else:
        print(n//d+4)
elif min(a,b,c,d,e)==e:
    if n%e!=0:
        print(n//e+1+4)
    else:
        print(n//e+4)


Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b,d,r;
    double f;
    cin >> a;
    cin >> b;
    d=a/b;
    r=a%b;
    f=double(a)/double(b);
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed  << setprecision(5) <<f;
    cout << endl;
    
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
long long x,y;
int zzxc(long long  a,long long  b)
{
	if(a<b)
	{
		int t=a;
		a=b;
		b=t;
	}
	while(b!=0)
	{
		int z=a%b;
		a=b;
		b=z;
	}
	return a;
}
int main()
{
	scanf("%lld%lld",&x,&y);
	long long  yy=zzxc(x,y);
	printf("%lld",x*y/yy);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(1LL<<32);

ll t[10];
ll sum;
int n;

ll change(char ch){
  if('0'<=ch&&ch<='9')return (ch-'0');
  else return (ch-'a'+10);
}

ll change(string &s){
  ll res=0;
  for(int i=0;i<(int)s.size();i++){
    res=res*16LL+change(s[i]);
    res%=mod;
  }
  return res;
}

char change(ll n){
  if(n<10)return '0'+n;
  else return 'a'+n-10;
}

void printfunc(ll n){

  string str="";
  
  while(1){
    str.push_back(change(n%16LL));
    n/=16LL;
    if(n==0)break;
  }
  reverse(str.begin(),str.end());
  cout<<str<<endl;
}

void solve(){
  ll cnt[64]={};
  ll ans=0;
  ll co=0;
  for(int i=0;i<32;i++){
    for(int j=0;j<8;j++)
      if(t[j]>>i&1)cnt[i]++;
    
    int a=(co+cnt[i])&1;
    
    if(a!=(sum>>i&1)){
      ans+=(1LL<<i);
      co=(co+8-cnt[i])/2;
    }else{
      co=(co+cnt[i])/2;
    }
  }

  printfunc(ans);
}

int main(){
  
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<8;j++){
      cin>>s;
      t[j]=change(s);
    }
    cin>>s;
    sum=change(s);
    solve();
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
     
       int s,w;
       cin>>s>>w;
       if(s<=w)cout<<"unsafe"<<endl;
       else cout<<"safe"<<endl;
                  
}


        


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

int main(){
  int N;
  cin>>N;
  vector<int> X(N);
  for (int i=0;i<N;i++){
    cin>>X.at(i);
  }
  int sum =0;
  for (int i=0;i<N;i++){
    sum+=X.at(i);
  }
  int x1,x2;
  x1 = sum/N;
  x2 = sum/N+1;
  int diff1=0;
  int diff2 =0;
  for (int i=0;i<N;i++){
    diff1+=(x1-X.at(i))*(x1-X.at(i));
    diff2+=(x2-X.at(i))*(x2-X.at(i));
  }
  if(diff1<diff2){
    cout<<diff1<<endl;
  }
  else{
    cout<<diff2<<endl;
  }
}

Measured memory_bytes: 256
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<int> v;
    rep(i, n) {
        int t; cin >> t;
        v.pb(t);
    }
    sort(all(v));
    iter(i, 1, n) {
        if(v[i] == v[i-1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}



Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N;
  cin >> N;

  ll ans = 0;
  REP3(i,1,10){
    if (N%i==0 && N/i<10){
      ans = 1;
      break;
    }
  }


  cout << ((ans>0) ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
/*

  1????????????cin >> ????????????????????¢????????????????????????????????????????????????????????????????????????
???2????????\?????????cin >> ??????????????????????????????????????£????????????????????¨??????????????????????????????????§?

#include <iostream>

bool judgeUruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

int flag = 0;

void printUruyear(int year_begin, int year_end)
{

    if(flag == 1){
        std::cout << std::endl;
    }
    flag = 1;

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou
    for (int i = year_begin; i <= year_end; i++) {
        
        if (judgeUruyear(i)) {

            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }
    
}

int main()
{
    int year_begin, year_end;

    while (true) {

        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }

        printUruyear(year_begin, year_end);
    }
    
    return 0;
}

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1877346#1

*/

#include <iostream>

bool judgeUruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

int flag = 0;

void printUruyear(int year_begin, int year_end)
{

    if(flag == 1){
        std::cout << std::endl;
    }
    flag = 1;

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou
    for (int i = year_begin; i <= year_end; i++) {
        
        if (judgeUruyear(i)) {

            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }
    
}

int main()
{
    int year_begin, year_end;

    while (true) {

        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }

        printUruyear(year_begin, year_end);
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define LL long long
#define M 100020
using namespace std;
namespace IO{
	const int BS=(1<<20)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=getchar();
		for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
int A,B,n,top,last,S[M],now; char res; bool vis[M];
bool ask(int x,int y){cout<<"? "<<x-1<<" "<<y-1<<endl;cin>>res; return res=='Y';}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>A>>B; n=A+B; S[top=1]=n;
	if(A<=B){cout<<"Impossible"<<endl;return 0;}
	for(int k=1,cnt=0;k<n;k++){
		if(!top){S[top=1]=k;continue;}
		if(!ask(S[top],k)) top--;else S[++top]=k;
	}now=S[top];
	for(int i=1;i<=n;i++) vis[i]=ask(now,i); cout<<"! "; 
	for(int i=1;i<=n;i++) cout<<vis[i]; cout<<endl;
	return 0;
}

Measured memory_bytes: 724
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

dictA = {}

for z in A:
    dictA.setdefault(z, 0)
    dictA[z] += 1

sumA = sum(A)

BC = [list(map(int, input().split())) for i in range(Q)]
for x in BC:
    if x[0] in dictA.keys():
        sumA += (x[1] - x[0]) * dictA[x[0]]
        dictA.setdefault(x[1], 0)
        dictA[x[1]] += dictA[x[0]]
        dictA.pop(x[0])
    print(sumA)


Measured memory_bytes: 102828
using System;
using System.Linq;

public class Program
{
    private int N, W;
    private int[] v, w;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        W = sc.NextInt();
        v = new int[N];
        w = new int[N];
        for (int i = 0; i < N; i++)
        {
            v[i] = sc.NextInt();
            w[i] = sc.NextInt();
        }

        var ans = new int[W + 1];
        for (int i = 1; i <= W; i++)
        {
            ans[i] = -1;
        }

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j <= W; j++)
            {
                if (ans[j] != -1 && j + w[i] <= W && ans[j + w[i]] < ans[j] + v[i])
                {
                    ans[j + w[i]] = ans[j] + v[i];
                }
            }
        }
        Console.WriteLine(ans.Max());
    }


    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}


class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 20348
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int n, t, x, y, F = 0;
    cin >> n;
    rep(i, 1, n + 1) {
        cin >> t >> x >> y;
        if (x + y <= t && (t - x - y) % 2 == 0) {
            continue;
        } else {
            F = 1;
        }
    }
    if (F == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int64_t divceil(int64_t a, int64_t b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}
int main() {
    int N;
    i64 H;
    cin >> N >> H;
    vector<pair<i64,i64>> a(N);
    vector<i64> b;
    for(auto &x : a) {
        cin >> x.first >> x.second;
    }
    sort(REV_WHOLE(a));
    for(auto &x : a) {
        b.push_back(x.second);
    }
    sort(REV_WHOLE(b));
    i64 ans = 1e10;
    i64 S = 0;
    for(int i = 0; i <= N; i++) {
        ans = min(ans, 
            (H > S ? divceil(H - S, a[0].first) : 0) + i);
        if(i < N) S += b[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2936
def solve(string):
    n, *abc = map(int, string.split())
    a, b, c = sorted(abc[:n]), sorted(abc[n:2 * n]), sorted(abc[2 * n:])
    ai = ci = ans = 0
    for _b in b:
        while ai < n and a[ai] < _b:
            ai += 1
        while ci < n and c[ci] <= _b:
            ci += 1
        ans += ai * (n - ci)
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(3)])))


Measured memory_bytes: 42112
count = int(input())

c = {}

for s in (["S", "H", "C", "D"]):
    c[s] = {}

for s in c:
    for n in range(1, 14):
        c[s][str(n)] = False

for i in range(count):
    s, n = input().split()
    
    c[s][n] = True
    #print(i, s, n, c[s][str(n)])

for s in c:
    for n in c[s]:
        if not c[s][n]:
            print(f'{s} {n}')
    #print(f'{s} {n} {c[s][n]}')


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

#define MAXN 200001

#define MOD 2019

using namespace std;

int A, B, mid, out=INT_MAX;

int main(){

	cin>>A>>B;	for(int i=A;i<min(A+2019, B);i++)

		for(int j=A+1;j<=min(A+2019, B);j++)

			out=min(out, ((i%MOD)*(j%MOD))%MOD);

	cout<<out;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] lis = new int[n + 1];

        for (int i = 0; i < m; ++i) {
            lis[sc.nextInt()] = 1;
        }

        long[] cnt = new long[n + 1];
        cnt[0] = 1;
        if (lis[1] == 1) {
            cnt[1] = 0;
        } else {
            cnt[1] = 1;
        }
        for (int i = 2; i <= n; ++i) {
            if (lis[i] == 1) {
                cnt[i] = 0;
            } else {
                cnt[i] = (cnt[i - 1] + cnt[i - 2]) % mod;
            }
        }

        System.out.println(cnt[n]);
    }
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int count = 0;
  bool check = true;
  while(check) {
    for(int i = 0; i < N; i++){
      if(A[i] % 2 == 0){
        A[i] /= 2;
      }
      else {
        check = false;
        break;
      }
    }
    if(check == true){
    count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int p = 1;
  int cnt = 0;
  while (p <= n) {
    int pp = p * 10 - 1;
    pp = min(pp, n);
    cnt += pp - p + 1;
    p *= 100;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define srep(i) for (int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int n, w;
int weight[105] = {}, value[105] = {};

int dp[105][10005] = {};

int main()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
dishes = []
for i in range(5):
    time = int(input())
    diff = (10 - time % 10) % 10
    dishes.append([time, diff])
dishes = sorted(dishes, key=lambda x: x[1])
ans = 0
for i in range(4):
    time = dishes[i][0]
    ans += time + dishes[i][1]
ans += dishes[-1][0]
print(ans)

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    if i+1 < n:
        dp[i+1] = min(dp[i+1], abs(h[i] - h[i+1]) + dp[i]) 
    if i+2 < n:
        dp[i+2] = min(dp[i+2], abs(h[i] - h[i+2]) + dp[i])
print(dp[-1])



Measured memory_bytes: 20516
import os
import sys
from io import BytesIO, IOBase


def main():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    ans = 0
    k=max(arr)
    d = [0]*(k+1)
    if arr[0] == 1:
        if n>1 and arr[1]==1:
            print(0)
            quit()
        else:
            print(1)
            quit()
    for i in range(n):
        d[arr[i]]+=1
    for i in range(n):
        x=arr[i]
        if d[x]==1:
            ans+=1
        for j in range(x,k+1,x):
            d[j]+=1
    print(ans)


# fast-io region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end="\n"):
    for x in args[:-1]:
        sys.stdout.write(str(x) + " ")
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()


Measured memory_bytes: 34140
#include <stdio.h>

int main(void)
{
    long int n=0,k=0;
    long int sum=0;
    scanf("%d %d",&n,&k);

    for(int i=k;i<=n+1;i++){
        sum+=i*(n-i+1)+1;
    }

    sum=sum%1000000007;
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;
typedef long long ll;
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 #define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) FOR(i,0,sz(v)-1) cout << v[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define PI 3.14159265358979323846264338327950288419716939937510
const ll inf = 1e9;
const ll cons= 1e16;
const ll MOD = 1e9+9;
const ll N = 2e4 + 1;
const ll m = MOD;
int mod(int x)
{
    if(x<0)return -x;
    else return x;
}
int power(int x, int y) 
{ 
    int res = 1;
    x = x % MOD;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % MOD;
            y = y>>1; 
        x = (x*x) % MOD;   
    } 
    return res; 
} 
int lis( int arr[], int n )  
{  
    int lis[n+1]={0}; 
   
    lis[1] = 1;    
    for (int i = 2; i <= n; i++ )  
    { 
        lis[i] = 1; 
        for (int j = 1; j < i; j++ )   
            if ( arr[i] > arr[j])  
                lis[i] = max(lis[i],lis[j] + 1);  
    } 
 int maxe=0;
   FOR(i,1,n)
   {
   	maxe=max(maxe,lis[i]);
   }
   return maxe;
}  	
//THIS IS LA LA LA PRODUCTION HOUSE;
//Longest Common Subsequence;
signed main()
{
	string s,t;
	cin>>s>>t;
	int n,m;
	n=s.size();m=t.size();
	int lcs[n+1][m+1];
	FOR(i,0,n)
	FOR(j,0,m)lcs[i][j]=0;
	FOR(i,1,n)
	{
		FOR(j,1,m)
		{
			if(s[i-1]==t[j-1])
			{
				lcs[i][j]=lcs[i-1][j-1]+1;
			}
			else
			lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
		}
	}
	//cout<<lcs[n][m]<<endl;
	string ans;
	 int i=n,j=m;
	  while(i>=1 && j>=1)
	  {
			if(s[i-1]==t[j-1])
			{
				ans+=s[i-1];
				i--;j--;
			}
			else
			{
				if(lcs[i][j]==lcs[i-1][j])
				i--;
				else j--;
			}
	  }
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 73944
def main():
    N = input()
    sum_all_digits = 0

    for ch in N:
        sum_all_digits += int(ch)

    if sum_all_digits % 9 == 0:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[100000];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int light=1,cnt=0;
	while(light!=2){
		light=a[light-1];
		cnt++;
		if(cnt>=n){
			cnt=-1;
			break;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string.h>
using namespace std;

typedef struct {
	int top;
	int S;
	int E;
	int W;
	int N;
	int down;
} stDICEINFO;


#define MAX 110
#define DICEMAX 6

char* input(char *str, int size)
{
	char *c;
	fgets(str, size, stdin);
	if ((c=strchr(str,'\n')) != NULL) {
		*c = '\0';
	}

	return str;
}

int main(void)
{
	stDICEINFO stDice = {0,1,2,3,4,5};
	char str[MAX];
	long lInput[DICEMAX];
	long tmp;
	char *c;
	int i;

	(void)input(str, MAX);
	for (i=0; i<DICEMAX; i++) {
		if (i==0) {
			c = strtok(str," ");
		}
		else {
			c = strtok(NULL," ");
		}
		lInput[i] = strtol(c,NULL, 10);
	}

	(void)input(str, MAX);
	for (i=0; str[i]!='\0'; i++) {
		switch(str[i]) {
		case 'S':
			tmp			= stDice.top;
			stDice.top	= stDice.N;
			stDice.N	= stDice.down;
			stDice.down	= stDice.S;
			stDice.S	= tmp;
			break;
		case 'W':
			tmp			= stDice.top;
			stDice.top	= stDice.E;
			stDice.E	= stDice.down;
			stDice.down	= stDice.W;
			stDice.W	= tmp;
			break;
		case 'N':
			tmp			= stDice.top;
			stDice.top	= stDice.S;
			stDice.S	= stDice.down;
			stDice.down	= stDice.N;
			stDice.N	= tmp;
			break;
		case 'E':
			tmp			= stDice.top;
			stDice.top	= stDice.W;
			stDice.W	= stDice.down;
			stDice.down	= stDice.E;
			stDice.E	= tmp;
			break;
		default:
			break;
		}
	}
	printf("%ld\n", lInput[stDice.top]);

	return 0;
}


Measured memory_bytes: 3224