akhauriyash/Code-Regression huggingface dataset:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def cut(A, k, size) -> bool:
    cnt = 0
    for a in A:
        cnt += a // size
        if a % size == 0:
            cnt -= 1
        if cnt > k:
            return False
    if cnt <= k:
        return True


def main():
    n, k = input_int_list()
    A = input_int_list()

    left = 0
    right = max(A)

    while right > left + 1:
        mid = (left + right) // 2
        res = cut(A, k, mid)
        if res:
            right = mid
        else:
            left = mid
    print(right)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 103828
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
ll ans = 0;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    int mn = 1;
    F0R(i,N) {
        int x; cin >> x;
        // cout << "HI " << x << mn << "\n";
        int ti = (x-1)/mn;
        ans += ti;
        x -= ti*mn;
        if (ti == 0 || i == 0) mn = max(mn,x+1);
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int n,a[N],b[N],c[N],f[N],g[N],id[N];
struct BIT{
	int c[N];
	inline void clr(){memset(c,0,(n+1)<<2);}
	inline void upd(R int x,R int y){for(;x<=n;x+=x&-x)c[x]+=y;}
	inline int query(R int x){R int res=0;for(;x;x-=x&-x)res+=c[x];return res;}
}t1,t2;
bool ck(){
	fp(i,1,n){
		id[i]=(a[i]-1)/3+1;
		if((i&1)!=(id[i]&1))return false;
		R int x=(id[i]-1)*3+1,y=(id[i]-1)*3+2,z=(id[i]-1)*3+3;
		if(a[i]==x&&b[i]==y&&c[i]==z){g[i]=(n<<1);continue;}
		if(a[i]==z&&b[i]==y&&c[i]==x){g[i]=(n<<1|1);continue;}
		return false;
	}
	return true;
}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	fp(i,1,n)scanf("%d",&b[i]);
	fp(i,1,n)scanf("%d",&c[i]);
	if(!ck())return puts("No"),0;
	for(R int i=1;i<=n;i+=2)t1.upd(i,1);
	for(R int i=n-(n&1^1);i>0;i-=2){
		f[i]=t1.query(n)-t1.query(id[i])+t2.query(id[i]-1);
		t1.upd(id[i],-1),t2.upd(id[i],1);
	}
	t1.clr(),t2.clr();
	for(R int i=2;i<=n;i+=2)t1.upd(i,1);
	for(R int i=n-(n&1);i>0;i-=2){
		f[i]=t1.query(n)-t1.query(id[i])+t2.query(id[i]-1);
		t1.upd(id[i],-1),t2.upd(id[i],1);
	}
	fp(i,1,n)g[i]=(g[i]-f[i])&1;
	R int s=0,t=0;
	for(R int i=1;i<=n;i+=2)s+=g[i];
	for(R int i=2;i<=n;i+=2)t+=f[i];
	t>>=1;
	if((s&1)!=(t&1))return puts("No"),0;
	s=0,t=0;
	for(R int i=2;i<=n;i+=2)s+=g[i];
	for(R int i=1;i<=n;i+=2)t+=f[i];
	t>>=1;
	if((s&1)!=(t&1))return puts("No"),0;
	return puts("Yes"),0;
}

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

int main(){
    int n;
    cin >> n;
    int p[n+5];
    int count = 0;
    for (int i = 0; i < n; ++i){
        cin >> p[i];
        if (i<2){
            continue;
        }
        if ((p[i-2]<p[i-1] && p[i-1]<p[i]) || (p[i]<p[i-1] && p[i-1]<p[i-2])){
            count+=1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
while True:
    count=0
    n,x = map(int,input().split())
    if n ==0 and x ==0:
        break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    count+=1
    print(count)
                


Measured memory_bytes: 5592
n, k = map(int,input().split())
lst = [0 for i in range(n)]
for i in range(k):
  x = int(input())
  lst2 = list(map(int,input().split()))
  for j in range(x):
    if (lst[lst2[j] - 1] == 0):
      lst[lst2[j] - 1] = 1
ans = 0
for i in range(n):
  if (lst[i] == 0):
    ans = ans + 1
print(ans)


Measured memory_bytes: 9184
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 105;
int n, m;
char c[maxn][maxn];

bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%s", c[i]);
  }
  return true;
}

int d[maxn][maxn];

void solve() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      d[i][j] = inf;
    }
  }
  d[0][0] = (c[0][0] == '#' ? 1 : 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      auto cur = d[i][j];
      if (i + 1 < n) {
        int w = (c[i][j] == '.' && c[i + 1][j] == '#' ? 1 : 0);
        d[i + 1][j] = min(d[i + 1][j], cur + w);
      }
      if (j + 1 < m) {
        int w = (c[i][j] == '.' && c[i][j + 1] == '#' ? 1 : 0);
        d[i][j + 1] = min(d[i][j + 1], cur + w);
      }
    }
  }
  printf("%d\n", d[n - 1][m - 1]);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

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


Measured memory_bytes: 256
// 1_3_A
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFSIZE 900
#define STACKSIZE 100

typedef long elemtype;

typedef struct{
    elemtype operands[STACKSIZE];
    int top;
} stack_t;

void InitStack(stack_t *stack){
    stack->top = -1;
    return;
}

void Push(stack_t *stack, long num){
    stack->top += 1;
    stack->operands[stack->top] = num;
    return;
}

long Pop(stack_t *stack){
    long num;
    num = stack->operands[stack->top];
    stack->top -= 1;
    return num;
}

int main(){
    char buf[BUFSIZE + 2], *p;
    stack_t stack;
    long x, y;

    InitStack(&stack);
    fgets(buf, BUFSIZE, stdin);

    // ?????????????????????
    if((p = strchr(buf, '\n')) != NULL) *p = '\0';

    // buf???????????§?????????????????????????????????
    p = strtok(buf, " ");
    while(p != NULL){
        if(*p == '+'){
            x = Pop(&stack); y = Pop(&stack);
            Push(&stack, y+x);
        } else if(*p == '-'){
            x = Pop(&stack); y = Pop(&stack);
            Push(&stack, y-x);
        } else if(*p == '*'){
            x = Pop(&stack); y = Pop(&stack);
            Push(&stack, y*x);
        } else{
            Push(&stack, (long)atoi(p));
        }

        p = strtok(NULL, " ");
    }
    printf("%ld\n", Pop(&stack));
    return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M, b, c;
    cin >> N >> M;
    vector<int> a(N);
    vector<pii> v(M);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < M; i++) {
        cin >> b >> c;
        v[i] = pii(c, b);
    }
    sort(a.begin(), a.end());
    sort(v.begin(), v.end(), greater<pii>());

    int j = 0;
    for (int i = 0; i < N && j < M; i++) {
        int c = v[j].first;
        if (a[i] < c) {
            a[i] = c;
            v[j].second--;
        }
        if (v[j].second == 0) j++;
    }
    cout << accumulate(a.begin(), a.end(), 0LL) << '\n';
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++)cin>>vec[i];
  vector<int> ans(n+1);
  for(int i=0;i<n;i++)
  {
    if(i<=2){
      ans[i]+=abs(vec[i]-vec[0]);
      continue;
    }
    ans[i]=min(abs(vec[i-2]-vec[i])+ans[i-2],abs(vec[i-1]-vec[i])+ans[i-1]);
  }
  cout<<ans[n-1]<<endl;
  return 0;
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int x; cin >> x;
  cout << (x<1200?"ABC":"ARC");

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3656
import java.util.*;
public class Main {
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    int[] a = new int[n];
    HashMap map = new HashMap();
    boolean flg = true;
    for (int i=0;i<n;i++){
	    a[i]=sc.nextInt();
        if (map.containsKey(a[i])) {
            flg=false;
            break;
        } else {
            map.put(a[i],a[i]);
        }
     }

     if (flg) {
         System.out.println("YES");
     } else {
        System.out.println("NO");
     }
  }
}







Measured memory_bytes: 104972
"""
1年1月1日が1日目

3で割り切れる年は 1年が200日

割り切れない日は 1年が195日

3年単位で, 200+195+195 = 590日

+あまりの年×195


月から日への変換方法は

もし3で割り切れないあり and 

(i)月が奇数の時　 20

(ii)月が偶数の時 19

日はそのまま足す


1000年1月1日 を基準にする
計算時間短縮のために先に日に直しておこう
1年1月1日を1日目としているから　1年引く
(1000-1) // 3 = 333*3 

割り切れない　年から日は590*333 + 1*195

月から日は　割り切れない　1は奇数だから +20 と思いきや
1年1月1日を1日目としているから、1-1 = 0となる

よって 590*333  + 1 =196471

999 年　10月 20日の場合

999-1 //3 = 332 + 2


999は3で割り切れる

10-1 *20 = 180日 

590*332 + 2*195 +180 + 20 =196470

差分は1
"""
def get_days(y,m,d):
    day = 0
    if int((y-1) % 3) == 0: 
        day += (int(y-1)//3)*590
    elif int((y-1) % 3) != 0:
        day += (int((y-1)//3))*590 + (int((y-1)%3))*195

    if int(y% 3) == 0:
        day+= (m-1)*20
    else:
        day += (m-1)*20-int((m-1)//2)

    day += d

    comp = 196471 -day
    return comp



n = input()
n = int(n)
"""
inputlist = []

for i in range(n):
	yc , mc , dc = input().split()
	yc = int(yc)
	mc = int(mc)
	dc = int(dc)
	inputlist.append([yc,mc,dc])
	"""
#i = 0
while(True):

	if n == 0:
		break
	#day = 0
	
	yc , mc , dc = input().split()
	yc = int(yc)
	mc = int(mc)
	dc = int(dc)
	n -= 1
	#i += 1
	print(get_days(yc,mc,dc))

	"""
	y = inputlist[i][0]
	m =inputlist[i][1] 
	d = inputlist[i][2]
	"""
	
	
"""	
	if int((y-1) % 3) == 0:
		day += (y-1)*590
	elif int((y-1) % 3) != 0:
		day += (int((y-1)//3))*590 + (int((y-1)%3))*195
	
	if int(y % 3) == 0:
		day+= (m-1)*20
	else:
		day += (m-1)*20-int((m-1)//2)
	
	day += d
	
	comp= 196471 -day
	n -= 1
	i += 1
	print(comp)
	"""











Measured memory_bytes: 5616
n = int(input())
a = [int(i) for i in input().split()]
flag = 0
sum = 0
while flag == 0:
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            flag = 1
            break
    if flag == 0:
        sum += 1
print(sum)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

// Euler-Tour
struct EulerTour {
  vector< vector<int> > graph;
  vector<int> tour, begins, ends;
  int idx, root;
  EulerTour(){}
  EulerTour(int n) : graph(n), begins(2*n), ends(2*n), idx(0), root(0){}
  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  void dfs(int cur, int par)
  {
    begins[cur] = idx;
    tour.push_back(cur);
    idx++;
    for(int& to : graph[cur]) {
      if(to == par) continue;
      dfs(to, cur);
    }
    ends[cur] = idx;
  }
};

// Lazy-evaluated Segment Tree
struct SegmentTree
{
  vector<int> sum;
  vector<bool> lazy;
  int sz;
  SegmentTree(int n)
  {
    sz = 1; while(sz < n) sz *= 2;
    sum.resize(2*sz-1, 0);
    lazy.resize(2*sz-1, false);
  }
  inline void lazy_evaluate(int k, int l, int r)
  {
    if(lazy[k]) {
      sum[k] = (r - l) - sum[k];
      if(r - l > 1) {
	lazy[2*k+1] = !lazy[2*k+1];
	lazy[2*k+2] = !lazy[2*k+2];
      }
      lazy[k] = false;
    }
  }
  void update(int a, int b, int k, int l, int r)
  {
    lazy_evaluate(k, l, r);
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] = !lazy[k];
      lazy_evaluate(k, l, r);
      return;
    }
    update(a, b, 2*k+1, l, (l+r)/2);
    update(a, b, 2*k+2, (l+r)/2, r);
    sum[k] = sum[2*k+1] + sum[2*k+2];
  }
  void update(int a, int b)
  {
    update(a, b, 0, 0, sz);
  }
  int query(int a, int b, int k, int l, int r)
  {
    lazy_evaluate(k, l, r);
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) {
      return sum[k];
    }
    return query(a, b, 2*k+1, l, (l+r)/2) + query(a, b, 2*k+2, (l+r)/2, r);
  }
  int query(int a, int b)
  {
    return query(a, b, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, q;
  cin >> n >> q;

  EulerTour et(n);
  rep(i, n-1) {
    int p;
    cin >> p; --p;
    et.add_edge(p, i+1);
  }
  vector<char> c(n);
  rep(i, n) cin >> c[i];
  et.dfs(0, -1);

  SegmentTree seg(n);
  rep(i, n) {
    if(c[i] == 'G') seg.update(et.begins[i], et.begins[i]+1);
  }
  while(q--) {
    int v;
    cin >> v; --v;
    seg.update(et.begins[v], et.ends[v]);
    int res = seg.query(0, n);
    //cout<<res<<endl;
    cout << (n-res < res ? "broccoli" : "cauliflower") << endl;
  }

  return 0;
}



Measured memory_bytes: 18092
from collections import deque

N = int(input())

d = deque()
for _ in range(N):
    command = input().split()
    
    if command[0] == 'insert':
        d.appendleft(command[1])
    elif command[0] == 'delete':
        try:
            d.remove(command[1])
        except ValueError:
            pass
    elif command[0] == 'deleteFirst':
        _ = d.popleft()
    elif command[0] == 'deleteLast':
        _ = d.pop()
        
print(*d)


Measured memory_bytes: 69736
#include <stdio.h>

int main() {
    int n, a, b;

    scanf("%d", &n);
    if (n == 1) {
        printf("Hello World\n");
    } else if (n == 2) {
        scanf("%d", &a);
        scanf("%d", &b);
        printf("%d\n", a + b);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
	string s;
	cin>>s;
	int a, b, c, d;
	a=(int)s[0]-'0';b=(int)s[1]-'0';c=(int)s[2]-'0';d=(int)s[3]-'0';
	if (a+b+c+d==7) return 0*printf("%d+%d+%d+%d=7\n",a,b,c,d);
	if (a+b+c-d==7) return 0*printf("%d+%d+%d-%d=7\n",a,b,c,d);
	if (a+b-c+d==7) return 0*printf("%d+%d-%d+%d=7\n",a,b,c,d);
	if (a+b-c-d==7) return 0*printf("%d+%d-%d-%d=7\n",a,b,c,d);
	if (a-b+c+d==7) return 0*printf("%d-%d+%d+%d=7\n",a,b,c,d);
	if (a-b+c-d==7) return 0*printf("%d-%d+%d-%d=7\n",a,b,c,d);
	if (a-b-c+d==7) return 0*printf("%d-%d-%d+%d=7\n",a,b,c,d);
	if (a-b-c-d==7) return 0*printf("%d-%d-%d-%d=7\n",a,b,c,d);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ {
    class ALDS1_4_A {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] inputS = Console.ReadLine().Split();
            int q = int.Parse(Console.ReadLine());
            string[] inputT = Console.ReadLine().Split();
            int[] S = new int[n+1];
            int count = 0;
            for (int i = 0; i < n; i++) S[i] = int.Parse(inputS[i]);
            for (int i = 0; i < q; i++) if (LinearSearch(S, n, int.Parse(inputT[i]))) count++;
            Console.WriteLine(count);
        }

        static bool LinearSearch(int[] A, int n, int key) {
            int i = 0;
            A[n]=key;
            while (A[i] != key) i++;
            return i != n;
        }
    }
}



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

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

const ll MOD = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= MOD;
	if(k%2 == 1){
		ret *= x; ret %= MOD;
	}
	return ret;
}

int main(){
	ll n,h,d;
	cin >> n >> h >> d;
	
	static ll dp[1000010];
	dp[0] = 1;
	
	ll x = 1;
	ll y = 0;
	for(int i = 1 ; i <= n ; i ++){
		x *= i; x %= MOD;
		y += x; y %= MOD;
	}
	ll sum = 0;
	for(int i = 0 ; i < h ; i ++){
		if(i > 0){dp[i] *= y; dp[i] %= MOD;}
		sum += dp[i];
		if(i >= d)sum += MOD-dp[i-d];
		sum %= MOD;
		dp[i+1] = sum;
	}
	cout << (dp[h]*x)%MOD << endl;
}

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

using namespace std;

int c[5][5];

int main(){
	for(int i=1;i<=3;i++)
	for(int j=1;j<=3;j++)
	cin>>c[i][j];
	int b11,b12,b13,b21,b22,b23,b31,b32,b33;
	for(int a1=0;a1<=100;a1++)
	{
		b11=c[1][1]-a1;
		b21=c[1][2]-a1;
		b31=c[1][3]-a1;
		for(int a2=0;a2<=100;a2++)
		{
			b12=c[2][1]-a2;
			b22=c[2][2]-a2;
			b32=c[2][3]-a2;
			if(b11!=b12 || b21!=b22 || b31!=b32)
			continue;	
			for(int a3=0;a3<=100;a3++)
			{
			b13=c[3][1]-a3;
			b23=c[3][2]-a3;
			b33=c[3][3]-a3;
			if(b11==b13 && b21==b23 && b31==b33)
			{
			cout<<"Yes";
			return 0;
			}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#pragma once

#include<iostream>
#include<string>
//#include<stdio.h>

using namespace std;

int n;
int a[100001];
int result=0;

int main() {

	cin >> n;

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

	for (int i = 1; i<=n; i++) {
		if (i == a[a[i]]) {
			result++;
		}
	}

	result /= 2;

	cout << result << endl;

	return 0;
}





Measured memory_bytes: 768
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;
	long N, M; cin >> N >> M;

	res = (fact(N) * fact(M)) % mod;

	if (N == M) res *= 2;
	if (abs(N - M) > 1) res *= 0;
    res %= mod;
	cout << res << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		ans+=i;
	}
	cout<<ans;
}

Measured memory_bytes: 3628
#include<cstdio>
int i,j,k,n,m,p[200001];
int r(int i){
  if(i==p[i])return i;
  return p[i]=r(p[i]);
}
int main(){
  for(scanf("%d%d",&n,&m);++i<=n+m;p[i]=i);
  for(i=0;++i<=n;)for(scanf("%d",&k);k--;p[r(j+n)]=r(i))scanf("%d",&j);
  // for(i=0;++i<=n;)for(scanf("%d",&k);k--;p[r(i)]=r(j+n))scanf("%d",&j);
  // for(i=1;i<=n+m;i++)printf("%d %d\n",i,p[i]);
  // for(i=1;i<=n+m;i++)printf("%d %d\n",i,r(i));
  for(k=r(n),i=1;i<n;++i)if(r(i)!=k)break;
  if(i<n)puts("NO");else puts("YES");
}


Measured memory_bytes: 2560
#pragma GCC optimize("O2") 

#include<bits/stdc++.h>
#define int long long
using namespace std;


//https://www.geeksforgeeks.org/prime-factorization-using-sieve-olog-n-multiple-queries/

int MAXN = 10000001;
  
// stores smallest prime factor for every number 
int spf[10000001]; 

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
int getFactorization(int x) 
{ 
    map<int, int> ret; 
    while (x != 1) 
    { 
        ret[spf[x]]++;
        x = x / spf[x]; 
    } 
    int mult = 1;
    for(auto x: ret)
        mult *= (x.second+1);
    return mult;
} 

int32_t main(){
    int n;
    cin >> n;
    sieve();
    int ans = 0;
    for(int i=1; i<n+1; i++){
        int fact = getFactorization(i);
        ans += i*fact;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 81764
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	string cs[10]={
		" ","',.!?",
		"abcABC","defDEF","ghiGHI","jklJKL",
		"mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"
	};
	
	for(string s;cin>>s;){
		vector<string> ss;
		for(int i=0,j=0;;){
			if(j==s.size()){
				ss.push_back(s.substr(i));
				break;
			}
			else if(s[j]=='0'){
				if(i==j)
					ss.push_back("0");
				else
					ss.push_back(s.substr(i,j-i));
				i=j=j+1;
			}
			else if(s[j]!=s[i]){
				ss.push_back(s.substr(i,j-i));
				i=j;
			}
			else
				j++;
		}
		for(int i=0;i<ss.size();i++){
			int j=ss[i][0]-'0';
			cout<<cs[j][(ss[i].size()-1)%cs[j].size()];
		}
		cout<<endl;
	}
	
	return 0;
}

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

typedef long long ll;
const int N = 200006;
int a[N];

int main () {
    int n; scanf("%d", &n);
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        int x; scanf("%d", &x);
        a[x]++;
        ans += x;
    }
    int q; scanf("%d", &q);
    while (q--) {
        int b, c; scanf("%d%d", &b, &c);
        ans += a[b] * (c - b);
        a[c] += a[b];
        a[b] = 0;
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 4180
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *R;
  struct node *L;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

Node tMin(Node);
Node tMax(Node);
Node tSea(Node,int);
Node tSor(Node);
void tDel(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int main()
{
  int n, i, x;
  char meirei[20];
  
  scanf("%d",&n);/*命令数入力*/
  
  for (i=0;i<n;i++)
    {
      scanf("%s",meirei);/*何の命令か入力*/
      
      if (meirei[0]=='f')/*findが入力された場合*/
	{
	  scanf("%d",&x);/*探す数入力*/
	  
	  Node t = tSea(root,x);/*xがあるかどうか探す*/
	  if ( t != NULL ) printf("yes\n");
	  else printf("no\n");
	}
      else if (meirei[0]=='i')/*insertが入力された場合*/
	{
	  scanf("%d", &x);
	  insert(x);/*二分木にroot追加*/
	}
      else if ( meirei[0] == 'p' )/*printが入力された場合*/
	{
	  inorder(root);/*中間順巡回*/
	  printf("\n");
	  preorder(root);/*先行順巡回*/
	  printf("\n");
	}
      else if ( meirei[0] == 'd' )/*dereteが入力された場合*/
	{
	  scanf("%d", &x);
	  tDel(tSea(root, x));/*削除*/
	}
    }

  return 0;
}

Node tMin(Node x)
{
  while(x->L!=NULL)
    {
      x=x->L;
    }
  return x;
}

Node tMax(Node x)
{
    while(x->R!=NULL)
    {
      x=x->R;
    }
  return x;
}

Node tSea(Node x, int k)
{
  if(x==NULL||k==x->key)return x;
  if(k<x->key)return tSea(x->L,k);
  else return tSea(x->R,k);
}

Node tSor(Node x)
{
  Node y;
  
  if(x->R!=NULL)return tMin(x->R);

  y=x->parent;
  while(y!=NULL&&x==y->R)
    {
      x=y;
      y=y->parent;
    }
  return y;
}

void tDel(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if(z->L==NULL||z->R==NULL)y=z;
  else y=tSor(z);

  if(y->L!=NULL)x=y->L;
  else x=y->R;

  if(x!=NULL)x->parent=y->parent;
  if(y->parent==NULL)root=x;
  else if(y==y->parent->L)y->parent->L=x;
  else  y->parent->R=x;

  if(y!=z)z->key=y->key;
}

void insert(int k)
{
  Node y = NULL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  
  z->key = k;
  z->L = NULL;
  z->R = NULL;

  while(x!=NULL)
    {
      y=x;
      if(z->key<x->key)x=x->L;
      else x=x->R;
    }
  z->parent=y;

  if(y==NULL)root=z;
  else if(z->key<y->key)y->L=z;
  else y->R=z;
}

void inorder(Node u)
{
  if(u==NULL)return;
  
  inorder(u->L);
  printf(" %d",u->key);
  inorder(u->R);
}
void preorder(Node u)
{
  if(u==NULL)return;
  printf(" %d",u->key);
  preorder(u->L);
  preorder(u->R);
}



Measured memory_bytes: 20452
#include<stdio.h>
#include<string.h>
#include<iostream>

using namespace std;

char ch[200015];

int main(){

    int i,a=0,b=0;
    scanf("%s",ch);
    for(i=0;ch[i];i++){
        if(48+(i&1)==ch[i])a++;
        if(49-(i&1)==ch[i])b++;
    }
    printf("%d",a<b?a:b);
    return 0;
}


Measured memory_bytes: 384
function Main (input) {
  const num = input.split(/\s/g).filter((num) => num).map(num => parseInt(num))[0];
  if (num % 2 === 0 && num > 2) return console.log('%s',num);
  if (num % 2 === 0 && num <= 2) return console.log('%s',2);
  console.log('%s',num * 2);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        scanner.nextLine();
        List<Integer> values = Arrays.stream(scanner.nextLine().split(" "))
                .map(Integer::parseInt)
                .sorted()
                .collect(Collectors.toList());

        double tr = values.get(0);
        for (int i = 1; i < values.size(); i++) {
            tr = (tr + values.get(i)) / 2;
        }
        System.out.println(tr);
    }
}

Measured memory_bytes: 28884
import sys
from operator import itemgetter

inf = 1<<30

def solve():
    while 1:
        N = int(sys.stdin.readline().rstrip())

        if N == 0:
            return

        p = [set(list(map(int, sys.stdin.readline().split()))[1:]) for i in range(N)]
        l = list(map(int, sys.stdin.readline().split()))[1:]

        cnt = 0
        suspect = -1

        for i, pi in enumerate(p, start=1):
            if all(li in pi for li in l):
                cnt += 1
                suspect = i

                if cnt > 1:
                    print(-1)
                    break
        else:
            if cnt == 1:
                print(suspect)
            else:
                print(-1)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 9108
n = int(input())
L = []
for _ in range(n):
    s, p = input().split()
    p = int(p)
    L.append([s, p, _ + 1])
# print(L)


sorted_list = sorted(L, key=lambda x: (x[0], -x[1]))
for i in sorted_list:
    print(i[2])


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::vector<uint32_t> A(3 * N);
  for (auto &&a_n : A) std::cin >> a_n;

  std::sort(A.begin(), A.end(), std::greater<uint32_t>());
  uint64_t sum = 0;
  for (size_t i = 0; i < N; i++) sum += A[i * 2 + 1];

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
int main() {
	string s;
	int w;
	string ans = "";
	cin >> s >> w;
	for (int i = 0; i < s.size(); i += w) {
		ans = ans + s[i];
	}
	cout << ans << endl;
	return 0;
}

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

int ans;
string s;

int main() {
	cin >> s;
	for( int i = 0 , j = 0 ; i < 3 ; i = j+1 ) {
		j = i;
		while(s[i] == 'R' && j+1 < 3 && s[j+1] == 'R')
			j++;
		if(s[i] == 'R')
			ans = max(ans,j-i+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>

int main(){
   int x;
   scanf("%d", &x);

   switch(x % 10){
   case 2:
   case 4:
   case 5:
   case 7:
   case 9:
      puts("hon");
      break;
   case 0:
   case 1:
   case 6:
   case 8:
      puts("pon");
      break;
   case 3:
      puts("bon");
      break;
   }
   return 0;
}

Measured memory_bytes: 1656
import Control.Monad
import Control.Monad.State
import qualified Data.Map as M
import Data.Map ((!))
type Ints = M.Map Int Int
type Memo a b = M.Map a b
type DP a b = a -> State (Memo a b) b

main :: IO ()
main = do
    [n, c] <- (map read . words) <$> getLine
    wvs <- map readLine2 <$> replicateM n getLine
    print $ solve (n, c) wvs

-- |
--
-- >>> solve (4,6) [(2,1),(3,4),(4,10),(3,4)]
-- 11
solve :: (Int, Int) -> [(Int, Int)] -> Int
solve (n, c) wvs = rec (0, c)
  where
    (ws, vs) = toMap2 wvs

    rec :: (Int, Int) -> Int
    rec = evalDP rec'

    rec' :: DP (Int, Int) Int
    rec' = dp $ \ (i, j) ->
      if i >= n
        then return 0
        else do
          yes <- rec' (i + 1, j - (ws ! i))
          no <- rec' (i + 1, j)
          if ws ! i > j
            then return no
            else return $ max ((vs ! i ) + yes) no

-- DP
dp :: Ord a => DP a b -> DP a b
dp f x = do
  memo <- gets (M.lookup x)
  case memo of
       Just y  -> return y
       Nothing -> do
         y <- f x
         modify (M.insert x y)
         return y

evalDP :: DP a b -> a -> b
evalDP f x = evalState (f x) M.empty

-- Utility
toMap2 :: [(Int, Int)] -> (Ints, Ints)
toMap2 x2s = (x0map, x1map)
  where
    x0map = M.fromList $ zip ixs x0s
    x1map = M.fromList $ zip ixs x1s
    ixs = [0 .. (length x2s - 1)]
    (x0s, x1s) = unzip x2s

readLine2 :: String -> (Int,Int)
readLine2 = tuplify2 . map read . words
    where
      tuplify2 [] = (0, 0)
      tuplify2 [x] = (x, 0)
      tuplify2 (x:y:_) = (x, y)


Measured memory_bytes: 60796
#include<bits/stdc++.h>
using namespace std;
int main(){
#define int long
  int N;cin>>N;
  vector<int> A(N);for(int i=0;i<N;i++)cin>>A[i];
  int ans=0;
  int r=0;
  int s=0;
  for(int l=0;l<N;l++){
    while((!(s&A[r]))&&r<N){
    //while(s|A[r]==s+A[r]&&r<N){
      s|=A[r];
      r++;
    }
    ans+=r-l;
    s=s^A[l];
  }
  cout<<ans;
}

Measured memory_bytes: 1792
// ------------------------------------
// Date:2018/ 3/15
// Problem:ABC 066 ss b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  bool ok;
  int ans = 0;
  for (int i = 0; i < (s.size() + 1) / 2; ++i) {
    ok = false;
    for (int j = 0; j < i; ++j) {
      if (s[j] != s[i + j]) break;
      if (j == i - 1) ok = true;
    }
    if (ok) ans = i;
  }
  
  cout << ans * 2 << endl;
  
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<64)-1
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);

/*
   -------
         |
    **   |
   -------      
   |
   ------------------------------------------------------------------------------------------------------
*/

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

    for(int i =1;i <= 1e4; ++i)
    {
        int a2=i*8/100, b2 = i*10/100;
        if(a2==a && b2==b){
            cout<<i<<" ";
            return ;
        }
    }
    cout<<-1<<endl;
}

int main()
{   
     f_ip
  
      solve();

     return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

ll dp[3010][3010];
ll a[3010];

ll rec(int i, int j, bool b) {
	ll res;
	if(dp[i][j] != -1e18){
		return dp[i][j];
	} 
	else {
		if(b){
			 res = max(rec(i,j-1,false)+a[j], rec(i+1,j,false) + a[i]);
		} 
		else {
			 res = min(rec(i+1,j,true)-a[i], rec(i,j-1,true)-a[j]);
		}
	}
	return dp[i][j] = res;
}

int main() {
	int n;
	cin >> n;
	rep(i,n) {
		cin >> a[i];
	}
	rep(i,n) rep(j,n) dp[i][j] = -1e18;
	rep(i,n) {
		if(n%2==1) dp[i][i] = a[i];
		else dp[i][i] = -1*a[i];
	}
	cout << rec(0,n-1,true) << endl;
	/*rep(i,n) {
		rep(j,n) {
			if(dp[i][j] == -1e18) cout << setw(3) << "NA";
			else cout << setw(3) << dp[i][j];
		}
		cout << endl;
	}*/

  return 0;
}


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

#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define pb push_back
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std ;
typedef long long ll ;
const int mx = 200005;
ll x[mx] ;
ll y[mx] ;


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,d ;
	cin >> n >> d ;
	for(int i =1 ; i<= n ; i++){
		cin >> x[i] >> y[i] ;
		x[i] = ((ll)x[i]*(ll)x[i]) + ((ll)y[i]*(ll)y[i]) ;
//		cout << x[i] << ' ' ;
	}
	for(int i =1 ; i<=n;i++){
		if((ll)x[i] <= (ll)d*d){
			x[mx-1]++;
		}
	}
	cout << x[mx-1] ;
	return 0 ;
}


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

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(std::vector<long long> M, std::vector<long long> D){
  std::cout << (M[0]+1==M[1] and M[0]!=12) << std::endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n ;
  int d[n],e[101],a=0;
  for(int i=0;i<101;i++){
    e[i]=0;
  }
  for(int i=0;i<n;i++){
    cin >> d[i];
    e[d[i]]=1;
  }
  for(int i=1;i<=100;i++){
    a=a+e[i];
  }
  cout << a;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef struct{
  int num;
  int solve;
}data;
int main(void){
  int q,n,i,j,c;
  data m[100];
  for(n=0;;n++){
    scanf("%d,%d",&m[n].num,&m[n].solve);
    if(m[n].num==0){
      n++;
      break;
    }
  }
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(m[j-1].solve<m[j].solve){
	data t=m[j-1];
	m[j-1]=m[j];
	m[j]=t;
      }
    }
  }
  while(scanf("%d",&q)!=EOF){
    c=0;
    for(i=0;i<n;i++){
      c++;
      if(i>0&&m[i].solve==m[i-1].solve)
	c--;
      if(m[i].num==q){
	printf("%d\n",c);
	break;
      }
    }
  }
  return 0;
}

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

int main() {
    int n,x;
    int k;
    int m[110];
     
    cin >> n >> x;
    for(int i = 0; i < n; i++) cin >> m[i];
    sort(m,m+n);
  
    int sum;
    sum = 0;
    
    for(int i = 0; i < n; i++){
      sum = sum + m[i];
     }
   
    k = (x - sum) / m[0];
    
    cout << n + k << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(a-c)<=d)||(abs(a-b)<=d && abs(b-c)<=d)) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

    int main(void){
          int a,b,c;
          
           while(scanf("%d %d",&a,&b) !=EOF)
          {
               c=1; c=c+log10(a+b);
             printf("%d\n",c);
          }
             return 0;
            }

Measured memory_bytes: 644
a,b = map(int,input().split())

def f(x):
    if x < 0:
        return 0
    if x%4 == 0:
        return x
    if x%4 == 1:
        return x^(x-1)
    if x%4 == 2:
        return x^(x-1)^(x-2)
    return 0

print(f(b)^f(a-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int n,k,q; cin >> n >> k >> q;
  int a[n];
  FOR(i,0,n-1) a[i] = k - q;
  FOR(i,0,q-1){
    int input; cin >> input;
    --input;
    ++a[input];
  }
  FOR(i,0,n-1){
    if(a[i]>0) cout << "Yes" << "\n";
    else cout << "No" << "\n";
  }
    

}


Measured memory_bytes: 1024
N = int(input())
es = [0] * 1001
ans = 1

def div(n):
    b = 2
    while b <= n:
        while n%b==0:
            n //= b
            es[b] += 1
        b += 1

for i in range(1,N+1):
    div(i)

for e in es:
    ans *= e + 1
    ans %= 10**9+7
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dis[100005];
int n;
vector<int>vec[100005];
void dfs(int i)
{
	dis[i]=1;
	for(int j=0;j<vec[i].size();j++)
		if(dis[vec[i][j]]==0)
		{
			dfs(vec[i][j]);
			dis[i]+=dis[vec[i][j]];
		}
}
vector<int>ans;
bool vis[100005],ok;
void dfs2(int x)
{
	vis[x]=1;
	if(!ok)ans.push_back(x);
	if(x==n)
	{
		ok=1;
		return;
	}
	for(int i=0;i<vec[x].size();i++)
		if(!vis[vec[x][i]])
			dfs2(vec[x][i]);
	if(!ok)ans.pop_back();
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	dfs(1);
//	for(int i=1;i<=n;i++)
//		cout<<dis[i]<<' ';
//	cout<<endl;
	dfs2(1);
	int x=ans[(ans.size()+1)/2];
//	for(int i=0;i<ans.size();i++)
//		cout<<ans[i]<<' ';
//	cout<<endl;
	x=dis[x];
	if(x>=n-x)cout<<"Snuke";
	else cout<<"Fennec";
	return 0;
}


Measured memory_bytes: 9980
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define vi vector<long long>
#define mkp make_pair
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(max(a, d), max(b, c))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

int n;
int c[500], s[500], f[500];
int ans[500];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    cin >> n;
    for(int i=0; i<n-1; i++)
        cin >> c[i] >> s[i] >> f[i];
    for(int i=0; i<n-1; i++)
    {
        int x = 0;
        for(int j=i; j<n-1; j++)
        {
            if(x<=s[j]) x = s[j] + c[j];
            else x = s[j] + (x-s[j]+f[j]-1)/f[j] * f[j] + c[j];
        }
        cout << x << endl;
    }
    cout << 0;
}



Measured memory_bytes: 256
s=input()
K=int(input())
d=['zzzzz']
for i in range(len(s)):
    for j in range(i+1,i+6):
        for k in range(len(d)):
            if s[i:j] not in d and s[i:j]<d[k]:
                d.insert(k,s[i:j])
                if len(d)>5:
                    d.pop()
                break
print(d[K-1])

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

int main() {
	int n, l;
	cin >> n >> l;
	string str[110];
	for (int i = 0; i < n; i++)
		cin >> str[i];

	sort(str, str + n);
	for (int i = 0; i < n; i++)
		cout << str[i];
	cout << endl;

	return 0;
}

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

using pii = pair<int, int>;
using ll = long long;

constexpr int INF = 1e9;

struct edge {
    int to, cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, int cost) {
    g[from].push_back(edge{to, cost});
    g[to].push_back(edge{from, -cost});
}

std::vector<int> tsort(std::vector<std::vector<int>> const& g) {
    const int n = g.size();
    std::vector<int> in(n);
    for(int i = 0; i < n; ++i) {
        for(auto to : g[i]) {
            ++in[to];
        }
    }
    std::vector<int> S;
    for(int i = 0; i < n; ++i) {
        if(in[i] == 0) {
            S.push_back(i);
        }
    }
    std::vector<int> res;
    while(!S.empty()) {
        int v = S.back();
        S.pop_back();
        res.push_back(v);
        for(auto to : g[v]) {
            --in[to];
            if(in[to] == 0) {
                S.push_back(to);
            }
        }
    }
    bool ok = true;
    for(int i = 0; i < n; ++i) {
        ok &= in[i] == 0;
    }
    if(!ok) {
        res.clear();
    }
    return res;
}


bool dfs(graph const& g, int v, vector<int>& d, int sum) {
    if(d[v] == -INF) {
        d[v] = sum;
        for(auto& e : g[v]) {
            if(!dfs(g, e.to, d, sum + e.cost)) {
                return false;
            }
        }
    } else {
        if(d[v] != sum) {
            return false;
        }
    }
    return true;
}

int main() {
    int N, M;
    cin >> N >> M;
    graph g(N);
    vector<vector<int>> g2(N);
    for(int i = 0; i < M; ++i) {
        int L, R, D;
        cin >> L >> R >> D;
        add_edge(g, L - 1, R - 1, D);
        g2[L - 1].push_back(R - 1);
    }
    auto tp = tsort(g2);
    if(tp.size() == 0) {
        cout << "No" << endl;
        return 0;
    }
    vector<int> d(N, -INF);
    for(auto v : tp) {
        if(d[v] == -INF) {
            if(!dfs(g, v, d, 0)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}



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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;

ll dp[100010][4] = {};
string s;
ll n;

void init(){
  n = int(s.size());
  // dp[0][0] = 1;
}

void solve(){
  for (int i = n; i >= 0; i--) {
    for (int j = 3; j >= 0; j--) {
      if(i == n) dp[i][j] = (j == 3 ? 1 : 0);
      else{
        dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3LL : 1LL);
        if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
          dp[i][j] += dp[i+1][j+1];
        }
        dp[i][j] %= MOD;
      }
    }
  }
}

int main(){
  cin >> s;
  init();
  solve();
  cout << dp[0][0] << endl;
}



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

int main() 
{
    int i, j, bingo[3][3];

    for(i=0; i<3; i++)
    {
    	for(j=0; j<3; j++)
    	{
    		scanf("%d", &bingo[i][j]);
    	}
    }
    
    int n;

    scanf("%d", &n);

    int array[n];

    for(i=0; i<n; i++)
    {
    	scanf("%d", &array[i]);
    }

    int crtl1 = 0, crtl2 = 0, crtl3 = 0, crtc1 = 0, crtc2 = 0, crtc3 = 0, crtdp = 0, crtds = 0;

    for(i=0; i<n; i++)
    {
    	if(array[i] == bingo[0][0] || array[i] == bingo[0][1] || array[i] == bingo[0][2])
    	{
    		crtl1++;
    	}
    	if(array[i] == bingo[1][0] || array[i] == bingo[1][1] || array[i] == bingo[1][2])
    	{
    		crtl2++;
    	}
    	if(array[i] == bingo[2][0] || array[i] == bingo[2][1] || array[i] == bingo[2][2])
    	{
    		crtl3++;
    	}
    	if(array[i] == bingo[0][0] || array[i] == bingo[1][0] || array[i] == bingo[2][0])
    	{
    		crtc1++;
    	}
    	if(array[i] == bingo[0][1] || array[i] == bingo[1][1] || array[i] == bingo[2][1])
    	{
    		crtc2++;
    	}
    	if(array[i] == bingo[0][2] || array[i] == bingo[1][2] || array[i] == bingo[2][2])
    	{
    		crtc3++;
    	}
    	if(array[i] == bingo[0][0] || array[i] == bingo[1][1] || array[i] == bingo[2][2])
    	{
    		crtdp++;
    	}
    	if(array[i] == bingo[0][2] || array[i] == bingo[1][1] || array[i] == bingo[2][0])
    	{
    		crtds++;
    	}
    }

    if(crtl1 == 3 || crtl2 == 3 || crtl3 == 3 || crtc1 == 3 || crtc2 == 3 || crtc3 == 3 || crtdp == 3 || crtds == 3)
    {
    	printf("Yes\n");
    }
    else
    {
    	printf("No\n");
    }

	return 0;
}

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

ans = 0

if (n > k):
    hx = sorted(h)[0: n - k]
    """
    hx = h.sort(reverse=True)
    for i in range(k):
        hx.pop(0)
    """
    ans += sum(hx)

print(ans)



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

using namespace std;

const int N = 3e2 + 5;
double f[N][N][N];
int main() {
    int n;
    cin >> n;
    auto h = vector<int>(3, 0);
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        h[x - 1]++;
    }
    
    for(int u3 = 0; u3 <= n; u3++)
        for(int u2 = 0; u2 <= n; u2++)
            for(int u1 = 0; u1 <= n; u1++) if (u1 + u2 + u3 <= n){
                if (u1 == 0 && u2 == 0 && u3 == 0) continue;
                int u0 = n - u1 - u2 - u3;
                f[u1][u2][u3] = n;
                if (u1) f[u1][u2][u3] += u1 * f[u1 - 1][u2][u3];
                if (u2) f[u1][u2][u3] += u2 * f[u1 + 1][u2 - 1][u3];
                if (u3) f[u1][u2][u3] += u3 * f[u1][u2 + 1][u3 - 1];
                f[u1][u2][u3] /= n - u0;
            }
    cout << fixed << setprecision(12) << f[h[0]][h[1]][h[2]];
}


Measured memory_bytes: 219392