akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())

s = [list(map(int, input().split()))[1:] for _ in range(M)]

p = list(map(int, input().split()))

res = 0

for i in range(2**N):
    sw = []
    for j in range(N):
        if (i>>j) & 1:
            sw.append(True)
        else:
            sw.append(False)
    for j in range(M):
        c = 0
        for y in s[j]:
            if sw[y-1]:
                c += 1
        if c%2 != p[j]:
            break
    else:
        res += 1

print(res)

Measured memory_bytes: 3064
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{

    static int n;
    static int m;
    static int ans;
    static int[] rate;
    static int var;
    static int ansmin;
    static int ansmax;
    static int[] w;
    static int[] ww;
    static boolean[] visit;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        ansmin = 0;
        ansmax = 0;
        rate = new int[9];
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (tmp >= 3200) {
                tmp = 3200;
            }
            rate[tmp/400]++;
        }
        for (int i = 0; i < 7; i++) {
            if (rate[i] != 0) {
                ansmin++;
                ansmax++;
            }
        }
        if (rate[7] == 0) {
            if (rate[8] != 0) {
                ansmin++;
                ansmax+=rate[8];
            }
        }else{
            ansmin++;
            ansmax++;
            if (rate[8] != 0) {
                ansmax+=(rate[8]);
            }
        }

        System.out.println(ansmin + " " + ansmax);

        sc.close();
    }

    public static void dfs(int placenow) {
        // if went all -> success! 
        // if not went all -> fail...
        
        /*
         dfs
         Go All Place that there is way to and not having been yet. 

         if island 1 is start point, dfs(1);
         if there is way to island 2 and island 3,
         - island 2 changes non-visited -> visited, and dfs(2).
         - island 3 changes non-visited -> visited, and dfs(3).
         

        */

        visit[placenow] = true;
        boolean success = true;
        for (int i = 0; i < n; i++) {
            if (visit[i] == false) { // not go all place
                success = false;
                break;
            }
        }
        if (success) {
            ans++;
            visit[placenow] = false;
            return;
        }

        for (int i = 0; i < m; i++) {
            if (w[i] == placenow && visit[ww[i]] == false ) {
                dfs(ww[i]);
            }else if(ww[i] == placenow && visit[w[i]] == false){
                dfs(w[i]);
            }else{
                continue;
            }
        }
        visit[placenow] = false;
        return;
    }

}



Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    ll n,k,s;
    cin>>n>>k>>s;
    V<ll> a(n);
    int j=0;
    while(k!=0){
        a[j]=s;
         j++;
         k--;
    }
    if(j!=n){
        for(int i=j;i<n;i++){
            if(s==1000000000)a[i]=1000000000-1;
            else a[i]=1000000000;
        }
    }
    for(int i=0;i<n;i++)cout<<a[i]<<" ";
        cout<<endl;
}

Measured memory_bytes: 2176
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b = inpl()
if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    if a-1 <= n-b:
        res = (b-a-1)//2 + a
    else:
        res = (n-(a+n-b+1))//2 + (n-b+1)
    print(res)

Measured memory_bytes: 63980
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

vec Start;

ll dfs(ll N, ll k, ll a){
    if(N==1) return a;
    if(k*k>N) return a+1;
    ll Count=0;
    while(true){
        if(N%k) break;
        Count++;
        N/=k;
    }
    ll X=upper_bound(ALL(Start),Count)-Start.begin();
    X--;
    return dfs(N,k+1,a+X);
}

int main(){
    ll N; cin>>N;
    ll x=2;
    rep(i,10){
        if(!i) Start.pb(0);
        else Start.pb(Start[i-1]+i);
    }
    cout<<dfs(N,2,0)<<endl;


}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

bool check(string ss) {
    if(ss.size() < 6) return false;
    bool is_num,is_c,is_C;
    is_num = is_c = is_C = false;
    rep(i,ss.size()) {
        char c = ss[i];
        if('0'<=c && c<='9') is_num = true;
        if('a'<=c && c<='z') is_c = true;
        if('A'<=c && c<='Z') is_C = true;
    }
    return is_num & is_c & is_C;
}

int main() {
    string ans[2] = {"VALID","INVALID"};
    string ss;cin>>ss;
    cout<<ans[!check(ss)]<<endl;

    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	if(n==m) cout << "Draw";
	else if(n==1 && m!=1) cout << "Alice";
	else if(n!=1 && m==1) cout << "Bob";
	else if(n>m) cout << "Alice";
	else cout << "Bob";
}


Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
int main()
{
    ll n, m;
    read(n), read(m);
    int l = 1, r = n;
    for (int i = m; i >= 1; --i)
    {
        if (i & 1)
        {
            printf("%lld %lld\n", l, l + i);
            ++l;
        }else
        {
            printf("%lld %lld\n", r - i, r);
            --r;
        }
    }
}

Measured memory_bytes: 3728
from collections import deque
n=int(input())
ls=[input() for i in range(n)]
answer=deque([])
for order in ls:
    if order[:6]=='insert':
        answer.appendleft(order[7:])
    elif order[6]==' ':
        try:answer.remove(order[7:])
        except:pass
    elif len(order) > 10:
        answer.popleft()
    elif len(order) > 6:
        answer.pop()
print(*answer)


Measured memory_bytes: 212432
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for ( int num = a; num <= b * a; num = num + a ) {
        if ( num % b == c ) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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;
}
//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN=1000001;//変更可
ll fac[MXN],inv[MXN],finv[MXN];

void COMinit(int M) {
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<MXN;i++){
        fac[i]=fac[i-1]*i%M;
        inv[i]=M-M/i*inv[M%i]%M;
        finv[i]=finv[i-1]*inv[i]%M;
    }
}

ll COMBI(int N,int K,int M){
    if(N<K){
        return 0;
    }
    if(N<0||K<0){
        return 0;
    }
    return fac[N]*finv[N-K]%M*finv[K]%M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,A,B,K;
    cin >> N >> A >> B >> K;
    COMinit(MOD2);
    ll ans=0;
    rep(a,N+1){
        ll b=(K-a*A)/B;
        if(a*A+b*B==K){
            ans+=COMBI(N,a,MOD2)*COMBI(N,b,MOD2);
            ans%=MOD2;
        }
    }
    cout << ans << endl;
}

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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAXX 1005
#define int long long int
#define INT_BITS 32
const int MOD = 1000000007;

int power(int a,int n)
{

    int res = 1;
    while(n)
    {
        if(n&1)
        {
            n--;
            res = ((res%MOD)*(a%MOD))%MOD;
        }
        else
        {
            n/=2;
            a = ((a%MOD)*(a%MOD))%MOD;
        }
    }
    return (res%MOD);
}


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

void solve()
{
    int n;
    cin >> n;
    if(n==0)
        cout<<1<<"\n";
    else cout<<0<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
    {
        solve();
    }

    return 0;
}
                                                                                                 


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000000007;
 
int main() {
  ll n;
  cin >> n;
  vector<ll>a(n);
  ll ans =0; 
  ll count = 0;
  ll mini=10e9;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]<0){
      count++;
      a[i]*=-1;
    }
    ans+=a[i];
    mini=min(mini,a[i]);
  }
  
  if(mini==0 || count%2==0) cout << ans << endl;
  else cout << ans-mini*2 << endl;
  
  
  return 0;
  
  
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;
 
class Main {
	int n;
	int m;
	boolean[] a;
	long[] step;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		m = sc.nextInt();
		a = new boolean[n+1];
		step = new long[n+1];
		for(int i = 0; i <= n;i++){
			a[i] = true;
			step[i] = 0;
		}
		for(int i=0;i<m;i++){
			a[sc.nextInt()] = false;
		}
		step[0] = 1;
	}
	void solve(){
		for(int i = 0;i<n;i++){
			for(int j = i + 1;j <= Math.min(i+2, n);j++){
				if(a[j]){
					step[j] += step[i];
					step[j] %= 1000000007;
				}
			}
		}
		System.out.println(step[n]);
	}
}


Measured memory_bytes: 49076
(N,K) = list(map(int,input().split()))
tree_list = []
for i in range(N):
    tree_list.append(int(input()))

tree_list.sort()
min = 1145141919810
for i in range(K-1,N):

    if min > (tree_list[i] - tree_list[i-K+1]):
        min = tree_list[i] - tree_list[i-K+1]

print(min)

Measured memory_bytes: 7384
N, X = map(int, input().split())
x = list(map(int, input().split()))
x_diff = [abs(x[i] - X) for i in range(N)]

def gcd(m, n):
  a = max(m, n)
  b = min(m, n)
  if a % b == 0:
    return b
  else:
    return gcd(b, a % b)

D = x_diff[0]
for i in range(1, N):
  D = gcd(D, x_diff[i])
print(D)

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
 
int main() {
  int K, N;
  cin >> K >> N;
  int temp, a1;
  int len = 0;
  cin >> temp;
  a1 = temp;
  for(int i = 1; i < N; i++) {
    int a;
    cin >> a;
    if(abs(a - temp) > len) {
      len = abs(a - temp);
    }
    temp = a;
  }
  if(K - temp + a1 > len) {
    cout << (temp - a1) << endl;
  } else {
    cout << K - len << endl;
  }
  return 0;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
   cin>>a[i];
  vector<bool> dp(k+1,false);
  for(int i=0;i<=k;i++)
  { if(dp[i]==false){
    for(int j=0;j<n;j++)
    {  
      if(i+a[j]<=k)
      dp[i+a[j]]=true;
     }
    
  }
 }
  
  
  
  
  
  
  if(dp[k]==false)
  cout<<"Second";
  else
  cout<<"First";
  
   
}

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

int main()
{
	string strT, strH;
	int nCount;
	int nT = 0, nH = 0;
	cin >> nCount;
	while (nCount--)
	{
		cin >> strT >> strH;
		if (strT > strH)
		{
			nT += 3;
		}
		else if (strT == strH)
		{
			nT += 1;
			nH += 1;
		}
		else
		{
			nH += 3;
		}
	}
	cout << nT << " " << nH << endl;

	//system("pause");
	return 0;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}


signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    cout << n << ":";
    for(int i=2; i*i<=n; i++){
        while(n % i == 0){
            cout << " " << i;
            n /= i;
        }
    }
    if(n != 1) cout << " " << n;
    cout << endl;

    return 0;
}


Measured memory_bytes: 3136
N=int(input())
A=list(map(int,input().split()))
import math
import collections
powers =[2**i for i in range(1,int(math.log(max(A),2)+2))]
table=collections.defaultdict(int)
table2=collections.defaultdict(set)
ans=0
for i in range(N):
  table[A[i]]+=1
for x in table:
  for y in reversed(powers):
    if y - x in table:
      table2[x].add(y-x)
        
        
        
table2 =list(table2.items())
table2.sort(key = lambda x:len(x[1]))

for x,y in table2:
  while(table[x]>0):
    table[x]-=1
    for z in y:
      if table[z]>0:
        ans+=1
        table[z]-=1
        break
print(ans)  
      



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

int main() {
       vector<int>V(3);
       for (int i=0 ; i<3 ; i++)
       cin >> V.at(i);
       cout << V.at(2) << ' ' << V.at(0) << ' ' << V.at(1) << endl;
   }



Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	x = readline() |> split |> parseMap
	k = div(sum(x),n)
	s1 = 0
	s2 = 0
	for i in 1:n
		s1 += (x[i]-k)^2
		s2 += (x[i]-k-1)^2
	end
	println(min(s1,s2))
end

main()

Measured memory_bytes: 166896
n,m=map(int,input().split())
k=[]
for i in range(m):
    k.append(list(map(int,input().split()))[1:])
p=list(map(int,input().split()))
a=0
for i in range(2**n):
    i=list(map(int,list(bin(i)[2:].zfill(n))))
    for j in range(m):
        x=p[j]
        for l in k[j]:
            x^=i[l-1]
        if x==1:break
    else:a+=1
print(a)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#define ll long long
using namespace std;
int main(void){
    // Your code here!
    ll n,k,cul;
    cin>>n>>k;
    k=min(k,n-1);
    ll h[n];
    ll c[n];
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }
    c[0]=0;
    for(ll i=1;i<k+1;i++){
    c[i]=abs(h[0]-h[i]);
    }
    for(ll i=k+1;i<n;i++){
        cul=c[i-k]+abs(h[i-k]-h[i]);
        for(ll j=1;j<k;j++){
            cul=min(cul,c[i-j]+abs(h[i-j]-h[i]));
        }
        c[i]=cul;
    }
    cout<<c[n-1];
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>
#include <algorithm>
#include<cmath>

using namespace std;

int main(){
    double x;
    vector<double> ans;
    cin >> x;
    for(double b=0; b<x; b++){
        if(b==1 || b==0){
            ans.push_back(1);
        }else{
            double p = b*b;
            while(p <= x){
                ans.push_back(p);
                p = p*b;
            }
            
        }
    }
    cout << *max_element(ans.begin(), ans.end());
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string s;
    long long int k;
    int i,cnt=1,flag=0,ans=0;
    cin >> s;
    cin >> k;
    if(s[0]==s[s.size()-1])flag=-1;
    for(i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1])cnt++;
        else{
            if(flag==-1) flag=cnt;
            else ans+=(cnt-cnt%2)/2;
            cnt=1;
        }
    }
    if(flag==-1) cout << (s.size()*k-s.size()%2*k%2)/2;
    else if(flag>0) cout << ans*k+((flag+cnt)-(flag+cnt)%2)*(k-1)/2+(flag-flag%2)/2+(cnt-cnt%2)/2;
    else {
        ans+=(cnt-cnt%2)/2;
        cout << ans*k;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	Vec2 operator/(T s) const { return Vec2(x/s, y/s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }
	T sqlength() const { return x*x + y*y; }
	double length() const { return sqrt(sqlength()); }
	bool operator<(const Vec2& rhs) const
	{
		if (x != rhs.x) return x < rhs.x;
		return y < rhs.y;
	}

	T x;
	T y;
};

int main()
{
	typedef Vec2<double> Vec;
	Vec P[3];
	cin >> P[0].x >> P[0].y;
	cin >> P[1].x >> P[1].y;

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> P[2].x >> P[2].y;

		Vec d1 = P[1] - P[0];
		Vec d2 = P[2] - P[0];
		Vec prj = d1 * d1.dot(d2) / d1.sqlength();
		Vec ans = (prj - d2) * 2 + P[2];
		printf("%.10f %.10f\n", ans.x, ans.y);
	}
	return 0;
}


Measured memory_bytes: 3188
program ddd
implicit none

integer(8) :: n, w, i, j
integer(8),allocatable,dimension(:) :: g, v
integer(8),allocatable,dimension(:,:) :: dp

read*, n, w

allocate(g(n))
allocate(v(n))
allocate(dp(0:w,0:n))
dp=0

do i=1,n
read*, g(i), v(i)
end do

do i=1, n
 do j=0, w
 if(j>=g(i)) then
 dp(j,i)=max(dp(j,i-1),dp(j-g(i),i-1)+v(i))
 end if
 dp(j,i)=max(dp(j,i),dp(j,i-1))
 end do
end do

write(*,'(i0)') dp(w,n)

end program

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==1){
		cout<<"Hello World";
		return 0;
	}
	else{
		int a,b;
		cin>>a;
		cin>>b;
		cout<<a+b;
		return 0;
	}
} 

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

int main() {
    string s;
    cin >> s;

    bool ans = true;
    for(char c = 'a'; c <= 'z'; c++) {
        int cnt = 0;
        for(int i = 0; i < s.size(); i++) {
            if(s[i] == c) cnt++;
        }
        if(cnt > 1) ans = false;
    }

    if(ans) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 3013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
ll dp[2][MAXN];
ll ans;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	string temps; cin >> temps;
	dp[0][0] = 1;
	FOR(i, 1, N)
	{
		FOR(j, 0, i + 1)
		{
			dp[i & 1][j] = 0;
		}
		char c = temps[i - 1];
		ll sum = 0;
		if (c == '<')
		{
			//it has to get bigger!
			FOR(j, 1, i + 1)
			{
				sum += dp[i & 1 ^ 1][j - 1]; sum %= INF;
				dp[i & 1][j] = sum;
			}
		}
		else
		{
			//it ahs to get <=
			FORD(j, i, 0)
			{
				sum += dp[i & 1 ^ 1][j]; sum %= INF;
				dp[i & 1][j] = sum;
			}
		}
	}
	FOR(i, 0, N) ans += dp[N & 1 ^ 1][i];
	ans %= INF;
	cout << ans << '\n';
	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	int n,k,x;
	int ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>x;
		int temp=min(x,abs(k-x));
		ans+=temp*2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        if(N%2==0){
            System.out.println((double)1/2);
        }
        if(N%2!=0){
            System.out.println((double)(N/2+1)/N);
        }
    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  int L[2010];
  for(int i=0;i<N;++i){
    cin >> L[i];
  }

  sort(L,L+N);

  int ans = 0;
  int c;
  for(int a=0;a<N-2;++a){
    c = a+1;
    for(int b=a+1;b<N-1;++b){
      if(c<=b){
        c=b+1;
      }
      while(c<N and L[a]+L[b]>L[c]){
        c += 1;
      }
      ans += c-b-1;
    }
  }
  cout << ans << endl;

  
}


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

int main(void) {
  int n, x;
  cin >> n >> x;
  int ans = 1;
  int distanceSum = 0;
  rep (i, n) {
    int h;
    cin >> h;
    distanceSum += h;
    if (distanceSum <= x) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def foo
  while input = gets
    x1, y1, x2, y2, x3, y3, x4, y4 = input.split(',').map(&:to_f)
    v31 = [x3-x1, y3-y1]
    v21 = [x2-x1, y2-y1]
    cp1 = v31[0] * v21[1] - v31[1] * v21[0]

    v42 = [x4-x2, y4-y2]
    v32 = [x3-x2, y3-y2]
    cp2 = v42[0] * v32[1] - v42[1] * v32[0]

    v13 = [x1-x3, y1-y3]
    v43 = [x4-x3, y4-y3]
    cp3 = v13[0] * v43[1] - v13[1] * v43[0]

    v24 = [x2-x4, y2-y4]
    v14 = [x1-x4, y1-y4]
    cp4 = v24[0] * v14[1] - v24[1] * v14[0]

    cps = [cp1, cp2, cp3, cp4]
    puts cps.all? { |i| i < 0 } || cps.all? { |i| i > 0 } ? 'YES' : 'NO'
  end
end

foo

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

namespace abc100a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var a = int.Parse(s[0]); var b = int.Parse(s[1]);
            if(a<=8 && b<=8)
                Console.WriteLine("Yay!");
            else
                Console.WriteLine(":(");
        }
    }
}


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

int main(){
    int a, b, w, tmp, ans=0;
    cin >> a >> b >> w;
    int c = a, d = b;
    if(a<b){
        tmp=a;
        a=b;
        b=tmp;
    }
    while(a%b){
        tmp = a;
        a = b;
        b = tmp%b;
    }
    ans = c*d/b/b;
    cout << ans*w << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;

vector<vector<ll>> comb(int n){
  vector<vector<ll>> v(n+1, vector<ll>(n+1,0));
  for (int i=0;i< n+1;++i){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j=1;j< n+1;++j){
    for (int k=1;k< j;++k){
      v[j][k] = v[j-1][k-1]+ v[j-1][k];
    }
  }
  return v;
}

int main() {
  int n,p;cin >> n>>p;
  std::vector<int> a(n);
  for(int i=0;i<n;++i){
    cin >> a[i];
    a[i] = a[i]%2;
  }
  ll cnt1 = count(all(a),1);
  auto comb1 = comb(cnt1);
  ll cnt0 = count(all(a),0);
  ll cnt1_p = 0;
  for(int i=p;i<=cnt1;++i)if(i%2==p) cnt1_p += comb1[cnt1][i];
  ll out = cnt1_p * (ll)pow(2LL,cnt0);

  cout << out << endl;
  return 0;
}


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

int main() {
    int n;
    scanf("%d ", &n);
    for (int i = 0; i < n; i++) {
        string input;
        getline(cin, input);
        while (input.find("Hoshino") != string::npos) {
            input.replace(input.find("Hoshino"), 7, "Hoshina");
        }
        cout << input << endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
//
//        int a = 11;
//        int b = 5;
//        int c = 5;
        Scanner cin = new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        int c = cin.nextInt();

        int res = 0;
        int cost1 = Math.abs(b-a)+Math.abs(c-b);
        res = cost1;
        int cost2 = Math.abs(c-a)+Math.abs(b-c);
        if (cost2<res) res =cost2;
        int cost3 = Math.abs(c-b)+Math.abs(a-c);
        if (cost3<res) res = cost3;
        int cost4 = Math.abs(a-b)+Math.abs(c-a);
        if (cost4<res) res = cost4;
        int cost5 = Math.abs(a-c)+Math.abs(b-a);
        if (cost5<res) res = cost5;
        int cost6 = Math.abs(b-c)+Math.abs(a-b);
        if (cost6<res) res = cost6;

        System.out.println(res);

    }

}

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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int t[n], x[n], y[n];
    rep(i, n) cin >> t[i] >> x[i] >> y[i];
    int T = 0;
    int X = 0;
    int Y = 0;
    rep(i, n){
        int dt = t[i] - T;
        int dx = abs(X - x[i]);
        int dy = abs(Y - y[i]);
        if (dt >= dx + dy){
            if ((dt - (dx + dy)) % 2 != 0){
                cout << "No" << endl;
                return 0;
            }
        }else{
            cout << "No" << endl;
            return 0;
        }   
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std; 
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 1000005
long long int MOD=1e9+7;
long long int INF=1e18;
                                                 /*:-]*/
long long  int modulo(long long int a,long long  int b,long long  int n)
{
    long long int  x=1, y=a; 
    while (b > 0) 
    {
        if (b%2 == 1) 
        {
              x = (x*y) % n;
        }
        y = (y*y) % n; 
        
        b /= 2;
    }
    return x % n;
}



int main()
{
         ios_base::sync_with_stdio(false); 
         cin.tie(NULL);
         cout.tie(NULL);
         long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;
         string s;
    cin>>n>>k;
    maxi=n;
 long long int A[n];
    long long int B[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>B[i];
    }
    sort(A,A+n);
    sort(B,B+n);
    low=0;
    high=1e12;
    ans=high;
    while(low<=high)
    {
        mid=(low+high)/2;
        j=0;
        for(i=0;i<n;i++)
        {
            l=A[i]*B[n-1-i];
            if(l>=mid)
            {
                p=mid/B[n-1-i];
                j+=A[i]-p;
                
            }
        }
        if(j<=k)
        {
            ans=min(ans,mid);
            high=mid-1;
        }
        else
            low=mid+1;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3328
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let alphabet = 26;
    let mut x = vec![0; alphabet];
    let mut y = vec![0; alphabet];

    x[(s[0] as u8 - 'a' as u8) as usize] = 1;
    for i in 1..n {
        y[(s[i] as u8 - 'a' as u8) as usize] += 1;
    }

    let mut maximum = 0;
    for i in 1..n {
        let mut count = 0;
        for j in 0..alphabet {
            if x[j] > 0 && y[j] > 0 {
                count += 1;
            }
        }
        if maximum < count {
            maximum = count;
        }
        x[(s[i] as u8 - 'a' as u8) as usize] += 1;
        y[(s[i] as u8 - 'a' as u8) as usize] -= 1;
    }

    println!("{}", maximum);
}

Measured memory_bytes: 2144
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
g=s[1::2]
k=s[0::2]
if "L" in k or "R" in g:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x,a,b;

int main(){
	cin>>x>>a>>b;
	if(a>=b) cout<<"delicious"<<endl;
	else if(b-a<=x) cout<<"safe"<<endl;
	else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: i64 = input();
    let a_vec = input_vec();
    let mut sum_vec: Vec<i64> = Vec::new();
    let mut sub_vec: Vec<i64> = Vec::new();
    for i in 0..n {
        let sum = a_vec[i as usize] + i + 1;
        sum_vec.push(sum);

        let sub = i + 1 - a_vec[i as usize];
        sub_vec.push(sub);
        // let e = sub_map.entry(sub).or_insert(0);
        // *e += 1;
    }
    // println!("{:?}", sum_vec);
    // println!("{:?}", sub_vec);

    let mut sub_map: HashMap<i64, i64> = HashMap::new();
    for sub in &sub_vec {
        let n = sub_map.entry(*sub).or_insert(0);
        *n += 1;
    }

    // println!("{:?}", sub_map);

    let mut ans = 0;
    let n = sub_map.entry(sub_vec[0]).or_insert(0);
    *n -= 1;
    for i in 0..sum_vec.len() {
        if sub_map.contains_key(&sum_vec[i]) {
            ans += sub_map.get(&sum_vec[i]).unwrap();
        }
        let n = sub_map.entry(sub_vec[i]).or_insert(0);
        if *n > 0 {
           *n -= 1;
        }
        // println!("{:?}", sub_map);
    }
    println!("{}", ans);
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int m,d;cin>>m>>d;
    int ans=0;
    for(int j=4;j<=m;j++){
        for (int i=22;i<=d;i++) {
            if(i/10<2||i%10<2){
                continue;
            }
            if((i/10)*(i%10)==j){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = ["SS","SW","WS","WW"]
for a in ans:
    for i in range(2,n+1):
        if s[i-1] == "o":
            if a[-2:] == "SS" or a[-2:] == "WW":
                a += "S"
            else:
                a += "W"
        if s[i-1] == "x":
            if a[-2:] == "SW" or a[-2:] == "WS":
                a += "S"
            else:
                a += "W"
    else:
        if a[n] == a[0]:
            if (((s[0],a[0]) in (("o","S"),("x","W")) and a[1] == a[n-1])
                or ((s[0],a[0]) in (("x","S"),("o","W")) and a[1] != a[n-1])):
                print(a[:n])
                exit()
print(-1)


Measured memory_bytes: 3572
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[300001];
    REP(i, 3*n){
        cin >> a[i];
    }

    sort(a, a+3*n);

    ll ans = 0;

    for(int i = 3*n - 2; i >= 3*n - 2*n; i-=2){
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main() {

    int X, N;
    cin >> X >> N;
    vector<int> p(N);

    rep(i, N) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());
    int j = 0;

    int min_d = 1e9;
    vector<int> D(300);
    for(int i=-150; i<150; i++) {
        if (j<N && i == p[j]) {
            j++;
            D[i+150] = 1e9;
        }
        else {
            D[i+150] = abs(i - X);
            min_d = min(D[i+150], min_d);
        }
    }

    rep(i, 300) {
        if (D[i] == min_d) {
            cout << i-150 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

double max1;
double a[30],b[30],l[30];

double distance(double x1,double y1,double z1,double x2,double y2,double z2){
	return  (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1);
}

void solve(int *flag,int num){
	double sum=0;
//	for(int i=0;i<num;i++){
//		cout<<flag[i]<<" ";
//	}
//	cout<<endl;

	for(int i=0;i<num;i++){
		if(flag[i]==0)continue;
		else{
			for(int j=i+1;j<num;j++){
				if(flag[j]==1){
					sum += distance(a[i],b[i],l[i],a[j],b[j],l[j]);
				}
			}
		}
	}

//	cout<<"sum="<<sum<<endl;

	if(max1<=sum)max1=sum;
}




void makePattern(int *flag,int cnt,int obj,int num,int objNum){

	if(cnt==obj){
		solve(flag,obj);
	}
	else{
		flag[cnt]=0;
		makePattern(flag,cnt+1,obj,num,objNum);
		if(num<objNum){
			flag[cnt]=1;
			makePattern(flag,cnt+1,obj,num+1,objNum);
		}
	}
}

int main(){
	int flag[30];

	int n,m;

	while(cin>>n>>m){
		if(n==0 && m==0)break;
		max1=0;

		for(int i=0;i<30;i++)flag[i]=0;


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

		makePattern(flag,0,n,0,m);
		printf("%.10f\n",max1);
	}

	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define int long long
const int INF=1e18;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,W,val=0;
    cin>>n>>W;
    int dp[W+1];
    rep(i,0,W+1){
        dp[i]=0;
    }
    vector<int>w(n),v(n);
    rep(i,0,n){
        cin>>w[i]>>v[i];
        for(int j=W-w[i];j>=0;j--){
            dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    rep(i,0,W+1){
        val=max(val,dp[i]);
    }
    cout<<val;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
int vis[N];
vector<vector<int>>adj(N);


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
void dfs(int x){
    vis[x]=1;
    for(auto i:adj[x]){
        if(!vis[i])
            dfs(i);
    }
}


void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n<=1)
            cout<<0<<endl;
        else{
            int no0=power(9,n);
            int no09=power(8,n);
            int total=power(10,n);
            total=(total-2*no0+no09)%mod;
            
            if(total<0)
                cout<<(total+mod)%mod<<endl;
            else
                cout<<total<<endl;
        }        
    }
    return 0;
}

Measured memory_bytes: 7836
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
d=[0]*(n+1)
for i in range(1,n+1):d[i]=d[i-1]+a[i-1]
m=int(input())
b,c=[list(map(int,input().split())) for _ in [0,0]]
for i in range(m):
    p=bisect.bisect_right(a,b[i])
    print(['Yes','No'][d[p]<c[i]])

Measured memory_bytes: 79556
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD  = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}
using namespace atcoder;
#endif

int main(){
	init();

	/*double R;cin>>R;
	cout <<(acos(-1)*R*2);*/

	int N;cin>>N;
	intv A(N-1);cin>>A;
	intv ans(N);for(int i=0;i<N;i++)ans[i]=0;
	for(int i : A){
		ans[i-1]++;
	}
	outln(ans);
}

Measured memory_bytes: 4784
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n, tmp, ans = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());
    int tar = (a[0] + 1) / 2;
    int diff = a[0] - tar;
    for(int n : a){
        if(abs(tar - n) < diff){
            diff = abs(tar - n);
            ans = n;
        }
    }
    cout << a[0] << " " << ans << endl;
}


Measured memory_bytes: 640
def common(x, y):
    ans = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            ans += 1
            
    return ans

s = input()
t = input()

m = -1

for i in range(len(s)-len(t)+1):
    r = s[i:i+len(t)]
    m = max(m, common(r, t))
    
print(len(t)-m)

Measured memory_bytes: 9108
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _Ty> static _Ty tp_abs(const _Ty& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _Ty> static _Ty tp_min(_Ty a, _Ty b) {
	return a < b ? a : b;
}
template <class _Ty> static _Ty tp_max(_Ty a, _Ty b) {
	return a > b ? a : b;
}
template<class T> static void get1int(T& a) {
	const char* fmt = " %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class T> static void get2int(T& a, T& b) {
	const char* fmt = " %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class T> static void get3int(T& a, T& b, T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static const int EduDp_INF = 1100000000;
static const int MOD_NUM = 1000000007;
static void I_Coins();

#if 1
int main()
{
	I_Coins();
	fflush(stdout);
	return 0;
}
#endif

static void I_Coins()
{
	const int IMAX = 2999;
	int N;
	get1int(N);

	auto pi = new double[N];
	for (int i = 0; i < N; i++) {
		scanf(" %lf", &pi[i]);
	}

	int revMax = N / 2;
	auto dp = new double[N + 1][IMAX + 1];
	memset(dp, 0, sizeof(double) * (N + 1) * (IMAX + 1));
	dp[0][0] = 1.0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i + 1][j + 1] += dp[i][j] * pi[i];
			dp[i + 1][j] += dp[i][j] * (1 - pi[i]);
		}
	}

	double ans = 0.0;
	for (int j = revMax + 1; j <= N; j++) {
		ans += dp[N][j];
	}
	printf("%.10lf\n", ans);

	delete[] dp;
	delete[] pi;
}


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

int main(){
	int n,val;
	while(cin >> n){
		val = 0;
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
						if(i+j+k+l == n){
							val += 1;
						}
					}
				}
			}
		}
		cout << val << endl;
	}
	return 0;
}
	

Measured memory_bytes: 1160
S = input()

S1 = S[0:2]
S2 = S[2:4]

def is_MM(s):
  if 1 <= int(s) <= 12:
    return(True)
  else:
    return(False)

def is_YY(s):
  if 0 <= int(s) <= 99:
    return(True)
  else:
    return(False)

if (not is_MM(S1) and not is_MM(S2)) or (not is_YY(S1) and not is_YY(S2)):
  print("NA")
elif is_YY(S1) and is_MM(S1) and is_YY(S2) and is_MM(S2):
  print("AMBIGUOUS")
elif is_YY(S1) and is_MM(S2):
  print("YYMM")
elif is_YY(S2) and is_MM(S1):
  print("MMYY")



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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


int main(){
    ll c;
    cin >> c;
    cout << c*c*c << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
//#include<vector>
#include<algorithm>


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;
const int MAXN=1005;
char str[100];


int main(){
	#ifdef L_JUDGE
		freopen("in.txt","r",stdin);
//		freopen("out.txt","w",stdout);
	#endif
    scanf("%s",str);
    str[5]=str[13]=' ';
    printf("%s\n",str);

	#ifdef L_JUDGE
		fclose(stdin);
		fclose(stdout);
//		system("out.txt");
	#endif

	return 0;
}


Measured memory_bytes: 384