akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int mod = 1e9 + 7;

long long mod_pow(long long x,long long n){
    if(n==0) return 1;
    long long res = mod_pow(x*x % mod, n/2);
    if(n & 1) res = res*x % mod;
    return res;
}
long long fact[200010];//書き換えよう!
long long get_nCk(long long n, long long k, long long mod){
    if(fact[0] == 0){
        fact[0] = 1;
        for(int i = 1; i < 200010; i++) fact[i] = fact[i-1] * i % mod;
    }
    return fact[n] * mod_pow(fact[k], mod - 2) % mod * mod_pow(fact[n - k], mod - 2) % mod;
}

signed main(){
    int h, w, a, b;
    int ans = 0;
    cin >> h >> w >> a >> b;
    rep(i, 0, h - a){
        (ans += get_nCk(i + b - 1, b - 1, mod) * (get_nCk(h - 1 - i + w - 1 - b, w - 1 - b, mod))) %= mod;
    }
    cout << ans << endl;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
}c(200005);


//m^n
mint f(int m, int n) {
	if (0 == n) {
		return 1;
	}
	mint x = f(m, n / 2);
	x *= x;
	if (1 == n % 2) {
		x *= (mint)m;
	}
	return x;
}
// nCa
mint choose(int n, int a) {
	mint x = 1;
	mint y = 1;
	for (int m = 0; m < a; ++m) {
		x *= (mint)(n - m);
		y *= (mint)(a - m);
	}
	return x / y;
}
// nPk
mint nPk(int n, int a) {
	mint ret = choose(n, a);
	for (int n = 1; n <= a; ++n) {
		ret *= n;
	}
	return ret;
}

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
	int n;
	vector<T> d;
	BIT(int n = 0) :n(n), d(n + 1) {}
	void add(int i, T x = 1) {
		for (i++; i <= n; i += i & -i) {
			d[i] += x;
		}
	}
	T sum(int i) {
		T x = 0;
		for (i++; i; i -= i & -i) {
			x += d[i];
		}
		return x;
	}
	T sum(int l, int r) {
		return sum(r - 1) - sum(l - 1);
	}
};

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>A(K);
	vector<int>B(K);
	for (int i = 0; i < K; ++i) {
		cin >> A[i] >> B[i];
	}
	BIT<mint> d(2 * N);
	d.add(N, (mint)1);
	for (int i = 1; i < N; ++i) {
		mint memo = 0;
		for (int j = 0; j < K; ++j) {
			memo += (d.sum(N + i - A[j]) - d.sum(N + i - B[j] - 1));
			//cout << (d.sum(N + i - A[j]) - d.sum(N + i - B[j] - 1)) << endl;
		}
		d.add(N + i, memo);
		if (i == N - 1) {
			cout << memo << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<pair<int, string>> L(N);
  for (int i = 0; i < N; i++){
    string C;
    int D;
    cin >> C >> D;
    L[i] = make_pair(D, C);
  }
  sort(L.begin(), L.end());
  int M;
  cin >> M;
  vector<string> O(M);
  for (int i = 0; i < M; i++){
    cin >> O[i];
  }
  int pos = 0;
  int cd = 0;
  bool ok = false;
  for (int i = 0; i < N; i++){
    string C = L[i].second;
    int D = L[i].first;
    if (C == O[pos] && D > cd){
      pos++;
      cd = D;
      if (pos == M){
        ok = true;
        break;
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

class AtCoderCS {
    static void Main(string[] args) {
        int N = int.Parse(Console.ReadLine());
        IEnumerable<int> A = Console.ReadLine().Split(' ').Select(i => int.Parse(i));

        int[] ans = new int[N];
        foreach (int i in A)
            ans[i - 1]++;

        foreach (int i in ans)
            Console.WriteLine(i);
    }
}

Measured memory_bytes: 42592
mod = pow(10, 9)+7
k = int(input())
s = input()
n = len(s)
ans = 0
key = pow(26, k, mod)
sub = 1
c = 1
for i in range(k+1):
    ans += key*sub*c
    ans %= mod
    sub *= 25
    sub %= mod
    key = key*pow(26, mod-2, mod)%mod
    c *= (n+i)
    c *= pow(i+1, mod-2, mod)
    c %= mod
print(ans)

Measured memory_bytes: 70640
N = int(input())
name_list = [input() for name in range(N)]
char_list = ['M', 'A', 'R', 'C', 'H']
count_list = [0 for _ in range(len(char_list))]

flag = False

for name in name_list:
    if name[0] in char_list:
        count_list[char_list.index(name[0])] += 1
score = 0
for x in range(5):
    for y in range(x + 1, 5):
        for z in range(y + 1, 5):
            score += count_list[x] * count_list[y] * count_list[z]

print(score)


Measured memory_bytes: 9808
n=int(input())
a=map(int, input().split())
a=sorted(a)[::-1]
k=-2
l=-2
for i in range(n-1):
    if (a[i]==a[i+1])&(i>k+1):
        if (k>=0):
            l=i
            break
        else:
            k=i
if l>=0:
    print(a[k]*a[l])
else:
    print(0)

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
vector<int> v[100010];

struct UnionFind {
	vector<int> data;
 	UnionFind(int size):data(size, -1) {}
	bool unite(int x,int y){
		x=root(x);
		y=root(y);
 	   if(x!=y){
			if (data[y]<data[x]){
				swap(x, y);
			}
			data[x]+=data[y];
			data[y]=x;
		}
		return x!=y;
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0? x:data[x]=root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

signed main(){
	cin>>N>>M;
	UnionFind UF(N+10);
	REP(i,N){
		int a;
		cin>>a;
		REP(j,a){
			int b;
			cin>>b;
			b--;
			v[b].push_back(i);
		}
	}
	REP(i,M){
		if(v[i].size()==0)continue;
		int t=v[i][0];
		for(int j=1;j<v[i].size();j++){
			UF.unite(t,v[i][j]);
		}
	}
	REP(i,N-1){
		if(UF.same(i,i+1)==false){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 5116
from heapq import heappop, heappush

MOD = int(1e9+7)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    q = []
    numneg = 0
    for a in A:
        if a < 0:
            heappush(q, [a, "n"])
            numneg += 1
        elif a >= 0:
            heappush(q, [-a, "p"])
    if K % 2 == 1 and numneg == N or N == K:
        ans = 1
        A.sort(reverse=True)
        for i in range(K):
            ans = (ans * A[i]) % MOD
        print(ans)
        return
    ans = 1
    is_positive = True
    prevpos = None
    prevneg = None
    for i in range(K):
        num, posneg = heappop(q)
        ans = (ans * -num) % MOD
        if posneg == "n":
            is_positive = not is_positive
            prevneg = num
        else:
            prevpos = num
    if ans != 0 and not is_positive:
        nextpos = None
        nextneg = None
        while len(q) and (nextneg is None or nextpos is None):
            num, posneg = heappop(q)
            if posneg == "p" and nextpos is None:
                nextpos = num
            elif posneg == "n" and nextneg is None:
                nextneg = num
        # nextneg / prevpos < nextpos / prevneg
        if prevpos is None or nextneg is None:
            ans = div(ans * nextpos, prevneg)
        elif prevneg is None or nextpos is None:
            ans = div(ans * nextneg, prevpos)
        else:
            if nextneg * prevneg < nextpos * prevpos:
                ans = div(ans * nextpos, prevneg)
            else:
                ans = div(ans * nextneg, prevpos)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 116516
S=input()
T=input()
t=len(T)
for i in range(len(S)-t,-1,-1):
    for j in range(t):
        k=S[i+j]
        if k !=T[j] and k!="?" :break
    else:
        print((S[:i]+T+S[i+t:]).replace("?","a"))
        exit()
print("UNRESTORABLE")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
using P = pair<int,int>;
signed main(){
    string s;
    cin >> s;
    int N = s.size();
    s += "??";

    int A = -1,B = -1;
    rep(i,N){
        if(s[i] == s[i+1]) A = i+1, B = i+2;
        if(s[i] == s[i+2] && s[i] != s[i+1]) A = i+1, B = i+3;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  while(A){
    C = C-B;
    if(C<=0) break;
    A = A-D;
  }

  if(A>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
<?php
$dw = trim(fgets(STDIN));
$az = [];
for($a = "a"; strlen($a) == 1; $a++){
  $az[$a] = $a;
}

if($dw == 'zyxwvutsrqponmlkjihgfedcba'){
  echo -1;
  exit;
}elseif(strlen($dw) < 26){
  for($i = 0; $i < strlen($dw); $i++){
    unset($az[$dw[$i]]);
  }
  echo $dw.array_shift($az);
}else{
  $left[] = $dw[strlen($dw)-1];
  for($i = strlen($dw) - 2; $i >= 0; $i--){
    if($dw[$i] < $dw[$i+1])break;
    $left[] = $dw[$i];
  }
  echo substr($dw, 0, $i);
  sort($left);
  foreach($left as $l){
    if($l>$dw[$i]){
      echo $l;exit;
    } 
  }
}


Measured memory_bytes: 4728
import java.util.Scanner;

/**
 * https://abc049.contest.atcoder.jp/tasks/abc049_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		sc.nextInt();
		String[] s = new String[H];
		for(int i=0; i<H; i++) s[i] = sc.next();
		sc.close();
		
		for(int i=0; i<H; i++){
			System.out.println(s[i]);
			System.out.println(s[i]);
		}

	}

}


Measured memory_bytes: 24432
#include <bits/stdc++.h>
using namespace std;
using pr = pair<int, int>;

int N, M, K, ans = 1e9;
int d[4] = { 1, -1, 0, 0 }, Sx, Sy;
int dist[808][808];
char A[808][808];
queue<pr> q;

int f(int x, int y) { return min({ x - 1, y - 1, N - x, M - y }); }

int main() {
    scanf("%d %d %d", &N, &M, &K);
    for(int i=1; i<=N; i++) scanf("%s", A[i] + 1);
    for(int i=1; i<=N; i++) for(int j=1; j<=M; dist[i][j] = 1e9, j++) if(A[i][j] == 'S') Sx = i, Sy = j;
    q.push(pr(Sx, Sy)), dist[Sx][Sy] = 0;
    while(!q.empty()) {
        int x = q.front().first, y = q.front().second; q.pop();
        ans = min(ans, f(x, y));
        if(dist[x][y] == K) continue;
        for(int i=0; i<4; i++) {
            int xx = x + d[i], yy = y + d[3-i];
            if(A[xx][yy] == '.' && dist[xx][yy] > dist[x][y] + 1) {
                q.push(pr(xx, yy));
                dist[xx][yy] = dist[x][y] + 1;
            }
        }
    }
    printf("%d\n", ans / K + !!(ans % K) + 1);
}


Measured memory_bytes: 3456
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<utility>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,m,u[2005][2005],d[2005][2005],l[2005][2005],r[2005][2005],ans;
char a[2005][2005];
int main(){
	ans=-99999;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			if(j==1||a[i][j-1]=='#')
				l[i][j]=1;
			else
				l[i][j]=l[i][j-1]+1;
		for(int j=m;j>=1;j--)
			if(j==m||a[i][j+1]=='#')
				r[i][j]=1;
			else
				r[i][j]=r[i][j+1]+1;
	}
	for(int j=1;j<=m;j++)
	{
		for(int i=1;i<=n;i++)
			if(i==1||a[i-1][j]=='#')
				u[i][j]==1;
			else
				u[i][j]=u[i-1][j]+1;
		for(int i=n;i>=1;i--)
			if(i==n||a[i+1][j]=='#')
				d[i][j]==1;
			else
				d[i][j]=d[i+1][j]+1;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]!='#')
				ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]);
	cout<<ans-1;
	return 0;
}

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

int main(){
  long long int n,k;
  cin>>n>>k;
  long long int a=n%k;
  long long int b=k-n%k;
  cout<<min(a,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

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

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >>n&&n){
    vector<vector<int>> v(n+1,vector<int>(n+1,0));
    rep(i,n){
      rep(j,n){
        cin >> v[j][i];
      }
    }
    rep(i,n){
      int sum = 0;
      rep(j,n){
        scout(5)<< v[j][i] ;
        sum += v[j][i];
      }
      v[n][i] = sum;
      scout(5)<< sum << endl;
    }
    rep(i,n+1){
      int sum = 0;
      rep(j,n){
        sum += v[i][j];
      }
      scout(5)<< sum ;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  ll n,k,q;
  cin >> n >> k >> q;
  vector<ll>a(q);
  rep(i,q) cin >> a[i];
  vector<ll>ans(n);
  
  rep(i,q){
    a[i]--;
    ans[a[i]]++;
  }
  
  rep(i,n){
    if(q-ans[i]>=k)cout<<"No"<<endl;
    else cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;

	const int MOD = 998244353;

	auto f = [](char c) {
		if(c == 'R') return 0;
		if(c == 'G') return 1;
		if(c == 'B') return 2;
	};
	
	i64 ans = 1;
	std::vector<i64> A(3), B(1 << 3);
	for(int i = 0; i < s.size(); i++) {
		int type = f(s[i]);

		if(B[7 ^ (1 << type)]) (ans *= B[7 ^ (1 << type)]--) %= MOD;
		else {
			i64 S = 0;
			for(int k = 0; k < 3; k++) if(k != type) S += A[k];

			if(S) {
				(ans *= S) %= MOD;
				for(int k = 0; k < 3; k++) if(k != type and A[k]) {
					B[(1 << k) | (1 << type)]++;
					A[k]--;
					break;
				}
			} else A[type]++;
		}
	}
	for(i64 i = 1; i <= n; i++) (ans *= i) %= MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;
const int MOD = 1e9+7;

const int MAX_N = 3e5;
ll fac[MAX_N],inv[MAX_N];
ll qpow(ll x, int k)
{
    x=x%MOD;
    ll ans=1;
    while(k)
    {
        if(k&1) ans=ans*x%MOD;
        x=x*x%MOD;
        k>>=1;
    }
    return ans;
}
void init()
{
    fac[0]=1;
    for(int i=1; i<MAX_N; i++)
        fac[i]=fac[i-1]*i%MOD;
    inv[MAX_N-1]=qpow(fac[MAX_N-1],MOD-2);
    for(int i=MAX_N-1; i>0; i--)
        inv[i-1]=inv[i]*i%MOD;
}
ll Comb(int n, int m)
{
    return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}

int main(){
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  init();

  ll sum = 0;
  rep(i,b,w){
    ll pos = h-a-1;
    //cout << 1 << endl;
    ll g = Comb(i+pos,pos) * Comb(a-1+w-i-1,a-1) %MOD;
    //cout << 215 << endl;;
    sum = (sum+g)%MOD;
    //sum %= MOD;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4992
# abc089c
import itertools
import sys
n = int(input())
s = [input() for i in range(n)]
'''
1.
M,A,R,C,Hから始まる名前を抽出する
2.
MARCHの5文字から3文字選ぶ
3.
選んだ文字ごとに、人数の掛け算を行う
'''
m = 0
a = 0
r = 0
c = 0
h = 0
for si in s:
    if si[0] == 'M':
        m += 1
    elif si[0] == 'A':
        a += 1
    elif si[0] == 'R':
        r += 1
    elif si[0] == 'C':
        c += 1
    elif si[0] == 'H':
        h += 1
if m == 0 and a == 0 and r == 0 and c == 0 and h == 0:
    print(0)
else:
    p = itertools.combinations(['M','A','R','C','H'], 3)
    ans = 0
    for i in p:
        ans_ = 1
        if 'M' in i:
            ans_ *= m
        if 'A' in i:
            ans_ *= a
        if 'R' in i:
            ans_ *= r
        if 'C' in i:
            ans_ *= c
        if 'H' in i:
            ans_ *= h
        ans += ans_
    print(ans)

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

signed main(){
	ll A;
	cin >> A;
	double B;
	cin >> B;
	int HB = 100*B+EPS;
	ll ans = A*HB/100;

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

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

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int q = (a % d) ? a / d + 1 : a / d;
	int r = (c % b) ? c / b + 1 : c / b;
	if(q >= r)
		cout << "Yes\n";
	else
		cout << "No\n";

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 17
using namespace std;
int n,lim,A,B,a[1<<N];I int C(RI x) {RI t=0;W(x) ++t,x&=x-1;return t;}
I void Paint(CI x,CI y,CI s)
{
	if(C(s^(lim-1))==1) return (void)printf("%d %d ",y,x^y);RI i,j;
	for(i=0;i^n;++i) if(!((s>>i)&1)&&(x>>i&1)) for(j=0;j^n;++j) if(!((s>>j)&1)&&i^j)
		return Paint(1<<j,y,s|(1<<i)),Paint(x^(1<<i)^(1<<j),y^(1<<i)^(1<<j),s|(1<<i));
}
int main()
{
	RI i,t;if(scanf("%d%d%d",&n,&A,&B),lim=1<<n,!(C(A^B)&1)) return puts("NO"),0;
	return puts("YES"),Paint(A^B,A,0),0;
}

Measured memory_bytes: 3844
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}


struct Edge{
  int to;
  int weight;

  Edge(int t,int w){
    to = t;
    weight = w;
  }
};

using Graph = vector<vector<Edge>>;

int main(){
  long ii,jj,kk;
  vector<int> a;
  int v,e;
  cin >> v >> e ;

  //cout << v << " "  << e << endl;
  
  Graph g;
  g.resize(v);
  int s,t,d;

  for(ii=0;ii<e;ii++){
    cin >> s >> t >> d;
    g[s].push_back(Edge(t,d));
  }

  // s位置を0〜vにして、aと同じ処理
  vector<bool> seen;
  vector<int> todo;
  int dists[100][100];
  int negcnt[100][100];
  for(ii=0;ii<100;ii++){
    for(jj=0;jj<100;jj++){
      dists[ii][jj] = INF;
    }
  }

  int dist;
  int todo_pos;

  //printf("%d\n",g[0][0].weight);
  bool neg = false;
  memset(negcnt,0,sizeof(negcnt));
  for(ii=0;ii<v;ii++){
    //各頂点毎に各頂点までの最短距離を取得

    //iiがスタート
    seen.assign(v,false);
    seen[ii] = true;
    todo.push_back(ii);
    dists[ii][ii] = 0;

    while(todo.empty() != true){

      
      todo_pos = todo[0];
      dist = dists[ii][todo_pos];
      
      todo.erase(todo.begin());

      for(Edge edge : g[todo_pos]){

        if(dist + edge.weight < dists[ii][edge.to]){
          dists[ii][edge.to] = dist + edge.weight;

          negcnt[ii][edge.to]++;
          if(negcnt[ii][edge.to] > e+2){
            neg = true;
            goto negbreak;
          }
          seen[edge.to] = false;
        }

        if(seen[edge.to] == false){
          todo.push_back(edge.to);
        }

        seen[edge.to] =true;
        
      }      
    }

  }

 negbreak:
  //for(ii=0;ii<v;ii++){
  //  if(dists[ii][ii] < 0){
  //    neg = true;
  //  }
  //}
  if(neg){
    cout << "NEGATIVE CYCLE" << endl;
  }
  
  else{
    for(ii=0;ii<v;ii++){
      for(jj=0;jj<v;jj++){
        //cout << jj << " ";
        if(dists[ii][jj] != INF){
          cout << dists[ii][jj];
        }
        else{
          cout << "INF";
        }
      
        if(jj != v-1){
          cout << " ";
        }
        else{
          cout << endl;
        }
      
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3276
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]
	H := list[2]
	M := list[3]

	aPosM := 60*H + M          // max 720
	bPosM := M % 60            // max 60
	bPosM = bPosM * (720 / 60) // to max 720

	if aPosM == bPosM {
		ans := math.Abs(float64(A) - float64(B))
		fmt.Printf("%.19f", ans)
	} else {
		AFloat := float64(A)
		BFloat := float64(B)
		aPosRad := 2.0 * math.Pi * float64(aPosM) / 720.0
		bPosRad := 2.0 * math.Pi * float64(bPosM) / 720.0
		rad := math.Abs(aPosRad - bPosRad)
		ans := AFloat*AFloat + BFloat*BFloat - 2.0*AFloat*BFloat*math.Cos(rad)
		ans = math.Sqrt(ans)
		fmt.Printf("%.19f", ans)
	}

	fmt.Printf("\n")
}

var sc = bufio.NewScanner(os.Stdin)

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 1740
using System;

class Program
{
    static void Main(string[] args)
    {
        var num = Console.ReadLine();
        var containNine = false;
        for(var i = 0; i < num.Length; i++)
        {
            containNine=num.Substring(i, 1)=="9";
            if (containNine) break;
        }

        var result = containNine ? "Yes" : "No";
        Console.WriteLine(result);


    }
}


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

int main() {
  long N;
  cin >> N;
  for (int i=(int)sqrt((double)N)+1; i>0; i--) {
    if (N%i == 0) {
      long l = N/i;
      int ans = 0;
      while (l != 0) {
        ans++;
        l /= 10;
      }
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int c = 0;
        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == t.charAt(i)) {
                c++;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 23892
def main():
    n = int(input())
    col = list(map(int, input().split()))
    col_min, col_max = min(col), max(col)
    if col_min == col_max:
        if col_min == 1 or col_min == n-1:
            print("Yes")
        elif 2*col_min <= n:
            print("Yes")
        else:
            print("No")
    elif col_min + 1 == col_max:
        cnt_min, cnt_max = 0, 0
        for v in col:
            if v == col_min:
                cnt_min += 1
            else:
                cnt_max += 1
        if cnt_max == 1:
            print("No")
        else:
            m = cnt_max//2
            if col_min < cnt_min-1 + 1 or cnt_min-1 + m < col_min:
                print("No")
            else:
                p = col_min - (cnt_min-1)
                if p + cnt_min == col_max:
                    print("Yes")
                else:
                    print("No")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 20720
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MAX=1e6;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
typedef struct{int SPF[1000001],Primes[168],sz;}Template;
Template P;
static inline void ready(void)
{
  *P.SPF=1,*P.Primes=2,P.sz=1;
  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  rep(i,MAX/2-1)
  {
    int x=2*(i+1)+1;if(P.SPF[x]==x){P.Primes[P.sz++]=x;}if(x*x>MAX)break;
    rep(j,P.sz){if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];else break;}
  }
}
const char common[]="not coprime",disjoint[]="pairwise coprime",several[]="setwise coprime";
int  vol=0,esc[1000000];
static inline int Divise(int x)
{
  if(!x){return 0;}
  rep(i,P.sz)
  {
    if(P.Primes[i]*P.Primes[i]>x)break;
    if(x%P.Primes[i]==0)
    {
      if(esc[P.Primes[i]-1])return 0;
      esc[P.Primes[i]-1]=1;
      while(x%P.Primes[i]==0&&x)x/=P.Primes[i];
    }
  }
  if(x>1){if(esc[x-1])return 0;esc[x-1]=1;}
  return 1;
}
int main(void)
{
  int N=IN(),A=0,flag=0,g=0;ready();
  rep(i,N){A=IN();g=GCD(g,A);if(i&&g!=1){flag=1;}if(!Divise(A)){flag=1;}}
  if(g>1)return puts(common),0;
  if(flag)return puts(several),0;else return puts(disjoint),0;
}

Measured memory_bytes: 9340
fun main() = Thread(null, ::abc172d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc172d() {
    val k = readLine()!!.toLong()

    var answer = 0L

    for (n in 1..k) for (m in n..k step n) {
        answer += m
    }

    println(answer)
}


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

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;

  string ans = "Zero";
  if (0 < a)
    ans = "Positive";
  else if (b < 0)
    ans = (b - a) % 2 ? "Positive": "Negative";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void cal(string str, string ptr, int n, int m)
{
	int dp[n+1][m+1];
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=m; j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(str[i-1]==ptr[j-1])
				dp[i][j] = 1 + dp[i-1][j-1];
			else 
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	
	int index = dp[n][m];
	char lcs[index];
	lcs[index]='\0';
	
	int i=n, j=m;
	while(i > 0 && j > 0)
	{
		if(str[i-1] == ptr[j-1])
		{
			lcs[index-1]=str[i-1];
			i--; j--; index--;
		}
		else if(dp[i-1][j] > dp[i][j-1])
		{
			i--;
		}
		else
		{
			j--;
		}
	}
	cout<<lcs;
}
int main()
{
	int n,m;
	string str , ptr;
	cin>>str>>ptr;
	n=str.length();
	m=ptr.length();
	cal(str,ptr,n,m);
	return 0;
}

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

using namespace std;

int main(){
    int len;
    long ans = 0;
    string s;
    cin >> s;
    len = s.size();
    vector<long> vc;
    for(int i=0; i<len; i++){
        vc.push_back((long)((int)(s[i]-'0')));
    }
    for(int bit=0; bit<(1<<(len-1)); bit++){
       long tmp = vc[0];
       for(int i=0; i<len-1; i++){
          if(bit & 1<<i){
            ans += tmp;
            tmp = vc[i+1];
          }else{
            tmp *= 10;
            tmp += vc[i+1];
          }
       }
       ans += tmp;
    }

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int now = 0;
  string s;
  cin >> s;
  int n = s.size();
  
  rep(i,n){
    if(s[i]=='+')now++;
    else now--;
  }
  
  cout << now << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, k;
int positive[114514], sum[114514];
signed main() {
	cin >> n >> k;
	rep(i, n) {
		int a; cin >> a;
		if (i) {
			positive[i] += positive[i - 1];
			sum[i] += sum[i - 1];
		}
		if (a > 0)positive[i] += a;
		sum[i] += a;
	}
	int ans = 0;
	rep(i, n - k + 1) {
		int cnt = 0;
		if (i) {
			cnt += positive[i - 1];
			cnt += max(0ll, sum[i + k - 1] - sum[i - 1]);
		}
		else {
			cnt += max(0ll, sum[i + k - 1]);
		}
		cnt += positive[n - 1] - positive[i + k - 1];
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int main()
{
	int n, m, x, y;
	int a[100010]={};
	int b[100010]={};
	int c[100010]={};
	cin >> n >> m;
	rep(i, n)
	{
		cin >> x;
		a[x]++;
		b[(x%m)]++;
	}
	repp(i, 1, 100010)
	{
		y=a[i]/2;
		c[(i%m)]+=y;
	}
	int ans=0;
	int t;
	if(m%2!=0)
	{
		repp(i, 1, (m/2)+1)
		{
			t=min(b[i], b[m-i]);
			b[i]-=t;
			b[m-i]-=t;
			ans+=t;
			ans+=min(b[i]/2, c[i]);
			ans+=min(b[m-i]/2, c[m-i]);
		}
		ans+=b[0]/2;
	}
	else
	{
		repp(i, 1, (m/2))
		{
			t=min(b[i], b[m-i]);
			b[i]-=t;
			b[m-i]-=t;
			ans+=t;
			ans+=min(b[i]/2, c[i]);
			ans+=min(b[m-i]/2, c[m-i]);			
		}
		ans+=b[0]/2;
		ans+=b[(m/2)]/2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
n = int(input())
x = list(map(int, input().split()))
ans = 0
mod = 1000000007
p = 1
for i in range(1, n):
  p *= i
  p %= mod
for i in range(n-1):
  ans += (x[n-1]-x[i])*pow(i+1, mod-2, mod)
ans *= p
ans %= 1000000007
print(ans)

Measured memory_bytes: 62960
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  string S;
  cin >> S;

  vl Rp, Gp;
  
  rep(i, N){
    if(S[i] == 'R') Rp.push_back(i);
    if(S[i] == 'G') Gp.push_back(i);
  }

  /*
  vl BL(N);

  BL[0] = S[0] == 'B' ? 1 : 0;
  rep2(i, 1, N) BL[i] = BL[i - 1] + (S[i] == 'B' ? 1 : 0);
  */

  ll Bcnt = 0;
  rep(i, N) Bcnt += S[i] == 'B' ? 1 : 0;
  
  ll Rc = Rp.size(), Gc = Gp.size();

  ll ans = 0;

  rep(i, Rc){
    rep(j, Gc){
      ll maxi = max(Rp[i], Gp[j]);
      ll mini = min(Rp[i], Gp[j]);
      ll dif = maxi - mini;

      ans += Bcnt;

      if(mini - dif >= 0) ans -= S[mini - dif] == 'B' ? 1 : 0;
      if((maxi + mini) % 2 == 0) ans -= S[(maxi + mini) / 2] == 'B' ? 1 : 0;
      if(maxi + dif <= N - 1) ans -= S[maxi + dif] == 'B' ? 1 : 0;
    }
  }

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


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<random>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<unordered_map>
#include<time.h>
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
#define int long long
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace std;
int dp[1001][8], n, a[1001];
string s;
int solve(int i, int s) {
	if (i == n)
		return 1;
	if (dp[i][s] != -1) return dp[i][s];
	int d = a[i + 1];
	int ans = 0;
	bool l[8];
	fill(l, l + 8, 1);
	for (int j = 1; j < 8; j++) {
		if (d&j&&s & j&&l[d | j]) {
			ans += solve(i + 1, d | j);
			l[d | j] = 0;
		}
	}
	return dp[i][s] = (ans % 10007);
}
signed main() {
	cin >> n >> s;
	for (int i = 1; i <= n; i++) {
		switch (s[i-1]) {
		case 'J':a[i] = 1; break;
		case 'O':a[i] = 2; break;
		case 'I':a[i] = 4; break;
		}
		for (int j = 0; j < 8; j++)
			dp[i][j] = -1;
	}
	for (int i = 0; i < 8; i++)
		dp[0][i] = -1;
	cout << solve(0, 1) << endl;

	getchar(); getchar();
}

Measured memory_bytes: 3292
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import Counter

def main():
    _ = input()
    D = Counter(input().split())
    _ = input()
    T = Counter(input().split())
    D.subtract(T)
    if min(D.values()) < 0:
        print("NO")
    else:
        print("YES")
    return None

if __name__ == "__main__":
    main()

Measured memory_bytes: 67680
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
long long p[100000];
long long q[100000];
int main(void){
    // Your code here!
    int W;
    int H;
    cin >> W >> H;
    for(int i = 0; i < W; i++){
        cin >> p[i];
    }
    for(int i = 0; i < H; i++){
        cin >> q[i];
    }
    
    vector <pair <long long, bool> > pq;
    for(int i = 0; i < W; i++){
        pq.push_back(make_pair(p[i], true));
    }
    for(int i = 0; i < H; i++){
        pq.push_back(make_pair(q[i], false));
    }
    
    sort(pq.begin(), pq.end());
    long long total_cost = 0;
    int vertical_set_num = W + 1;
    int horizontal_set_num = H + 1;
    for(int i = 0; i < pq.size(); i++){
        long long cur_cost = pq[i].first;
        bool is_p = pq[i].second;
        if(is_p){
            total_cost += horizontal_set_num * cur_cost;
            vertical_set_num --;
        } else {
            total_cost += vertical_set_num * cur_cost;
            horizontal_set_num --;
        }
    }
    cout << total_cost << endl;
}

Measured memory_bytes: 7792
A,B,K = map(int,input().split())
def gcd(x,y):
    if x<y:x,y = y,x
    if y==0:return x
    return gcd(y,x%y)
C = gcd(A,B)
Z = []
for i in range(1,C+1):
    if i*i>C:break
    if C%i==0:
        Z.append(i)
        if i!=C//i:
            Z.append(C//i)
Z.sort()
print(Z[-K])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
const int AI = 100000, M = 1'000'000'007;
ll Csum[AI+1] = {};
ll add(ll x, ll y) { return (x + y) % M; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> s(n + 1), t(m + 1);
    for(int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    for(int i = 1; i <= m; i++) {
        cin >> t[i];
    }
    vector<vector<ll>> C(n + 1, vector<ll>(m + 1));
    for(int i = 0; i <= n; i++) {
        map<int, ll> Csum;
        for(int j = 0; j <= m; j++) {
            if(i == 0) {
                C[i][j] = 1;
            } else {
                if(j > 0) {
                    ll& p = Csum[t[j]];
                    p = add(p, C[i - 1][j - 1]);
                }
                C[i][j] = add(C[i - 1][j], Csum[s[i]]);
            }
        }
    }
    cout << C[n][m] << endl;
    return 0;
}


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

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


  int A,B,N;
  cin >> N >> A >> B;

  if (N==1) {
    cout << "Hello World" << endl;
  }

  else if (N==2) {
    cout << A+B << endl;
  }
  return 0;
}


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

int main() {
  int A,B,C; cin >>A >>B >>C;
  if (C<=A+B) {cout <<"Yes" <<endl;}
  else cout <<"No" <<endl;
  return 0;
}


Measured memory_bytes: 256
N_D = list(map(int,input().split()))
j = 0
for i in range(N_D[0]):
  X_Y = list(map(int,input().split()))
  R = (X_Y[0]**2 + X_Y[1]**2)**(1/2)
  if R<=N_D[1]:
    j+=1

print(j)

Measured memory_bytes: 9628
#include <iostream>
#include <array>

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

    long long int n;

    while (std::cin >> n, n) {
        std::array<long long int, 7> arr{{}};
        int age;
        for (; n--;) {
            std::cin >> age;
            age = (age < 60 ? age : 60);
            ++arr[(int)(age * 0.1)];
        }

        for (const auto& cnt : arr) {
            std::cout << cnt << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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 long long ll;

using namespace std;

class UnionFind
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};

struct city{int x,y,id;};
struct edge{int to,from,cost;};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<city>ci(n);
  rep(i,n)
  {
    int x,y;
    cin>>x>>y;
    ci[i]={x,y,i};
  }
  sort(all(ci),[&](city a,city b){return a.x<b.x;});
  vector<edge>ed;
  rep(i,n)
  {
    if(i>0){
      ed.push_back({ci[i-1].id,ci[i].id,ci[i].x-ci[i-1].x});
      ed.push_back({ci[i].id,ci[i-1].id,ci[i].x-ci[i-1].x});
    }
    if(i<n-1){
      ed.push_back({ci[i+1].id,ci[i].id,ci[i+1].x-ci[i].x});
      ed.push_back({ci[i].id,ci[i+1].id,ci[i+1].x-ci[i].x});
    }
  }
  sort(all(ci),[&](city a,city b){return a.y<b.y;});

  rep(i,n)
  {
    if(i>0){
      ed.push_back({ci[i-1].id,ci[i].id,ci[i].y-ci[i-1].y});
      ed.push_back({ci[i].id,ci[i-1].id,ci[i].y-ci[i-1].y});
    }
    if(i<n-1){
      ed.push_back({ci[i+1].id,ci[i].id,ci[i+1].y-ci[i].y});
      ed.push_back({ci[i].id,ci[i+1].id,ci[i+1].y-ci[i].y});
    }
  }
  sort(all(ed),[](edge a,edge b){return a.cost<b.cost;});
  UnionFind uf(n);
  ll res=0;
  for(auto te:ed)
  {
    if(uf.connect(te.to,te.from))res+=te.cost;
  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 15852
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
inline __int128 read(){
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

inline void print(__int128 x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
__int128 ABS(__int128 x)
{
	return x < 0 ? -x : x;
}
int main()
{
	__int128 x,k,d;
	x=ABS(read()),k=read(),d=read();
//	print(k*d);
	if(k*d>=x)
	{
		if((k-(x/d))%2==0)	print(x%d);
		else	print(min(ABS(x%d+d),ABS(x%d-d)));
	}
	else	print(x-k*d);
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll A,B,C,K;
    cin >> A >> B >> C >> K;

    ll ans = 0;
    ll cnt = 0;
    ll amari = 0;

    amari = K - A;
    if(amari <= 0){
        ans += K;
        cout << ans << endl;
        return 0;
    }
    ans += A;


    amari -= B;

    if(amari <= 0){
        cout << ans << endl;
        return 0;
    }

    ans -= amari;

    cout << ans << endl;
}


Measured memory_bytes: 3624