akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;


long long countdebt(long long bj, int n) {
	if (n == 0)
		return bj;
	else
		countdebt(bj + (((bj / 20) % 1000 == 0) ? (bj / 20) : (((bj / 20) / 1000ll + 1ll) * 1000ll)),n-1);
}

int main() {
	int n = 0;
	cin >> n;
	cout << countdebt(100000, n) << endl;
	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmin(a,b) a=min(a,b);
#define N 100010
vector<P> g[2*N];
ll d[2*N],n,h,w;
 
ll mi[2];
bool dfs(ll x,ll dis,ll col){
    if(d[x]!=-1e17){
	if(d[x]!=dis)return 0;
	return 1;
    }//cout<<"#"<<x<<" "<<dis<<" "<<col<<endl;
    d[x]=dis; chmin(mi[col],dis);
    for(auto y:g[x]){
	if(!dfs(y.first,y.second-dis,col^1))return 0;
    }
    return 1;
}
 
int main(){
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
	ll a,b,c;cin>>a>>b>>c;
	b+=N;
	g[a].push_back(make_pair(b,c));
	g[b].push_back(make_pair(a,c));
    }
    for(int i=0;i<2*N;i++)d[i]=-1e17;
    bool ok=1;
    for(int i=0;i<2*N;i++){
	if(d[i]!=-1e17)continue;
	mi[0]=mi[1]=1e17;
	ok&=dfs(i,1,0);
	if(mi[0]+mi[1]<0)ok=0;
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 16384
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < n; ++i)

char s[100001];

bool c(char *a, string b) {
	f(i, 0, b.size())if (a[i] != b[i])return false;
	return true;
}

int main() {
	scanf("%s", s);
	int n = strlen(s), i = 0;
	bool z = false, k = false;
	while (i < n) {
		if (c(s + i, "dream"))i += 5, z = true, k = false;
		else if (c(s + i, "erase"))i += 5, k = true, z = false;
		else if (z && c(s + i, "er"))i += 2, z = false;
		else if (k && c(s + i, "r"))++i, k = false;
		else printf("NO\n"), exit(0);
	}
	printf("YES\n");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    S = "#" + S;
    int maxi = max(C, D);
    for(int i = A; i < maxi; i++) {
        if(S[i] == '#' && S[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if(C < D) {
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = B; i <= D; i++) {
        if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void){
  int X, Y;
  cin >> X >> Y;
  for(int c = 0; c <= X; c++){
      int t;
      t = X - c;
      int asi = 2*c + 4*t;
      if(asi == Y){
          cout << "Yes" << endl;
          return 0;
      }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B; cin >> A >> B;
  if(1 <= A && A <= 9 && 1 <= B && B <= 9) cout << A*B << endl;
  else cout << -1 << endl;
  return 0;
}


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

int main() {
    int n, wmax;
    cin >> n >> wmax;
    int w[n], v[n];
    for (int i=0; i<n; i++)
        cin >> w[i] >> v[i];

    long long dp[n+1][wmax+1];
    for (int i=0; i<=n; i++)
        for (int j=0; j<=wmax; j++)
            dp[i][j]=0;

    for (int i=1; i<=n; i++)
        for (int j=1; j<=wmax; j++)
            if (j-w[i-1]>=0)
                dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1]);
            else
                dp[i][j]=dp[i-1][j];

    cout << dp[n][wmax];
}



Measured memory_bytes: 79104
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]*(n+1)
count = 1
for i in range(n):
    
    d[i+1]=d[i]+l[i]
    if d[i+1] <=x:
        count += 1
    #print(d)
print(count)


Measured memory_bytes: 2940
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
dst = {}
for i in range(m):
    a,b,c = inm()
    if a not in dst:
        dst[a] = {}
    dst[a][b] = c
    if b not in dst:
        dst[b] = {}
    dst[b][a] = c
d = [[BIG]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
    d[i][i] = 0
    for j in dst[i]:
        d[i][j] = dst[i][j]
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
sm = 0
for i in range(1,n):
    for j in range(i+1,n+1):
        if j in dst[i] and dst[i][j]>d[i][j]:
            sm += 1
print(sm)


Measured memory_bytes: 42476
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <cctype>
using namespace std;
#define _USE_MATH_DEFINES


int main() {
	string str;
	while (1) {
		cin >> str;
		if (str == "0")
			break;
		else {
			int sum = 0;
			for (int i = 0; i < str.size(); i++) {
				sum += (int)(str[i] - '0');
			}
			cout << sum << endl;
		}
	}
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示    
		int N = sc.nextInt();
		int X[] = new int[N];

		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int c = 0;
			
			for (int i : X) {
				c += (i - j) * (i - j);
			}
			ans = Math.min(ans, c);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27220
#include <iostream>
#include <unordered_map>
using namespace std;
int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M, D, T;
	cin >> N;
	unordered_map<int, int> mp(N);
	for (int i = 0; i < N; ++i) {
		cin >> D;
		mp[D] = mp[D] +1;
	}
	cin >> M;
	bool ok = true;
	for (int i = 0; i < M; ++i) {
		cin >> T;
		if (mp[T] > 0) mp[T] = mp[T] - 1;
		else {
			ok = false;
			break;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];
  
  vector<int> c(N);
  c[0] = 0;
  c[1] = abs(h[0] - h[1]);
  for(int i = 2; i < N; ++i) {
    c[i] = min(c[i - 2] + abs(h[i - 2] - h[i]), c[i - 1] + abs(h[i - 1] - h[i]));
  }
  
  cout << c[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
int n,i,d,a[N],cnt[N];
int main()
{
//	freopen("tree.in","r",stdin);
//	freopen("tree.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n) {
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	sort(a+1,a+1+n);
	if (a[n-1]!=a[n]) {
		printf("Impossible\n");
		return 0;
	}
	cnt[a[n]]-=2;
	rep(i,1,a[n]-1)
	{
		d=max(i,a[n]-i);
		if (cnt[d]<1) {
			printf("Impossible\n");
			return 0;
		}
		cnt[d]--;
	}
	rep(i,1,(a[n]+1)/2)
		if (cnt[i]) {
			printf("Impossible\n");
			return 0;
		}
	printf("Possible\n");
	return 0;
}

Measured memory_bytes: 128
def get_num(u, map, vis):
    if u in vis:
        return 0;
    else:
        vis[u] = True;
    ans = 0;
    if u in map:
        for v in map[u]:
            ans += get_num(v, map, vis);
    else:
            ans += 1;
    return ans;
def main():
    while True:
        n = int(input());
        if n == 0:
            break;
        edge = {}; name = {}; vis = {};
        for i in range(0, n):
            str = input();
            u = name[i] = str.split(':')[0];
            group = str.split(':')[1].split('.')[0].split(',');
            for v in group:
                if u in edge:
                    edge[u][v] = True;
                else:
                    edge[u] = {v:True};
        print(get_num(name[0], edge, vis));
main();

Measured memory_bytes: 6904
n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int,input().split()))
def add_check(i,m):
    if m == 0:
        return True
    if m < 0 or m > sum(A[i:n]):
        return False
    if i >= n:
        return False
    if add_check(i+1,m) or add_check(i+1,m-A[i]):
        return True
for i in range(q):
    if add_check(0,M[i]):
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5620
from collections import Counter

N = int(input())
a = list(map(int,input().split()))

# a^c == b
# b^(a^c) == b^b == 0
# a^b^c == 0

if sum(a)  == 0:
    print("Yes")
    exit(0)

if N%3 != 0:
    print("No")
    exit(0)

b = list(set(a))
if len(b) > 3:
    print("No")
    exit(0)

A = Counter(a)
if len(b) == 3:
    if A[b[0]] == A[b[1]] == A[b[2]]:
        if b[0]^b[1]^b[2] == 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    if A[0] == N//3:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14468
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    i64 n;
    std::cin >> n;
    i64 a, b;
    std::cin >> a >> b;
    if((b - a) % 2 == 0) {
        std::cout << (b - a) / 2 << std::endl;
    } else {
        i64 d1, d2, d3, d4;
        d1 = std::max(a - 1, b - 1);
        d2 = std::max(n - b, n - a);
        d3 = (a - 1) + (b - a + 1) / 2;
        d4 = (n - b) + (b - a + 1) / 2;
        std::cout << std::min<i64>({d1, d2, d3, d4}) << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
int n,k;
int A[200010],F[200010];
bool judge(int x){
    int count=0;
    rep(i,n){
        count+=max((int)0,A[i]-x/F[i]);
    }
    //cout<<count<<endl;
    if(count<=k)return true;
    return false;
    
}
signed main() {
    cin>>n>>k;
    rep(i,n)cin>>A[i];
    rep(i,n)cin>>F[i];
    sort(A,A+n,greater<int>());
    sort(F,F+n);
    int f=-1,e=1000000000005;
    while(e-f>1){
        int mid=(e+f)/2;
        if(judge(mid))e=mid;
        else f=mid;
    }
    cout<<f+1<<endl;
    
    
}

Measured memory_bytes: 3328
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n),zip;
  rep(i,n) cin>>a[i];
  zip=a;
  sort(all(zip));
  for(int &x:a) x=lower_bound(all(zip),x)-zip.begin();
  int re=0;
  rep(i,n) if(i%2 != a[i]%2) ++re;
  cout<<re/2<<endl;
  return 0;
}


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

int main(){
  string s ; cin >> s ;
  bool ok = true ;
  for(int i=1;i<4;i++){
    if(s.at(i)==s.at(i-1)) ok = false ;
  } 
  if(ok) cout << "Good" << endl ;
  else cout << "Bad" << endl ;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int,int> pll;
const int maxn= 2e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;

LL fact[maxn],infact[maxn];
int qmi(int a, int k, int p)    // 快速幂模板
{
    int res = 1;
    while (k)
    {
        if (k & 1)
            res = (LL)res * a % p;
        a = (LL)a * a % p;
        k >>= 1;
    }
    return res;
}
LL C(LL a,LL b)
{
    return fact[a]*infact[b]%mod*infact[a-b]%mod;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    LL ans=0;
    // 预处理阶乘的余数和阶乘逆元的余数
    fact[0] = infact[0] = 1;
    for (int i = 1; i <=n; i ++ )
    {
        fact[i] = (LL)fact[i - 1] * i % mod;
        infact[i] = (LL)infact[i - 1] * qmi(i, mod - 2, mod) % mod;
    }
    for(int i=1; i<=min(k,n-1); i++)
    {
        ans=(ans+C(n,i)*C(n-1,n-1-i)%mod+mod)%mod;
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
int main(void){
    long prime[500000]; // prime numbers
    long n;
    long *ptr,*cur;
    long j;
    int i;
    long counter;
    ptr = prime;
    *ptr=2;
    while(fscanf(stdin,"%d",&n) != EOF){
        if(n > *ptr){ // prime update
            for(j=*ptr+1; *ptr < n; j++){ // j -> candidate for prime numbers
                for(cur=prime;*cur <= sqrt(j);cur++){
                    if(j % *cur == 0){
                        break;
                    }
                }
                if(j % *cur != 0){
                    ptr++;
                    *ptr = j;
                }
            }
        }
        //count prime 
        counter = 0;
        while(prime[counter] <= n){
            counter++;
            if(prime[counter-1] == n){
                break;
            }
        }
        printf("%d\n",counter);
    }
    return 0;
}

Measured memory_bytes: 1216
import sys
sys.setrecursionlimit(2*10**5)
question = 1
AND = -1
OR = -2
left = -3
right = -4

tr = {'?': 1, '&': -1, '|': -2, '(': -3, ')': -4}

def evalor(L):
    if len(L) == 1:
        return L[0]
    x0, x1 = L[0]
    for i in range(1, len(L)):
        y0, y1 = L[i]
        x0, x1 = x0 + y0, min(x1, x0 + y1)
    return (x0, x1)

def push(f, s):
    if f and f[-1] == (AND, AND):
        f.pop()
        p = f.pop()
        return push(f, andeval(p, s))
    else:
        f.append(s)
        return f

def andeval(p, s):
    x0, x1 = p
    y0, y1 = s
    return (min(x0, x1 + y0), x1 + y1)
    

S = [tr[s] for s in input().strip()]
f = []
for s in S:
    if s == question:
        f = push(f, (s, s))
    elif s == AND or s == left:
        f.append((s, s))
    elif s == right:
        stack = []
        while f[-1] != (left, left):
            sp = f.pop()
            assert sp[0] > 0 and sp[1] > 0
            stack.append(sp)
        assert f.pop() == (left, left)
        push(f, evalor(stack[::-1]))
f = evalor(f)
print(*f)


Measured memory_bytes: 7480
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <string>

template <class T>
using sp = std::shared_ptr<T>;

struct Node
{
    explicit Node(int key)
        : key {key}
    {}

    int key;
    sp<Node> paprent {nullptr};
    sp<Node> left {nullptr};
    sp<Node> right {nullptr};
};

class BinarySearchTree
{
public:

    void insert(int key)
    {
        auto z = std::make_shared<Node>(key);
        //xの親を保持
        sp<Node> y {nullptr};
        auto x {root};

        while (x != nullptr)
        {
            //親を保持
            y = x;
            if (key < x->key)
                x = x->left;
            else
                x = x->right;
        }
        z->paprent = y;

        if (y == nullptr)           root = z;
        else if (z->key < y->key)   y->left = z;
        else                        y->right = z;
    }

    bool find(int key)
    {
        return find(key, root);
    }

    void printInorder()
    {
        printInorder(root);
    }

    void printPreorder()
    {
        printPreorder(root);
    }

private:

    sp<Node> root {nullptr};

    bool find(int key, sp<Node> n)
    {
        if (n == nullptr)
            return false;
        if (key == n->key)
            return true;
        else if (key < n->key)
            return find(key, n->left);
        else
            return find(key, n->right);
    }

    void printInorder(sp<Node> c)
    {
        if (c == nullptr)
            return;

        printInorder(c->left);
        std::cout << " " << c->key;
        printInorder(c->right);
    }

    void printPreorder(sp<Node> c)
    {
        if (c == nullptr)
            return;

        std::cout << " " << c->key;
        printPreorder(c->left);
        printPreorder(c->right);
    }
};

void solve();

int main()
{
    solve();
    return 0;
}

void solve()
{
    using namespace std;

    int n;
    cin >> n;
    BinarySearchTree tree;

    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;

        int key;
        if (s == "insert")
        {
            cin >> key;
            tree.insert(key);
        }
        else if (s == "find")
        {
            cin >> key;
            cout << (tree.find(key) ? "yes" : "no") << endl;
        }
        else
        {
            tree.printInorder();
            cout << endl;
            tree.printPreorder();
            cout << endl;
        }
    }


}


Measured memory_bytes: 34412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  string judge;
  cin >> S >> T;
 
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == T.at(i)) {
      judge = "Yes";
    }
    else {
      judge = "No";
      break;
    }
  }
  
  if (S.size() > 10){
    judge = "No";
  }
  if (T.size() - S.size() != 1){
    judge = "No";
  }
  
  cout << judge << endl ;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  if(n/10%10==n/100%10 && (n/1000==n/100%10||n%10==n/100%10)){
    cout << "Yes" << endl; 
  } else {
    cout << "No" << endl; 
  }

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, x, d[20], c[20];
bool v[300000];

int main(){
	cin >> n >> x;
	rep(i, n) cin >> d[i] >> c[i];
	
	priority_queue<pi> q;
	q.push(pi(0, 0));
	while(!q.empty()){
		int cur = q.top().second, cost = -q.top().first; q.pop();
		if(v[cur]) continue;
		v[cur] = 1;
		if(cur == x){
			cout << cost << endl;
			return 0;
		}
		rep(i, n){
			int nxt = cur + d[i];
			if(nxt < 300000 && !v[nxt]) q.push(pi(-cost - c[i], nxt));
			
			nxt = cur - d[i];
			if(nxt >= 0 && !v[nxt]) q.push(pi(-cost - c[i], nxt));
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 19604
N, X = map(int, input().split())
def f(n, x):
    if x ==0:
        return 0
    if n == 0:
        return 1
    if x <= 2**(n+1) - 2:
        return f(n-1, x-1)
    else:
        return 2**n+f(n-1, x-2**(n+1)+1)
print(f(N, X))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 998244353
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 
ll power(ll x,ll y,ll p){ll res=1;x=x%p;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res%MOD;}  

int main(){
    int r;
    cin>>r;
    double c = (double)r*(double)3.141592*2.00;
    cout<<c<<endl;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
ll dp[1010][1010];
int main()
{
    string t,b;
    cin>>t>>b;
    REP(i,t.size()+1)dp[0][i]=1;
    REP(i,b.size())
    {int dpi=i+1;
        REP(j,t.size())
        {int dpj=j+1;
            dp[dpi][dpj]+=dp[dpi][dpj-1];dp[dpi][dpj]%=mod;
            if(t[j]==b[i])dp[dpi][dpj]+=dp[dpi-1][dpj-1];
            dp[dpi][dpj]%=mod;
        }
    }
    cout<<dp[b.size()][t.size()]<<endl;
}



Measured memory_bytes: 11076
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int div4 = 0;
        int div2 = 0;
        int odd = 0;
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(a % 4 == 0){
                div4++;
            }else if(a % 2 == 0){
                div2++;
            }else{
                odd++;
            }
        }
        if(n/2 <= div4 || n-div4*2 <= div2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 48328
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X, Y, Z = LI()

print(Z, X, Y)

Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

void check(int n, vector<uint32_t> const & x, vector<uint32_t> const & y) {
    auto distinguishable = vectors(n, n, bool());
    REP (k, 8) {
        REP (j, n) REP (i, j) if (i != j) {
            if ((x[i] & (1 << k)) != (x[j] & (1 << k))) {
                distinguishable[i][j] = true;
            }
            if ((y[i] & (1 << k)) != (y[j] & (1 << k))) {
                assert (distinguishable[i][j]);
            }
        }
    }
}

uint8_t kth_column(vector<uint32_t> const & x, int k) {
    int n = x.size();
    assert (n <= 8);
    uint8_t acc = 0;
    REP (i, n) {
        if (x[i] & (1 << k)) {
            acc |= 1 << i;
        }
    }
    return acc;
}

int main() {
    // input
    int n; cin >> n;
    vector<uint32_t> x(n), y(n);
    REP (i, n) cin >> x[i] >> y[i];
    // solve
    check(n, x, y);
    string result = "0";
    vector<string> memo(1 << n);
    memo[0] = "0";
    memo[(1 << n) - 1] = "1";
    REP (k, 8) {
        // prepare a queue
        queue<uint8_t> que;
        auto push = [&](uint8_t a, string const & s) {
            if (memo[a].empty()) {
                que.push(a);
                memo[a] = s;
            }
        };
        { // add a new primitive
            ostringstream oss;
            oss << "(x&" << (1 << k) << ")";
            push(kth_column(x, k), oss.str());
        }
        // breath first search
        while (not que.empty()) {
            uint8_t a = que.front(); que.pop();
            string s = memo[a];
            {
                ostringstream oss;
                oss << "((~" << s << ")&" << (1 << k) << ")";
                push((~ a) & ((1 << n) - 1), oss.str());
            }
            REP (b, 1 << n) if (not memo[b].empty()) {
                string t = memo[b];
                push(a & b, "(" + s + "&" + t + ")");
                push(a | b, "(" + s + "|" + t + ")");
                push(a ^ b, "(" + s + "^" + t + ")");
            }
        }
        // add to the result
        assert (not memo[kth_column(y, k)].empty());
        result = "(" + result + "|" + memo[kth_column(y, k)] + ")";
        // lshift old items
        REP (a, 1 << n) if (not memo[a].empty()) {
            memo[a] = "(" + memo[a] + "*2)";
        }
    }
    // output
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3288
1# bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
2#   flag = 1 // 逆の隣接要素が存在する
3#   while flag
4#     flag = 0
5#     for j が N-1 から 1 まで
6#       if A[j] < A[j-1]
7#         A[j] と A[j-1] を交換
8#         flag = 1

n = int(input())
nums = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for j in range(n-1, 0, -1):
        if nums[j] < nums[j-1]:
            nums[j], nums[j-1] = nums[j-1], nums[j]
            count += 1
            flag = True

print(*nums)
print(count)


Measured memory_bytes: 5608
// In The Name Of God
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()


char g[111][111];

/// . a
/// # b

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a,b; cin >> a >> b;
    int x,y;
    x = 0;
    y = 0;
    for2(i,0,100) g[0][i] = '#';
    x++;
    b--;
    while(a != 1){
        g[x][y] = '.';
        a --;
        y++;
        g[x][y] = '#';
        y++;
        if(y==100){
            x++;
            y = 0;
            for2(i,0,100) g[x][i] = '#';
            x++;
        }
    }

    for2(i,y,100) g[x][i] = '#';
    x++;
    for2(i,0,100) g[x][i] = '#';
    x++;
    y = 0;
    for2(i,0,100) g[x][i] = '.';
    x++;
    a--;
    while(b != 0){
        g[x][y] = '#';
        b --;
        y++;
        g[x][y] = '.';
        y++;
        if(y==100){
            x++;
            y = 0;
            for2(i,0,100) g[x][i] = '.';
            x++;
        }
    }
    while(x != 100){
        g[x][y] = '.';
        y++;
        if(y==100){
            y = 0;
            x++;
        }
    }
    cout << 100 << ' ' << 100 << endl;
    for2(i,0,100){
        for2(j,0,100) cout << g[i][j];
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>
#include <stack>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

int n;
int x[101];

void solve(){
  cin >> n;
  int c;
  stack<int>q;
  for(int i=0;i<n;i++){
    cin >> c;
    if(c<0){
      if(q.size()==0 || q.top()!=abs(c)){
        cout << i+1 << endl;
        return;
      }
      else{
        x[q.top()]=0;
        q.pop();
      }
    }
    if(c>0){
      if(x[c]==1){
        cout << i+1 << endl;
        return;
      }
      else{
        q.push(c);
        x[c]=1;
      }
    }
  }
  cout << "OK" << endl;
}

int main() {
  solve();
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int A; cin >> A;
    cout << "ABC" << A << endl;
}



Measured memory_bytes: 256
#include <iostream>
void calcNum(int a,int b,char op);
using namespace std;

int main(int argc, const char * argv[]) {
    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        //op == '?' ? break : calcNum(a, b, op);  <-これ何故できないのかわかりません
        if (op=='?') {
            break;
        }else{
            calcNum(a, b, op);
        }
    }
    return 0;
}
void calcNum(int a,int b,char op){
    if (op=='+') {
        cout << a+b << endl;
    }else if(op=='-'){
        cout << a-b << endl;
    }else if(op=='*'){
        cout << a*b << endl;
    }else if(op=='/'){
        cout << a/b << endl;
    }
}



Measured memory_bytes: 3116
#include<stdio.h>

int main(void){
  int n,m,i,now,man[1000],remain;
  while(scanf("%d %d",&n,&m) && (n!=0 || m!=0)){
    remain=n;
    now=0;
    for(i=0;i<n;i++) man[i]=0;
    i=1;
    while(remain>1){
      //printf("now:%d,i:%d\n",now,i);
      if(!man[now]){
	if(i==m){
	  //puts("retire");
	  man[now]++;
	  //printf("%d\n",now);
	  remain--;
	}
	i++;
	if(i>m) i%=m;
      }
      now++;
      if(now==n) now=0;
    }
    for(i=0;i<n;i++){
      if(!man[i]){
	printf("%d\n",i+1);
	break;
      }
    }
  }
  return 0;
}
      
    
  

Measured memory_bytes: 604
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

template<typename T>
struct range_max{
    vector<T> tr;
    void build(int l,int r,int v=1){
        if(l==r){
            //tr[v]=a[r];
            return;
        }
        int mid=(l+r)/2;
        build(l,mid,2*v);
        build(mid+1,r,2*v+1);
        tr[v]=max(tr[2*v],tr[2*v+1]);
    }

    void update(int l,int r,int pos,T val,int v=1){
        if(pos<l || pos>r)return;
        if(l==r && l==pos){
            tr[v]=val;
            return;
        }
        else if(l==r)return;
        int mid=(l+r)/2;
        update(l,mid,pos,val,2*v);
        update(mid+1,r,pos,val,2*v+1);
        tr[v]=max(tr[2*v+1],tr[2*v]);
    }

    T query(int l,int r,int st,int end,int v=1){
        //debug(l,r,st,end);
        if(st>end)return 0;
        if(l==st && r==end)return tr[v];
        int mid=(l+r)/2;
        T t1=query(l,mid,st,min(mid,end),2*v);
        T t2=query(mid+1,r,max(st,mid+1),end,2*v+1);
        return max(t1,t2);
    }
};

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for(auto &x:h)cin>>x;
    vector<int> a(n);
    for(auto &x:a)cin>>x;
    range_max<ll> seg_tree;
    seg_tree.tr.resize(4*n+1);
    for(int i=0;i<n;i++){
        ll mx=seg_tree.query(0,n-1,0,h[i]-1);
        seg_tree.update(0,n-1,h[i]-1,mx+a[i]);
    }
    ll ans=seg_tree.query(0,n-1,0,n-1);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 11196
/*
Task:
Author: John_05
State: Unknown
Lang: C++
Solution:
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int main() {
	int a,b,c;
	a=read();
	b=read();
	c=read();
	if(c>b/a) printf("%d\n",b/a);
	else printf("%d\n",c);
	return 0;
}

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

int main(){
    int a[4][3][10],n;
    memset(a,0,sizeof(a));
    
    cin >> n;
        for(int i = 0 ; i < n ; i++){
            int b,f,r,v;
            cin >> b >> f >> r >> v;
            a[b-1][f-1][r-1] += v;
        }
    
        for(int i = 0 ; i < 4 ; i++){
            if(i) cout << "####################" << endl;
            for(int j = 0 ; j < 3 ; j++){
                for(int k = 0 ; k < 10 ; k++){
                    cout << ' ' << a[i][j][k];
                }
                puts("");
            }
        }

    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define f(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define int long long int
#define mii map<int, int>
#define vi vector<int>
#define fi(i, a, n)             \
    for (int i = 0; i < n; i++) \
    {                           \
        cin >> a[i];            \
    }
#define fo(i, a, n)             \
    for (int i = 0; i < n; i++) \
    {                           \
        cout << a[i] << " ";    \
    }
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define mk(arr, n, type) type *arr = new type[n];
#define pw(b, p) pow(b, p) + 0.1
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define lbrk printf("\n")

using namespace std; //_S_A_R_T_H_A_k_//
/// JAI SHREE RAM!!! ;{'*' <_l_> '*' };
/// Saare jahan se acha hindustan humara .....
/// JAI HIND DOSTON //-__ -//
void lcsBU(string s1,string s2,int n,int m){
    int dp[n+1][m+1];
    for(int i=0;i <= n;i++)
    {
        for(int j=0;j <= m;j++)
        {
            if(i==0 || j == 0)
            {
                dp[i][j] = 0;
                continue;
            }
 
            if(s1[i-1] == s2[j-1])
            {
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
  //    return dp[s1.size()][s2.size()];
    int i = n;
    int j = m;
    string res;
    while (i>0 and j>0)
    {
        if(dp[i][j]==dp[i][j-1]){
            j--;
        }
        else if (dp[i][j]==dp[i-1][j])
        {
            i--;
        }
        else{
         res = s1[i-1]+res;   
         i--;
        j--;
        }
    }
    cout<<res<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    string s1, s2;
    cin>>s1>>s2;
 int n =s1.length();
 int m = s2.length();
   lcsBU(s1,s2,n,m);
}

Measured memory_bytes: 70656
S = list(input())
ans = [0] * len(S)

count = 0
for i, s in enumerate(S):
    if S[i] == 'R':
        if S[i+1] == 'L':
            ans[i] += count//2 + 1
            ans[i+1] += count//2 + count%2 + 1
            count = 0
            continue
        count += 1

S.reverse()
ans.reverse()

count = 0
for i, s in enumerate(S):
    if S[i] == 'L':
        if S[i+1] == 'R':
            ans[i] += count//2
            ans[i+1] += count//2 + count%2
            count = 0
            continue
        count += 1

ans.reverse()
print(' '.join(map(str, ans)))

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

using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int m=n;
    int a,b;
    vector<int>v1,v2;
    int c=0;
    while(n--)
    {
         cin>>a;
         v1.push_back(a);
         cin>>b;
          v2.push_back(b);
    }
    c=0;
    int flag=0;
    for(int i=0;i<m;i++)
    {
         if(v1[i]==v2[i])
         {
         c++;
         if(c>=3)
         {
              flag=1;
              break;
         }
         }
         else
         c=0;
    }
    if(flag==1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
	return 0;
}

Measured memory_bytes: 3580
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      long a = sc.nextLong();
      long b = sc.nextLong();

      if((b - a) % 2 == 0) {
        System.out.println((b - a) / 2);
        return;
      }
      
      
      long leftCnt = a - 1;
      long nb = b - (a - 1);
      if(nb % 2 == 0) {
          leftCnt++;
          nb--;
      }
      leftCnt += (nb-1) / 2;

      long rightCnt = n - b;
      long na = a + (n - b);
      if((na % 2) != (n % 2)) {
        rightCnt++;
        na++;
      }
      rightCnt += (n - na) / 2;
     
      System.out.println(Math.min(leftCnt, rightCnt));
  }
}

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

using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second

ll cnt[1000004]={};
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        ll ans=0;
        bool ch=0;
        for(ll i=0;i<n;i++){cin>>a[i];cnt[a[i]]++;a[i]==1? ch=1:ch=ch;}
        if(ch&&cnt[1]==1){cout<<1;return 0;}
        else if(ch){cout<<0;return 0;}
        for(ll i=0;i<n;i++)
        {
            if(cnt[a[i]]>1){ans++;continue;}
            for(ll j=2;j<=sqrt(a[i]);j++)
            {

                if(a[i]%j==0&&cnt[a[i]/j]){ans++;break;}
                else if(a[i]%j==0&&cnt[j]){ans++;break;}
            }
        }
        cout<<n-ans;
    }
    return 0;
}


Measured memory_bytes: 12916
n = gets.to_i
a = n.times.map {gets.to_i}

x = 0
ans = 0
n.times do |i|
    if a[i] > x
        p -1
        exit
    elsif a[i] == x
        x += 1
    else
        ans += x - 1
        x = a[i] + 1
    end
end

p ans + x - 1

Measured memory_bytes: 3764
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;

 int main() {
   int H, W, cnt = 0;
   cin >> H >> W;

   vector<vector<char>> s(H + 2, vector<char>(W + 2, '#'));
   vector<vector<int>> dist(H + 2, vector<int>(W + 2, -1));

   rep(i, 1, H + 1) {
     rep(j, 1, W + 1) {
       cin >> s.at(i).at(j);
       if (s.at(i).at(j) == '.') cnt++;
     }
   }

   queue<pair<int, int>> q;
   q.push({1, 1});
   vector<pair<int, int>> adj{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
   dist.at(1).at(1) = 0;

   while (!q.empty()) {
     pair<int, int> tmp = q.front();
     q.pop();
     for (auto a : adj) {
       if (dist.at(tmp.first + a.first).at(tmp.second + a.second) == -1 && s.at(tmp.first + a.first).at(tmp.second + a.second) == '.') {
         q.push({tmp.first + a.first, tmp.second + a.second});
         dist.at(tmp.first + a.first).at(tmp.second + a.second) = dist.at(tmp.first).at(tmp.second) + 1;
       }
     }
   }

   if (dist.at(H).at(W) == -1) cout << -1 << endl;
   else cout << cnt - dist.at(H).at(W) - 1 << endl;
 }


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

ll modpow(ll a, ll n){
  ll ans = 1;
  while(n > 0){
    if(n & 1) ans = ans * a % 2019;
    n >>= 1;
    a = a * a % 2019;
  }
  return ans;
}

int main(){
	st s;
	cin >> s;
	ll n = s.size();
	vll mod2019(n + 1, 0);
	rep(i, 0, n) mod2019.at(n - 1 - i) = (mod2019.at(n - i) + (s.at(n - 1 - i) - '0') * modpow(10, i + 1)) % 2019;
	vll count(2019);
	rep(i, 0, n + 1) count.at(mod2019.at(i))++;
	ll ans = 0;
	rep(i, 0, 2019) ans += count.at(i) * (count.at(i) - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 5208
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int comp(const void *p1,const void *p2){
  int n1,n2;
  n1=*((const int *)p1);
  n2=*((const int *)p2);
  return n2-n1;
}

int main(void){
  int n,a,b,c,i,j,k,price=0,num=0,cal=0;
  double ratio=0,tmp;
  int *topping;

  scanf("%d",&n);
  topping=(int *)calloc(n,sizeof(int));
  scanf("%d %d",&a,&b);
  price=a;
  scanf("%d",&c);
  cal=c;
  ratio=(double)cal/price;

  for(i=0;i<n;i++) scanf("%d",topping+i);
  qsort(topping,n,sizeof(int),comp);
  for(i=0;i<n;i++){
    if((tmp=(double)(cal+topping[i])/(price+b))<ratio) break;
    price+=b;
    cal+=topping[i];
    ratio=tmp;
  }
  printf("%d\n",(int)floor(ratio));
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll m = n + 1;
    for (ll i = sqrt(n); i >= 2; i--) {
        bool f = n % i == 0;
        if (f) {
            ll j = n / i;
            m = min(m, i + j);
            break;
        }
    }
    cout << m - 2 << "\n";
    return 0;
}

Measured memory_bytes: 256