akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
int N,P[200010];
int main(){
	scanf("%d",&N);
	for(int i=0,p;i<N;i++)scanf("%d",&p),P[p]=i;
	int ans=0;
	for(int i=1,j=1;i<=N;i++){
		if(j<i)j=i;
		while(j<N&&P[j+1]>P[j])++j;
		if(j-i+1>ans)ans=j-i+1;
	}
	printf("%d\n",N-ans);
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	ll a1, m1, a2, m2, a3, m3;
	while (1) {
		cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
		if (!(a1 | m1 | a2 | m2 | a3 | m3))
			break;
		ll a, b, c, x, y, z;
		a = b = c = x = y = z = 1;
		x = a1 * x % m1;
		y = a2 * y % m2;
		z = a3 * z % m3;
		for (; x != 1; a++)
			x = a1 * x % m1;
		for (; y != 1; b++)
			y = a2 * y % m2;
		for (; z != 1; c++)
			z = a3 * z % m3;
		cout << lcm(lcm(a, b), c) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c;
  cin >> a >> b >> c;

  if (b - a == c - b){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll A, B;
set<ll> S;

void gather_prime(ll n) {
    ll a = 2;
    while (a * a <= n) {
        if (n % a == 0) {
            S.insert(a);
            while(n % a == 0) n /= a;
        }
        a++;
    }
    if (n > 1) S.insert(n);
}

void solve() {
    cin >> A >> B;
    S.insert(1);
    ll a = __gcd(A, B);
    gather_prime(a);
    cout << S.size() << endl;

}

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


Measured memory_bytes: 256
#include<set>
#include<iostream>
#include<ctime>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<string.h>
#include<limits.h>
#define int long long
using namespace std;

int a[100005];
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int b; cin >> b;
		a[b + 1]++;
	}
	int ans = 0;
	for (int i = 1; i < 100003; i++) {
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long a1 = Long.parseLong(sc.next());
		Long a2 = Long.parseLong(sc.next());
		
		Long ans = lcm(a1,a2);
		
		System.out.println(ans);;
	}



	static Long gcd (Long a, Long b) {return b>0?gcd(b,a%b):a;}
	static Long lcm (Long a, Long b) {return a*b/gcd(a,b);}

}



Measured memory_bytes: 21716
N, A, B = gets.split.map(&:to_i)

if A > B
  puts 0
  exit
end

if N == 1
  if A != B
    puts 0
  else
    puts 1
  end

  exit
end

max = (A + B) + B * (N - 2)
min = (A + B) + A * (N - 2)

puts max - min + 1


Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<long int, long int>

int main(){
    long int n;
    cin >> n;
    P a[n];
    rep(i, n) cin >> a[i].second >> a[i].first;
    long int t = 0;
    sort(a, a + n);
    rep(i, n){
        t += a[i].second;
        if (t > a[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3328
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    ll n;
    cin >> n;
    ll minx = n-1;
    for(ll i=2;i*i<=n;i++){
        if(n % i)
            continue;
        ll j = n / i;
        minx = min(minx, i+j-2);
        
    }

    cout << minx << endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A;
map<int, int> cnt;
int main() {
    cin >> N;
    A.resize(N);
    for (auto &val : A){
        cin >> val;
        cnt[val]++;
    }
    int result = 0;
    for (auto &val : cnt){
        if (val.first > val.second){
            result += val.second;
        }else{
            result += val.second - val.first;
        }
    }
    cout << result << endl;
  return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  int MOD=1000000007;
  long long ans=1;
  if (abs(N-M)>1){
    cout << 0 << endl;
  }
  else if (N==M){
    ans=2;
    for (int i=1;i<N+1;i++){
      ans=ans*i%MOD*i%MOD;
    }
    cout << ans << endl;
  }
  else {
    for (int i=1;i<N+1;i++){
      ans=ans*i%MOD;
    }
    for (int i=1;i<M+1;i++){
      ans=ans*i%MOD;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractCollection;
import java.util.stream.Stream;
import java.util.Collection;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.stream.Collectors;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int index = 0;
            LinkedList<Character> ans = new LinkedList<>();
            for (char c : s) {
                if (c == 'B') {
                    if (!ans.isEmpty()) {
                        ans.removeLast();
                    }
                } else {
                    ans.add(c);
                }
            }
            out.println(ans.stream().map(Object::toString).collect(Collectors.joining()));
        }

    }
}



Measured memory_bytes: 28756
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(){
    int n, i, s, first, now_place, c=0, next_place;
    int place[20];
    string status[20];
    bool flag = false;
    cin >> n;
    --n;
    if(n/2 % 2 != 0)    place[1] = n/2 + 1;
    else    place[1] = n/2;
    place[0] = 0;
    cout << "0\n";
    cin >> status[0];
    i = 1;
    int up = n;
    int down = 0;
    next_place = place[i];
    while(!flag){
        cout << place[i] << '\n';
        cin >> status[i];
        if(status[i] == status[i-1]){
            next_place += (up - place[i])/2;
            if(true){
                down = place[i];
                if(next_place % 2 != 0)  next_place++;
            }
        }
        else if(status[i] != status[i-1] && status[i] != "Vacant"){
            next_place -= (place[i] - down)/2;
            if(abs(place[i] - next_place) != 1){
                up = place[i];
                status[i] = status[i-1];
                if(next_place % 2 != 0) next_place++;
            }
        }
        else if(status[i] == "Vacant"){
            next_place = place[i];
        }
        ++i;
        if(i < 20)  place[i] = next_place;
        else flag = true;
    }

    return 0;
}

Measured memory_bytes: 852
unittest
{
	assert( [ "125" ].parse.expand.solve == 176 );
	assert( [ "9999999999" ].parse.expand.solve == 12656242944 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	return f( 0, s );
}

long f( long l, string rs )
{
	if( rs.length == 0 ) return l;
	
	auto t = 0L;
	for( auto i = 1L; i <= rs.length; i++ )
	{
		t += f( l + rs[ 0 .. i ].to!long, rs[ i .. $ ] );
	}
	return t;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 1e12;
const ll MOD = 1000000000 + 7;
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define mii map<int, int>
#define mci map<char, int>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i)
{
  return i % 2;
}

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b)
{
  return __gcd(a, b);
}
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f)
{
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f)
{
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x)
{
  cout << "debug: " << x << "\n";
}

template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void)
{
  int n;
  cin >> n;
  vi s(n);
  rep(i, n) cin >> s[i];
  sort(all(s));
  int ans = accumulate(all(s), 0);
  if (ans % 10 != 0)
  {
    cout << ans << endl;
    return;
  }
  int x = -1;
  int i = 0;
  while (x == -1 && i < n)
  {
    if (s[i] % 10 != 0)
      x = s[i];
    i++;
  }
  if (x == -1)
    cout << 0 << endl;
  else
    cout << ans - x << endl;
}

int main(void) { solve(); }


Measured memory_bytes: 3608
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

fn main() {
    let _: i32 = read();
    let s: String = read();
    let mut cnt = 0;
    let mut pre = 0;
    for c in s.as_bytes() {
        let c = *c as char;
        if c == '(' {
            cnt += 1;
        } else {
            if cnt == 0 {
                pre += 1;
            } else {
                cnt -= 1;
            }
        }
    }
    println!("{}{}{}",
             String::from_utf8(vec!['(' as u8;pre]).unwrap(),
             s,
             String::from_utf8(vec![')' as u8;cnt as usize]).unwrap());
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> data = new TreeMap<String, Integer>();


        for(int i=1; i<n+1; i++){
            String town = sc.next();
            int point = sc.nextInt();
            data.put(town+(200-point), i);
        }

        for(String nkey: data.keySet()){
            System.out.println(data.get(nkey));
        }

        sc.close();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

vector<pii_> op;
vector<int> g;
int tr[maxn<<2];
ll sum[maxn<<2];
void update(int id,int stl,int str,int pos)
{
    if(stl==str){
        tr[id]++;return ;
    }
    int mid = (stl+str)>>1;
    if(pos<=mid) update(id<<1,stl,mid,pos);
    else update(id<<1|1,mid+1,str,pos);
    tr[id] = tr[id<<1] + tr[id<<1|1];
}
int query(int id,int l,int r,int k)
{
    if(l==r){
        return l;
    }
    int mid = (l+r)>>1;
    if(tr[id<<1] >= k) return query(id<<1,l,mid,k);
    else return query(id<<1|1,mid+1,r,k-tr[id<<1]);
}
void change(int id,int l,int r,int pos,int k)
{
    if(l==r){
        sum[id] += k;
        return ;
    }
    int mid = (l+r)>>1;
    if(pos<=mid) change(id<<1,l,mid,pos,k);
    else change(id<<1|1,mid+1,r,pos,k);
    sum[id] = sum[id<<1] + sum[id<<1|1];
}
ll ask(int id,int stl,int str,int l,int r)
{
    if(stl==l && str==r) return sum[id];
    int mid = (stl+str)>>1;
    if(r<=mid) return ask(id<<1,stl,mid,l,r);
    else if(l>mid) return ask(id<<1|1,mid+1,str,l,r);
    else return ask(id<<1,stl,mid,l,mid) + ask(id<<1|1,mid+1,str,mid+1,r);
}
int main()
{
    fastio();
    int q,o,a,b; cin>>q;
    ll B = 0;
    while(q--){
        cin>>o;
        if(o==1){
            cin>>a>>b;
            op.pb(mp_(a,b));
            g.pb(a);
        }else{
            op.pb(mp_(-inf,-inf));
        }
    }
    sort(ALL(g));
    g.erase(unique(ALL(g)),g.end());
    int n = g.size();
    int cnt = 0;
    for(auto x:op){
        if(x.fi==-inf && x.se==-inf){
            int id = query(1,1,n,(cnt+1)/2) - 1;
            ll ans1 = g[id];
            ll k = (cnt+1)/2;
            ll ans2;
            {
                int L = 1,R = cnt,res=-1;
                while(L<=R){
                    int mid = (L+R)>>1;
                    if(query(1,1,n,mid)>id+1) R=mid-1,res=mid;
                    else L = mid+1;
                }
                if(res==-1) ans2 = ans1 * cnt - ask(1,1,n,1,id+1);
                else{
                    ll tmp = ask(1,1,n,1,id+1);
                    ans2 = ans1 * (res-1) - tmp + sum[1] - tmp - ans1 * (cnt-res+1);
                }
            }
            cout<<ans1<<" "<<ans2+B<<endl;
        }else{
            int pos = lower_bound(ALL(g),x.fi)-g.begin()+1;
            update(1,1,n,pos);
            change(1,1,n,pos,x.fi);
            cnt++;
            B += x.se;
        }
    }
    return 0;
}


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

int gcd(int a,int b){
	int v0=a,v1=b,v2=a%b;
	while(v2!=0){
		v0=v1;
		v1=v2;
		v2=v0%v1;
	}
	return v1;
}

int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i=0;i<N;++i){
		cin>>a[i];
		a[i]--;
	}
	long ans=0;
	for(int i=0;i<N;++i){
		ans+=a[i];
	}
	cout<<ans<<endl;
}


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

bool reachable(int idx, int n, const vector<pair<char, char>>& magic,
               string s) {
    for (int i = 0; i < magic.size(); i++) {
        if (s[idx] == magic[i].first) {
            if (magic[i].second == 'L') idx--;
            if (magic[i].second == 'R') idx++;
        }
        if (idx == n) return true;
    }
    return false;
}

int binary(int ok, int ng, int n, const vector<pair<char, char>>& magic,
           string s) {
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;
        if (reachable(mid, n, magic, s)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<pair<char, char>> magic(q);
    for (int i = 0; i < q; i++) {
        cin >> magic[i].first >> magic[i].second;
    }
    int dieLeft = binary(-1, n, -1, magic, s);
    int dieRight = binary(n, -1, n, magic, s);
    cout << n - min(n, dieLeft + 1 + n - dieRight) << endl;
}

Measured memory_bytes: 1344
import itertools
import math
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
ans=0
it=list(itertools.permutations(range(n),n))
for i in it:
    tmpx=l[i[0]][0]
    tmpy=l[i[0]][1]
    tmp=0
    for j in i[1:]:
        tmp+=math.sqrt((tmpx-l[j][0])**2+(tmpy-l[j][1])**2)
        tmpx=l[j][0]
        tmpy=l[j][1]
    ans+=tmp
print(ans/math.factorial(n))

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(vector<A> v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(q), b(q), c(q), d(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vector<int> a1(n + m - 1);
  for (int i = 1; i <= m - 1; i++) {
    a1[i] = 0;
  }
  for (int i = m - 1; i <= n + m - 2; i++) {
    a1[i] = 1;
  }
  int ans = 0;
  do {
    vector<int> v(1, 0);
    v.insert(v.end(), a1.begin(), a1.end());
    vector<int> w;
    int cnt = 0;
    for (auto vi : v) {
      if (vi == 0)
        cnt++;
      else
        w.emplace_back(cnt);
    }
    int sum = 0;
    for (int i = 0; i < q; i++) {
      if (w[b[i] - 1] - w[a[i] - 1] == c[i]) sum += d[i];
    }
    ans = max(ans, sum);
  } while (next_permutation(a1.begin(), a1.end()));
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3608
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	g := gcd(a, b)
	a /= g
	b /= g
	x, y := eucrid(a, b)
	fmt.Fprintln(writer, fmt.Sprintf("%d %d", x, y))
}
func gcd(m, n int) int {
	if n == 0 {
		return m
	}
	return gcd(n, m%n)
}
func eucrid(a, b int) (int, int) {
	if b == 0 {
		return 1, 0
	}
	x, y := eucrid(b, a%b)
	return y, x - a/b*y
}



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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, k;
	cin >> n >> k;
	int a[n + 7];
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll len[n + 7] = {0};
	ll x = a[1];
	ll cnt = 1;
	while (x != 1 && len[x] == 0) {
		len[x] = cnt;
		x = a[x];
		++cnt;
	}

	if (x == 1) len[1] = cnt;

	if (k < cnt) {
		x = 1;
		for (ll i = 0; i < k; ++i) {
			x = a[x];
		}
		cout << x;
	}
	else {
		k -= len[x];
		ll cnt = 1;
		ll v[n + 7] = {0};
		ll s = x;
		x = a[x];
		v[0] = s;
		while (x != s) {
			v[cnt] = x;
			x = a[x];
			++cnt;
		}

		int ans = (k % cnt);
		cout << v[ans];
	}

	return 0;
}


Measured memory_bytes: 7548
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	int u,v,w;
	vector<vector<pair<int, int>>> path(n);
	vector<int> has(n, -1);
	has[0] = 0;
	rep(i, n-1) { cin >> u >> v >> w;
		u--;
		v--;
		path[u].eb(v, w);
		path[v].eb(u, w);
	}
	deque<int> q;
	int at;
	
	
		q.pb(0);
		while (!q.empty()) {
			at = q.front();
			q.pop_front();

			repi(itr, path[at]) {
				if (has[itr->F] != -1) continue;
				if (itr->S % 2 == 0) {
					has[itr->F] = has[at];
				} else {
					has[itr->F] = (has[at] + 1) % 2;
				}
				q.push_back(itr->F);
			}
	
	}
	//clog << has << endl;
	rep(i, n) { cout << has[i] << endl; }
}

Measured memory_bytes: 9508
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBalance solver = new BBalance();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBalance {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] w = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
                sum += w[i];
            }

            int first = 0;
            int answer = Integer.MAX_VALUE;
            for (int i = 0; i < n - 1; i++) {
                first += w[i];
                sum -= w[i];
                answer = Math.min(answer, Math.abs(first - sum));
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
[H,W] = list(map(int,input().split()))
N = int(input())
a = list(map(int,input().split()))

flag=0  #left-->right

out = [[0]*W for i in range(H)]
# print(*out, sep="\n")

dammy=0
k=0
l=0
for i in range(N):
    # print('a:',a[i])
    for j in range(a[i]):
        out[k][l] = i+1
        if l==W-1:
            l=0
            k+=1
        else:
            l+=1
    # print('out:',out)


#reverse
for i in range(H):
    if i%2==1:
        #out[i] = reversed(out[i])
        out[i].reverse()
        print(*out[i])
    else:
        print(*out[i])


Measured memory_bytes: 73912
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll ans = 1;
    rep(i,N) {
        if (A[i]==0) {
            cout << 0 << ln;
            return 0;
        }
    }
    ll MAX = 1e18;
    rep(i,N) {
        if (A[i] >= MAX*2/ans) {
            cout << -1 << ln;
            return 0;
        }
        ans *= A[i];
    }

    if (ans > MAX) {
        cout << -1 << ln;
        return 0;
    }

    cout << ans << ln;
}


Measured memory_bytes: 3996
// Knapsack

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

#define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << "\t"; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) {solve();line1;}
	printf("Time : %fms\n", (1000*(double)clock())/CLOCKS_PER_SEC);
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n,wt;
	cin >> n >> wt;

	vi v(n);
	vi w(n);
	rep(i,0,n) cin >> w[i] >> v[i];

	// dp[i][j] : 
	// Max value that can be obtained after considering 
	// the first i points with combined weight at max j. 
	vector<vi> dp(n+1, vi(wt+1,0));

	// pvi(w);
	// pvi(v);

	rep(i,0,n+1){
		req(j,0,wt+1){
			// Ignore the current element.
			if(i > 0) dp[i][j] = max(dp[i-1][j], dp[i][j]);
			
			// Consider the current element.
			if(i > 0 && j >= w[i-1]) dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1], dp[i][j]);
		}
	}

	// for(auto v:dp) pvi(v);
	ret(dp[n][wt]);	
}


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

using namespace std;

int main(){
  int N;
  cin >>N;
  int count=0;
  for(int i=1;i<N+1;i++)
    {
      if(i%2==1)
	count++;
    }
  cout<<(double)count/N<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 50100
#define INF (1<<30)
#define ll long long
int wa[MAXN],wb[MAXN],wv[MAXN],wss[MAXN];
int cmp(int *r,int a,int b,int l){
    return r[a]==r[b] && r[a+l]==r[b+l];
}
int sa[MAXN],Rank[MAXN],height[MAXN];
void SA(int *r,int n,int m){
    int *x=wa,*y=wb;

    for(int i=0; i<m; ++i) wss[i]=0;
    for(int i=0; i<n; ++i) ++wss[x[i]=r[i]];
    for(int i=1; i<m; ++i) wss[i]+=wss[i-1];
    for(int i=n-1; i>=0; --i) sa[--wss[x[i]]]=i;

    int p=1;
    for(int j=1; p<n; j<<=1,m=p){
        p=0;
        for(int i=n-j; i<n; ++i) y[p++]=i;
        for(int i=0; i<n; ++i) if(sa[i]>=j) y[p++]=sa[i]-j;
        for(int i=0; i<n; ++i) wv[i]=x[y[i]];
        for(int i=0; i<m; ++i) wss[i]=0;
        for(int i=0; i<n; ++i) ++wss[wv[i]];
        for(int i=1; i<m; ++i) wss[i]+=wss[i-1];
        for(int i=n-1; i>=0; --i) sa[--wss
            [wv[i]]]=y[i];
        swap(x,y); x[sa[0]]=0; p=1;
        for(int i=1; i<n; ++i) x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++;
    }

    for(int i=1; i<n; ++i) Rank[sa[i]]=i;
    int k=0;
    for(int i=0; i<n-1; height[Rank[i++]]=k){
        if(k) --k;
        for(int j=sa[Rank[i]-1]; r[i+k]==r[j+k]; ++k);
    }
}
int check(int n,int mid)
{
    int i,s=1;
    int mi=-1,ma=-1;
    for(i=1;i<=n;i++)
    if(height[i]>=mid)
    {
        if(mi==-1)mi=min(sa[i],sa[i-1]),ma=max(sa[i],sa[i-1]);
        else mi=min(min(sa[i],sa[i-1]),mi),ma=max(max(sa[i],sa[i-1]),ma);
        if(ma-mi>=mid)return 1;
    }
    else mi=-1,ma=-1;
    return(0);
}

int a[MAXN];

int main(){
    int n;
    char ss[50100];
    scanf("%d",&n);
    scanf("%s",ss);
    int len=strlen(ss);
    for(int i=0; i<len; ++i){
        a[i]=(int)ss[i];
        //cout<<a[i]<<"    ";
    }
    a[len]=0;
    //cout<<endl<<endl;
    SA(a,len+1,300);
    
    int min=1,max=n;
    while(min<=max)
    {
     int mid=(min+max)/2;
     if(check(n,mid)) min=mid+1;
     else max=mid-1;
    }
    printf("%d\n",max);




    return 0;
}


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

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

	sort(s,s+n);

	for(int i=0;i<n;i++)cout<<s[i];
	cout<<endl;

	return 0;
}


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

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string s, left, right;
    cin>>s;
    left = "";
    right = s;
    int q;
    cin>>q;
    int swtch = 1;
    while(q--){
        int t;
        cin>>t;
        if (t==1) swtch = !swtch;
        else if (t==2) {
            int f;
            char c;
            cin>>f>>c;
            if (!swtch) f = 3-f;
            if (f==1) {
                left.push_back(c);
            }
            else {
                right.push_back(c);
            }
        }
    }
    reverse(left.begin(), left.end());
    if (swtch) cout<<left.append(right);
    else {
        string ans = left.append(right);
        reverse(ans.begin(), ans.end());
        cout<<ans;
    }
}


Measured memory_bytes: 1536
N = int(input())

C0 = C1 = C2 = C3 = 0

for i in range(N):
    S = input()
    if S == "AC":
        C0 += 1
    elif S == "WA":
        C1 += 1
    elif S == "TLE":
        C2 += 1
    elif S == "RE":
        C3 += 1

print("AC x "+str(C0))
print("WA x "+str(C1))
print("TLE x "+str(C2))
print("RE x "+str(C3))




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


long double p[3500];

long double dp[3500][3500];

int main(){
    int n;
    cin>>n;
    
    p[0]=0.000000000;
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    dp[1][1]=p[1];
    dp[1][0]=1-p[1];
    for(int i=2;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(j>i){
                dp[i][j]=0;
            }else{
                if(j==0){
                    dp[i][j]=dp[i-1][j]*(1-p[i]);
                }
                else{
                    dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
                }
            }
        }
    }
    long double ans=0;

    
  int start=int(floor((double)n/2))+1;
  //  cout<<start<<"\n";
    for(;start<=n;start++){
        ans+=dp[n][start];
    }
    cout<<setprecision(10)<<ans;
 

}

Measured memory_bytes: 166016
import java.util.*;
  
class Main {
    public static void main(String args[]) {
        Scanner sc =new Scanner(System.in);
        int n= sc.nextInt();
        int i;
        long s=1;
         
        for(i=2;i<=n;i++)
        s*=i;
         
        System.out.println(s);
         
    }
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  int cnt = 0;
  for(int i=0; i<N; i++) cin >> V.at(i);
  for(int i=0; i<N; i++) cin >> C.at(i);
  for(int i=0; i<N; i++){
    if(V.at(i)-C.at(i)>=0) {
      cnt = cnt + V.at(i)-C.at(i);
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
def m():
    N, M, X = map(int, input().split())
    A = [int(i) for i in input().split()]
    B = [0 for _ in range(N)]
    for a in A:
        B[a] = 1
    cost = min(sum(B[X:]), sum(B[:X]))
    return cost


print(m())


Measured memory_bytes: 3060
// B - ss
#include <bits/stdc++.h>
using namespace std;

bool check(string s){
	int n = s.size();
	if(n&1) return false;
	return s.substr(0, n/2) == s.substr(n/2);
}

int main(){
	string S; cin>>S;
	for(int n=S.size()-1; n>1; --n){
		if(check(S.substr(0, n))){
			cout<< n <<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<queue>
#include<vector>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n,k;
	cin>>n>>k;
	long long i,z;
	long long ans=0;
	for(i=1;i*k<=2*n;i++)
    {
        if(k%2==1&&i%2==1)
            continue;
        //cout<<i*k/2<<" ";
        z=(i+1)/2;
        //cout<<z<<" ";
        ans=z*z*z;
        //cout<<(z-1)*(z-2)+6*(z-1)+1<<endl;
    }
    i-=2;
    if(k%2==0)
    {
        z=(i+1)/2;
        ans+=z*z*z;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] X = new int[M];
        for(int i = 0; i < M; i++) {
            X[i] = sc.nextInt();
        }
        
        Arrays.sort(X);
        int[] Y = new int[M-1];
        for(int i = 0; i < M-1; i++) {
            Y[i] = X[i+1] - X[i];
            //System.out.println(Y[i] +"="+ X[i+1] +"-"+ X[i]);
        }
        Arrays.sort(Y);
        int ans = 0;
        for(int i = 0; i < (M-1)-(N-1); i++) {
            ans += Y[i];
        }
        System.out.println(ans);
    }
	
}


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

class Cmondai
{
    static void Main()
    {
        var N = Int64.Parse(Console.ReadLine());
        var nKeta = Math.Log10(N)+1;
        var max = (int)Math.Pow(3,9);
        var list = new List<string>();
        var ans = 0;
        for (int i=0;i<nKeta;++i)
        {
            for (int j=0;j<Math.Pow(3,i+1);++j) {

                var num = j;
                var keta = 0;
                var amari = 0;
                var suji = "";

                while (keta<i+1) {
                    amari = num % 3;
                    switch (amari)
                    {
                        case 0: suji += "3"; break;
                        case 1: suji += "5"; break;
                        case 2: suji += "7"; break;
                    }
                    num /= 3;
                    keta++;
                }
                if (Int64.Parse(suji) <= N && suji.Contains("3") && suji.Contains("5") && suji.Contains("7")) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 15292
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, m = na()
memo = [-1] * n
def dp(v):
    if memo[v] != -1:
        return memo[v]
    if G[v]:
        memo[v] = max(dp(i) for i in G[v]) + 1
    else:
        memo[v] = 0
    return memo[v]


G = [[] for _ in range(n)]
for _ in range(m):
    f, t = na()
    G[f-1].append(t-1)
print(max([dp(i) for i in range(n)]))


Measured memory_bytes: 119856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k, q;
  cin >> n >> k >> q;
  vl ans(n, k - q);
  rep(i, q) {
    ll a;
    cin >> a;
    ans[a - 1]++;
  }
  rep(i, n) cout << (ans[i] > 0 ? "Yes" : "No") << '\n';
}

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

using namespace std;

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

    if(k%2==0) {
    	printf("%d\n", (k/2)*(k/2));
    } else {
    	printf("%d\n", ((k-1)/2)*(((k-1)/2)+1));
    }


	return 0;

}

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

int main(void){
    int sum = 0,len;
    char num[200010]; 
    scanf("%s",num);

   len =  strlen(num);
  

    for(int i = 0;i < len; i++)
    {
        sum += num[i] - '0';
    }

   
    if(sum % 9 == 0)
    {
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }
    
    return 0;
    
}




Measured memory_bytes: 1808
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    
    string S;
    cin>>S;
    int len=0;
    for(int i=0;i<S.length();i++){
        if(S[i]=='A'){
            S.erase(0,i);
            break;
        }
    }
    reverse(S.begin(),S.end());
    for(int i=0;i<S.length();i++){
        if(S[i]=='Z'){
            S.erase(0,i);
            len=S.length();
            break;
        }
    }
    
    cout<<len<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	ll n; scanf("%lld", &n);
	ll ans = 0;
	FOR(i, 1, n+1){
		ll k = n/i;
		ans += i * k * (k+1) / 2;
	}
	printf("%lld\n", ans);
}


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

int main()
{
int X[ 5 ];
int B;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> X[ 0 ];
	cin >> X[ 1 ];
	cin >> X[ 2 ];

	sort( X, X + 3 );

	cout << X[2]*10+ X[0]+X[1]<< endl;

	return 0;
}






Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A, B, C, ab, ans;
    REP(i, X) {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    REP(i, Y) {
        ll tmp;
        cin >> tmp;
        B.push_back(tmp);
    }
    REP(i, Z) {
        ll tmp;
        cin >> tmp;
        C.push_back(tmp);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());


    REP(i, X) {
        REP(j,Y){
            ab.push_back(A[i]+B[j]);
        }
    }

    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());
    int N = ab.size();
    REP(i, min(N,K)) {
        REP(j,min(Z,K)){
            ans.push_back(ab[i]+C[j]);
        }
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    REP(i, K) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 43384
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
char s[300005];
int f1[300005], f2[300005];
int main(){
    int n;
    cin >> n;
    scanf("%s", s);
    for(int i = 1; i <= n; i++){
        f1[i] = f1[i-1]; f2[i] = f2[i-1];
        if(s[i-1] == 'W') f1[i]++;
        if(s[i-1] == 'E') f2[i]++;
    }
    int ans = INF;
    for(int i = 0; i < n; i++){
        int res = f1[i] + f2[n] - f2[i];
        if(s[i] == 'E') res--;
        ans = min(ans, res);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2944