akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

double sq_calc(ll X,ll Y){
    return sqrt(X*X+Y*Y);
}
template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    
    using pdd = pair<double,double>;
    vector<pdd> ps(N);
    for(int i = 0; i < N;i++){
        cin >> ps[i].first >> ps[i].second;
    }
    auto update = [&](double X,double Y){
        res = max(res,sq_calc(X,Y));
    };
    
    sort(ps.begin(),ps.end(),[](const pdd& l,const pdd& r){
        return atan2(l.second,l.first) < atan2(r.second,r.first);
    });
    
    for(int i = 0; i < N;i++){
        for(int j = 0; j < N;j++){
            
            double X = 0,Y = 0;
            for(int k = i;; (k += 1)%=N){
                X += ps[k].first;
                Y += ps[k].second;
                
                if(k == j) break;
            }
            update(X,Y);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    int x,y,z;cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int box[26]={};
  char str='a',ch;
  while ( scanf("%c", &ch) != EOF ){
    if(ch>=65 && ch<=90)ch+=32;
    if(ch>=97 && ch<=122)box[ch-'a']++;
  }
    for(int i=0;i<26;i++){
      printf("%c : %d\n",str+i,box[i]);
    }



  return 0;
}



Measured memory_bytes: 2080
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

int main() {
	double x, y;
	double W, H;
	cin >> W >> H >> x >> y;

	double ans = W * H / 2.0;

	cout << fixed << setprecision(10) << ans << " ";
	
	if (x == W / 2.0 && y == H / 2.0) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}



	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K,*H = map(int,read().split())

H = [H[0]]*K+H

dp = [0]*(K+N)

for n in range(K,N+K):
    h = H[n]
    dp[n] = min(x+abs(y-h) for x,y in zip(dp[n-K:n],H[n-K:n]))

answer = dp[-1]
print(answer)

Measured memory_bytes: 12444
//https://atcoder.jp/contests/abc144/tasks/abc144_a
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b;
    cin >> a >> b;
    if(a>=1 && a<= 9 && b>=1 && b<=9 ) cout << a*b << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mag (ll)1e6

int main(){
ll a,b;cin>>a>>b;
if(a*b<0)
    cout<<"Zero";
else if(a>0 && b>0)
    cout<<"Positive";
else {
if(abs(a+b)%2==0)
    cout<<"Negative";
else
    cout<<"Positive";
}

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

def cnt(n):
    x = 0
    while n%2 == 0:
        x += 1
        n = n//2
    return x
    
ans = 10**9

for i in a:
    ans = min(ans,cnt(i))
    
print(ans)

Measured memory_bytes: 9112
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
char s[100005];
int ans[100005];
int n,flag;
int check(int i,int x)
{
    int l = i - 1,r = i + 1;
    if(i == 1)l = n;
    if(i == n)r = 1;
    if(x)
    {
        if((s[i] == 'o' && ans[r] != ans[l]) || (s[i] == 'x' && ans[r] == ans[l]))
            return true;
        else return false;
    }
    else
    {
        if((s[i] == 'x' && ans[r] != ans[l]) || (s[i] == 'o' && ans[r] == ans[l]))
            return true;
        else return false;
    }
}
void dfs(int h,int x)//x = 1ÀÇ£¬x = 0Ñò
{
    if(flag)return;
    ans[h] = x;
    if(h > n)return;
    if(h == n && check(n,x) && check(1,ans[1]))
    {
        flag = 1;
        return ;
    }
    if(x)
    {
        if(s[h] == 'o')
        {
            dfs(h + 1,ans[h - 1]^1);
        }
        else {
            dfs(h + 1,ans[h - 1]);
        }
    }
    else {
        if(s[h] == 'o')
        {
            dfs(h + 1,ans[h - 1]);
        }
        else {
            dfs(h + 1,ans[h - 1]^1);
        }
    }
}
int main()
{
    while(~scanf("%d",&n))
    {
        scanf("%s",s + 1);
        flag = 0;
        memset(ans,0,sizeof ans);
        ans[1] = 1;
        dfs(2,1);
        if(!flag)
        {
            memset(ans,0,sizeof ans);
            ans[1] = 1;
            dfs(2,0);
        }
        if(!flag)
        {
            memset(ans,0,sizeof ans);
            ans[1] = 0;
            dfs(2,0);
        }
        if(!flag)
        {
            memset(ans,0,sizeof ans);
            ans[1] = 0;
            dfs(2,1);
        }
        if(flag)
        {
            for (int i = 1; i <= n; i++)
            {
                if(ans[i])
                    printf("W");
                else printf("S");
            }
            printf("\n");
        }
        else printf("-1\n");
    }
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	ll n;
	cin >> n;
	vector<ll>fx(n), fy(n);
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		fx[i] = x + y;
		fy[i] = x - y;
	}
	sort(fx.begin(), fx.end());
	sort(fy.begin(), fy.end());

	ll mafx = fx[n - 1]-fx[0];
	ll mafy= fy[n - 1] - fy[0];
	cout << max(mafx, mafy);
	return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
char maze[21][21];
#define r(z,x) for(int z=0;z<x;z++)
int ans,a,b;
void dfs(int x,int y){
	int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0};
	maze[x][y]='#',ans++;
	r(i,4)if(maze[x+dx[i]][y+dy[i]]=='.')dfs(x+dx[i],y+dy[i]);
}
int main(){
	while(cin>>a>>b,a||b){
		ans=0;
		fill(maze[0],maze[20],'#');
		r(i,b)r(j,a)cin>>maze[i][j];
		r(i,b)r(j,a)if(maze[i][j]=='@')dfs(i,j),cout<<ans<<endl;
	}
}

Measured memory_bytes: 3076
#include<iostream>

using namespace std;
//D. Menagerie

//円環状に羊か狼が並んでいる
//羊は正直で狼が嘘つき
//各動物に対して「両隣は同じ動物？」と質問
//各動物は"o"か"x"で答える

//動物の数 N と答えの文字列 s が与えられる
//あり得る組み合わせを羊ならS、狼ならWで出力
//組み合わせができない場合は-1を出力

#define FOR(i,a,b) for(long long i =(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define debug(x) cerr << #x << " = " << x << endl;
#define maxN 100000

int candidate[4][maxN];

void printAnimal(int num,int N){

    REP(i,N){
        if(candidate[num][i] == 0){
            cout << "W";
        }else{
            cout << "S";
        }
    }
    cout << endl;
    return;
}

int main(void){

    
    int N;
    string s;

    cin >> N;
    cin >> s;
    
    fill((int*)candidate,(int*)(candidate+4),-1);
    
    // S = 1, W = 0で円環の繋ぎ目のあり得る組み合わせ(4つ)
    candidate[0][0]   = 0; candidate[0][N-1] = 0; // W W
    candidate[1][0]   = 0; candidate[1][N-1] = 1; // W S
    candidate[2][0]   = 1; candidate[2][N-1] = 0; // S W
    candidate[3][0]   = 1; candidate[3][N-1] = 1; // S S

    
    REP(i,4){
        // 最初に決めたものと推定したものが一致する？
        bool flag1 = false; // 末尾が一致
        bool flag2 = false; // 先頭が一致
        REP(k,N){
            
            int cand;
            //１つ前と今見ている所のXORをとる
            if(k == 0){ //円環の繋ぎ目
                cand = candidate[i][N-1]^candidate[i][0];
            }else{
                cand = candidate[i][k-1]^candidate[i][k];
            }
            //XORは答えが"x"の時の次の動物を示す
            //"o"の時はビット反転させる
            if(s[k] == 'o'){
                cand = not(cand);
            }
            
            if(k != 0 && k == N-2){
                flag1 = (cand == candidate[i][k+1]);
                continue;
            }
            
            if(k != 0 && k == N-1){
                
                flag2 = (cand == candidate[i][0]);
                
                //推定したものが一致するなら出力して終了
                if(flag1 && flag2){
                    printAnimal(i,N);
                    return 0;
                }
            }
            candidate[i][k+1] = cand;
        }
        // i = 0~3まで(4つの候補)で一致しなければ存在しない
        if(i == 3) cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
/*C - management*/
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int tam;
	cin >> tam;

	vector <int> arr(tam);

	int pos;

	for (int i = 0; i < tam - 1; ++i)
	{
		cin >> pos;
		pos--;

		arr[pos]++;
	}

	for (int i = 0; i < tam; ++i)
	{
		cout << arr[i] << '\n';
	}


	return 0;	
}

Measured memory_bytes: 3988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            var A = Input.NextInt();
            var list = Input.IntList().Select(x => x - A).ToList(); // Aとの相対
            var array = new long[10000]; // id=5000 を0

            array[5000] = 1; // 何も取らないのが1通り

            foreach (var i in list) {
                for (int j = 1000; j < 9000 && i <= 0; j++) {
                    array[i + j] += array[j];
                }
                for (int j = 9000; j > 1000 && i > 0; j--) {
                    array[i + j] += array[j];
                }
            }

            Console.WriteLine(array[5000] - 1); // 何も取らない状態を除く
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13436
#include <bits/stdc++.h>
#define len(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define chmax(x, v) x = max((x), (v))
#define chmin(x, v) x = min((x), (v))
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	n %= 1000;
	if (n) n = 1000-n;
	cout << n << "\n";
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long double ld;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
typedef vector<ll>::iterator vit;
const ll INF = 1LL<<18;
const ll MOD = 1e9 + 7;
const ll EPS = 1e-6;
#define each(it,s) for(vit it = s.begin(); it != s.end(); ++it)
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.begin(), v.end(), greater<ll>())
#define fill(a) memset(a, 0, sizeof (a))
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i < (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define pq(x) priority_queue<x,std::vector<x>,compare>
#define rpq(x) priority_queue<x,std::vector<x>,compare>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(a,n) vll a;rep(i,n){ll in;cin>>in;a.pb(in);}
#define arrin(arr,n) rep(i,n){cin>>arr[i];}
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ignore cin.ignore(256,'\n');
ll gcd(ll x,ll y) {if(x==0) return y;return gcd(y%x,x);}
ll powM(ll x,ll y,ll m) {ll ans=1,r=1;x%=m;while(r>0&&r<=y){if(r&y){ans*=x;ans%=m;}r<<=1;x*=x;x%=m;}return ans;}
ll modI(ll a, ll m) {ll m0=m,y=0,x=1;if(m==1) return 0;while(a>1){ll q=a/m;ll t=m;m=a%m;a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
ll max(ll a,ll b,ll c) {return max(max(a,b),c);}
ll power(ll x,ll y) {ll z=1;while(y>0){if(y%2)z=(z*x);x =(x*x) ;y/=2;}return z;}
void solve()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    if(k>=a) {ans+=a;
    k-=a;}
    else{
        ans = k;
        cout<<ans;
        return;
    }
    if(k>=b) k-=b;
    else
    {
        cout<<ans;
        return;
    }
    ans-=k;
    cout<<ans;
    return;
}
int main()
{
fastio;
/*#ifndef ONLINE_JUDGE
freopen("/home/naman/Desktop/CP/input.txt","r",stdin);
freopen("/home/naman/Desktop/CP/output.txt","w",stdout);
#endif*/
ll t=1;
//cin>>t;
while(t--)
{
solve();
}
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time - start_time;
/*#ifndef ONLINE_JUDGE
cerr << "Time Taken : " << diff.count() << "s\n";
#endif*/
}

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

using namespace std;

bool is_palindrome(string s) {
    string str(s.rbegin(), s.rend());
    return s == str;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if (is_palindrome(s) && is_palindrome(s.substr(0, (n - 1) / 2)) && is_palindrome(s.substr((n + 1) / 2)))
        cout << "Yes";
    else cout << "No";

}


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

using namespace std;
using ll=long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;
const int MOD = 1000000007;

double dp[310][310][310];
int n;
double rec(int i,int j,int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i==0&&j==0&&k==0) return 0.0;
    double res = 0.0;
    if(i >0)res += rec(i-1,j,k) * i;
    if(j >0)res += rec(i+1,j-1,k) * j;
    if(k >0)res += rec(i,j+1,k-1) * k;
   
    res += n;
    res *= 1.0 / (i+j+k);
    return dp[i][j][k] = res;
}

int main() {

cin >> n;
int a[4]={0};

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

memset(dp,-1,sizeof(dp));

printf("%.10lf\n",rec(a[1],a[2],a[3]) );
return 0;
}




Measured memory_bytes: 232960
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

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

// DP
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(){
    ll N, D;
    cin >> N >> D;
    ll cnt = 0;
    REP(i, N){
        ll x, y;
        cin >> x >> y;

        if(sqrt(x * x + y * y) <= D) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main()
{
	int n;
	string data;
	cin>>n>>data;
	int w=0,r=0;
	for(int i=0;i<data.length();i++)
	{
		if(data[i]=='W')
		w++;
		else
		r++;
	}
	int answer=0;
	for(int i=0;i<data.length()-w;i++)
	{
	   	if(data[i]=='W')
		answer++;
	}
	cout<<answer;
}

Measured memory_bytes: 3524
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        N: usize, W: usize,
        wv: [(usize, i64); N]
    }

    // let mut ans = if wv[0].0 <= W { wv[0].1 } else { 0 };
    // if N == 1 {
    //     println!("{}", ans);
    //     return;
    // }

    let mut ans = 0;
    for k in 1..=N {
        let w0 = wv[0].0;
        if W < k * w0 {
            continue;
        }
        let W = W - k * w0;
        let wv = wv.iter().map(|&(w, v)| (w - w0, v)).collect_vec();

        let mut dp = vec![vec![vec![0; 3 * k + 1]; k + 1]; N];
        let (w0, v0) = wv[0];
        dp[0][1][w0] = v0;
        for (i, (w, v)) in (0..).zip(wv).skip(1) {
            for count in 1..=k {
                dp[i][count] = dp[i-1][count].clone();
            }
            if W < w {
                continue;
            }
            for count in 1..=k {
                dp[i][count][w] = max(dp[i][count][w], v);
                if count == k {
                    continue;
                }
                for prev_w in (0..=min(3*k-w, W-w)).rev() {
                    let prev_v = dp[i-1][count][prev_w];
                    dp[i][count+1][prev_w+w] = max(dp[i][count+1][prev_w+w], prev_v+v);
                }
            }
        }
        for w in 0..=min(3*k, W) {
            ans = max(ans, dp[N-1][k][w]);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 25988
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	string s;
	ll dp[M][13]={};
	cin>>s;
	dp[0][0]=1;
	int n=s.size();
	rep(i,0,n){
		if(s[i]=='?'){
			rep(j,0,13){
				rep(k,0,10){
					dp[i+1][(j*10+k)%13]+=dp[i][j];
					dp[i+1][(j*10+k)%13]%=MOD;
				}
			}
		}else{
			int k=s[i]-'0';
			rep(j,0,13){
				dp[i+1][(j*10+k)%13]+=dp[i][j];
				dp[i+1][(j*10+k)%13]%=MOD;
			}
		}
	}
	print(dp[n][5]);

}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

using namespace std;

int main(){
    string s,ans;
    ans="NA";
    cin >>s;

    int fro =atoi(s.c_str())/100;
    int back=atoi(s.c_str())%100;
    if(1<=fro && fro<=12){
        if(1<=back && back<=12){
            ans="AMBIGUOUS";
        }
        else{
            ans="MMYY";
        }
    }
    else if(1<=back && back<=12){
        ans="YYMM";
    }
    cout<< ans<< endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string X;
  rep(i,0,4){
    char Y; cin>>Y;
    X+=Y;
    }
  sort(ALL(X));
  string ans="NO";
  if(X=="1479")
    ans="YES";
  cout<<ans<<endl;
  }


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

int main() {
    int N; cin >> N;
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    sort(V.begin(), V.end(), greater<int>());
    float sum_val = 0;
    for (int i = 0; i < N; i++) {
        if (i == N - 1) {
            sum_val += pow(0.5, N-1) * V[i];
        } else {
            sum_val += pow(0.5, i+1) * V[i];
        }
    }
    cout << sum_val << endl;
    return 0;
}

Measured memory_bytes: 512
import collections

n=int(input())
vList=list(map(int,input().split()))

gusuList=[]
kisuList=[]

for i in range(n):
  if(i % 2==0):
    gusuList.append(vList[i])
  else:
    kisuList.append(vList[i])
#print(gusuList)
#print(kisuList)

g = collections.Counter(gusuList)
gStatus=g.most_common()

k = collections.Counter(kisuList)
kStatus=k.most_common()

ans=-100
if(not gStatus[0][0]==kStatus[0][0]):
    ans=(n/2-gStatus[0][1])+(n/2-kStatus[0][1])
else:
    ans1=-101
    ans2=-102
    if(not len(kStatus)==1):
      ans1=(n/2-gStatus[0][1])+(n/2-kStatus[1][1])
    else:
      ans1=(n/2-gStatus[0][1])+n/2

    if(not len(gStatus)==1):
      ans2=(n/2-gStatus[1][1])+(n/2-kStatus[0][1])
    else:
      ans2=n/2+(n/2-kStatus[0][1])

    ans=min(ans1,ans2)

print(int(ans))

Measured memory_bytes: 24288
import java.util.*;

/**
 * SmallLargeOrEqual
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        if (a < b) {
            System.out.println("a < b");
        } else if (a == b) {
            System.out.println("a == b");
        } else {
            System.out.println("a > b");
        }
    }
}


Measured memory_bytes: 26260
#include <stdio.h>
int main() {
	long long n,i=0,s;
	scanf("%lli",&n);
	long long o[n], l[n];
    for (i=0; i<n;i++){
      l[i]=0;
    }
	for (i=0; i < n; i++) {
		scanf("%lli", &o[i]);
		l[o[i] - 1]++;
	}
	for (i=0; i < n; i++) {
		s += l[i] * (l[i] - 1) / 2;
	}
	for (i=0; i < n; i++) {
		printf("%lli\n",s-l[o[i]-1]+1);
	}
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n , mx = INT_MAX;
    cin >> n;
    ll a[n] , pre[n] , suf[n];
    for( int i = 0 ; i < n ; i++ )
        cin >> a[i];
    pre[0] = 0;
    for( int i = 1 ; i < n ; i++ )
        pre[i] = pre[i - 1] + a[i - 1];
    suf[n - 1] = a[n - 1];
    for( int i = n - 2 ; i >= 0 ; i-- )
        suf[i] = suf[i + 1] + a[i];
    for( int i = 0 ; i < n ; i++ )
    {
        ll temp = abs( pre[i] - suf[i] );
        if( temp < mx )
            mx = temp;
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
 
 
class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)
 
 
def solve():
    N, M, K = map(int, input().split())

    uft = UnionFind(N)

    d = {i:set() for i in range(1, N+1)}
    # e:enemy　i番目の人のブロック関係の人数
    e = {i:0 for i in range(1, N+1)}
    # f:friend　i番目の人の友人関係の人数
    f = {i:0 for i in range(1, N+1)}
 
    for _ in range(M):
        A, B = map(int, input().split())
        d[A].add(B)
        d[B].add(A)
        f[A] += 1
        f[B] += 1
        # 友人関係はUnion-Findで
        uft.unite(A, B)
 
    for _ in range(K):
        C, D = map(int, input().split())
        # 同じグループかチェック　＝　友人の友人の…という状態かをチェック
        if uft.isunited(C, D):
            # if not D in d[C]:
            e[C] += 1
            # if not C in d[D]:
            e[D] += 1
 
    print(*(uft.getsize(i)-e[i]-f[i]-1 for i in range(1, N+1)))
 
 
if __name__ == "__main__":
    solve()

Measured memory_bytes: 88752
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val heap = readLine.split(" ").map(_.toLong)
    val b = new ArrayBuffer[String]

    for(i<-1 to n) {
      val parent = if(i==1) "" else "parent key = " + heap(i/2-1) + ", "
      val left = if(2*i-1<n) "left key = " + heap(2*i-1) + ", " else ""
      val right = if(2*i<n) "right key = " + heap(2*i) + ", " else ""
      b += "node " + (i) + ": key = " + heap(i-1) + ", " + parent + left + right
    }
    println(b.mkString("\n"))
  }
}

Measured memory_bytes: 44272
N = int(input())
a = [input() for i in range(N)]

c0 = a.count("AC")
c1 = a.count("WA")
c2 = a.count("TLE")
c3 = a.count("RE")

print("AC x %d" % c0)
print("WA x %d" % c1)
print("TLE x %d" % c2)
print("RE x %d" % c3)


Measured memory_bytes: 16300
N,K=map(int,input().split())
A=list(map(int,input().split()))
res=0
for d in range(40,-2,-1):
    if(d!=-1 and K&(1<<d)==0):
        continue
    tmp=0
    for e in range(40,-1,-1):
        mask=1<<e
        num=0
        for i in range(N):
            if(mask&A[i]):
                num+=1
        #numというのはd桁目の1が立ってる数
        #e>dというのはxとkは上からみてd桁目で0と1が変わるってことでfor文まわしてるから
        #つまりe>dというのはd桁目より大きい所を見てる感じ、だからその部分はkとxは同じ数字にになってるよね、そう考えると
        if(e>d):
            #ここではKのe桁目が1のときnumというのは1がたってる数だからそれらがeが1で反転しちゃうから足し合わせるのは0になってる法(つまりN-num)
            if(K&mask):
                tmp+=mask*(N-num)
            #上と全く逆
            else:
                tmp+=mask*num
        #e==dというのはちょうどKとXの桁が変わるところK>=XだからK=1,X=0になるよね、だから足すのはnumの方
        elif(e==d):
            tmp+=mask*num      
        #e<dではxは01好きな方を使っていいよね、、ということは足し合わせるのはnumでもN-numでもどっちでもOK!
        else:
            tmp+=mask*max(num,N-num)
    #この処理をdが大きいところから順にやってあげて一番大きくなったのが答え!
    res=max(res,tmp)
print(res)

Measured memory_bytes: 69264
n = int(input())
march = [0, 0, 0, 0, 0]

# 集計
for i in range(n):
    name = input()
    if name[0] == "M":
        march[0] += 1
    elif name[0] == "A":
        march[1] += 1
    elif name[0] == "R":
        march[2] += 1
    elif name[0] == "C":
        march[3] += 1
    elif name[0] == "H":
        march[4] += 1

# 組み合わせカウント
combi = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            combi += march[i] * march[j] * march[k]
print(combi)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;



int main() {
   

    string s;
    cin >> s;
    if(s.length() == 3){
        reverse(s.begin(),s.end());
        cout << s << endl;
    }else{
        cout << s << endl;
    }

}

Measured memory_bytes: 256
n=int(input())
a=map(int,input().split())
a=sorted(a)
a=list(reversed(a))
h,w=0,0
tmp=0
f=0
for x in a:
    if tmp==x:
        if w!=0:
            h=x
            break
        else:
            w=x
            tmp=0
            continue
    tmp=x
print(w*h)


Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,l,r,ans;
int main()
{
    scanf("%d",&n);
    ans = 0;
    while(n--)
    {
        scanf("%d %d",&l,&r);
        ans+=r-l+1;
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    cout << (N == M ? "Yes": "No") << '\n';

    return 0;
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    ll ans = 0;
    for (ll i = n - 1; i >= 0; i--) {
        if ((a[i] + ans) % b[i] == 0) continue;
        ll r = (ans + a[i]) / b[i];
        ll toadd = ((r + 1) * b[i]) - (ans + a[i]);
        ans += toadd;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
    int a[3],w,i,j;
	for(i=0;i<3;i++){
	    scanf("%d",&a[i]);
	}
	for(i=0;i<2;i++){
	    for(j=i+1;j<3;j++){
		    if(a[i]>a[j]){
			    w=a[i];
				a[i]=a[j];
				a[j]=w;
			}
		}
	}
	printf("%d\n",a[0]+a[1]);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

    String a = sc.next();
    char[] chars = a.toCharArray();

    int num = 0;
    for (int i = 0; i < a.length() / 2; i++) {
      if (chars[i] != chars[a.length() - i - 1]) {
        num++;
      }
    }
    System.out.println(num);
  }
}


Measured memory_bytes: 23252
#pragma warning(disable:4996)
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
using mint = boost::multiprecision::cpp_int; //int1024_t etc...
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;

TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int N, K;
	string S;
	cin >> N >> S >> K;
	for (int i = 0; i < N; ++i) {
		if (S[i] != S[K - 1]) {
			S[i] = '*';
		}
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

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

int main()
{
    int H,W,K;
    cin >> H >> W >> K;
    bool tile[H][W];
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            char tmp;
            cin >> tmp;
            if(tmp=='.') tile[h][w] = false;
            else tile[h][w] = true;
        }
    }

    vector< vector<bool> > checked(H, vector<bool>(W, 0));
    vector< vector<int> > ans(H, vector<int>(W, 0));
    int cnt=0;
    for(int h=0; h<H; h++){
        cnt++;
        bool flag=0;
        for(int w=0; w<W; w++){
            if(!tile[h][w]) ans[h][w]=cnt;
            else{
                flag=1;
                ans[h][w]=cnt;
                cnt++;
            }
        }

        if(flag==1){
            cnt--;
            for(int w=W-1; w>=0; w--){
                ans[h][w]=cnt;
                if(tile[h][w]==1)break;
            }
        }else if(h>0){
            for(int w=0; w<W; w++){
                ans[h][w] = ans[h-1][w];
            }
            cnt--;
        }else if(h==0){
            cnt--;
            for(int w=0; w<W; w++){
                ans[h][w] = 0;
            }
        }
    }

    int h;
    for(h=0; h<H; h++){
        if(ans[h][0]!=0) break;
    }
    int cp[W];
    if(h!=0){
        for(int w=0; w<W; w++){
            cp[w]=ans[h][w];
        }
        for(int i=0; i<h; i++){
            for(int w=0; w<W; w++){
                ans[i][w]=cp[w];
            }
        }
    }

    for(int h=0; h<H; h++){
        for(int w=0; w<W-1; w++){
            cout << ans[h][w] << ' ';
        }
        cout << ans[h][W-1] << endl;
    }

    

    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[101];
		for (int i = 0; i < d.length; i++) {
			d[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			int s = sc.nextInt();
			d[s] = 1;
		}
		int sum = 0;
		for (int i = 0; i < 101; i++) {
			sum += d[i];
		}
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 22868
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n, m; cin >> n >> m;
  cout << (n - 1) * (m - 1) << '\n';
  return 0;
}


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

#define rep(i, n) for(int i = 1; i <= (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >>n;
    vi a(n+1), b(n+1), c(n+1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
  	c.push_back(-100);

    int cnt = 0;
    int pre_I = -100;
    rep(i,n){
        int I = a[i];
        cnt += b[I];
        if(I == pre_I+1) cnt += c[pre_I];
        pre_I = I;
    }
    cout <<cnt << '\n';
}

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


int main(void){
    int n;
    string s;
    cin >> n >> s;
    int num[n];
    rep(i,n){
        num[i] = (int)(s[i] - 'a');
    }
    int ans =0;
    for(int i=1;i<n;i++){
        int cnt = 0;
        rep(j,26){
            bool left = 0;
            bool right = 0;
            for(int k=0;k<i;k++){
                if(num[k] == j){
                    left = 1;
                }
            }
            for(int k=i;k<n;k++){
                if(num[k]==j){
                    right = 1;
                }
            }
            if(left && right){
                cnt++;
            }
        }
        ans = max(cnt,ans);
    }
    
    cout << ans <<endl;
    
    
    return 0;
}





























































Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import bisect



def main():
    width, high, num = map(int, input().split())
    data = [[0 for i in range(width)] for j in range(high)]

    for i in range(num):
        x, y, a = map(int, input().split())
        if a == 1:
            for j in range(high):
                for k in range(x):
                    data[j][k] = 1
        elif a == 2:
            for j in range(high):
                for k in range(x, width):
                    data[j][k] = 1
        elif a == 3:
            for j in range(y):
                for k in range(width):
                    data[j][k] = 1
        elif a == 4:
            for j in range(y, high):
                for k in range(width):
                    data[j][k] = 1

        # print(data)

    # for i in range(high):
    #     print(data[i])

    ans = 0
    for i in range(high):
        ans += data[i].count(0)

    print(ans)





if __name__ == '__main__':
    main()

Measured memory_bytes: 41968
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	string s;
	string t;
	string mod;
	cin>>s;
	cin>>t;
	int lens=s.length();
	int lent=t.length();
	int flag=0;
	int pos=-1;
	int k=0;
	for(int i=lens-lent;i>=0;i--)
	{
		for(int j=0;j<lent;j++)
		{
			
			if(t[j]==s[i+j]||s[i+j]=='?')	
			{

			if(j==lent-1) 
			{
			flag=1;
			pos=i;
			break;
			}
			continue;
			
			}
			else
			{
				break;
			}
		}
		if(flag) break;
	}
	if(flag==0) cout<<"UNRESTORABLE"<<endl;
	else 
	{
		for(int i=0;i<lens;i++)
		{
			if(i<=pos-1||i>=pos+lent)
			
				if(s[i]=='?') cout<<"a";
				else cout<<s[i];
			else if(i>=pos&&i<pos+lent)
			{
				cout<<t[k++];
			}
			
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

ans = "YES"
cntd = {}
for di in d:
    if di in cntd:
        cntd[di] += 1
    else:
        cntd[di] = 1
cntt = {}
for ti in t:
    if ti in cntt:
        cntt[ti] += 1
    else:
        cntt[ti] = 1

for k, v in cntt.items():
    if k not in cntd or cntd[k] < v:
        ans = "NO"
        break
print(ans)

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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	vint as(q);
	for(int i = 0; i < q; ++i){
		scanf("%d", &as[i]);
		--as[i];
	}

	vint vis(m);
	vector<int> seq;
	for(int i = q; i--; ){
		if(!vis[as[i]]){
			vis[as[i]] = 1;
			seq.push_back(as[i]);
		}
	}
	for(int i = 0; i < m; ++i){
		if(!vis[i]){ seq.push_back(i); }
	}
	vint rtbl(m);
	for(int i = 0; i < m; ++i){
		rtbl[seq[i]] = i;
	}

	vint nxt(n);
	for(int i = q; i--; ){
		int x = rtbl[as[i]];
		int k = lower_bound(ALL(nxt), x, greater<int>()) - nxt.begin();
		if(k < n && nxt[k] == x){
			++nxt[k];
		}
	}

	int minimum = *min_element(ALL(nxt));
	vis.assign(m, 0);
	vint seq2;
	for(int i = 0; i < minimum; ++i){
		seq2.push_back(seq[i]);
		vis[seq[i]] = 1;
	}
	for(int i = 0; i < m; ++i){
		if(!vis[i]){
			seq2.push_back(i);
		}
	}

	puts(seq == seq2 ? "Yes" : "No");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 2936
#include<stdio.h>

int S[100000], n;

int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;

  while(left < right){
    mid = (left + right) / 2;
    if(key == S[mid]) return 1;
    if(key > S[mid]) left = mid+1;
    else if(key < S[mid]) right = mid;
  }
  return 0;
}

int main()
{
  int q, T[50000], C, i;
  C = 0;
 
  scanf("%d", &n);

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

  scanf("%d", &q);

  for(i = 0;i < q;i++){
    scanf("%d", &T[i]);
    if(binarySearch(T[i])) C++;
  }
 
  printf("%d\n", C);
 
  return 0;
}

Measured memory_bytes: 2264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    ll n,m; cin>>n>>m;
    priority_queue<ll> que;
    rep(i,0,n){
        ll a; cin>>a;
        que.push(a);
    }
    rep(i,0,m){
        ll tp=que.top();
        tp/=2;
        que.pop(); que.push(tp);
    }
    ll sum=0;
    while(!que.empty()){
        sum+=que.top();
        que.pop();
    }
    cout<<sum<<endl;
}

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

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

int main(){
  
  string S,ans;
  cin >> S;
  rep(i,S.size()){
    if(S[i]=='1'){
      ans +='1';
    }else if(S[i]=='0'){
      ans += '0';
    }else if(S[i]=='B'){
      if(ans.size()!=0){
	ans.pop_back();
      }
    }
  }
      cout << ans << endl;    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    ans += i % 2 == 1 && a % 2 == 1;
  }
  cout << ans << endl;
}

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

using namespace std;
const int N = 1e5 + 5;
char str[N];

int main() {
   // freopen("in.txt", "rt", stdin);
    // freopen("out.txt", "w", stdout);
    int n, k;
    scanf("%d %d", &n, &k);
    int r, b, s;
    scanf("%d %d %d", &r, &s, &b);
    scanf("%s", str);
    int ans = 0;
    set<int> st, dum;
    dum.insert('r');
    dum.insert('p');
    dum.insert('s');
    map<char, char> win;
    map<char, int> val;
    win['r'] = 'p';
    win['p'] = 's';
    win['s'] = 'r';
    val['r'] = r;
    val['s'] = s;
    val['p'] = b;
    for (int i = 0; str[i]; ++i) {
        st = dum;
        if (i >= k) st.erase(str[i - k]);
        char w = win[str[i]];
        if (st.find(w) != st.end()) {
            str[i] = w;
            ans += val[w];
            continue;
        }
        if(i+k<n){
            w = win[str[i+k]];
            st.erase(w);
            str[i]=*st.begin();
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 384