akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int h,w,k;
int ans=0;
int a[10][10],b[10][10],cnt[10][10];
void dfs(int num,int goal,int x){
   // cout<<"***"<<goal<<" "<<x<<" "<<endl;
    if(x>h+w)return ;
    if(num==goal){
        int sum=0;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                sum+=b[i][j];
            }
        }
        if(sum==k)ans++;
        return ;
    }
    if(x>=h){
        for(int i=0;i<h;++i){
            cnt[i][x-h]++;
            b[i][x-h]=0;
        }
        dfs(num+1,goal,x+1);
        for(int i=0;i<h;++i){
            cnt[i][x-h]--;
            if(!cnt[i][x-h])b[i][x-h]=a[i][x-h];
        }
        dfs(num,goal,x+1);
    }
    else{
        for(int i=0;i<w;++i){
             cnt[x][i]++;
             b[x][i]=0;
         }
         dfs(num+1,goal,x+1);
         for(int i=0;i<w;++i){
             cnt[x][i]--;
             if(!cnt[x][i])b[x][i]=a[x][i];
         }
         dfs(num,goal,x+1);
    }
}
int main(){
    scanf("%d%d%d",&h,&w,&k);
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            char x;
            scanf(" %c",&x);
            if(x=='.')a[i][j]=b[i][j]=0;
            else a[i][j]=b[i][j]=1;
        }
    }
    for(int k=0;k<=h+w;++k){
        for(int i=0;i<h;++i){
             for(int j=0;j<w;++j){
                b[i][j]=a[i][j];
             }
         }
        memset(cnt,0,sizeof(cnt));
        dfs(0,k,0);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3816
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<int,int>
int N;
LL A[100010];
LL res;
int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		std::cin >> A[i];
		res += std::abs(A[i] - A[i - 1]);
	}
	res += std::abs(A[N]);
	for (int i = 1; i <= N; i++) {
		LL tmp = res;
		tmp -= std::abs(A[i] - A[i - 1]) + std::abs(A[i + 1] - A[i]);
		tmp += std::abs(A[i + 1] - A[i - 1]);
		std::cout << tmp << std::endl;
	}
	return 0;
}

Measured memory_bytes: 2048
import heapq
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(n):
    A[i] = -A[i]
heapq.heapify(A)
for i in range(m):
    hoge = -heapq.heappop(A)
    hoge = hoge // 2
    heapq.heappush(A, -hoge)
print(-sum(A))


Measured memory_bytes: 14180
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int sh, sm, ss, eh, em, es;
  rep(i, 3){
    scanf("%d%d%d%d%d%d", &sh, &sm, &ss, &eh, &em, &es);
    int time = (eh*3600 + em*60 + es) -  (sh*3600 + sm * 60 + ss);

    printf("%d %d %d\n", time/3600, (time%3600)/60, (time%60));
  }
  return 0;
}

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

int main()
{
	string S, T;

	cin >> S;
	cin >> T;

	int count = 0;
	for (int i = 0; i < 3; i++)
	{
		if (S[i] == T[i])
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n, k, q;
    cin >> n >> k >> q;
    vector<LL> cnt(n);
    for(LL i = 0; i < q; ++i){
        LL a;
        cin >> a;
        --a;
        cnt[a] += 1;
    }
    for(LL i = 0; i < n; ++i){
        if(cnt[i] - q + k > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;

int a[3003];

int main()
{
  int n,sum=0;
  cin>>n;
  for (int i=0;i<n;i++)
  {
  	cin>>a[i];
  	sum+=a[i];
  }
  cout<<sum-n<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[][] matrix = new int[n][m];
			int[] vector = new int[m];
			int[] product = new int[n];

			IntStream.range(0, n).forEachOrdered(i -> {
				IntStream.range(0, m).forEachOrdered(j -> matrix[i][j] = sc.nextInt());
			});
			IntStream.range(0, m).forEachOrdered(i -> vector[i] = sc.nextInt());

			for (int i = 0; i < matrix.length; i++) {
				for (int j = 0; j < matrix[i].length; j++) {
					product[i] += matrix[i][j] * vector[j];
				}
			}
			IntStream.range(0, n).forEachOrdered(i -> System.out.println(product[i]));
		}
	}
}


Measured memory_bytes: 44076
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int i, N;
    double T, A;
    double H[1200];
    double ans_h = 100000;
    int ans;

    cin >> N >> T >> A ;

    for (i=0; i<N; i++){
        cin >> H[i];
        }
    
     for (i=0; i<N; i++){
        if (abs(A-(T-H[i]*0.006)) < ans_h){
            ans_h = abs(A-(T-H[i]*0.006));
            ans = i;
            }
        }
    

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


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

using namespace std;

int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if(a < b && b < c){
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef pair<ll,ll> P;
#define se second
#define fi first
struct PP{ll fi;ll se;ll th;};
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[0].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    int n;cin>>n;
    string s;cin>>s;
    rep(i,s.size()){
        s[i]='A'+(s[i]-'A'+n)%26;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

ll modpow(ll a, ll n){
	ll res = 1;
	while(n > 0){
		if (n & 1) res = res * a %MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

ll dp[801][2001];

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

	for (int i = 3; i <= s; i++){
		dp[1][i] = 1;
	}
	for (int i = 1; i < 800; i++){
		for (int j = 0; j <= s; j++){
			if (dp[i][j] != 0){
				for (int k = 3; j+k <= s; k++){
					dp[i+1][j+k] += dp[i][j];
					dp[i+1][j+k] %= MOD;
				}
			}
		}
	}
	ll ans = 0; 
	for (int i = 1; i < 800; i++){
		ans += dp[i][s];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 10920
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	a := make([]int, n)
	oddSum := make([]int, n)
	evenSum := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if i == 0 {
			oddSum[i] = 0
			evenSum[i] = a[i]
		} else if i%2 == 0 {
			oddSum[i] = oddSum[i-1]
			evenSum[i] = evenSum[i-1] + a[i]
		} else {
			oddSum[i] = oddSum[i-1] + a[i]
			evenSum[i] = evenSum[i-1]
		}
	}

	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Print(" ")
		}
		var b int
		if i == 0 {
			b = evenSum[n-1] - oddSum[n-1]
		} else if i%2 == 0 {
			b = (evenSum[n-1] - evenSum[i-1]) + (oddSum[i-1]) - ((oddSum[n-1] - oddSum[i-1]) + evenSum[i-1])
		} else {
			b = (oddSum[n-1] - oddSum[i-1]) + (evenSum[i-1]) - ((evenSum[n-1] - evenSum[i-1]) + oddSum[i-1])
		}
		fmt.Print(b)
	}

	fmt.Println("")
}


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

h_sort = sorted(h)

if k>=len(h):
  print(0)
else:
  teki = len(h) - k
  
  h_teki = h_sort[:teki]
  print(sum(h_teki))

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	cin >> n;
	if(n==1) {puts("1.000"); return 0;}
	cout << ((n+1)/2) /(double)n << endl;
}


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

int main() {
  int R;
  cin >> R;
  if(R < 1200){
    cout << "ABC" <<endl;
  }
  else if(R < 2800){
    cout << "ARC" <<endl;
  }
  else {
    cout << "AGC" <<endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    if((b - a) % 2 == 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 	    unsigned long long
#define ll 	    long long
#define N	    100005
#define M 	    1000000007
#define pb 	    push_back
#define p_q 	    priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 	    make_pair
#define lb 	    lower_bound
#define ub	    upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define re 		resize


signed main(void)
{ios
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
	{
		int n,W;
		cin>>n>>W;
		int v[n+1];
		int w[n+1];
		rep(i,1,n+1)
		{
			cin>>w[i]>>v[i];
		}
		int dp[n+1][W+1];
		rep(i,0,W+1) dp[0][i]=0;
		rep(i,1,n+1)
		{
			rep(j,0,W+1)
			{
				if(w[i]<=j)
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
				else
					dp[i][j]=dp[i-1][j];
			}
		}
		cout<<dp[n][W];
	}
	
}

Measured memory_bytes: 79232
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;

    int reps = min(count(ALL(S), '0'), count(ALL(S), '1'));
    cout << (reps * 2) << endl;
    return 0;
};


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

signed main(){
    int n;
    cin>>n;
    int arr[n],i;
    for(i=0;i<n;i++)
    cin>>arr[i];
    int zero=0;
    for(i=0;i<n;i++){
        if(arr[i]==0)
        zero++;
    }
    if(zero>0)
    cout<<"0";
    else{
        int mul=1,temp=1;
        for(i=0;i<n;i++){
            if(arr[i]<=1000000000000000000/mul)
            mul=mul*arr[i];
            else{
                temp=0;
                break;
            }
        }
        if(temp)
        cout<<mul;
        else
        cout<<"-1";
    }
}

Measured memory_bytes: 4316
N = int(input())
mod = 10**9 + 7
if N == 1:
    print(0)
elif N == 2:
    print(2)
else:
    a = 1
    b = 1
    c = 1
    for i in range(N):
        a *= 10
        b *= 9
        c *= 8
        a %= mod
        b %= mod
        c %= mod
    print((a-2*b+c)%mod)

Measured memory_bytes: 9184
# -*- coding: utf-8 -*-
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    c=Counter(A)
    m=c.most_common()[::-1]
    ans=0
    for _,n in m[:-K]:
        ans+=n
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 99544
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
a = l()
num1 = 0
num2 = 0
num3 = 0
for i in range(N):
    if a[i]%4 == 0:
        num3 += 1
    elif a[i]%2 == 0:
        num2 += 1
    else:
        num1 += 1
if num3+1 < num1:
    print('No')
elif num3+1 == num1 and num2 != 0:
    print('No')
else:
    print('Yes')

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

int main(){
    int n;
    cin>>n;

    int count = 0;

    for(int i=1;i<=9;i++){
      for(int j=1;j<=9;j++){
        if(i*j == n){
          count++;
          break;
        }
      }
    }

    if(count >= 1){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0){
            if(a%3&&a%5){
                cout << "DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}


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

#define int long long 
#define pb push_back
#define ff first
#define ss second


int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;
    
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << " ";
    return out;
}

istream& operator>> (istream& in, pii& b) {
    in >> b.first >> b.second;
    return in;
}

ostream& operator<< (ostream& out, const pii& b) {
    out << "{" << b.first << ", " << b.second << "}";
    return out;
}

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
#else
    #define dbg(x) 57
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
#endif

const ld PI = acos(-1);

#define time clock() / (double) CLOCKS_PER_SEC

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

#define no() {cout << "Impossible\n"; return 0;}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] >= n) {
            no();
        }
    }
    if (n == 2) {
        if (a[0] == 1 && a[1] == 1) {
            cout << "Possible\n";
            return 0;
        }
        no();
    }
    vector<int> cnt(n, 0);
    int d = 0;
    for (int i = 0; i < n; i++) {
        cnt[a[i]]++;
        chkmax(d, a[i]);
    }
    if (d % 2 == 0 && cnt[d / 2] != 1) {
        no();
    }
    if (d % 2 == 1 && cnt[(d + 1) / 2] != 2) {
        no();
    }
    for (int i = d / 2 + 1; i <= d; i++) {
        if (cnt[i] < 2) {
            no();
        }
    }
    for (int i = 1; i < (d + 1) / 2; i++) {
        if (cnt[i]) {
            no();
        }
    }
    cout << "Possible\n";
}
/*

*/

Measured memory_bytes: 3632
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = 1024

def main(N, V, W, v, L):
    def precompute(N, V, W):
        U = 10**5 + 10
        dp = np.zeros((A, U), np.int32)
        for v in range(1, min(A, N + 1)):
            p = v // 2
            dp[v] = dp[p]
            dp[v, W[v]:] = np.maximum(dp[v, W[v]:], dp[p, :-W[v]] + V[v])
            for i in range(1, U):
                dp[v][i] = max(dp[v][i], dp[v][i - 1])
        return dp

    dp = precompute(N, V, W)
    values = np.empty(A, np.int32)
    weights = np.empty(A, np.int32)

    def solve(i, lim, values, weights, dp):
        if i < A:
            return dp[i][lim]
        values[0] = 0
        weights[0] = 0
        p = 0
        while i >= A:
            for j in range(1 << p):
                values[j + (1 << p)] = values[j] + V[i]
                weights[j + (1 << p)] = weights[j] + W[i]
            p += 1
            i >>= 1
        best = 0
        for n in range(1 << p):
            if weights[n] > lim:
                continue
            x = dp[i][lim - weights[n]] + values[n]
            best = max(best, x)
        return best

    Q = len(v)
    for i in range(Q):
        x = solve(v[i], L[i], values, weights, dp)
        print(x)

        
if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i4,i4[:],i4[:],i4[:],i4[:])')(main)
    cc.compile()
    exit()

from my_module import main

N = int(readline())
stdin = np.array(read().split(), np.int32)
V = np.zeros(N + 1, np.int32)
W = np.zeros(N + 1, np.int32)
V[1:] = stdin[:N + N:2]
W[1:] = stdin[1:N + N:2]
query = stdin[N + N + 1:]
v, L = query[::2].copy(), query[1::2].copy()

main(N, V, W, v, L)


Measured memory_bytes: 435040
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, mod;
vector <int> E[100010];
ll dp[100010];
ll ans[100010];

void pdfs(int x, int fa) {
	dp[x] = 1;
	for(int e : E[x]) if(e != fa) {
		pdfs(e, x);
		dp[x] = dp[x] * dp[e] % mod;
	}
	dp[x] = (dp[x] + 1) % mod;
}

void dfs(int x, int fa, ll uv) {
	ans[x] = uv;
	vector <int> child;
	for(int e : E[x]) if(e != fa) child.pb(e);
	for(int e : child) ans[x] = ans[x] * dp[e] % mod;
	vector <ll> fv[2];
	int m = szz(child);
	rep(u, 2) fv[u].resize(m);
	for(int i=0;i<m;i++) {
		fv[0][i] = (i?fv[0][i-1]:1) * dp[child[i]] % mod;
	}
	for(int i=m-1;i>=0;i--) {
		fv[1][i] = (i<m-1?fv[1][i+1]:1) * dp[child[i]] % mod;
	}
	rep(i, m) {
		ll nw = uv * (i > 0 ? fv[0][i-1] : 1) % mod * (i < m-1 ? fv[1][i+1] : 1) % mod;
		nw = (nw + 1) % mod;
		dfs(child[i], x, nw);
	}
}

int main() {
	scanf("%d%d", &N, &mod);
	for(int i=1;i<N;i++) {
		int x, y; scanf("%d%d", &x, &y);
		E[x].pb(y);
		E[y].pb(x);
	}
	pdfs(1, -1);
	dfs(1, -1, 1);
	for(int i=1;i<=N;i++) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 28544
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let k:u32 = read();
    let h:Vec<u32> = (0..n).map(|_| read()).collect();

    println!("{}", h.iter().filter(|&x| *x >= k).count());
    
}


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

#define ll long long
#define ar array

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

	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if(s==u)
		--a;
	else
		--b;
	cout << a << " " << b;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>

#define r(i, v, n) for(int i = v; i < n; i++)
#define re(i, v, n) for(int i = v; i <= n; i++)

using namespace std;


int main() {
    int n, k, x, y;
    char c;
    vector<vector<int>> v(4100, vector<int>(4100, 0));
    scanf("%d %d", &n, &k);
    int dk = 2 * k;
    r(i, 0, n) {
        scanf("%d %d %c", &x, &y, &c);
        if (c == 'W') {
            c = 'B';
            x += k;
        }
        x %= dk;
        y %= dk;
        v[x+1   ][y+1   ]++;
        v[x+1+k ][y+1   ]--;
        v[x+1   ][y+1+k ]--;
        v[x+1+k ][y+1+k ]+=2;
        v[x+1+dk][y+1+k ]--;
        v[x+1+k ][y+1+dk]--;
        v[x+1+dk][y+1+dk]++;
    }

    r(i, 0, 4 * k) {
        r(j, 0, 4 * k) {
            if (i == 0 && j == 0) {
                continue;
            } else if (i == 0 && j != 0) {
                v[i][j] += v[i][j - 1] + 0 - 0;
            } else if (i != 0 && j == 0) {
                v[i][j] += 0 + v[i - 1][j] - 0;
            } else {
                v[i][j] += v[i][j - 1] + v[i - 1][j] - v[i - 1][j - 1];
            }
        }
    }

    r(i, 0, 4 * k) {
        r(j, 0, 4 * k) {
            if (i < dk && j < dk) {
                continue;
            } else if (dk <= i && j < dk) {
                v[i%dk][j] += v[i][j];
            } else if (i < dk && dk <= j) {
                v[i][j%dk] += v[i][j];
            } else {
                v[i%dk][j%dk] += v[i][j];
            }
        }
    }

    int max_count = 0;
    r(i, 0, dk) {
        r(j, 0, dk) {
            int val = v[i][j];
            if (max_count < val) {
                max_count = val;
            }
        }
    }

    printf("%d", max_count);

    return 0;
}

Measured memory_bytes: 66048
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m;
    cin >> m;
    ll digitsum = 0;
    ll allsum = 0;
    rep(i,m){
        ll d, x;
        cin >> d >> x;
        digitsum += x;
        allsum += d * x;
    }
    cout << (digitsum - 1) + ((allsum-1) / 9)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=3e5+5;
int val[M],wt[M];
pair<int,int> res[2][M];
vector<pair<int,int>> vec[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>val[i]>>wt[i];
	}
	vec[0].pb({0,0});
	for(int i=1;i<(1<<10);i++)
	{
		int p=i/2;
		for(int j=0;j<sz(vec[p]);j++)
		{
			vec[i].pb(vec[p][j]);
			vec[i].pb({vec[p][j].ff+wt[i],vec[p][j].ss+val[i]});
		}
		sort(all(vec[i]));
		for(int j=1;j<sz(vec[i]);j++)
			vec[i][j].ss=max(vec[i][j].ss,vec[i][j-1].ss);
	}
	int q;
	cin>>q;
	while(q--)
	{
		int v,L;
		cin>>v>>L;
		vector<int> vt;
		while(v>=(1<<10))
		{
			vt.pb(v);
			v/=2;
		}
		vector<pair<int,int>> res;
		for(int i=0;i<(1<<sz(vt));i++)
		{
			int x=0,y=0;
			for(int j=0;j<sz(vt);j++)
			{
				if((i&(1<<j))==0)
					continue;
				x+=val[vt[j]];
				y+=wt[vt[j]];
			}
			res.pb({y,x});
		}
		sort(all(res));
		int curr=sz(vec[v])-1;
		int ans=0;
		for(int i=0;i<sz(res);i++)
		{
			while(curr>=0)
			{
				if(res[i].ff+vec[v][curr].ff>L)
					curr--;
				else
					break;
			}
			if(curr<0)
				break;
			ans=max(ans,res[i].ss+vec[v][curr].ss);
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 18008
#include<stdio.h>
#include<stdlib.h>
#define min(a,b) ((a)>(b)?(b):(a))
int N, X[20], Y[20], P[20], a[20];
long Z[1<<16][16][2], ans[20]={1l<<60};
int popcount(int n){
	if(!n)return 0;
	return (n&1) + popcount(n>>1);
}
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d%d%d", X+i, Y+i, P+i);
		ans[i+1] = 1l<<60;
	}
	for(int i=0; i<(1<<N); i++){
		for(int j=0; j<N; j++){
			Z[i][j][0] = abs(X[j]);
			Z[i][j][1] = abs(Y[j]);
			for(int k=0; k<N; k++){
				if((i>>k)&1){
					Z[i][j][0] = min(Z[i][j][0], (long)abs(X[j]-X[k]));
					Z[i][j][1] = min(Z[i][j][1], (long)abs(Y[j]-Y[k]));
				}
			}
		}
	}
	while(!a[N]){
		int h=0, v=0;
		for(int i=0; i<N; i++){
			if(a[i]==1)h |= (1<<i);
			if(a[i]==2)v |= (1<<i);
		}
		int t = popcount(h|v);
		long sum = 0;
		for(int i=0; i<N; i++){
			sum += (long)P[i] * min(Z[h][i][0], Z[v][i][1]);
		}
		int i=0;
		while(a[i]==2)a[i++]=0;a[i]++;
		ans[t] = min(ans[t], sum);
	}
	for(int i=0; i<=N; i++){
		printf("%ld\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 9924
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main (){
   ll x;
   ll ans =0;
   cin >> x;
   ll q500=x/500;
   ans+=q500;
   x=x-500*q500;
   ll q5=x/5;
   cout << q500*1000+q5*5 <<endl;



    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n,p;cin>>n>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	ll ans=1;
	for(int i=2;i<=sqrt(p);++i){
		int cnt=0;
		if(p%i==0){
			while(p%i==0){
				p/=i;
				cnt++;
			}
			if(cnt>=n){
				while(cnt>=n){
					cnt-=n;
					ans*=i;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
  int n,m,h,w; cin >> n >> m >> h >> w;
  cout << n*m-h*m-w*n+h*w << endl;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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 lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

struct edge
{
    int from, to,cost;
    edge() :from(-1),to(-1),cost(1){}
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

// vec<vec<bool>>  G (100100,vec<bool> (100100,false));
using Graph = vector<vector<int>>; // グラフ型


int main()
{
    int n,m;cin>>n>>m;
    Graph G(n); // グラフ

    int a,b;
    rep(i,m){
        cin>>a>>b;

        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vec<int> dist(100100,-1);
    vec<int> prev (100100,-1);
    dist[0]=0;

    queue<int> Q;

    int now=0;
    Q.push(now);
    while(!Q.empty()){
        now=Q.front();
        Q.pop();
        for(auto& e:G[now]){
            int node=int(e);
            if(dist[node]==-1){
                Q.push(node);
                dist[node]=dist[now]+1;
                prev[node]=now;
            }
        }
    }

    cout<<"Yes"<<endl;
    loop(i,1,n){
        cout<<prev[i]+1<<endl;
    }

    return 0;

}




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

int main() {
  ll X,A,B;
  cin>>X>>A>>B;
  if(B<=A){
    cout<<"delicious"<<endl;
  }
  else if(B-A<=X){
    cout<<"safe"<<endl;
  }
  else{
    cout<<"dangerous"<<endl;
  }
}


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

using namespace std;

int main(){//22:14
    int n;
    cin >> n;
    vector<bool> flag(8, false);
    int over=0, under=0;
    int a;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a>=3200){
            ++over;
        }else{
            ++under;
            if(a<400){
                flag[0]=true;
            }else if(a<800){
                flag[1]=true;
            }else if(a<1200){
                flag[2]=true;
            }else if(a<1600){
                flag[3]=true;
            }else if(a<2000){
                flag[4]=true;
            }else if(a<2400){
                flag[5]=true;
            }else if(a<2800){
                flag[6]=true;
            }else{
                flag[7]=true;
            }
        }
    }
    int num=0;
    for(bool b : flag){
        if(b)
            ++num;
    }
    int min=1;
    if(num!=0){
        min=num;
    }
    cout << min << " " << num+over;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
int main()
{
  using namespace std;
  int N, M, i, sum = 0;
  int max_break;
  int z = pow(10, 4);
  int A[z];
  cin >> N >> M;
  i = 0;
  while (i < M)
  {
    cin >> A[i];
    sum += A[i];
    i++;
  }
  max_break = N - sum;
  if (max_break >= 0)
  {
    cout << max_break;
  }
  else
  {
    cout << -1;
  }
  return 0;
}

Measured memory_bytes: 3644
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector> //*max_element(all(変数))で最大値を獲得
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n;  cin >> n;
  priority_queue<int> d;
  rep0(i,n){
    int x; cin >> x;
    d.push(x);
  }
  int m;  cin >> m;
  priority_queue<int> t;
  rep0(i,m){
    int x; cin >> x;
    t.push(x);
  }

  while(!d.empty()){
    if(d.top() == t.top()){
      t.pop();
    }
    d.pop();
    if(t.empty()){
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}


Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

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

  int n,k,s;
  cin>>n>>k>>s;

  int a[n+5];
  for(int i=0;i<k;i++){
    a[i]=s;
  }
  if(s!=1){
    for(int i=k;i<n;i++){
      a[i]=s-1;
    }
  }
  else{
    for(int i=k;i<n;i++){
      a[i]=s+1;
    }
  }

  rep(i,n-1){
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<'\n';
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  vector<vector<int>>A(3,vector<int>(3));
  vector<vector<bool>>use(3,vector<bool>(3,false));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>A[i][j];
    }
  }
  int N;
  cin>>N;
  for(int q=0;q<N;q++){
    int b;
    cin>>b;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(A[i][j]==b){use[i][j]=true;}
      }
    }
  }
  for(int i=0;i<3;i++){
    bool ok=true;
    for(int j=0;j<3;j++){
      if(!use[i][j]){ok=false;}
    }
    if(ok){cout<<"Yes"<<endl;return 0;}
  }
  for(int j=0;j<3;j++){
    bool ok=true;
    for(int i=0;i<3;i++){
      if(!use[i][j]){ok=false;}
    }
    if(ok){cout<<"Yes"<<endl;return 0;}
  }
  if(use[0][0]&&use[1][1]&&use[2][2]){cout<<"Yes"<<endl;return 0;}
  if(use[0][2]&&use[1][1]&&use[2][0]){cout<<"Yes"<<endl;return 0;}
  cout<<"No"<<endl;
  return 0;
}

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

int main(){
    int N, K, Q, a;
    cin >> N >> K >> Q;
    int point[N];
    for(int i=0; i<N; i++){
        point[i] = K-Q;
    }
    for(int i=0; i<Q; i++){
        cin >> a;
        point[a-1] += 1;
    }
    for(int i=0; i<N; i++){
        //cout << "num=" << i << " point=" << point[i] << endl;
        if(point[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main()
{
	long long A, B, N;
	cin >> A >> B >> N;

	long long x = N;
	if( B - 1 <= N ) x = B - 1;
	long long ans =  A * x / B - x / B * A;

	cout << ans << endl;
}


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

int main(void)
{
  int N;
  cin >> N;
  int ans;
  for (int i=1; i<=N; ++i) {
    if (N == (int)(i * 1.08)) {
        cout << i << endl;
        return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm> // std::sort(begin,end)
#include <utility> // std::swap

using namespace std;
using ll = long long;

ll div_cnt(ll i){
  ll  cnt = 0;
  
  while(i%2==0){
    i/=2;
    cnt++;
  }

  return cnt;
}


int main(int argc, char const* argv[])
{
    
  ll n;
  cin >> n;
  ll a,cnt=0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    cnt += div_cnt(a);
  } 
  cout << cnt  << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int a,p;
	cin >> a >> p;
	a *= 3;
	int ans = (a+p)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())
p = [(int(x)+1)/2for x in input().split()]

result = []
sub_total = sum(p[:k])
result.append(sub_total)

for i in range(1, n-k+1):
    sub_total = sub_total - p[i-1] + p[i-1+k]
    result.append(sub_total)

print(max(result))

Measured memory_bytes: 23148
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n)(for i-0;i<(n);++i)
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int n, f = 0;
  ll d, to = 1;
  cin >> n;
  vector<ll> a;
  for (int i = 0; i < n; i++) {
    cin >> d;
    a.push_back(d);
  }
  sort(a.begin(), a.end());
  if (a[0] == 0) {
    cout << 0;
    return 0;
  } else {
    for (int i = 0; i < n; i++) {
      if (a[i] <= 1000000000000000000 / to) {
        to = to * a[i];
      } else {
        cout << -1;
        return 0;
      }
    }
  }
  cout << to;
  return 0;
}

Measured memory_bytes: 4316
s = int(input())
n = 0
if s==1 or s == 2:
  print("4")
elif s==3:
  print("9")
if s >=4:
  s = 2*s
  while s % 2 == 0:
    s = s/2
    n += 1
    if s!=1 and s%2 == 1:
      s = 3*s+1
      n+=1
    if s == 1:
      print(n+1)
      break



Measured memory_bytes: 3188
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int min = Math.min(a,b);
        int mid = Math.abs(a-b);
        int ans = 0;
        if(mid % 2 == 0){
            ans = mid/2 + min;
        }
        else{
            ans = (mid/2 + 1) + min;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using ll = long long;
#define ull unsigned ll
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll, ll>
#define ppi pair<int, pii>
#define vpi vector<pii>
#define vpl vector<pll>
#define mt make_tuple
#define eb emplace_back
using namespace std;

const ll N = 2e5 + 5, mod = 1e9 + 7;
const ll inf = 1e18;

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    int tt = b * c;
    if(tt < a){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("Input.txt", "r", stdin);
    #endif*/
    //freopen("running_on_fumes_chapter_1_input (1).txt", "r", stdin);
    //freopen("Output.txt", "w", stdout);
    int t = 1, p;
    //cin >> t;
    for(p = 1; p <= t; p++){
        //cout << "Case #" << p << ": ";
        solve();
    }
    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n;
    cin>>n;
    set<string>ap;
    bool ok=true;
    string p;
    cin>>p;
    char back=p[p.size()-1];
    ap.emplace(p);
    rep(i,n-1){
        string w;
        cin>>w;
        if(ap.find(w)!=ap.end()){
        ok=false;
        break;
        }
        if(back!=w[0]){
            ok=false;
            break;
        }
        ap.emplace(w);
        back=w[w.size()-1];
    }

    if(ok){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <iostream>

using namespace std;
char s[101];
int main() {
    int n;
    cin >> n;
    for (int i=0; i<n; i++) cin >> s[i];

    int red = 0;
    int blue = 0;
    for(int i=0; i<n; i++) {
        if (s[i] == 'R') red++;
        else blue++;
    }

    cout << (red > blue ?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (void)
{
  string s;
  cin >> s;
  if(s[0] != s[1] && s[1] != s[2] && s[2] != s[0]){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i=0 ; i<n ; i++)
    cin >> l.at(i);
  
  sort(l.begin(), l.end());
  
  int sum = 0;
  for (int i=0 ; i<n-1 ; i++)
    sum += l.at(i);
  
  if (sum > l.at(n-1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628