akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

bool ok = false;
map<ll,ll>mp;
void dfs(ll now, ll itr, vector<ll> A){
    /*
    if(now == res){
        ok = true;
    }else if(now > res){

    }else if(itr < A.size()){
        //select
        dfs(res, now+A[itr], itr+1, A);
        //not select
        dfs(res, now, itr+1, A);
    }
    */

    if(itr < A.size()){
        //select
        mp[now+A[itr]]++;
        dfs(now+A[itr], itr+1, A);
        //not select
        dfs(now, itr+1, A);
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;
    vector<long long> A(n);
    rep(i, n) cin >> A[i];
    ll q;
    cin >> q;
    vector<long long> m(q);
    rep(i, q) cin >> m[i];

    dfs(0, 0, A);
    rep(t,q){
        if(mp.count(m[t]) >=1){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }

}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+1000;
const ll INF=1e9+7;
inline ll read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll n,m,p;
char str[maxn];
int vis[maxn];
int main()
{
    scanf("%lld%lld%lld",&n,&m,&p);
    for(int i=1;i<=p;i++)
    {
        int x;
        scanf("%d",&x);
        vis[x]++;
    }
    for(int i=1;i<=n;i++) vis[i]=p-vis[i];
    for(int i=1;i<=n;i++)
    {
        int temp=m-vis[i];
        if(temp<=0) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    vector<int> vX(3);
    cin >> vX[0] >> vX[1] >> vX[2];
    sort(vX.begin(), vX.end());
    
    cout << vX[2]*10+vX[1]+vX[0] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    int n; cin >> n;
    map<string, int> mp;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s >> a[i];
        mp[s] = i;
    }
    string x; cin >> x;
    int idx = mp[x];
    int ans = 0;
    for (int i = idx + 1; i < n; ++i) {
        ans += a[i];
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007ll
using namespace std;

int main() {
	speed;
	int n, q, l, r;
	string s;
	cin >> n >> q >> s;
	vector<int>v(n), p(n);
	for (int i = 0; i < n - 1; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'C')
			v[i] = 1;
		p[i] = (i ? p[i - 1] : 0) + v[i];
	}
	for (int i = 0; i < q; ++i) {
		cin >> l >> r;
		--l, --r;
		cout << p[r - 1] - (l - 1 >= 0 ? p[l - 1] : 0) << '\n';
	}
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef vector<int> vi;

const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;

vector<int> bfs(int N, vector<vector<int> >& G, int s) {
	vector<int> d(N, INF); d[s] = 0;
	queue<int> q; q.push(s);
	while (q.size()) {
		int u = q.front(); q.pop();
		for (int v : G[u])
			if (d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				q.push(v);
			}
	}
	return d;
}

int main() {
	int N, M; cin >> N >> M;
	vector<vector<int> > G(N);
	while (M--) {
		int u, v; scanf("%d%d", &u, &v);
		u--, v--;
		G[u].pb(v), G[v].pb(u);
	}
	vector<int> d = bfs(N, G, 0);
	cout << (d[N - 1] == 2 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 13168
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
 
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
 
 
 
int main() {
    
    fastio;
    int n;
    cin >> n;
    vector<ll> x[n];
    rep(i, n)
    {
        rep(j, 3)
        {
            ll y;
            cin >> y;
            x[i].pb(y);
        }
    }
    
    ll dp[n][3];
    rep(i, 3)
    dp[0][i] = x[0][i];
    fr(i, 1, n-1)
    {
        dp[i][0] = x[i][0]+max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = x[i][1]+max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = x[i][2]+max(dp[i-1][1], dp[i-1][0]);
    }
    ll ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << ans;
    return 0; 
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

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

  ll ans = longinf;
  REP(p,0,100){
    ll tmp  = 0;
    rep(i,n){
      tmp += (a[i]-p)*(a[i]-p);
    }
    ans = min(ans, tmp);
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

#define MAX_V 50
int V;
struct edge{int to, cost;};
vector<edge> G[MAX_V];

void add_edge(int from, int to, int cost){
    G[from].push_back(edge({to, cost}));
}

void add_edge2(int v1, int v2, int cost){
    G[v1].push_back(edge({v2, cost}));
    G[v2].push_back(edge({v1, cost}));
}

int d[MAX_V];
void dijkstra(int s, int t){
    priority_queue<Pii, vector<Pii>, greater<Pii>> que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(Pii(0, s));

    while(!que.empty()){
        Pii p = que.top(); que.pop();
        int v = p.second;
        if(v == t) return;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(Pii(d[e.to], e.to));
            }
        }
    }
}

signed main(){

    int N, M;
    cin >> N >> M;
    V = N;
    vector<int> a(M), b(M);
    vector<Pii> number(M);
    REP(i, M){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(edge({b[i], 0}));
        G[b[i]].push_back(edge({a[i], 0}));
        number[i] = Pii(G[a[i]].size() - 1, G[b[i]].size() - 1);

    }

    int ans = 0;
    REP(i, M){
        int a1 = number[i].first;
        int b1 = number[i].second;
        G[a[i]][a1].cost = INF;
        G[b[i]][b1].cost = INF;

        int tmp = 0;
        dijkstra(0, -1);
        REP(i, N){
            if(d[i] > 0) tmp = 1;
        }
        ans += tmp;

        G[a[i]][a1].cost = 0;
        G[b[i]][b1].cost = 0;

    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 384
N = int(input())
T = []
for n in range(N):
    T.append(int(input()))


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


ans = 1
for t in T:
    ans = lcm(ans, t)

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

int search(int A[], int n, int key){
    int i=0;
    A[n] = key;
    while(A[i]!=key) i++;
    return i!=n;
}
int main(){
    int i, n, A[10000+1], q, key, sum=0;

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

    scanf("%d", &q);
    for(i=0; i<q;i++){
        scanf("%d", &key);
        if(search(A, n, key)) sum++;
    }
    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 2704
n,m= list(map(int, input().split()))
INF=1000000007

def fac(n):
    f=1
    for i in range(1,n+1):
        f*=i
        f%=INF
    return f

if abs(n-m)>=2:
    print(0)
elif n==m:
    print(2*fac(n)**2%INF)
else:
    print(fac(min(n,m))**2*max(n,m)%INF)

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

using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int result = 0;
  for (int i = 0; i < n - 2; i++) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int wlf[10001];
int main()
{
	int n;
	string str;
	cin >> n >> str;
	for(int i=0;i<4;i++)
	{
		wlf[0]=i&1;
		wlf[1]=(i>>1)&1;
		for(int j=2;j<n;j++)
		{
			wlf[j]=wlf[j-1]^wlf[j-2]^(str[j-1]=='x');
		}
		bool flg=true;
		for(int i=0;i<n;i++)
		{
			int le=(i-1+n)%n;
			int ri=(i+1+n)%n;
			if(wlf[ri]!=wlf[i]^wlf[le]^(str[i]=='x'))
			{
				flg=false;
				break;
			}
		}
		if(flg)
		{
			for(int i=0;i<n;i++)
			{
				if(wlf[i]) cout << 'W';
				else cout << 'S';
			}
			cout << endl;
			return 0;
		}
	}
	cout << "-1";
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

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

using namespace std;

int main() {
    string s; cin >> s;
    if (s == "A")
    {
        cout << "T" << endl;
    }
    else if (s == "C")
    {
        cout << "G" << endl;        
    }
    else if (s == "G")
    {
        cout << "C" << endl;
    }
    else if (s == "T")
    {
        cout << "A" << endl;
    }
    
    
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()


nn = (n*(n-1))//2
print(nn)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
char s[5];
int main()
{
	scanf("%s", s);
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == '7')
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

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

    int n = sc.nextInt();
    int k = sc.nextInt();

    int[] p = new int[n];
    for (int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
    }

    Arrays.sort(p);

    long ret = 0;
    for (int i = 0; i < k; i++) {
      ret += p[i];
    }

    System.out.println(ret);
  }
}


Measured memory_bytes: 38908
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> a(N);
    for(int i = 0; i < N; i++)
        cin >> a.at(i);

    sort(a.begin(), a.end());

    vector<int> ans(201);

    for(int i = 0; i <= 200; i++){
        for(int j = 0; j < N; j++){
            ans.at(i) += ((i-100) - a.at(j)) * ((i-100) - a.at(j));
        }
    }

    sort(ans.begin(), ans.end());

    cout << ans.at(0) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
d = {0:4}
for a in A:
    d[a] = d.get(a, 0)+1
longest = 0
for i in d:
    if d[i]>=2:
        longest = max(longest, i)
d[longest]-=2

longest_2nd = 0
for i in d:
    if d[i]>=2:
        longest_2nd = max(longest_2nd, i)
print(longest*longest_2nd)

Measured memory_bytes: 22088
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
mint dp[105][4][4][4];
/* function */
/* main */
int main(){
    int N;
    cin >> N;

    dp[0][3][3][3] = 1;
    for (int n = 0; n < N; n++) {
        for (int i = 0; i < 4; i++) {
            for(int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    if(dp[n][i][j][k].x == 0) continue;
                    for (int l = 0; l < 4; l++) {
                        if (j == 0 && k == 1 && l == 2) continue;
                        if (j == 0 && k == 2 && l == 1) continue;
                        if (j == 1 && k == 0 && l == 2) continue;
                        if (i == 0 && j == 1 && l == 2) continue;
                        if (i == 0 && k == 1 && l == 2) continue;
                        dp[n+1][j][k][l] += dp[n][i][j][k];
                    }
                }
            }
        }
    }
    mint ans = 0;
    for (int i = 0; i < 4; i++)
        for(int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                ans += dp[N][i][j][k];
    cout << ans << '\n';
}


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

def main():
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    L.insert(0, -1)

    D = 0
    count = 1
    for i in range(2, N+2):
        D = D + L[i-1]
        if D > X:
            pass
        else:
            count += 1
    print(count)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
# coding: utf-8
# Here your code !
N = int(input())
S =list(input())

slide = N % 26
ans = ""

for i in S:
    moji = (ord(i) + slide) % 91
    if moji < 65:
        moji += 65
    else:
        pass
    ans += chr(moji)
    
print(ans)





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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int power(int x , int y , int p) {
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
    // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}



int32_t main()
{   fastio;

    int n;
    cin>>n;

    int z = 0;
    if(n == 2) {
        cout<<-1;
        return 0;
    }

    for(int i=0; i <= (sint)1e6; i++) {
        z = (((7)*(power(10  , i , n))%n)+z%n)%n;
        if(z == 0) {
            cout<<i+1<<"\n";
            return 0;
        }
    }
    cout<<-1<<"\n";

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution(){
	ll n; cin >> n;
	ll ans = 0;
	for(int num = 1; num < n; num++){
		ans += (n-1)/num;
	}
	cout << ans << endl;


	

}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

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

int main()
{
    ll K, A, B;
    cin >> K >> A >> B;

    ll ans = 0;
    if (A+2 < B){
        ll t = A-1;
        ll cnt = (K-t)/2;
        ans += A;
        ans += cnt * (B-A);
        ans += (K-t)%2;
    }else{
        ans = K+1;
    }

    cout << ans << endl;

    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string s; cin >> s;
    i64 N = s.length();
    i64 n_blue = 0;
    REP(i, N) n_blue += s[i] - '0';

    cout << min(n_blue, N - n_blue) * 2 << endl;

    return 0;
}

Measured memory_bytes: 512
// SeeAlso: 
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
#define MAX 100000
#define NIL -1
#define MOD 1000000007
 
typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
 
#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
 
#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
 
int main() {
    string n;
    cin >> n;
    bool flag=false;
    rep(i, n.size()) {
        if(n[i]=='7') {
            flag = true;
            break;
        }
    }
    print(flag?"Yes":"No");
    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int n, m;
string arr[101];

bool compare(string d1, string d2){
	return d1.compare(d2) < 0;
}
int main(){
	int i;
	scanf("%d %d", &n, &m);
	for(i = 0; i < n; i++){
		cin >> arr[i];
	}
	sort(arr, arr + n, compare);
	for(i = 0; i < n; i++) cout << arr[i];
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define jxc 1000000007
#define MN 100010
int Fac[MN],Ifac[MN],Inv[MN],a[MN],f[MN];
int A(int x,int y){return ((x+y)%jxc+jxc)%jxc;}
int D(int x,int y){return ((x-y)%jxc+jxc)%jxc;}
int M(int x,int y){return ((1ll*x*y)%jxc+jxc)%jxc;}
int C(int x,int y){return x<y?0:M(Fac[x],M(Ifac[y],Ifac[x-y]));}
int P(int x,int y){
	int res=1;
	for(;y;y>>=1,x=M(x,x))if(y&1)res=M(res,x);
	return res;
}
int main(){
	Fac[0]=Inv[1]=Fac[1]=Ifac[1]=Ifac[0]=1;
	for(int i=2;i<=100005;++i){
		Fac[i]=M(Fac[i-1],i);
		Inv[i]=M(Inv[jxc%i],(jxc-jxc/i));
		Ifac[i]=M(Ifac[i-1],Inv[i]);
	}
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)scanf("%d",a+i);
	f[0]=1<<n;
	sort(a+1,a+m+1);
	for(int i=m;i;--i){
		for(int j=(1<<n)-1;j;--j){
			for(int k=0;k<n;++k){
				if(j&(1<<k)){
					f[j]=D(f[j],M(f[j-(1<<k)],M(C((1<<n)-a[i]-j+(1<<k),(1<<k)-1),Fac[1<<k])));
				}
			}
		}
	}int res=0;
	for(int i=0;i<1<<n;++i)res=A(res,M(f[i],Fac[(1<<n)-i-1]));
		cout<<res;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << endl;
}


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

int main(){
	string str;
	//int num;
	
	cin >> str;	
	if(str.at(0)=='a' || 
			str.at(0)=='i' || 
			str.at(0)=='u' || 
			str.at(0)=='e' || 
			str.at(0)=='o' ){
				cout << "vowel" << endl;
				
			}else{
				cout << "consonant" << endl;
				
			}
	return 0;
}

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

int main(){
	int Vetor[5];
	int Resultado[5];
	int Soma[5] ={0,0,0,0,0};
	for(int i = 0; i <5;i++){
		
		scanf("%d",&Vetor[i]);
	}
	
	for(int i = 0; i <5;i++){
		
		if(Vetor[i] %10 != 0){
			Resultado[i] = Vetor[i];
			while(Resultado[i]%10 != 0)
			{
				Resultado[i] = Resultado[i]+1;
				Soma[i]++;
			}
		}
		else
		{
			Resultado[i] = Vetor[i];
			Soma[i]=0;
		}
		
	}

	int Maior = 0;
	for(int i = 0; i<5;i++){
		
		if(Soma[i] >= Soma[Maior]){
			
			Maior= i;
		}
	
	}

	
	int SomaFinal=0;
	for(int i = 0; i <5;i++){
		
		if(i == Maior)
		{
			SomaFinal = Vetor[i] + SomaFinal;
		}
		else
		{
			SomaFinal = Resultado[i] +SomaFinal;
		}
	}
	printf("%d\n",SomaFinal);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int perm[9] = {};
int check[9] = {};
int perms[43021][9] = {{}};
int num = 0;

int permutation(int n, int p) {
    if (n == p) {
        for (int i = 1; i < n; i++) {
            perms[num][i] = perm[i];
        }
        num++;
        return 0;
    }
    for (int i = 1 ; i < n; i++) {
        if (check[i]) continue;
        perm[p] = i;
        check[i] = 1;
        permutation(n, p+1);
        check[i] = 0;
    }
}

int main(void) {
    int n, idx, j, a, b;
    scanf("%d", &n);
    int P[n+1]; int Q[n+1];
    a = 0; b = 0;
    P[0] = 0; Q[0] = 0;
    for (idx = 1; idx <= n; idx++) {
        scanf("%d", &P[idx]);
    }

    for (idx = 1; idx <= n; idx++) {
        scanf("%d", &Q[idx]);
    }

    permutation(n+1, 1);
    
    for (idx = 0; idx < num; idx++) {
        for (j = 1; j < n + 1; j++) {
            if (perms[idx][j] < P[j]) {
                a++;
                break;
            } else if (perms[idx][j] > P[j]) break;
        }

        for (j = 1; j < n + 1; j++) {
            if (perms[idx][j] < Q[j]) {
                b++;
                break;
            } else if (perms[idx][j] > Q[j]) break;
        }
    }

    printf("%d\n", abs(a-b));
    return 0;
}

Measured memory_bytes: 1536
int main(int argc, const char * argv[]) {
    char str[1000],a[1000],wiki[10],r;
    int count=0,i=0,x=0,y=0,j=0,z=0;
    scanf("%s",str);
    scanf("%d",&count);
    while(count--){
        scanf("%s %d %d",wiki,&x,&y);
        if(strcmp(wiki,"print")==0){
            for(j=x;j<=y;j++){
                printf("%c",str[j]);
            }
            printf("\n");
        }else if(strcmp(wiki,"reverse")==0){
            while(x<y){
                r = str[x];
                str[x] = str[y];
                str[y] = r;
                x++;
                y--;
            }
////            for(j=x;j<y;j++){
////                r=str[j];
////                str[j]=str[y-i];
////                str[y-i]=r;
////                i++;
//            }
        }else if(strcmp(wiki,"replace")==0){
            scanf("%s",a);
            z=0;
            for(j=x;j<=y;j++){
                str[x+z]=a[z];
                z++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 572
n,m=map(int,input().split())
path=[[] for i in range(n+1)]
anser=[0 for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  path[a].append(b)
  path[b].append(a)
nowlis=[1]
nowdone=1
anser[1]=1
while nowdone<n:
  now=nowlis.pop(0)
  done=path[now]
  for i in done:
    if anser[i]==0:
      anser[i]=now
      nowlis.append(i)
      nowdone+=1
  #print("anser",anser)
nuki=anser.pop(0)
nuku=anser.pop(0)
print("Yes")
for i in anser:
  print(i)
      
  



Measured memory_bytes: 34088
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.split.to!(int[]);
    sort!"a > b"(S);
    int[] NS;
    {
        int last, c;
        foreach (s; S) {
            if (s == last) {
                ++c;
            } else {
                if (c) NS ~= c;
                c = 1;
                last = s;
            }
        }
        NS ~= c;
    }

    int[19] ts;
    ts[N] = 1;
    int tt = 1;
    foreach (ns; NS) {
        auto c = ns;

        if (tt < c) {
            writeln("No");
            return;
        }

        int[19] ss;
        foreach_reverse (i, ref t; ts) if (t) {
            if (c == 0) break;
            auto d = min(c, t);
            c -= d;
            t -= d;
            tt = tt - d + i.to!int*d;
            foreach (ref s; ss[0..i]) s += d;
        }
        ts[] += ss[];
    }
    writeln("Yes");
}

Measured memory_bytes: 11416
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.a=[[t,f,r,l,b,u]]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d,n):
        self.a[n]=[self.a[n][i] for i in self.direction[d]]
n=int(input())
for i in range(n):
    if i==0:
        t, f, r, l, b, u = map(int, input().split())
        dice = Dice(t, f, r, l, b, u)
    else:
        a = list(map(int, input().split()))
        dice.a.append(a)
s='SSSWEEE'
w='YYYY'
try:
    for u in range(n - 1):
        for t in range(u + 1, n):
            for j in s:
                for r in w:
                    if dice.a[t] == dice.a[u]:
                        raise Exception
                    dice.roll(r, t)
                dice.roll(j, t)
    else:
        print('Yes')
except:
    print('No')


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

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            string data1 = Console.ReadLine();
            string[] data = Console.ReadLine().Split(' ');
            int n = int.Parse(data1);
            int least = int.Parse(data[0]);
            int ans = 0;

            var P = new List<int>();

            for (int i = 0; i < n; i++)
            {
                int Pi = int.Parse(data[i]);

                if (least >= Pi)
                {
                    ans++;
                    least = Pi;

                }
            }
            Console.WriteLine(ans);
            
        }
    }
}


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

int main(){
     int N;
     while(cin>>N,N){
	  int ans=0;
	  for(int i=1;i<1001;i++){
	       for(int j=i+1;j<1001;j++){
		    if(((i+j)*(j-i+1)/2)==N){
			 //cout<<i<<j<<endl;
			 ++ans;
		    }
	       }
	  }
	  cout<<ans<<endl;
     }
}

Measured memory_bytes: 864
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf 1000000000000000000
#define norm 0
#define mod 1000000007
#define IO                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
ll faspow(ll base, ll pow)
{
    if(pow==0)return 1;
    else if (pow ==1)return base;
    ll x=faspow(base,pow/2.0);
   x=(((x)%mod)*((x)%mod))%mod;
    if(pow%2)x*=(base%mod);
    x%=mod;
    return x;
}
ll inv(ll x)
{
    return faspow(x,mod-2);
}
/*void fill()
{
    fact[0]=1;
    invfact[0]=inv(fact[0]);
    for(int i=1;i<2050;i++)
    {
        fact[i]=((fact[i-1])*(i))%mod;
    }
}
ll ncr(ll n,ll r)
{
    ll a=fact[n],b=inv(fact[n-r]),c=inv(fact[r]);
    //cout<<a<<" "<<b<< " "<<c<<endl;
    return (a*b%mod*c%mod)%mod;
}
*/


int main()
{
    IO
    int n;
    cin>>n;
    vector<int >arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    vector<int >::iterator it;
    ll res=0;
    for(int i=0;i<n;i++)
    {
        for(int ii=i+1;ii<n;ii++)
        {
            ll mx=arr[i]+arr[ii];
            it=lower_bound(arr.begin(),arr.end(),mx);
            res+=(it-(arr.begin()+ii))-1;
        }
    }
    cout<<res<<endl;
    return 0;
}

/*


 1
11 4
66 152 7 89 42 28 222 69 10 54 99
 * */

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

using namespace std;

int probC();

int main()
{
//    uint64_t N;
//    cin >> N;

//    for(int N = 1; N < 100; N++){
////        ct(6);
//        int c = calc(N);
//        int d = ct(N);
//        if(c != d){
//            cout << N << "\t" << c << "\t" << d << endl;
//        }
////        cout << calc(N) << "\t" << ct(N) << endl;
//    }

    cout << probC();

    return 0;
}

int probC(){
    int a = 0, b = 0, ab = 0, c = 0;
    std::string line;
    while (getline(std::cin, line))
    {
        if(line.size() == 0)
            break;
        if(line.back() == 'A'){
            if(line.front() == 'B'){
                ab += 1;
            }else{
                a += 1;
            }
        }else{
            if(line.front() == 'B'){
                b += 1;
            }
        }
        int i = -1;
        while((i = line.find("AB", i + 1)) != string::npos)
            c++;
    }
    if(a == 0 && b == 0){
        return (ab > 1 ? ab - 1 : 0) + c;
    }else{
        return (a > b ? b : a) + ab + c;
    }
}


Measured memory_bytes: 256
/*
contest <- "AtCoder Grand Contest 009",
task <- "D - Uninity".
*/
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int NMAX = 100005;
const int KMAX = 30;
vector<int> G[NMAX];
template<typename Type>
void showContent(Type input)
{
	for(auto iterator=input.begin(); iterator!=input.end(); ++iterator)
	{
		cout<<(*iterator)<<", ";
	}
	return;
}
array<int, KMAX> dfs(int node, int prev) {
    array<int, KMAX> ret;
    fill(ret.begin(), ret.end(), 0);
    ret[0] = 1;
    for (int to: G[node]) {
        if (to != prev) {
            array<int, KMAX> son = dfs(to, node);
            //->
            //cout<<"Next Is Not Equal To Previous <- <- Next Is Not Equal To Previous"<<endl;
            /*
          	cout<<"Current point node <- "<<node<<", prev <- "<<prev<<", to <- "<<to<<endl;
            cout<<"son <- ";
            showContent(son);
            cout<<endl;
            */
    		//cout<<"Next Is Not Equal To Previous <- <- Next Is Not Equal To Previous"<<endl<<endl<<endl;
            //<-
            for (int i = 0; i < KMAX; ++i) {
                ret[i] += son[i];
            }
            //->
            /*
          	cout<<"ret <- ";
            showContent(ret);
            cout<<endl;
            cout<<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<endl;
			*/
			//<-
        }
    }
    for (int i = KMAX - 1; i >= 0; --i) {
    //for(int i=0; i<KMAX; ++i)
    //{
        if (ret[i] > 1) {
            fill(ret.begin(), ret.begin() + i + 1, 0);
            for (int j = i + 1; j < KMAX; ++j) {
                //->
                //cout<<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<endl;
                /*
              	cout<<"node <- "<<node<<", prev <- "<<prev<<endl;
                cout<<"i <- "<<i<<", j <- "<<j<<endl;
                */
                //cout<<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<endl;
                //<-
                if (ret[j] > 0) {
                    ret[j] = 0;
                } else {
                    ret[j] = 1;
                    break;
                }
            }
            break;
        }
    }
    //->
  	/*
  	cout<<"node <- "<<node<<", prev <- "<<prev<<endl;
    cout<<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<endl;
    */
    //<-
  	return ret;
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    array<int, KMAX> ans = dfs(1, -1);
    int fans = 0;
    for (int i = 0; i < KMAX; ++i) {
        if (ans[i] > 0) {
            fans = i;
        }
    }
    cout<<fans<<'\n';
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;

ll initial[5] = {};

void divide(string s){
    if(s[0] == 'M') initial[0]++;
    else if(s[0] == 'A') initial[1]++;
    else if(s[0] == 'R') initial[2]++;
    else if(s[0] == 'C') initial[3]++;
    else if(s[0] == 'H') initial[4]++;
  }

int main(){
  int n;
  ll ans = 0;

  cin >> n;
  string name[n];
  REP(i,n) cin >> name[i];

  REP(i,n) divide(name[i]);

  FOR(i,1,4){
    REP(j,i){
        FOR(k,(i+1),5){
            ans += (initial[i] * initial[j] * initial[k]);
          }
      }
  }
      cout << ans << endl;
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <string>


using namespace std;

vector<int> A;

int N;



int main()
{

	A = vector<int>(9,0);

	for (int i = 0;i<9; i++) {
		cin >> A[i];
	}

	cin >> N;

	for (int j = 0; j < N; j++) {
		int b;
		cin >> b;
		for (int i = 0; i < 9; i++) {
			if (A[i] == b) { A[i] = 0; }
		}

	}

	bool ans = (!A[0] && !A[1] && !A[2]);
	ans |= (!A[3] && !A[4] && !A[5]);
	ans |= (!A[6] && !A[7] && !A[8]);
	ans |= (!A[0] && !A[3] && !A[6]);
	ans |= (!A[1] && !A[4] && !A[7]);
	ans |= (!A[2] && !A[5] && !A[8]);
	ans |= (!A[0] && !A[4] && !A[8]);
	ans |= (!A[2] && !A[4] && !A[6]);



	cout << (ans ? "Yes":"No") << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define  ONLINE_JUDGE 1
int main()
{
	/*
	#ifdef ONLINE_JUDGE
	freopen("C:/Users/wyx/Desktop/Amy/wangyixuan/c++/test data/data.txt", "r",stdin);
	#endif
	*/
	/*---------------Begin code---------------*/
	int n;
	double m;
	cin>>n;
	m=2*n*3.1415926535898;
	cout<<m;
	/*---------------End  code----------------*/
	/*
	#ifdef ONLINE_JUDGE
	fclose(stdin);
	#endif
	system("pause");
	*/
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define N 2000050
#define M 200
#define int long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define clr(a) a.clear()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;
int mod = 1e9 + 7;
int n;
vector< pair< int , string> > ar;
int ne[N][26];
int dp[N][26];
int root = 0;
int cur = 1;
void add(string x){
    int tmp = root;
    int fr[26]={0};
    for(int i=0;i<x.length();i++)
        fr[x[i]-'a']++;
    for(int i=0;i<x.length();i++){
        for(int j=0;j<26;j++){
            if(fr[j])dp[tmp][j]++;
        }
        int f = x[i]-'a';
        fr[f]--;
        if(ne[tmp][f]==-1){
            ne[tmp][f] = cur++;
        }
        tmp = ne[tmp][f];
    }
}
int query(string s, int in){
    int tem = root;
    for(int i=0;i<s.length();i++){
        int f = s[i]-'a';
        if(ne[tem][f]==-1)return 0;
        tem = ne[tem][f] ;
    }
    return dp[tem][in];
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>n;
    ar.resize(n);
    for(int i=0;i<n;i++){
        cin>>ar[i].y;
        ar[i].x = ar[i].y.length();
    }
    //return 0;
    sort(all(ar));
    reverse(all(ar));
    memset(dp,0,sizeof(dp));
    memset(ne,-1,sizeof(ne));
    int ans = 0;
   // return 0;
    for(int i=0;i<n;i++){
        reverse(all(ar[i].y));
        string a ="";
        string d = "";
        d += ar[i].y;
        for(int j=0;j<d.length()-1;j++)
            a+= d[j];
        int v = d[d.length()-1]-'a';
      //  cout<<a<<" "<<v<<"\n";
        ans += query(a,v);
        add(ar[i].y);
    }
    cout<<ans;
    
	return 0;
}



Measured memory_bytes: 823372
#include<stdio.h>
int main(){
  int a[31],i,b;
  int mi1=0,mi2;
for(i=1;i<=28;i++){
    scanf("%d",&b);
    a[b]=1;
  }
 for(i=1;i<=30;i++){
   if(a[i]!=1&&mi1==0)mi2=i;
   if(a[i]!=1)mi1=i;
 }
   if(mi1<mi2)printf("%d\n%d\n",mi1,mi2);
   else printf("%d\n%d\n",mi2,mi1);
   return 0;
 }

Measured memory_bytes: 592
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
class Pair{
	public:
		int a,b;
	Pair(){a=0;b=0;}
	Pair(int _a,int _b){a=_a;b=_b;}
	bool operator <(const Pair&r)const{
		return a+b>r.a+r.b;
	}
	
};
int main(){
	int n;
	cin>>n;
	vector<Pair>p(n);
	int tmp1,tmp2;
	rep(i,n){
		cin>>tmp1>>tmp2;
		p[i].a=tmp1;
		p[i].b=tmp2;
	}
	sort(p.begin(),p.end());
	/*
	rep(i,n){
		cout<<p[i].a<<" "<<p[i].b<<" ";
		cout<<endl;
	}
	*/
	long long int sum=0;
	rep(i,n){
		if(i%2==0){
			sum+=p[i].a;
		}else{
			sum-=p[i].b;
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int* P;
	P = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}

	int X; //入れ替え
	int j, k;
	for (j = 0; j < N; j++) {
		for (k = j+1; k < N; k++) {
			if (P[j] > P[k]) {
				X = P[j];
				P[j] = P[k];
				P[k] = X;
			}
		}
	}

	int sum = 0;//最小金額
	for (int t = 0; t < K; t++) {
		sum += P[t];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3596
def gcd(a,b):
	while b:
		a, b = b, a % b
	return a
a,b,c,d=map(int,input().split())
n=b-a+1
dc=(a%c==0)*1
dd=(a%d==0)*1
div_c=b//c-a//c+dc
div_d=b//d-a//d+dd
lcm=(c*d)//gcd(c,d)
dcd=(a%lcm==0)*1
div_cd=b//lcm-a//lcm+dcd
print(n-div_c-div_d+div_cd)

Measured memory_bytes: 3064
N = int(input())
WR = input()

i = 0
j = len(WR) - 1

num = 0

while(i < j):
  if(WR[j] == "R"):
    if(WR[i] == "W"):
      num += 1
      i += 1
      j -= 1
    else:
      i += 1
  else:
    j -= 1

print(num)
      





Measured memory_bytes: 9424
import java.util.Scanner;

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

        char[] alphabet = new char[26];
        char a = 'a';
        for (int i = 0; i < 26; i++) alphabet[i] = a++;
        
        String s = String.valueOf(alphabet);
        
        System.out.println(alphabet[s.indexOf(c)+1]);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=105;
const int M=100050;
ll dp[N][M],w[N],v[N];
int main()
{
for(int i=0;i<N;i++)
for(int j=0;j<M;j++)
dp[i][j]=1e18;
dp[0][0]=0;
int n,W;
scanf("%i %i",&n,&W);
for(int i=1;i<=n;i++)
scanf("%lld %lld",&w[i],&v[i]);
for(int i=1;i<=n;i++)
for(int j=0;j<M;j++)
dp[i][j]=min(dp[i-1][j],j>=v[i]?dp[i-1][j-v[i]]+w[i]:(ll)1e18);
int ans=0;
for(int i=0;i<M;i++)
if(dp[n][i]<=W)
ans=i;
printf("%i",ans);
return 0;
}

Measured memory_bytes: 82304
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>
#include <list>
#include <stack>

using namespace std;


typedef int INT;
#define int long long

INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n;
	cin >> n;
	vector <pair <int, int> > a(n);
	for (int i = 0; i < n; i++)
	{
		int b;
		cin >> b;
		a[i] = { b, i };
	}
	sort(a.begin(), a.end());

	int m = n / 2 - 1;
	vector <int> c(n);
	for (int i = 0; i < n; i++)
	{
		if (i <= m)
			c[a[i].second] = a[m + 1].first;
		else
			c[a[i].second] = a[m].first;
	}
	for (int i = 0; i < n; i++)
		cout << c[i] << endl;


	return 0;
}

Measured memory_bytes: 6912