akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, M;
    cin >> N >> M;
    vec penalty(N, 0);
    ll ans = 0, pen = 0;
    while (M--) {
        ll p;
        string S;
        cin >> p >> S;
        p--;
        if (S == "AC") {
            if (penalty[p] != -1) {
                pen += penalty[p];
                ans++;
                penalty[p] = -1;
            }
        } else {
            if (penalty[p] != -1) {
                penalty[p]++;
            }
        }
    }

    cout << ans << " " << pen << endl;
}

Measured memory_bytes: 1024
def find_gcd(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    if r == 0:
        return b
    else:
        return find_gcd(b, r)

A, B, K = [int(s) for s in input().split(' ')]
gcd = find_gcd(A, B)
if K == 1:
    print(gcd)
else:
    for i in range(gcd // 2, 0, -1):
        if gcd % i == 0:
            K -= 1
        if K == 1:
            break
    print(i)

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

def gcd(a,b):
    if b ==0:return a
    return gcd(b,a%b)

s=gcd(x[0],x[1])
if n==2: print(s)
else:
    for i in range(2,n):
        s=gcd(s,x[i])
    print(s)

Measured memory_bytes: 14252
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, T = LI()

    ans = T // A * B
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10004
function Main(input) {
  input = input.split("\n");
  A = parseInt(input[0].split(" ")[0]);
  B = parseInt(input[0].split(" ")[1]);
  C = parseInt(input[0].split(" ")[2]);
  X = parseInt(input[0].split(" ")[3]);
  Y = parseInt(input[0].split(" ")[4]);
  var ans =0;
  if(X<=Y){
    if(C<=(A+B)/2&&C*2>=B){
      ans=C*X*2+B*(Y-X);
    }else if(C<=(A+B)/2&&C*2<B){
      ans=C*Y*2;
    }else{
      ans=X*A+Y*B;
  
    }

  }else{
    if(C<=(A+B)/2&&C*2>=A){
      ans=C*Y*2+A*(X-Y);
    }else if(C<=(A+B)/2&&C*2<A){
      ans=C*X*2;
    }else{
      ans=X*A+Y*B;
  
    }
  }


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
ll t; cin >> t;
ll count = 0;
while(t--){
ll x,y; cin >> x >> y;
if(x == y)
count = min(count + 1, 3LL);
else if(count != 3 && x != y)
count = 0;
}
if(count == 3){
	cout<<"Yes";
}
else{
	cout<<"No";
}
return 0;}

Measured memory_bytes: 3592
class dsu:
    def __init__(self, n=0):
        self._n = n
        self.parent_or_size = [-1] * n
    
    def merge(self, a: int, b: int) -> int:
        x = self.leader(a)
        y = self.leader(b)
        if x == y:
            return x
        if self.parent_or_size[x] > self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x
    
    def same(self, a: int, b: int) -> bool:
        return self.leader(a) == self.leader(b)
    
    def leader(self, a: int) -> int:
        x = a
        while self.parent_or_size[x] >= 0:
            x = self.parent_or_size[x]
        while a != x:
            self.parent_or_size[a], a = x, self.parent_or_size[a]
        return x
    
    def size(self, a: int) -> int:
        return -self.parent_or_size[self.leader(a)]
    
    def groups(self):
        g = [[] for _ in range(self._n)]
        for i in range(self._n):
            g[self.leader(i)].append(i)
        return list(c for c in g if c)

import sys
input = sys.stdin.readline
n, q = map(int, input().split())
d = dsu(n)
for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        d.merge(u, v)
    else:
        print(int(d.same(u, v)))


Measured memory_bytes: 74804
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> struct Segtree {
    inline T merge(const T &a, const T &b) { return min(a, b); }
    inline void act(T &a, const T &b) { a = min(a, b); }
    int n;
    T e;
    vector<T> dat;
    Segtree(int n_, T e) : e(e) {
        n = 1;
        while (n < n_) {
            n <<= 1;
        }
        dat.resize(2 * n, e);
    }
    void upd(int k, const T &x) {
        k += n;
        act(dat[k], x);
        k >>= 1;
        while (k > 0) {
            dat[k] = merge(dat[k << 1], dat[k << 1 | 1]);
            k >>= 1;
        }
    }
    T get(const int &a, const int &b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return e;
        }
        if (a <= l && r <= b) {
            return dat[k];
        }
        return merge(get(a, b, k << 1, l, (l + r) >> 1),
                     get(a, b, k << 1 | 1, (l + r) >> 1, r));
    }
    inline T get(const int &a, const int &b) { //[a,b)
        if (a >= b) {
            return e;
        }
        return get(a, b, 1, 0, n);
    }
    int find(const int &a, const int &b, const T &x, int k, int l, int r) {
        if (b <= l || r <= a || dat[k] > x) {
            return -1;
        }
        if (k >= n) {
            return k - n;
        }
        int il = find(a, b, x, k << 1, l, (l + r) >> 1);
        if (il != -1) {
            return il;
        }
        return find(a, b, x, k << 1 | 1, (l + r) >> 1, r);
    }
    inline int find(const int &a, const int &b, const T &x) {
        if (a >= b) {
            return -1;
        }
        return find(a, b, x, 1, 0, n);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<pair<P, ll>> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i].first.second >> v[i].first.first >> v[i].second;
    }
    sort(all(v));
    Segtree<ll> seg(n + 2, LINF);
    seg.upd(1, 0);
    for (int i = 0; i < m; i++) {
        ll l = v[i].first.second, r = v[i].first.first, c = v[i].second;
        ll mi = seg.get(l, r);
        seg.upd(r, mi + c);
    }
    ll res = seg.get(n, n + 1);
    if (res == LINF) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }
}

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

int main() {
  char c;
  cin >> c;
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double tx=1.08;
int a;
int main(){
    cin>>a;
for(double k=1;k<=50000;k++){
   double val=k*tx;

   int h=(int)val;

   if(h==a){
    cout<<k;
    return 0;
   }
}
cout<<":(";
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[n];
        Arrays.setAll(array, i -> sc.nextInt());
        Arrays.sort(array);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += array[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38856
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint big=1e17-10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	llint n,a,b,c,d,i;cin>>n>>a>>b>>c>>d;n--;b-=a;b=abs(b);
	llint gen=0;
	for(i=0;i<n;i++){if(gen<b){gen+=c;}else{gen-=d;}}
	if(b<gen){gen-=c+d;}
	if(gen<=b&&b<=gen+((d-c)*n)){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	string s;

	cin >> s;

	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

Measured memory_bytes: 256
/*
    Author: DurJoy
*/

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x[i];
  sort(x.begin(), x.end());
  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> dif;
  ll res = 0;
  rep(i,m-1) {
    dif.push_back(abs(x[i] - x[i+1]));
    res += dif.back();
  }
  sort(dif.rbegin() , dif.rend());
  rep(i,n-1) {
    res -= dif[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1784
import bisect

s = input()
t = input()
T = set(t)
s_num = len(s)
t_num = len(T)

# make a dictonary whose keys are the alphabets in t
dict = {}
appearing_times = {}

# when each alphabet in t appears in s
for w in T:
    dict[w] = []
    appearing_times[w] = 0
    index = -1
    while True:
        index = s.find(w, index + 1)
        if index == -1 and appearing_times[w] == 0:
            print(-1)
            exit()
        elif index == -1:
            break
        else:
            dict[w].append(index)
            appearing_times[w] += 1

# how many times s is repeated
count = 0
# 0 <= length <= s_num - 1
s_index = 0
w_pre = 'none'

for w in t:
    idx = bisect.bisect_left(dict[w], s_index)
    if w == w_pre:
        idx += 1
        if idx == appearing_times[w]:
            count += 1
            idx = 0

    if idx < appearing_times[w]:
        s_index = dict[w][idx]
    else:
        count += 1
        s_index = dict[w][0]
    w_pre = w

print(count * s_num + s_index + 1)


Measured memory_bytes: 7284
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) {
            a[i + 1] <<= 1;
            a[i + 1] += a[i + 1] << 2;
            a[i + 1] += *pos++ - '0';
        }
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    rep(i, m) {
        while('0' <= *pos) {
            b[i + 1] <<= 1;
            b[i + 1] += b[i + 1] << 2;
            b[i + 1] += *pos++ - '0';
        }
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7836
H = int(input())
W = int(input())
N = int(input())

#行をa回、列をb回選んで操作した場合
#塗られるマスの数は(H *a + W *b - a * b)

A = list(range(H+1))
B = list(range(W+1))
AB = [[a, b] for a in A for b in B]

ANS = []
for ab in AB:
  a = ab[0]
  b = ab[1]
  SUM = H * a + W * b - a * b
  if N <= SUM:
    sum_N = a + b
    ANS.append(sum_N)

ANS.sort()
ans = ANS[0]
print(ans)

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

template <int32_t MOD>
struct mint {
    int32_t value;
    mint() : value() {}
    mint(int64_t value_) : value(value_ < 0 ? value_ % MOD + MOD : value_ >= MOD ? value_ % MOD : value_) {}
    inline mint<MOD> operator + (mint<MOD> other) const { int32_t c = this->value + other.value; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> operator - (mint<MOD> other) const { int32_t c = this->value - other.value; return mint<MOD>(c <    0 ? c + MOD : c); }
    inline mint<MOD> operator * (mint<MOD> other) const { int32_t c = (int64_t)this->value * other.value % MOD; return mint<MOD>(c < 0 ? c + MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
    inline mint<MOD> & operator -= (mint<MOD> other) { this->value -= other.value; if (this->value <    0) this->value += MOD; return *this; }
    inline mint<MOD> & operator *= (mint<MOD> other) { this->value = (int64_t)this->value * other.value % MOD; if (this->value < 0) this->value += MOD; return *this; }
};


constexpr int MOD = 1e9 + 7;


mint<MOD> solve(const string & l) {
    vector<mint<MOD> > dp(l.size() + 1);
    mint<MOD> boundary = 1;
    dp[0] = 1;
    REP (i, l.size()) {
        dp[i + 1] = dp[i] * 3 - (l[i] == '1' ? 0 : boundary * 2);
        if (l[i] == '1') {
            boundary *= 2;
        }
    }
    return dp[l.size()];
}

int main() {
    string l; cin >> l;
    cout << solve(l).value << endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
long long fac[8010], finv[8010], inv[8010]; 
long long MOD = 1000000007; 
int P[4010][4010]; 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 8005; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	int N; cin >> N; COMinit(); 
	int A[200010], B[200010]; 
	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
		P[2005+A[i]][2005+B[i]] ++; 
	}
	for(int s = 8009; s >= 4010; s--){
		for(int t = 4005; t >= s - 4005; t--){
			P[t][s-t] += P[t+1][s-t]; 
			P[t][s-t] += P[t][s-t+1]; 
			while(P[t][s-t] >= MOD) P[t][s-t] -= MOD; 
		}
	}
	long long all = 0LL; 
	for(int i = 5; i <= 4005; i++){
		all += (long long) P[i][4010-i] * P[4010-i][i] % MOD; 
	}
	all %= MOD; 
	long long minus = 0LL; 
	for(int i = 0; i < N; i++){
		minus += COM((A[i] + B[i]) * 2, A[i] * 2); 
	}
	minus %= MOD; 
	cout << (MOD + all - minus) * 500000004 % MOD << endl; 
}

Measured memory_bytes: 63360
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200000+10],b[200000+10];
int mmax,mmax2,mmax_i,mmax2_i;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    mmax=b[n-1];
    mmax2=b[n-2];
    for(int i=0;i<n;i++)
    {
        if(a[i]==mmax)  cout<<mmax2<<endl;
        else    cout<<mmax<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int key[N],ls[N],rs[N],fa[N],val[N],lim,k,r[N],st[N],tp=0,q,t[N],a[N],cov[N],add[N],rt=0,tt=0,ans[N];
bool flip[N];
vector<int> qry[N];

int newnode(int x) {
	++tt;val[tt]=x;cov[tt]=-1;add[tt]=0;key[tt]=rand();
	return tt;
}

void cover(int x,int v) {
	add[x]=0;cov[x]=val[x]=v;
}

void mdf(int x,int v) {
	val[x]+=v,add[x]+=v;
}

void down(int x) {
	if(~cov[x]) cover(ls[x],cov[x]),cover(rs[x],cov[x]),cov[x]=-1;
	if(add[x]) mdf(ls[x],add[x]),mdf(rs[x],add[x]),add[x]=0;
}

int merge(int a,int b) {
	if(!a||!b) return a|b;
	if(key[a]<key[b]) {
		down(a);rs[a]=merge(rs[a],b);fa[rs[a]]=a;return a;
	}
	else {
		down(b);ls[b]=merge(a,ls[b]);fa[ls[b]]=b;return b;
	}
}

pii split(int x,int v) {
	if(!x) return mp(0,0);
	pii y;down(x);
	if(val[x]>v) {
		y=split(ls[x],v);ls[x]=y.se;fa[y.se]=x;y.se=x;
	}
	else {
		y=split(rs[x],v);rs[x]=y.fi;fa[y.fi]=x;y.fi=x;
	}
	return y;
}

void pushall(int x) {
	if(fa[x]) pushall(fa[x]);
	down(x);
}

int find(int x) {
	return lower_bound(st+1,st+tp+1,x)-st;
}

void insert(int v) {
	pii x=split(rt,v);
	rt=merge(x.fi,merge(newnode(v),x.se));
}

int main() {
	srand(141905|141936);
	cin>>lim>>k;
	for(int i=1;i<=k;i++) st[++tp]=r[i]=gi();
	cin>>q;
	for(int i=1;i<=q;i++) st[++tp]=t[i]=gi(),a[i]=gi();
	sort(st+1,st+tp+1);
	tp=unique(st+1,st+tp+1)-st-1;
	for(int i=1;i<=k;i++) flip[find(r[i])]=1;
	for(int i=1;i<=q;i++) qry[find(t[i])].pb(i),insert(a[i]),fa[rt]=0;
	bool fl=0;
	for(int i=1;i<=tp;i++) {
		int d=st[i]-st[i-1];
		if(fl) {
			pii x=split(rt,lim-d);
			mdf(x.fi,d),cover(x.se,lim);
			rt=merge(x.fi,x.se);fa[rt]=0;
		}
		else {
			pii x=split(rt,d);
			cover(x.fi,0);mdf(x.se,-d);
			rt=merge(x.fi,x.se);fa[rt]=0;
		}
		fl^=flip[i];
		for(auto x:qry[i]) pushall(x),ans[x]=val[x];
	}
	for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';
	return 0;
}


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

vector<int> yakusuu(int n){
  vector<int> res;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i!=n/i){
        res.push_back(n/i);
      }
    }
  }
  return res;
}

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  int ans=0;
  rep(i,0,n){
    vector<int> b=yakusuu(a[i]);
    bool p=true;
    for(int x:b){
      if(x==a[i]){
        if(upper_bound(a,a+n,x)-lower_bound(a,a+n,x)>1) p=false;
      }
      else{
        if(upper_bound(a,a+n,x)-lower_bound(a,a+n,x)>0) p=false;
      }
    }
    if(p) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4328
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial, log, log10, log2
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n, k, q = map(int, readline().split())
  A = [0]*n
  for i in range(q):
    a = int(input())
    A[a-1] += 1
  ans = 0
  for i in range(n):
    if A[i]>q-k:
      print('Yes')
    else:
      print('No')
  
  
  
  
  
if __name__ == '__main__':
  main()

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
ll d[305][305];  /* 最短距離 */
vector<ll> d2[305]; /* 補給しなくてもいける点同士のつながり */ /* 幅優先探索をつかう */
ll ans[305][305];    /* 単一始点最小補給回数 */
bool isUsed[305];

int main(){
    ll n, m, l;
    cin >> n >> m >> l;

    REP(i, n) REP(j, n) {
        if(i == j) d[i][j] = 0;
        else d[i][j] = INF;
    }

    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    /* ワーシャルフロイド */
    /* i: 経由する頂点、j: 開始頂点、k: 終端 */
    REP(i, n) REP(j, n) REP(k, n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

    //REP(i, n) REP(j, n) cout << "kyori(" << i << ", " << j << ") = " << d[i][j] << endl;

    REP(i, n) REP(j, n) if(d[i][j] <= l && 0 < d[i][j]) d2[i].push_back(j);
    REP(i, n) REP(j, n) ans[i][j] = -1;

    int q;
    cin >> q;

    REP(query, q) {
        int s, t;
        cin >> s >> t;
        s--, t--;

        if(ans[s][t] != -1) {
            cout << ans[s][t] - 1 << endl;
            continue;
        }

        queue<int> que;
        que.push(s);
        ans[s][s] = 0;
        REP(i, n) isUsed[i] = false;
        while(que.size()) {
            REP(i, que.size()) {
                int k = que.front();
                que.pop();
                REP(j, d2[k].size()) if(!isUsed[d2[k][j]]) {
                    isUsed[d2[k][j]] = true;
                    ans[s][d2[k][j]] = ans[s][k] + 1;
                    que.push(d2[k][j]);
                }
            }
            if(ans[s][t] != -1) break;
        }
        if(ans[s][t] == -1) {
            cout << "-1" << endl;
        } else {
            cout << ans[s][t] - 1 << endl;
        }
    } 

    return 0;
}


Measured memory_bytes: 3072
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N;
    cin >> N;
    string S[N];
    int P[N];
    pair<pair<string,int>,int> R[N];
    REP(i,N) cin >> S[i] >> P[i],R[i]=make_pair(make_pair(S[i],-1*P[i]),i);
    sort(R,R+N);
    REP(i,N) cout << R[i].second+1 << endl;
    }

Measured memory_bytes: 256
n=int(input())
for i in range(1,n+1):
    x = i
    if x % 3 == 0: print('',i,end='')
    else: 
        while x > 0:
            if x % 10 == 3: 
                print('',i,end='')
                break
            x //= 10
print('')



Measured memory_bytes: 6160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    string s;
    cin >> s;

    if(s.length() == 3){
        reverse(all(s));
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)

int main(){
	ll n,m;
	string s;
	cin>>s;
	ll len = s.length();
	ll sum = 0;
	string tmp = "";
	string now = "";
	rep2(i,0,len){
		now += s[i];
		if(now != tmp){
			sum++;
			tmp = now;
			now = "";
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int time(int a){
  return 10 - ((a - 1) % 10 + 1);
}

int main(){
  int a[5],de = 0,ans = 0;
  for(int i = 0;i < 5;i++){
    scanf("%d",&a[i]);
    if(de < time(a[i] + 10)){
      de = time(a[i] + 10);
    }
    ans += a[i] - a[i] % 10 + 10;
    if(a[i] % 10 == 0)ans -= 10;
  }
  printf("%d\n",ans - de);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r,c;
  cin>>r>>c;
  string s[r];
  for(long long i=0;i<r;i++){
    cin>>s[i];
  }
  long long dp[r][c];
  for(long long i=0;i<r;i++){
    for(long long j=0;j<c;j++){
      dp[i][j]=0;
    }
  }
  dp[r-1][c-1]=1;
  for(long long i=r-1;i>=0;i--){
    for(long long j=c-1;j>=0;j--){
      if(s[i][j]=='#')
        dp[i][j]=0;
      else{
        if(i+1<r)
          dp[i][j]+=dp[i+1][j];
        if(j+1<c)
          dp[i][j]+=dp[i][j+1];
      }
      dp[i][j]%=1000000007;
    }
  }
  cout<<dp[0][0];
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>
int main(void){
    char s[100] = "";
    scanf("%s",s);
    int i,cnt=0;
    for(i=1;i<strlen(s)-1;i++){
        cnt++;
    }
    printf("%c%d%c",s[0],cnt,s[strlen(s)-1]);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

const int Score(const int N, const vector<int> &D,
    const int popFrontNum, const int popBackNum, const int maxReleaseNum)
{
    multiset<int> pops;
    for (int i = 0; i < popFrontNum; ++i)
    {
        pops.insert(D[i]);
    }
    for (int i = 0; i < popBackNum; ++i)
    {
        pops.insert(D[N - i - 1]);
    }
    int releaseNum = 0;
    for (auto itr = pops.begin(); itr != pops.end();)
    {
        if (releaseNum == maxReleaseNum)
        {
            break;
        }
        if (*itr < 0)
        {
            itr = pops.erase(itr);
            ++releaseNum;
        }
        else
        {
            break;
        }
    }
    return accumulate(pops.begin(), pops.end(), 0);
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> D;
    for (int i = 0; i < N; ++i)
    {
        int Vi;
        cin >> Vi;
        D.push_back(Vi);
    }
    const int maxPopNum = min(N, K);
    int maxScore = -1e9;
    for (int popNum = 0; popNum <= maxPopNum; ++popNum)
    {
        for (int popFrontNum = 0; popFrontNum <= popNum; ++popFrontNum)
        {
            for (int popBackNum = 0; popBackNum <= popNum - popFrontNum; ++popBackNum)
            {
                const int maxReleaseNum = K - (popFrontNum + popBackNum);
                const int score = Score(N, D, popFrontNum, popBackNum, maxReleaseNum);
                maxScore = score > maxScore ? score : maxScore;
            }
        }
    }
    cout << maxScore;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int dp[100001]={0};
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

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

int main() {
  int H;
  int W;
  char c;
  cin >> H >> W;
  
  for(int i = 0; i < W + 2; i++)
  {
    cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H; i++)
  {
    cout << '#';
    for(int j = 0; j < W; j++)
    {
      cin >> c;
      cout << c;
    }
    cout << '#' << endl;
  }
  for(int i = 0; i < W + 2; i++)
  {
    cout << '#';
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool map[101][3];
int dp[101][3];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			map[i][j]=true;
			dp[i][j]=0;
		}
	}
	int a,b;
	for(int i=0;i<k;i++){
		cin>>a>>b;
		for(int j=0;j<3;j++){
			if(j+1!=b){
				map[a-1][j]=false;
			}
		}
	}
	int sum0=0;
	for(int j=0;j<3;j++){
		dp[0][j]=map[0][j];
		sum0+=dp[0][j];
	}
	int sum1=0;
	for(int j=0;j<3;j++){
		if(map[1][j]==true){
			dp[1][j]=sum0;
		}
		sum1+=dp[1][j];
	}
	for(int j=0;j<3;j++){
		if(map[2][j]==true){
			dp[2][j]=sum1;
			if(map[0][j]==true&&map[1][j]==true){
				dp[2][j]-=dp[0][j];
			}
		}
	}
	for(int i=3;i<n;i++){
		for(int j=0;j<3;j++){
			if(map[i][j]==true){
				int sum=0;
				for(int r=0;r<3;r++){
					sum+=dp[i-1][r];
				}
				dp[i][j]=sum;
				if(map[i-1][j]==true&&map[i-2][j]==true){
					for(int r=0;r<3;r++){
						if(r!=j){
							dp[i][j]-=dp[i-3][r];
						}
					}
				}
			}
			dp[i][j]=dp[i][j]%10000;
			if(dp[i][j]<0)dp[i][j]+=10000;
		}
	}
	int ans=0;
	for(int j=0;j<3;j++){
		ans+=dp[n-1][j];
	}
	cout<<ans%10000<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int n, q, i, c[500005], l, r, las[500005], ans[500005];
i64 f[500005], g[500005];
vector<tuple<int, int>> Q[500005];

void ad(int x, int _f)
{
    i64 _g = x * (i64)_f;
    for (int z = x; z <= n; z += z & (-z))
    {
        f[z] += _f;
        g[z] += _g;
    }
}

void cl(int l, int r)
{
    if (l > r)
        return;
    ad(l, 1);
    ad(r + 1, -1);
}

i64 sm(int x)
{
    i64 _f = 0, _g = 0;
    for (int _x = x; _x; _x ^= _x & (-_x))
    {
        _f += f[_x];
        _g += g[_x];
    }
    return _f * (x + 1) - _g;
}

i64 sm(int l, int r)
{
    return sm(r) - sm(l - 1);
}

int main()
{
    scanf("%d%d", &n, &q);
    for (i = 1; i <= n; ++i)
        scanf("%d", &c[i]);
    for (i = 1; i <= q; ++i)
    {
        scanf("%d%d", &l, &r);
        Q[r].push_back(make_tuple(l, i));
    }
    for (i = 1; i <= n; ++i)
    {
        cl(las[c[i]] + 1, i);
        las[c[i]] = i;
        for (auto t : Q[i])
            ans[get<1>(t)] = sm(get<0>(t), get<0>(t));
    }
    for (i = 1; i <= q; ++i)
        printf("%d\n", ans[i]);
}

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

int main() {

  int n,m;
  cin >> n >> m;
  
  vector<int> h(n);  
  rep(i,n) cin >> h[i];			//高さhの配列
  
  vector<int> a(m);
  vector<int> b(m);
  
  rep(i,m) {
    cin >> a[i];
    cin >> b[i];
  }
  
  vector<int> ans(n,0);		//道の数の配列を作る。　例　{0,0,0,0,0}
  
  rep(i,m) {  
    
    int aaa = h[a[i]-1];
    int bbb = h[b[i]-1];
    //cout << aaa << " " << bbb << endl;
    
  	if( aaa >= bbb ) {
    	ans[b[i]-1] = 1;
  	}
  	if ( bbb >= aaa ) {
    	ans[a[i]-1] = 1;
	}  
  }
  
  int sum = 0;
  
  rep(i,n) {
    if(ans[i] == 0) sum += 1;
  }
  
  cout << sum << endl;
  


}


Measured memory_bytes: 4840
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#define NUM 10010
using namespace std;

int main(void){
    int a_end = 0;
    int b_end = 0;
    int ab_end = 0;
    int sum = 0;

    int N;
    scanf("%d", &N);

    vector<string> S(N);
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    for(int i = 0; i < N; i++){
        if(S[i][0] == 'B'){
            if(S[i][S[i].size()-1] == 'A'){
                ab_end++;
            }else{
                b_end++;
            }
        }else{
            if(S[i][S[i].size()-1] == 'A'){
                a_end++;
            }else{

            }
        }
        for(int j = 0; j < S[i].size() - 1; j++){
            if (S[i][j] == 'A' && S[i][j + 1] == 'B'){
                sum++;
            }
        }
    }

    if(ab_end != 0){
        sum += ab_end - 1;
        if(a_end >= 1){
            sum++;
            a_end--;
        }
        if(b_end >= 1){
            sum++;
            b_end--;
        }
        sum += min(a_end, b_end);
    }else{
        sum += min(a_end, b_end);
    }

    printf("%d\n", sum);
}



Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
void prime(ll n,vl &v){
    rep(i,n){
        ll d=i+1;
        if(d==1)continue;
        bool check=true;
        for(auto x:v){
            if(d%x==0)check=false;
            if(x*x>d)break;
        }
        if(check)v.pb(d);
    }
}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    vl p;prime(1000000,p);
    vl pcnt(p.size(),0);
    rep(i,n){
        ll k=v[i];
        ll t=0;
        while(p[t]<sqrt(v[i])+1){
            ll tmp=0;
            while(k%p[t]==0){
                k/=p[t];
                tmp++;
            }
            chmax(pcnt[t],tmp);
            t++;
        }
        if(k!=1){
            ll id=lower_bound(all(p),k)-p.begin();
            chmax(pcnt[id],(ll)1);
        }
    }
    ll ans=0;
    ll cus=1;
    rep(i,p.size()){
        cus*=modpow(p[i],pcnt[i],MOD);
        cus%=MOD;
    }
    rep(i,n){
        ll tmp=cus;
        tmp*=modinv(v[i],MOD);
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
    }
    cout <<ans <<endl;
}


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

int main() {
    int array[3];
    
    for (int i = 0; i < 3; ++i) {
        cin >> array[i];
    }
    
    for (int i = 0; i < 3; ++i) {
        for (int j = i + 1; j < 3; ++j) {
            if (array[i] > array[j]) {
                int temp = array[i];
                array[i] = array[j];
                array[j] = temp;
            }
        }
    }
    
    for (int i = 0; i < 3; ++i) {
        if (i < 2) {
            cout << array[i] << " ";
        } else {
            cout << array[i] << endl;
        }
    }
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, k;
string s;
int main() {
  cin >> n >> k >> s;
  vector<i64> a;
  a.push_back(0);
  i64 ans = 0;
  for (i64 i = 1; i < n; ++i) {
    if (s[i] == '1' && s[i - 1] == '0') {
      a.push_back(i);
    } else if (s[i] == '0' && s[i - 1] == '1') {
      i64 j = a.size() - 1;
      ans = max(ans, i - a[max(i64(0), j - k)]);
    }
  }
  i64 j = a.size();
  if (s[n - 1] == '1') --j;
  ans = max(ans, n - a[max(i64(0), j - k)]);
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <regex>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())
#define inf          1<<25

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; }

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

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

int main() {
    string s, t;
    cin >> s >> t;
    
    vector<string> vs(sz(s)), vt(sz(t));
    rep(i, sz(vs)) vs[i] = s[i];
    rep(i, sz(vt)) vt[i] = t[i];
    
    s = "";
    sort(vs.begin(), vs.end());
    rep(i, sz(vs)) s += vs[i];
    
    t = "";
	sort(vt.begin(), vt.end(), greater<string>());
    rep(i, sz(vt)) t += vt[i];
    
    cout << (s < t ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n; cin >> n;
  int sum=0, maxL=0;
  for(int i=0; i<n; i++){
    int L; cin >> L;
    sum+=L;
    maxL=max(maxL,L);
  }
  if(maxL<sum-maxL){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
h,w = map(int, input().split())

if h%3==0 or w%3==0:
    print(0)
    exit()

res = min(h,w)
for hi in range(1,h):
    b1 = hi*w
    b2 = (h-hi)*(w//2)
    b3 = (h-hi)*(w//2+w%2)
    res = min(res, max(b1,b2,b3)-min(b1,b2,b3))
for wi in range(1,w):
    b1 = wi*h
    b2 = (w-wi)*(h//2)
    b3 = (w-wi)*(h//2+h%2)
    res = min(res, max(b1,b2,b3) - min(b1,b2,b3))

print(res)


Measured memory_bytes: 9168
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

void solve(long long N, long long D, long long A, std::vector<long long> X, std::vector<long long> H){
  vector<pair<ll, ll>> v;
  for(ll i=0; i<N; i++) {
    v.push_back(make_pair(X[i], H[i]));
  }
  sort(v.begin(), v.end());
  vector<ll> nX, nH;
  for(ll i=0; i<N; i++) {
    nX.push_back(v[i].first);
    nH.push_back(v[i].second);
  }
  ll ans = 0;
  vector<ll> s(N+1, 0);
  for(ll i=0; i<N; i++) {
    if(nH[i] > s[i]) {
      ll num = (nH[i] - s[i] + A - 1) / A;
      ll it = upper_bound(nX.begin(), nX.end(), nX[i]+2*D) - nX.begin();
      s[i] += num*A;
      s[it] -= num*A;
      ans+=num;
    }
    s[i+1] += s[i];
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long D;
  scanf("%lld",&D);
  long long A;
  scanf("%lld",&A);
  std::vector<long long> X(N);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&X[i]);
    scanf("%lld",&H[i]);
  }
  solve(N, D, A, std::move(X), std::move(H));
  return 0;
}



Measured memory_bytes: 13676
#include <stdio.h>
#include <stdlib.h>
int upi(const void*a, const void*b){return*(int*)a-*(int*)b;}
void sortup(int*a,int n){qsort(a,n,sizeof(int),upi);}
int f(int n){
	if(n>1)return f(n/2)+f(n-n/2)+n;
	return 0;
}

int a[500010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	sortup(a,n);
	for(int i=0;i<n;i++)printf("%d%c",a[i],i==n-1?10:32);
	printf("%d\n",f(n));
}


Measured memory_bytes: 5448
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 400005;
const int MM = 1000000007;

ll D;
ll pw10[40];

ll solve(int s, int e, ll D, int ch = 1)
{
	if( abs(D) >= pw10[s+1] ) return 0;
	if( s < e ) return D == 0;
	if( s == e ) return (D == 0) * 10;
	ll v = pw10[s] - pw10[e], total = 0;
	for(int i = -9; i <= 9; i++){
		ll f = 10 - abs(i);
		if(ch && i >= 0) f--;
		total += f * solve(s-1, e+1, D-v*i, 0);
	}
	return total;
}

int main()
{
	pw10[0] = 1;
	for(int i = 1; i < 40; i++) pw10[i] = pw10[i-1] * 10;
	scanf("%lld", &D);
	ll ans = 0;
	for(int k = 1; k <= 18; k++){
		ans += solve(k-1, 0, D);
	}
	printf("%lld\n", ans);
}


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

int main()
{
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]!=s[1]||s[1]!=s[2]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}		

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<string> s(n);
    set<string> st;
    rep(i,n){
        cin>>s[i];
        st.insert(s[i]);
    }
    bool ok=true;
    if(st.size()!=n) ok=false;
    for(int i=1;i<n;i++){
        if(s[i][0]!=s[i-1][s[i-1].size()-1]) ok=false;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main()
{
   int a,b;
   cin>>a>>b;
   if(a > b)
    cout << "a > b" << endl;
   else if(a < b)
    cout << "a < b" << endl;
   else if (a == b)
    cout << "a == b" << endl;


    return 0;
}



Measured memory_bytes: 3076
import Control.Monad

main :: IO ()
main = do
  (n:t:_) <- fmap (map read . words) getLine :: IO [Int]
  am <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  solve t am

solve :: Int -> [[Int]] -> IO ()
solve t am
  | null candidates = putStrLn "TLE"
  | otherwise = print . minimum . map head $ candidates
  where
    candidates = filter (\(_:time:_) -> time <= t) $ am


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(whole(a));
    sort(whole(b));
    reverse(whole(a));
    reverse(whole(b));
    int ans = 0;
    int maxa = a[0];
    int index = 0;
    while (index<n && h>0 && b[index]>maxa) {
        h -= b[index];
        index++;
        ans++;
    }
    //debug(ans);
    //debug(h);
    if (h>0) {
        ans += ((h-1)/maxa+1);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4028
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x;
    
    cin>>n>>x;
    
    int L[n];
    int sum=0;
    
    for(int i=1; i<n+3; i++){
        cin>>L[i];
        //cout << sum << endl;
        sum=sum+L[i];
        if(sum>x){
            cout<<i;
            break;
        }
    }
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll xorxor(ll val) {
	int i;
	ll ret=((val+1)/2)%2;
	for(i=0;i<=59;i++) if((val>>i)%2) ret |= (1^(val%2))<<i;
	return ret;
}

ll A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	ll ret=xorxor(B);
	if(A) ret^=xorxor(A-1);
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256