akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int mod=1e9+7;
int n,k,cnt=0;
int head[maxn];
struct node{
    int v,nxt;
}t[2*maxn];
void add(int u,int v){
    t[++cnt].v=v;
    t[cnt].nxt=head[u];
    head[u]=cnt;
}
int dfs(int u,int fa,int m){
    if(m==0)return 0;
    int st=(u==1?k-1:k-2);
    int ans=1;
    for(int x=head[u];x;x=t[x].nxt){
    int v=t[x].v;

    if(v!=fa){
        ans=(1ll*ans*dfs(v,u,st))%mod;
        if(ans==0)return 0;
        st--;
    }

    }
    ans = 1ll*ans*m%mod;
    return ans;
}

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

    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }

    printf("%d\n",dfs(1,0,k));

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int k,a,b;
    cin>>k>>a>>b;
    REP(i,a,b+1){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

//a=97,z=122

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

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());

  cout << (a[0] - a[1]) + (a[1] - a[2]) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if(A>=D||B<=C)
	{
		printf("0");
	}
	else if(A<=C&&D<=B)
	{
		printf("%d",(D-C));
	}
	else if(C<=A&&B<=D)
	{
		printf("%d",(B-A));
	}
	else if(A<=C&&C<=B&&B<=D)
	{
		printf("%d",(B-C));
	}
	else if(C<=A&&A<=D&&D<=B)
	{
		printf("%d",(D-A));
	}
	return 0;
	}

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

void fib(string s)
{
    string h ="";
    for(int lp1=0;lp1<s.length();lp1++)
    {   
       if(s[lp1]!='B'){h=h+s[lp1];}
       else if(s[lp1]=='B')
       {
           if(h.length()==0){}
           else{h.erase(h.size()-1);}
       }
    }
    cout << h << endl;
}

int main() {
    
    string k;
    cin >> k;
    fib(k);

}

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

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

  ll r = 0;
  for (ll z = 2; z * z <= n; z++) {
    ll x = 0;
    while (n % z == 0) {
      n /= z;
      x++;
    }
    for (ll i = 1; i <= x; i++) {
      r++;
      x -= i;
    }
  }
  if (n > 1) r++;

  cout << r << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,K;
int a[101];
ll dp[101][101][256];
ll fact[101];

int main(void){
	scanf("%d%d",&n,&K);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	fact[0]=1;
	for(ll i=1;i<=n;i++){
		fact[i]=(ll)fact[i-1]*i%MOD;
	}
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			for(int k=0;k<256;k++){
				//if(i<5 && dp[i][j][k]>0)printf("%d %d %d %lld\n",i,j,k,dp[i][j][k]);
				dp[i+1][j][k]+=dp[i][j][k];
				dp[i+1][j][k]%=MOD;
				dp[i+1][j+1][k^a[i]]+=dp[i][j][k];
				dp[i+1][j+1][k^a[i]]%=MOD;
			}
		}
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		ans+=fact[i]*dp[n][i][K]%MOD;
		ans%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


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

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

    int n, m;
    cin >> n >> m;
    long long cnt = ((n - m) * 100 + m * 1900) * (1 << m);
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  ll sum = 0;

  ll minv = LONG_LONG_MAX;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    sum += tmp;
    if (tmp % 10 != 0) minv = min(minv, tmp);
  }

  ll ans = sum;
  if (sum % 10 == 0) {
    if(minv != LONG_LONG_MAX){
      ans = sum - minv;      
    } else {
      ans = 0;
    }
  }
  cout << ans << endl;

  return 0;
}


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

//?????????
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //???????????????????????????????????????????????????
std::ifstream ifs("data.txt");
#define put ifs >>
#else //?????£????????????????????§?????????????????????
#define put cin >>
#endif
#pragma endregion
//???????????°??????????????´
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef????????????????????????????¶????????????§?????????
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//??????????????°(???????????????????????§??????)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

int main() {
	int n; put n;
	int m; put m;
	int dp[21][50001];
	vi c; c.resize(m);
	rep(i, m) put c[i];	
	fill(*dp, *dp + 21 * 50001, INF);
	dp[0][0] = 0;
	rep(i, m) {
		dp[i+1][0] = 0;
		rep(j, n+1) {
			if (j - c[i] < 0) {
				dp[i + 1][j] = dp[i][j];
				continue;
			}
			dp[i+1][j] = min(dp[i][j],dp[i+1][j - c[i]]+1);
		}
	}
	ll ans = 0;

	cout << dp[m][n] << endl;
END:
	return 0;
}

Measured memory_bytes: 7176
#include <stdio.h>

int commondividor(int a, int b){
    int gcd, cd;
    if (a == b) return a;
    for(cd = 1; cd < b / 2; cd++){
        if(a % cd == 0 && b % cd == 0) gcd = cd;
    }
    return gcd;
}

int main(void)
{
    int a, b;
    int gcd;

    scanf("%d%d", &a, &b);
    if(a >= b) printf("%d\n", commondividor(a, b));
    else printf("%d\n", commondividor(b, a));
    return (0);
}


Measured memory_bytes: 2100
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)

	l := make([]int, N)
	r := make([]int, N)
	lc, rc := 0, 0
	for i := 0; i < N; i++ {
		if S[i] == 'W' {
			lc++
		}
		if S[(N-1)-i] == 'E' {
			rc++
		}
		l[i] = lc
		r[(N-1)-i] = rc
	}

	ans := N
	for i := 0; i < N; i++ {
		lc, rc := 0, 0
		if i > 0 {
			lc = l[i-1]
		}
		if i < N-1 {
			rc = r[i+1]
		}
		c := lc + rc
		if c < ans {
			ans = c
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
int main(){
    int n;cin>>n;
    string s; cin>>s;
    ll ans=0;
    vector<int> r(n+1),g(n+1),b(n+1);
    vector<int> right,left;
    char l1,r1;
    rep(i,n){
        r[i+1]=r[i];
        g[i+1]=g[i];
        b[i+1]=b[i];
        if(s[i]=='R'){
            r[i+1]+=1;
        }
        if(s[i]=='G'){
            g[i+1]+=1;
        }
        if(s[i]=='B'){
            b[i+1]+=1;
        }
    }
    //rep(i,n+1)cout<<g[i];cout<<endl;
    REP(i,1,n-1){
        if(s[i]=='R'){
            right=g;
            left=b;
            r1='G';
            l1='B';
        }
        if(s[i]=='G'){
            right=r;
            left=b;
            r1='R';
            l1='B';
        }
        if(s[i]=='B'){
            right=g;
            left=r;
            r1='G';
            l1='R';
        }
        ans+=right[i]*(left[n]-left[i+1]);
        ans+=left[i]*(right[n]-right[i+1]);
        //cout<<right[i]<<" "<<left[n]<<endl;
        rep(j,n){
            if(i-j<0 ||n<i+j){
                break;
            }
            else if((s[i+j]==r1 &&s[i-j]==l1)||(s[i+j]==l1 &&s[i-j]==r1)){
                ans--;
            }
        }
    }
    cout<<ans<<endl;
}

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

from collections import deque

q = deque()
for i in range(len(a)):
    if i & 1:
        q.appendleft(a[i])
    else:
        q.append(a[i])

q = list(q)
if len(q) & 1:
    q = reversed(q)

print(*q)


Measured memory_bytes: 26180
#include<iostream>
#include<algorithm>
using namespace std;
const int mod = 1e9 + 7;
typedef long long LL;
LL f[900015], r[900015];
LL th[900015];
LL inv(LL a) {
	LL ans = 1;
	LL b = mod - 2;
	while (b) {
		if (b % 2) ans = ans * a % mod;
		a = a * a % mod;
		b /= 2;
	}
	return ans;
}
LL C(int a, int b) {
	return f[a] * r[b] % mod * r[a - b] % mod;
}
int main() {
	f[0] = r[0] = th[0] = 1;
	for (int i = 1; i <= 900010; i++) {
		f[i] = f[i - 1] * i % mod;
		r[i] = inv(f[i]);
		th[i] = th[i - 1] * 3 % mod;
	}
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	LL ans = 0, sum = 1, ll = 0, rr = 0;
	for (int i = 0; i <= m + k; i++) {
		int l = max(0, i - k), r = min(i, m);
		if (ll < l) sum = (sum - C(i, ll) + mod) % mod, ll++;
		if (rr > r) sum = (sum - C(i, rr) + mod) % mod, rr--;

		LL res = C(i + n - 1, n - 1) * th[n + m + k - i - n] % mod * sum % mod;
		ans = (ans + res) % mod;

		sum = sum * 2 % mod;
		if (ll != 0) sum = (sum + C(i, ll - 1)) % mod;
		if (rr != i) sum = (sum + C(i, rr + 1)) % mod;
		rr++;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 21376
import java.util.*;

class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a <= 2 * b) {
            if (c % 1000 != 0) {
                if (c % 1000 <= 500 && b <= a) {
                    System.out.println(a * (c / 1000) + b);
                } else {
                    System.out.println(a * (c / 1000) + a);
                }
            } else {
                System.out.println(a * (c / 1000));
            }
        } else {
            if (c % 500 == 0) {
                System.out.println(c / 500 * b);
            } else {
                System.out.println(c / 500 * b + b);
            }
        }
    }
}



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

int main() {
  int N;
  cin >> N;
  int ans=1;
  for (int i=2; i*i<N; i++) {
    for (int j=i; j<=N; j*=i) {
      ans=max(ans,j);
    }
  }
  cout << ans << "\n";
}


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

if N == 1
    if A == 1 && B == 1
        print 1
    else
        print -1
    end

elsif N == 2
    if A == 2 && B == 1
        print '1 2'
    elsif A == 1 && B == 2
        print '2 1'
    else
        print -1
    end

# 1 2 3 4 5 ...
elsif B == 1
    if A == N
        print (1..N).to_a.join(' ')
    else
        print -1
    end

#####   middle = 3, wide = 13
#####
###
#
#
elsif A + B - 1 <= N && N <= A * B 
    stairs = Array.new(B){Array.new()}
    middle = (N - A + B - 2) / (B - 1)
    wide = N - A + middle
    wide.times do |i|
        stairs[i % B].unshift(N - i)
    end
    stairs[0] = (1..(N - wide)).to_a + stairs[0]
    result = []
    stairs.each_with_index do |stair, i|
        print (i > 0 ? ' ' : ''), stair.join(' ')
    end

else
    print -1 
end


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n],s=0,c1=0,c2=0;
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    s+=a[i];
	}
	s=s/n;
	for(int i=0;i<n;i++)
	{
	    c1+=(a[i]-s)*(a[i]-s);
	    c2+=(a[i]-s-1)*(a[i]-s-1);
	}
	c2<c1?cout<<c2:cout<<c1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF (long)1e10
#define MAX 50
typedef long long ll;
typedef pair<ll, ll> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z


int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int n, m;
    cin >> n >> m;
    P students[MAX];
    P checkpoints[MAX];
    rep(n, i) scanf("%lld%lld\n", &students[i].first, &students[i].second);
    rep(m, i) scanf("%lld%lld\n", &checkpoints[i].first, &checkpoints[i].second);
    rep(n, i){
        ll man_len_min = INF;
        int index = 0;
        rep(m, j) {
            ll man_len = abs(checkpoints[j].first - students[i].first) + abs(checkpoints[j].second - students[i].second);
            if (man_len_min > man_len) {
                man_len_min = man_len;
                index = j;
            }
        }
        cout << index+1 << '\n';
    }
}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

#define ll long long

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;
string s;

signed main()
{
	IOS;
	cin >> n >> s;
	int cur = s[0], cnt = 1;
	for (int i = 1; i < (int)s.size(); i++) {
		if (cur != s[i]) {
			cnt++;
			cur = s[i];
		}
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short

#define pb push_back

#define fst first
#define snd second
#define mp make_pair

#define MOD 1000000007
#define all(v) (v).begin(),(v).end()
#define frl(i,n) for(long long i=0;i<n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << "\n"
#define displayvec(vec) cout<<#vec<<": "; for(auto vd : vec) cout<<vd<<" "; cout<<"\n"

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

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) is >> v[i];
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) os << v[i] << " ";
  os << endl;
  return os;
}

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector< vector< ll > > a(n + 2, vector< ll > (3));
    vector< vector< ll > > dp(n + 2, vector< ll > (3));

    for(ll i = 1; i <= n; ++i){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }

    for(ll i = 1; i <= n; ++i){
        for(ll state = 0; state < 3; ++state){
            ll maxres = 0;
            for(ll other = 0; other < 3; ++other){
                if(other == state) continue;
                maxres = max(maxres, dp[i-1][other]);
            }
            dp[i][state] = maxres + a[i][state];
        }
    }

    ll ans = 0;

    for(auto &i : dp){
        for(auto j : i)
            ans = max(ans, j);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 14264
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;

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

	switch (n%10)
	{
	case 3:
		cout << "bon" << endl;
		break;

	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	default:
		cout << "hon" << endl;
		break;
	}

}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */
signed main() 
{
  int k,s;
  cin>>k>>s;
  int cnt=0;
  REP0(x,k) REP0(y,k)
  {
    int z=s-x-y;
    if(k>=z&&z>=0) cnt++;
  }
  print(cnt);

  return 0;
}

Measured memory_bytes: 384
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  const int N = 55556;
  vector<int> is_p(N, 1);
  for (int i = 2; i < N; i++) {
    if (is_p[i]) {
      for (int j = i * i; j < N; j += i) {
        is_p[j] = 0;
      }
    }
  }
  vector<int> v;
  for (int i = 11; i < N; i += 10) {
    if (is_p[i]) v.push_back(i);
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}



Measured memory_bytes: 768
def resolve():
    S = input()
    N = len(S)
    s1 = S[:(N-1)//2]
    s2 = S[((N+3)//2-1):]

    if S == S[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
        return print("Yes")
    else:
        return print("No")

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
using System;

namespace Transfer
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input =  Console.ReadLine().Split(' ');

            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            

            int result = c-(a-b);

            if(result < 0)
            {
                result = 0;
            }

            Console.WriteLine(result);

        }
    }
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	long long n;
	cin>>n;
	long long ara[n];
	for(long long i=0;i<n;i++) cin>>ara[i];
	long long mx1,mx2,x,y;
	if(ara[0]>ara[1]) mx1=ara[0],mx2=ara[1],x=0,y=1;
	else mx1=ara[1],mx2=ara[0],x=1,y=0;
	for(long long i=2;i<n;i++)
	{
		if(ara[i]>mx1)
		{
			mx2=mx1;
			mx1=ara[i];
			y=x;
			x=i;
		}
		else if(ara[i]>mx2)
		{
			mx2=ara[i];
			y=i;
		}
	}
	
	for(long long i=0;i<n;i++)
	{
		if(i==x) cout<<mx2;
		else cout<<mx1;
		cout<<" ";
	}
	return 0;
}


Measured memory_bytes: 3200
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
def dfs(v, cost, xy):
  if len(v)==0:
    return cost
  x1, y1 = xy
  res = 0
  for i, v_ in enumerate(v):
    x2, y2 = v_
    res += dfs(v[:i]+v[i+1:], cost+((x1-x2)**2 + (y1-y2)**2)**0.5, v_)
  return res

res = 0
p = 1
for i, xy_ in enumerate(xy):
  res += dfs(xy[:i]+xy[i+1:], 0, xy_)
  p *= (i+1)
print(res/p)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=100+2,M=5e3+5,INF=1e9,mod=924844033;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
short n,m,ex,ey,a[N][N],sum[N][N],f[N][N][N][N],ub,db,lb,rb;
char s[N][N];
il short getsum(short x1,short x2,short y1,short y2){
	x1=max(x1,ub);x2=min(x2,db);
	y1=max(y1,lb);y2=min(y2,rb);
	if(x1>x2||y1>y2)return 0;
	return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];
}
#define gmx(a,b) a=(a>b)?a:b;
int main(){cin>>n>>m;
	rep(i,1,n){
		scanf("%s",s[i]+1);
		rep(j,1,m){
			sum[i][j]=(s[i][j]=='o')+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			if(s[i][j]=='E')ex=i,ey=j;
		}
	}
	rep(u,0,ex-1)rep(d,0,n-ex)rep(l,0,ey-1)rep(r,0,m-ey){
		short u1=ex-u,d1=ex+d,l1=ey-l,r1=ey+r;
		ub=1+d,db=n-u,lb=1+r,rb=m-l;
		//printf("%d %d %d %d %d\n",u,d,l,r,f[u][d][l][r]);
		if(u1!=1)gmx(f[u+1][d][l][r],f[u][d][l][r]+getsum(u1-1,u1-1,l1,r1));
		if(d1!=n)gmx(f[u][d+1][l][r],f[u][d][l][r]+getsum(d1+1,d1+1,l1,r1));
		if(l1!=1)gmx(f[u][d][l+1][r],f[u][d][l][r]+getsum(u1,d1,l1-1,l1-1));
		if(r1!=m)gmx(f[u][d][l][r+1],f[u][d][l][r]+getsum(u1,d1,r1+1,r1+1));
	}
	cout<<f[ex-1][n-ex][ey-1][m-ey];
}

Measured memory_bytes: 203008
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int x,y,ans=1;
signed main(){
    cin>>x>>y;
    while(x<y){
        x*=2;
        if(x<=y)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,M,A[1000],i,j,k;

double R;

int main()
{
cin>> R;

R*=2.*3.14159265;

cout <<R;








}

Measured memory_bytes: 3784
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
struct node
{
	string s;
	int p,id;
}a[105];
int n;
bool cmp(node x,node y)
{
	if (x.s!=y.s)
	   return x.s<y.s;
	return x.p>y.p;
}
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	 {
		 cin>>a[i].s>>a[i].p;
		 a[i].id=i;
	 }
	 sort(a+1,a+n+1,cmp);
	 for (int i=1;i<=n;i++)
	    cout<<a[i].id<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
int main()
{
	int s=0;
    scanf("%lld",&n);
    for(int i=sqrt(n);i>0;--i)
    {
        if(n%i==0)
		{
            ans=n/i;
            while(ans>0)
			{ 
        		++s;
        		ans/=10;
    		}
    		printf("%d",s); 
    		return 0;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 105;
const int MAXV = 205;
const LL INF = (LL)1e18+5;

struct Dinic {
    struct Edge {
        int to, rev;
        LL cap;
    };

    int V, cur[MAXV], vis[MAXV], lv[MAXV];
    vector<Edge> G[MAXV];

    void init(int _V) {
        V = _V;
        for (int i = 0; i < V; i++) {
            G[i].clear();
        }
    }

    void add_edge(int from, int to, LL cap) {
        int id1 = G[from].size(), id2 = G[to].size();
        G[from].push_back({to, id2, cap});
        G[to].push_back({from, id1, 0});
    }

    bool bfs(int s, int t) {
        // cout << "BFS\n";
        for (int i = 0; i < V; i++) {
            cur[i] = 0;
            lv[i] = -1;
        }

        queue<int> q;
        q.push(s);
        lv[s] = 0;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (Edge &e : G[v]) {
                if (e.cap > 0 && lv[e.to] == -1) {
                    q.push(e.to);
                    lv[e.to] = lv[v] + 1;
                }
            }
        }

        return lv[t] != -1;
    }

    LL dfs(int v, int t, LL cur_flow) {
        // cout << "DFS " << v << "\n";
        vis[v] = true;
        if (v == t) return cur_flow;
        for (int &i = cur[v]; i < G[v].size(); i++) {
            Edge &e = G[v][i];
            if (vis[e.to] || e.cap <= 0) continue;
            LL f = dfs(e.to, t, min(cur_flow, e.cap));
            if (f > 0) {
                e.cap -= f;
                G[e.to][e.rev].cap += f;
                return f;
            }
        }
        return 0;
    }

    LL max_flow(int s, int t) {
        LL ans = 0;
        while (bfs(s, t)) {
            LL add = 0;
            do {
                for (int i = 0; i < V; i++) {
                    vis[i] = false;
                }
                add = dfs(s, t, INF);
                ans += add;
            }
            while (add != 0);
        }
        return ans;
    }
} algo;

LL a[MAXN];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    int N;
    cin >> N;

    int s = 0, t = N + 1;
    LL ans = 0;
    algo.init(t + 1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            algo.add_edge(i, t, -a[i]);
        }
        else {
            algo.add_edge(s, i, a[i]);
            ans += a[i];
        }
        for (int j = i + i; j <= N; j += i) {
            algo.add_edge(j, i, INF);
        }
    }

    cout << ans - algo.max_flow(s, t) << "\n";
}


Measured memory_bytes: 256
N = int(input())
s = []; t = []
for i in range(N):
    s_tmp, t_tmp = input().split()
    s.append(str(s_tmp))
    t.append(int(t_tmp))
X = str(input())

start = s.index(X)
ans = 0
if start < N - 1:
    ans = sum(t[start + 1:])
print(ans)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
		cout << "Yes";
	}
	else
		cout << "No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc .nextLong();
        long max = n - 1L;
        long result = 0;

        for (long i = 1L; i < n; i++) {
            long tempMax = max / i;
            result = result + tempMax;
        }

        System.out.println(result);

    }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
using namespace std;
#define Fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define m 1000000007
int dp[1005][1005];


int32_t main()
{	
	Fast_IO
	#ifdef __WIN32 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w",stdout);
	#endif
	int r,c;
	cin>>r>>c;
	vector<vector<char>> grid(r,vector<char>(c));
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>grid[i][j];
			if(grid[i][j]=='#')
				dp[i][j]=-1;
		}
	}
	for(int i=0;i<r;i++){
		if(grid[i][0]=='#')
			break;
		dp[i][0]=1;
	}
	for(int i=0;i<c;i++){
		if(grid[0][i]=='#')
			break;
		dp[0][i]=1;
	}
	for(int i=1;i<r;i++){
		for(int j=1;j<c;j++){
			if(grid[i][j]=='#')
				continue;
			dp[i][j]=(max(dp[i-1][j],0) + max(dp[i][j-1],0))%m;


		}
	}
	// for(int i=0;i<r;i++){
	// 	for(int j=0;j<c;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";	
	// }
	cout<<dp[r-1][c-1];
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
string s;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>s>>m;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if(s[i]!='1' || (i+1)==m)
        {
            cout<<s[i]<<"\n";
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int a; 
  string op;
	int b;
     cin >> a >> op >> b;  
 

  if (op == "+")
  {cout << a+b << endl;}
	else if (op == "-")
	{cout << a-b << endl;}






  }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin >> s;
	if (s[5] == '0'){
		if (s[6] - '0' <= 4){
			cout << "Heisei" << endl;
		}else{
			cout << "TBD" << endl;
		}
		return 0;
	}
	cout << "TBD" << endl;
	return 0;
 }

Measured memory_bytes: 256
#include <stdio.h>
int n,G[101][101];
int d[101];
int T = 0;
int F[101] = {0};
int k = 0;

void visit(int u) {
  int i,j,v;
  T++;  
  d[u] = T;

  for(v=0;v<n;v++) {
    if(G[u][v] == 1 && d[v] == 0 ) {
      visit(v);
    }
  }
  
  T++;
  F[u] = T;

}

int main() {
  
  
  int i,j,k,l,u,a,t;

  for(i=0;i<n;i++) d[i] = 0;

  scanf("%d",&n);

  for(i=0;i<n+1;i++)
    for(j=0;j<n+1;j++) {
      G[i][j] = 0;

    }

  for(i=0;i<n;i++){

    scanf("%d %d ",&k,&u);
    //    printf("u = %d\n",u);

    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k -1][a-1] = 1;
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
  for(i=0;i<n;i++) {
    if(d[i] == 0) 
    visit (i);
  }
    
  for(i=0;i<n;i++) {
    printf("%d %d %d\n",i+1,d[i],F[i]);
  }
  return 0;

    
    
}



Measured memory_bytes: 2740
#include<cstdio>
#include<algorithm>
using namespace std;

const int INF=1000000000;

int main(){
	int a,b;
	int s[5002],t[5002];
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",&s[i]);
	}
	for(int i=0;i<b;i++){
		scanf("%d",&t[i]);
	}

	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;

	int ret=0;
	for(int i=0;i<b-ret;i++){
		int p=0,q=i;
		int cnt=0;
		while(1){
			if(s[p]==t[q]){
				if(p>=memo[q])break;
				cnt++;
				p++;
				q++;
			}
			else {
				p++;
			}
			if(p==a){
				ret=max(ret,cnt);
				break;
			}
		}
	}

	printf("%d\n",ret);
}

Measured memory_bytes: 1084
# -*- coding: utf-8 -*-

import sys
import os

N = int(input())

for i in range(N):
    a, b = map(int, input().split())
    if a < b:
        lst = [j for j in range(a, b+1)]
        print(*lst)

    # a > b
    else:
        # easy
        if a <= 5:
            lst = list(range(a, b - 1, -1))
        elif b <= 5:
            lst = list(range(a, 10)) + list(range(5, b - 1, -1))

        # i.e. 7 -> 6
        else:
            lst = [j for j in range(a, 9 + 1)] + [j for j in range(5, 0, -1)] + list(range(0, b+1))
        print(*lst)

Measured memory_bytes: 7660
#include<stdio.h>
#define N 10

void swap(int *a , int *b) {
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void sort(int ary[N]) {
	int i , s;
	for(i = 0; i < N - 1; i++) {
		for(s = i + 1; s < N; s++) {
			if (ary[i] < ary[s]) {
				swap(&ary[i] , &ary[s]);
			}
		}
	}
}

int main () {
	int heights[N];
	int i;
	for(i = 0; i < N; i++) {
		scanf("%d" , &heights[i]);
	}
	sort(heights);
	for(i = 0; i < 3; i++) {
		printf("%d\n" , heights[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
	int n = 3;
	vii a(3, vi(3));
	rep (i, 3) {
		rep (j, 3) {
			cin >> a[i][j];
		}
	}

	int m;
	cin >> m;
	while (m--) {
		int x;
		cin >> x;
		rep (i, 3) {
			rep (j, 3) {
				if (a[i][j] == x) {
					a[i][j] = -1;
				}
			}
		}
	}
	
	rep (i, 3) {
		bool flag = true;
		rep (j, 3) {
			if (a[i][j] != -1) flag = false;
		}
		if (flag) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	rep (j, 3) {
		bool flag = true;
		rep (i, 3) {
			if (a[i][j] != -1) flag = false;
		}
		if (flag) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	bool flag = true;
	rep (i, 3) {
		if (a[i][i] != -1) flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
		return 0;
	}
	flag = true;
	rep (i, 3) {
		if (a[i][2 - i] != -1) flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cctype>

#define MAX 32
using namespace std;

class MCXI{
	string s;
	int N,m,c,x,i;
public:
	MCXI():N(0),m(0),c(0),x(0),i(0){}
	MCXI(const char *s){
		unsigned int len = strlen(s);
		this->N = 0;
		
		for(unsigned int i = 0; i < len; ++i){
			int dig = 1;
			if( isdigit( s[i] ) ){
				dig = s[i] - '0';
				++i;
			}
			switch( s[i] ){
				case 'm':
					this->N += dig * 1000;
					this->m = dig;
					break;
				case 'c':
					this->N += dig * 100;
					this->c = dig;
					break;
				case 'x':
					this->N += dig * 10;
					this->x = dig;
					break;
				case 'i':
					this->N += dig;
					this->i = dig;
					break;
			}
		}
	}
	MCXI operator+(const MCXI &b){
		MCXI c;
		c.N = this->N + b.N;
		c.Conv();
		return c;
	}
	const char *to_string(){
		if( m > 1 ) s += m+'0'; if( m > 0 ) s+='m';
		if( c > 1 ) s += c+'0'; if( c > 0 ) s+='c';
		if( x > 1 ) s += x+'0'; if( x > 0 ) s+='x';
		if( i > 1 ) s += i+'0'; if( i > 0 ) s+='i';
		return s.c_str();
	}
private:
	void Conv(){
		int tmp = this->N;
		this->m = tmp / 1000;
		tmp -= this->m * 1000;
		this->c = tmp / 100;
		tmp -= this->c * 100;
		this->x = tmp / 10;
		tmp -= this->x * 10;
		this->i = tmp;
	}
};
int main(){
	int n;

	scanf("%d",&n);
	for(int d=0;d<n;++d){
		char a[MAX], b[MAX];
		scanf("%s%s", a, b);
		MCXI mcxiA(a), mcxiB(b), mcxiC;
		mcxiC = mcxiA + mcxiB;
		printf("%s\n", mcxiC.to_string());
	}
	return 0;
}

Measured memory_bytes: 0
w,h,n = map(int, input().split())
xya = [list(map(int,input().split())) for _ in range(n)]
X = [0,w]
Y = [0,h]
for x,y,a in xya:
    if a == 1 and X[0] < x: X[0] = x
    elif a == 2 and X[1] > x: X[1] = x
    elif a == 3 and Y[0] < y: Y[0] = y
    elif a == 4 and Y[1] > y: Y[1] = y
h, w = Y[1]-Y[0], X[1]-X[0]
print(0 if h<0 or w<0 else h*w)

Measured memory_bytes: 3064
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))
print("%d\n" % len(ans), *ans)


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

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N= 1e5+1;
 
typedef long long ll;
typedef long double ld;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
} 
ll inv(ll x){
    return binpow(x,MOD-2,MOD);
}
ll binomialCoeff(ll n, ll k)  
{  
    ll res = 1,i;  
      if ( k > n - k )  
        k = n - k;  
    ll fact[k+1];
    fact[0] = 1;
    f(i,1,k+1){
        fact[i] = fact[i-1]*i;
        fact[i] = fact[i]%MOD;
    }
    for (i = 0; i < k; ++i)  
    {  
        res =(res*(n - i)%MOD)%MOD;  
    }  
    res = res*inv(fact[k]);  
    return res%MOD;  
} 
void test_case()
{
    ll n,a,b,i,j;
    cin>>n>>a>>b;
    ll x=binpow(2,n,MOD);
    x=(x+MOD+MOD+MOD+MOD-1-binomialCoeff(n,a)-binomialCoeff(n,b))%MOD;
    cout<<x<<'\n';

}
int main()
{
   IOS();
   
   test_case();
   return 0;
}



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

int main() {
	int n,m;
	cin>>n>>m;
	long long a,ans=0;
	for(int i=0;i<m;i++){
		cin>>a;
		ans=ans+a;
	}
	if(n-ans<0){
		cout<<-1<<endl;
	}else{
		cout<<n-ans<<endl;
	}
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	ll K,S,ans=0;
	cin>>K>>S;
	reg(i,0,K){
		reg(j,0,K){
			if(0<=S-i-j && S-i-j<=K)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>graph[100001];
vector<int>dp(100001,-1);

int solve(int temp)
{
	if(dp[temp]!=-1)
		return dp[temp];
	int ans=0;
	for(int i=0;i<graph[temp].size();i++)
	{
		ans=max(ans,solve(graph[temp][i])+1);	
	}
	return dp[temp]=ans;	
	
	
	
}
int main()
{
	int n,m;
	cin>>n>>m;

	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		graph[x].push_back(y);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,solve(i));
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 8192
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    char[] S = sc.next().toCharArray();
    int score = 0;
    for (int i = 0; i < N-1; i++) {
      if (S[i] == S[i+1]) {
        score++;
      }
    }
    int ans = Math.min(N-1, score+2*K);
    System.out.println(ans);
  }
}

Measured memory_bytes: 27732
n, k = map(int, input().split())
s = list(map(int, list(str(input()))))
c = 0
ran = [0,0]
for i in range(n):
    if s[c] == s[i]:
        ran[-1] += 1
    else:
        ran.append(i+1)
        c = i
result = []
for i in range(1, len(ran)):
    if s[ran[i-1]] == 1:
        result.append(ran[min(i+2*k,len(ran)-1)]-ran[i-1])
    else:
        result.append(ran[min(i+2*k-1, len(ran)-1)]-ran[i-1])
print(max(result))

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

int main()
{
    int n, a = 0;
    int a_array[21];
    int b_array[21];
    int c_array[21];

    scanf("%d", &n);

    for (int i = 1; i<=n; i++)
    {
        scanf("%d", &a_array[i]);
    }

    for (int i = 1; i<=n; i++)
    {
        scanf("%d", &b_array[i]);
    }

    for (int i = 1; i<n; i++)
    {
        scanf("%d", &c_array[i]);
    }

    for (int i = 1; i<=n; i++)
    {
        a += b_array[a_array[i]];

        if (i == n)
            break;

        if ((a_array[i] + 1) == (a_array[i + 1]))
        {
            a += c_array[a_array[i]];
        }
    }

    printf("%d", a);

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end(), greater<int>());

    int bob_sum = 0;
    int alice_sum = 0;
    for (int i = 0; i < vec.size(); ++i) {
        if (i % 2 == 0) {
            alice_sum += vec.at(i);
            continue;
        }
        bob_sum += vec.at(i);
    }

    cout << alice_sum - bob_sum << endl;
}


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

int main(void)
{
	char X, Y;
	cin >> X >> Y;

	string ret = "=";
	if(X > Y)
		ret = ">";
	else if(X < Y)
		ret = "<";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  string S;
  int ans = 0;
  for(int i = 1; i <= N; i++){
    S = to_string(i);
    if(S.size() % 2 == 1)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   cin >> n;
   vector<int> v(n);
   vector<int> u(n);
   rep(i,n){
      cin >> v[i];
      u[i] = v[i];
   }
   int l,r;
   sort(v.begin(),v.end());
   l = v[v.size()/2-1]; r = v[v.size()/2];
   for (int i= 0;i < n;i++){
      if (u[i] <= l) cout << r << endl;
      else cout << l << endl;
   }

   
   return 0;
   
}



Measured memory_bytes: 3712
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a,b;
  cin >> a >> b;
 
  cout << (b-a)*(b-a+1)/2-b << endl;
}

Measured memory_bytes: 256