akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visited = true;
    for(int i = 0; i < N; ++i){
        if(visited[i] == false)
            all_visited = false;
    }
    if(all_visited){
        return 1;
    }

    int ret = 0;
    for(int i = 0; i < N; ++i){
        if(graph[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i,N,visited);
        visited[i] = false;
    }
    return ret;
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; ++i){
        int A, B;
        cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }
    bool visited[nmax];
    for(int i = 0; i < N; ++i){
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0,N,visited) << endl;
    return 0;
}


Measured memory_bytes: 256
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: a,b,c,k, x,y,z, aa,bb,cc
      
      read*,a,b,c
      read*,k
      
      do x = 0,k
        do y = 0,k
          do z = 0,k
            if( x+y+z>k ) cycle
            
            aa = a*(2**(x))
            bb = b*(2**(y))
            cc = c*(2**(z))
                        
            if( bb>aa .and. cc>bb )then
              print*,'Yes'
              stop
            end if
          end do
        end do
      end do
      
      print*,'No'
      
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

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

using namespace std;
int main(void){
    int n;
    cin >> n;
    
    int a, b;
    cin >> a >> b;
    
    int number_of_first = 0;
    int number_of_second = 0;
    int number_of_third = 0;
    
    for (int i = 0; i < n; i++){
        int p;
        cin >> p;
        
        if (p <= a) number_of_first++;
        else if (a+1 <= p && p <= b) number_of_second++;
        else number_of_third++;
    }
    
    int temp = min(number_of_first,number_of_second);
    int ans = min(temp,number_of_third);
    cout << ans << endl;
}


Measured memory_bytes: 3576
N = int(input())
steps = list(map(int, input().split()))

dp = [99999999] * N
dp[0] = 0
for i in range(1, N):
    a = abs(steps[i] - steps[i - 1]) + dp[i - 1]
    if i < 2:
        dp[i] = a
        continue
    b = abs(steps[i] - steps[i - 2]) + dp[i - 2]
    dp[i] = a if a <= b else b

print(dp[N - 1])


Measured memory_bytes: 84884
#include<bits/stdc++.h>
using namespace std;;
int main(){
  int N,jug=1;
  cin >> N;
  vector<int> su(N);
  for(int i=0;i<N;i++)cin >> su[i];
  sort(su.begin(),su.end());
  int L,K;
  L=su[N/2-1];
  K=su[N/2];
  if(L==K)cout << 0 << endl;
  else cout << K-L << endl;
}
 


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#define maxn 105
using namespace std;
int ans=50000000,n,a[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=-100;i<=100;i++)
	{
		int cnt=0;
		for(int j=1;j<=n;j++) cnt+=(a[j]-i)*(a[j]-i);
		ans=min(ans,cnt);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
/*
 * File Name:	F.cpp
 * Author	:	CraZYali
 * Time		:	2020.01.25 20:35
 * Email	:	yms-chenziyang@outlook.com
 */

#define DEP(i, s, e) for (register int i(s), end_##i(e); i >= end_##i; i--)
#define REP(i, s, e) for (register int i(s), end_##i(e); i <= end_##i; i++)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) (a < (b) ? a = (b) : a) 
#define chkmin(a, b) (a > (b) ? a = (b) : a) 

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
using namespace std;
const int maxn = 1000 + 10, maxm = 2e5 + 10;

vector <int> G[maxn];

template <typename T> inline T read()
{
	T ans(0), flag(1);
	char c(getchar());
	while (!isdigit(c))
	{
		if (c == '-') flag = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * flag;
}

#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout);

int n, m, u[maxm], v[maxm];

int q[maxn], head, tail;
bool vis[maxn];
void bfs(bool c[], int S)
{
	REP(i, 1, n) vis[i] = 0;
	vis[S] = c[S] = 1;
	q[head = tail = 0] = S;
	while (head <= tail)
	{
		int u = q[head++];
		for (auto v : G[u]) if (!vis[v])
		{
			vis[v] = c[v] = 1;
			q[++tail] = v;
		}
	}
}
pair <int, int> ban;
void bfs(bitset <maxn> &c, int S, int qaq = 0)
{
	vis[S] = c[S] = c[qaq] = 1;
	q[head = tail = 0] = qaq;
	while (head <= tail)
	{
		int u = q[head++];
		for (auto v : G[u])
			if (make_pair(u, v) == ban) break;
			else if (!vis[v])
			{
				vis[v] = c[v] = 1;
				q[++tail] = v;
			}
	}
}

bool c[maxn][maxn];
vector <bitset <maxn> > cp[maxn], cs[maxn];
int p[maxn];

int main()
{
#ifdef CraZYali
	file("F");
#endif
	n = read<int>();
	m = read<int>();
	REP(i, 1, m)
	{
		u[i] = read<int>();
		v[i] = read<int>();
		G[u[i]].emplace_back(v[i]);
	}
	REP(i, 1, n) bfs(c[i], i);
	REP(i, 1, n) if (G[i].size()) 
	{
		REP(j, 1, n) vis[j] = 0;
		int l = G[i].size();
		cp[i].resize(l);
		cs[i].resize(l);
		int lst = i;
		REP(j, 0, l - 1)
		{
			ban = make_pair(i, G[i][j]);
			bfs(cp[i][j], i, lst);
			lst = G[i][j];
			if (j) cp[i][j] |= cp[i][j-1];
		}
		reverse(G[i].begin(), G[i].end());
#ifdef CraZYali
		printf("start = %d\n", i);
		for (auto j : G[i]) printf("%d ", j);putchar(10);puts("");
#endif
		REP(j, 1, n) vis[j] = 0;
		lst = i;
		DEP(j, l - 1, 0)
		{
#ifdef CraZYali
			cout << i << ' ' << j << ' ' << G[i][l - j - 1] << endl;
#endif
			ban = make_pair(i, G[i][l - j - 1]);
			bfs(cs[i][j], i, lst);
			lst = G[i][l - j - 1];
			if (j < l - 1) cs[i][j] |= cs[i][j+1];
		}
#ifdef CraZYali
		reverse(G[i].begin(), G[i].end());
#endif
	}
	REP(i, 1, m)
	{
		int u = ::u[i], v = ::v[i];
		bool pback = c[v][u];
		bool pto = cp[u][p[u]][v] | cs[u][p[u]][v];
		if (pto == pback) puts("same");
		else puts("diff");
#ifdef CraZYali
		cerr << u << ' ' << v << ' ' << pback << ' ' << cp[u][p[u]][v] << ' ' << cs[u][p[u]][v] << endl;
#endif
		p[u]++;
	}
	return 0;
}


Measured memory_bytes: 55424
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
ll a[200005],mod=1e9+7;
int main(){
    ll n,sum=0,ans=0;cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i];sum+=a[i];
    }
    for(ll i=1;i<=n;i++){
        sum-=a[i];
        ans=(ans%mod+sum%mod*a[i]%mod)%mod;
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
#define MOD (int)1e9+7
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int get_median(vector<int> v){
    sort(ALL(v));
    if(v.size()%2==1){
        return v[v.size()/2];
    }else{
        return (v[v.size()/2-1]+v[v.size()/2])/2;
    }
}
int main(){
    int N;cin>>N;
    vector<int> A(N,0);
    REP(i,N) cin>>A[i];
    vector<int> c(N,0);
    REP(i,N) c[i] = A[i] - i;
    int  b = get_median(c);
    ll ans = 0;
    REP(i,N) ans += abs(c[i]-b);
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,i,a,max_a,min_a=INT_MAX;
inline void solve(){
  IN(N);
  REP(i,N){
    IN(a);
    chmax(max_a,a);
    chmin(min_a,a);
  }
  OUT(max_a-min_a);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
def main():
    s = input()
    t = input()

    r = [[-1] * 26 for _ in range(2)]

    bl = True
    for se, te in zip(s, t):
        si = ord(se) - ord("a")
        ti = ord(te) - ord("a")

        if r[0][si] < 0:
            r[0][si] = ti
        else:
            if r[0][si] != ti:
                bl = False
                break

        if r[1][ti] < 0:
            r[1][ti] = si
        else:
            if r[1][ti] != si:
                bl = False
                break

    print("Yes" if bl else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
using namespace std;
template <class T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;

int x,y,a,b,c,p,q,r[100005];
multiset<int> s1,s2;

int main()
{
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=1;i<=a;i++)
	{
		scanf("%d",&p);
		s1.insert(p);
		if(sz(s1)>x) s1.erase(s1.begin());
	}
	for(int i=1;i<=b;i++)
	{
		scanf("%d",&q);
		s2.insert(q);
		if(sz(s2)>y) s2.erase(s2.begin());
	}
	for(int i=1;i<=c;i++)
		scanf("%d",&r[i]);
	sort(r+1,r+c+1,greater<int>());
	for(int i=1;i<=c;i++)
	{
		if(r[i]<=*s1.begin()&&r[i]<=*s2.begin()) break;
		if(r[i]<=*s2.begin())
		{
			s1.erase(s1.begin());
			s1.insert(r[i]);
		}
		else if(r[i]<=*s1.begin())
		{
			s2.erase(s2.begin());
			s2.insert(r[i]);
		}
		else
		{
			int num1=*s1.begin(),num2=*s2.begin();
			if(num1<=num2)
			{
				s1.erase(s1.begin());
				s1.insert(r[i]);
			}
			else
			{
				s2.erase(s2.begin());
				s2.insert(r[i]);
			}
		}
	}
	ll ans=0;
	for(multiset<int>::iterator it=s1.begin();it!=s1.end();it++)
	{
		ll num=*it;
		ans+=num;
	}
	for(multiset<int>::iterator it=s2.begin();it!=s2.end();it++)
	{
		ll num=*it;
		ans+=num;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {
    int A, B, C; cin >> A >> B >> C;

    int sum, i;
    for (i=0; true; i++) {
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) break;
        if (A == B && B == C) {
            cout << -1 << endl;
            return 0;
        }
        sum = A+B+C;
        A = (sum - A) / 2;
        B = (sum - B) / 2;
        C = (sum - C) / 2;
    }

    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		double input_x1  = 0.0;
		double input_y1  = 0.0;
		double input_x2  = 0.0;
		double input_y2  = 0.0;
		
		double distance_p1p2  = 0.0;


		Scanner sc= new Scanner( System.in );

		input_x1 = sc.nextDouble();
		input_y1 = sc.nextDouble();
		input_x2 = sc.nextDouble();
		input_y2 = sc.nextDouble();

		distance_p1p2 = Math.sqrt( Math.pow( input_x2 - input_x1, 2 ) + Math.pow( input_y2 - input_y1, 2 )) ;

		System.out.println( distance_p1p2 );
		
		sc.close();
	}
}


Measured memory_bytes: 28024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
int main(){
    ll n,m,k;cin>>n>>m>>k;
    if(n*k<=m){
        cout<<k<<endl;
        return 0;
    }else{
        cout<<m/n<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
// Aizu Vol0 0026: Dropping Ink
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

#define MAX  14
#define MAX2 12

char paper[MAX+1][MAX+1];

int main()
{
	int x, y, size;
	int cnt, max, d;

	for (x = 0; x < MAX; x++) for (y = 0; y < MAX; y++) paper[x][y] = 0;

	while (scanf("%d,%d,%d", &x, &y, &size) == 3) {
		x += 2, y += 2;
		if (size >= 3) {
			paper[x - 2][y]++;
			paper[x + 2][y]++;
			paper[x]    [y - 2]++;
			paper[x]    [y + 2]++;
		}
		if (size >= 2) {
			paper[x - 1][y - 1]++;
			paper[x - 1][y + 1]++;
			paper[x + 1][y - 1]++;
			paper[x + 1][y + 1]++;
		}
		paper[x]    [y]++;
		paper[x - 1][y]++;
		paper[x + 1][y]++;
		paper[x]    [y - 1]++;
		paper[x]    [y + 1]++;
	}
	cnt = 0, max = 0;
	for (x = 2; x < MAX2; x++) for (y = 2; y < MAX2; y++) {
		d = paper[x][y];
		if (d == 0) cnt++;
		if (d > max) max = d;
	}
	printf("%d\n%d\n", cnt, max);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

int main(void)
{
	ll x, y; cin >> x >> y;

	ll ans = 0;
	if (x == 1)
		ans += 300000;
	if (x == 2)
		ans += 200000;
	if (x == 3)
		ans += 100000;


	if (y == 1)
		ans += 300000;
	if (y == 2)
		ans += 200000;
	if (y == 3)
		ans += 100000;


	if (x == 1 && y == 1)
		ans += 400000;

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
# 解説動画の通り
# 前の提出間違ってた...ACしたけど
import sys
from bisect import *
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def dfs(u):
        fin[u] = True
        for v, e in to[u]:
            if fin[v]: continue
            dfs(v)
            if xx[v]:
                ans.append(e + 1)
                xx[u] ^= 1

    n, m = MI()
    ab = [LI() for _ in range(n)]
    lr = [LI() for _ in range(m)]
    # (a,b)をaでソートして分ける
    # bは先頭と末尾に番兵の0を追加する（全部を0にするのが目標だから）
    aa = []
    bb = [0]
    for a, b in sorted(ab):
        aa.append(a)
        bb.append(b)
    bb.append(0)
    # print(aa)
    # print(bb)
    # bの差分列を作る
    xx = [b0 ^ b1 for b0, b1 in zip(bb, bb[1:])]
    # print(xx)
    # lrをxxのインデックスに対応させる
    lr = [(bisect_left(aa, l), bisect_right(aa, r)) for l, r in lr]
    # print(lr)
    # lrを辺、xxの要素を頂点としてグラフを作る
    to = defaultdict(list)
    for i, (l, r) in enumerate(lr):
        if l == r: continue
        to[l].append((r, i))
        to[r].append((l, i))
    # 各連結成分についてdfsする
    ans = []
    fin = [False] * (n + 1)
    for i in range(n + 1):
        if fin[i]: continue
        dfs(i)
        # 根が1のときは実現不可能なので-1を出力して終了
        if xx[i]:
            print(-1)
            exit()
    # 答えの出力
    ans.sort()
    print(len(ans))
    print(*ans)

main()


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<P> ps(m);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        ll p = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            p |= (1LL << c);
        }
        ps[i] = { a,p };
    }
    vector<vector<ll>> dp(2, vector<ll>(1LL << n, INF));
    dp[0][0] = 0;
    rep(i, m) {
        rep(j, 1LL << n) {
            chmin(dp[1][j], dp[0][j]);
            ll& t = dp[1][j | ps[i].second];
            chmin(t, dp[0][j] + ps[i].first);
        }
        swap(dp[0], dp[1]);
    }
    if (dp[0][(1LL << n) - 1] == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << dp[0][(1LL << n) - 1] << endl;
    return 0;
}


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

int A = 10;
	int B = 11;
	int C = 12;
	int D = 13;
	int E = 14;
	int F = 15;

int main() {	
	
	char x,y; cin >>x>>y;
	int a,b;
	
	if (x=='A') a = 10;
	if (x=='B') a = 11;
	if (x=='C') a = 12;
	if (x=='D') a = 13;
	if (x=='E') a = 14;
	if (x=='F') a = 15;
	
	if (y=='A') b = 10;
	if (y=='B') b = 11;
	if (y=='C') b = 12;
	if (y=='D') b = 13;
	if (y=='E') b = 14;
	if (y=='F') b = 15;
	
	if (a < b) cout << "<";
	if (a > b) cout << ">";
	if (a == b) cout << "=";
   
   return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d;
    cin>>n>>d;
    int a=n/((2*d)+1);
    if(n%((2*d)+1)==0)
        cout<<a<<endl;
    else
        cout<<a+1<<endl;
    return 0;



return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
long long zxgbs(long long x,long long y)  
{     
    int z=y;  
    while(x%y!=0)  
    {  
        z=x%y;  
        x=y;  
        y=z;    
    }  
    return z;  
} 

long long  GetCount(long long a,long long b,long long c)
{
	long long count = 0;
	if(a%c==0)
	{
		count++;
		count += ((b-a))/c; 
	} 
	else
	{
		count += (a%c+(b-a))/c;		
	}

	return count;
}
 
int main()
{
	long long a,b,c,d,ans=0;
	cin>>a>>b>>c>>d;
	
	ans = b-a+1 - GetCount(a,b,c)-GetCount(a,b,d) + GetCount(a,b,c*d/zxgbs(c,d));
//cout<<__gcd(c,d);	
//cout<<GetCount(a,b,c);
//cout<<GetCount(a,b,d);

	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
while 1:
    N = int(input())
    if N == 0:
        break
    S = [list(map(int, input().split())) for i in range(N)]
    B = {max(S[i][j] for i in range(N)) for j in range(N)} & {min(S[i][j] for j in range(N)) for i in range(N)}
    if B:
        e, = B
        print(e)
    else:
        print(0)


Measured memory_bytes: 5600
import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt
    var min = Int.MaxValue
    var max = Int.MinValue
    for (i <- 0 until n) {
      val value = readInt
      if (value - min > max ) max = value - min
      if (value < min) min = value
    }
    println(max)
  }
}



Measured memory_bytes: 62320
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
const int inf=0x3f3f3f;
const int mod=1e9+7;

int main()
{
	int x;
	cin>>x;
	for (int i=1;i<=360;i++)
	if (i*x%360==0)
	{
		cout<<i<<endl;
		return 0;
	}
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var ab = Input.ar;
        if (ab[0] + ab[1] == 15) WriteLine("+");
        else if (ab[0] * ab[1] == 15) WriteLine("*");
        else WriteLine("x");
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public static long numL => ToInt64(read);
    public static char[][] gred(int h)
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public static string[] Make<T1, T2>(out T1 v1, out T2 v2)
    {
        var r = read.Split(' ');
        v1 = getValue<T1>(r[0]);
        v2 = getValue<T2>(r[1]);
        return r;
    }
    public static string[] Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3)
    {
        var r = Make(out v1, out v2);
        v3 = getValue<T3>(r[2]);
        return r;
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public const int MOD = 1000000007;
}


Measured memory_bytes: 13396
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();
        int[] a = new int[N];
        for(int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        boolean[] lose = new boolean[K+1];
        for(int k = 0; k < a[0]; k++) {
            lose[k] = true;
        }
        for(int k = a[0]; k < K+1; k++) {
            for(int i = 0; i < N; i++) {
                int next = k - a[i];
                if(next >= 0) {
                    if (lose[next]) {
                        lose[k] = false;
                        break;
                    }
                }
                lose[k] = true;
            }
        }
        if(lose[K]) {
            System.out.println("Second");
        } else {
            System.out.println("First");
        }
    }
}

Measured memory_bytes: 23380
def main():
    import itertools
    n = int(input())
    d = list(map(int,input().split()))
    d.sort()
    ans = [0]
    for i in range(n):
        if d[i]==0:
            ans.append(0)
        elif i%2==0:
            ans.append(24-d[i])
        else:
            ans.append(d[i])
    ans.sort()
    A = float('inf')
    for i in range(1,len(ans)):
        if A>min(ans[i]-ans[i-1],24-(ans[i]-ans[i-1])):
            A = min(ans[i]-ans[i-1],24-(ans[i]-ans[i-1]))
    if min(ans[-1]-ans[0],24-(ans[-1]-ans[0]))<A:
        A = min(ans[-1]-ans[0],24-(ans[-1]-ans[0]))
    print(A)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9128
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N, M; cin >> N >> M;
    vector<bool> AC(N);
    vector<int> WA(N);

    for (int i = 0; i < M; i++) {
        int p; string s; cin >> p >> s; p--;
        if (s == "AC") AC[p] = true;
        else {
            if (!AC[p]) WA[p]++;
        }
    }

    int AC_sum = accumulate(AC.begin(), AC.end(), 0);
    int WA_sum = 0;
    for (int i = 0; i < N; i++) {
        if (AC[i]) WA_sum += WA[i];
    }

    cout << AC_sum << endl;
    cout << WA_sum << endl;
}


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

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "NO\n"; return;}
#define yes {cout << "YES\n"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 1e6 + 7, MOD = 1e9 + 7;

int f[N] = { 1 }, rf[N] = { 1 };

int binpow(int x, int d) {
    int ans = 1;
    while (d) {
        if (d & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        d >>= 1;
    }
    return ans;
}

int binom(int n, int k) {
    return f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

void solve() {
    loop1(i, N - 1) {
        f[i] = f[i - 1] * i % MOD;
        rf[i] = binpow(f[i], MOD - 2);
    }
    int n, m;
    cin >> n >> m;
    int ans = 0;
    loop(i, n + 1)
        ans = (ans + binom(n, i) * f[m - i] % MOD * rf[m - n] % MOD * (i % 2 ? -1 : 1) + MOD) % MOD;
    cout << ans * f[m] % MOD * rf[m - n] % MOD;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


Measured memory_bytes: 19240
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

set<int> T, H;

main(){
	int i,j,n,m,sumt,sumh,s,diff;
	while(cin>>n>>m, n){
		sumt = 0;sumh = 0;
		T.clear();
		H.clear();
		for(i=0;i<n;i++){
			cin >> s;
			T.insert(s);
			sumt += s;
		}
		for(i=0;i<m;i++){
			cin >> s;
			H.insert(s);
			sumh += s;
		}
		diff = sumh - sumt;
		if(diff%2) cout << -1 << endl;
		else{
			diff/=2;
			set<int>::iterator it = T.begin();
			for(;it!=T.end();it++){
				if(H.find(*it + diff) != H.end()) break;
			}
			if(it!=T.end()) cout << *it << ' ' << *it + diff << endl;
			else cout << -1 << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;

#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}

int main(){
        string s; cin >> s;
        string ans = "";
        FOR(i, 0, s.size()){
            if(s[i] == 'B'){
                if(ans.size()) ans.ppb();
            }
            else ans += s[i];
        }
        cout << ans << endl;

    return 0;
}

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

int main()
{
  int a[3];
  int res=0;

  rep(i,3) cin >> a[i];

  sort(a,a+3);

  res = a[2]*10 + a[1]+a[0];

  cout << res << endl;
}

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

using namespace std;

#define ARRAY_SIZE 200000
uint32_t array[ARRAY_SIZE];

static uint32_t iright = (ARRAY_SIZE / 2);
static uint32_t ileft = (ARRAY_SIZE / 2) - 1;

int32_t main()
{
  uint32_t num;
  cin >> num;

  uint8_t dir = 0;
  for (uint32_t i = 0; i < num; i++) {
    uint32_t val;
    cin >> val;
    if (!dir) {
      array[iright] = val;
      iright++;
    } else {
      array[ileft] = val;
      ileft--;
    }
    dir = !dir;
  }

  for (uint32_t i = 0; i < num; i++) {
    uint32_t index;
    if ((num % 2) == 0) {
      ileft++;
      index = ileft;
    } else {
      iright--;
      index = iright;
    }
    cout << array[index];
    if (i != (num - 1)) cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3072
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Ord

main = C.interact $ put . sol . get

get = unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.pack . show

sol (x:_:ps) = minimumBy (comparing ev) $ filter (`notElem` ps) [-101..101]
  where
  ev i = (abs(i-x), i)

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

int main() {
  int n;
  cin >> n;
  long long ans;
  ans = 1;
  int i=1;
  while(i <= n){
    ans = (ans * i)%1000000007;
    i++;
  }
  ans = ans % 1000000007;
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	int n, m, i;
	long long sum = 0;
	scanf("%d%d",&n, &m);
	priority_queue<int> q;
	for (i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		q.push(x);
	}
	while (m--)
	{
		int x = q.top();
		q.pop();
		q.push(x / 2);
	}
	while (!q.empty())
	{
		sum += q.top();
		q.pop();
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3940
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt();
			int[] xt = new int[N];
			int[] yt = new int[N];
			int[] vt = new int[N];
			int[] xb = new int[M];
			int[] yb = new int[M];
			for (int i = 0; i < N; ++i) {
				xt[i] = sc.nextInt();
				yt[i] = sc.nextInt();
				vt[i] = sc.nextInt();
			}
			for (int i = 0; i < M; ++i) {
				xb[i] = sc.nextInt();
				yb[i] = sc.nextInt();
			}
			double[][] time = new double[M][N];
			for (int i = 0; i < M; ++i) {
				for (int j = 0; j < N; ++j) {
					time[i][j] = Math.sqrt((xb[i] - xt[j]) * (xb[i] - xt[j]) + (yb[i] - yt[j]) * (yb[i] - yt[j])) / vt[j];
				}
			}
			double lo = 0;
			double hi = 15000;
			while (hi - lo > 1e-9) {
				double mid = (lo + hi) / 2;
				BiMatching bm = new BiMatching(M, N);
				for (int i = 0; i < M; ++i) {
					for (int j = 0; j < N; ++j) {
						if (time[i][j] <= mid) {
							bm.addEdge(i, j);
						}
					}
				}
				if (bm.matching() == M) {
					hi = mid;
				} else {
					lo = mid;
				}
			}
			System.out.printf("%.8f\n", hi);
		}
	}

	static class BiMatching {
		ArrayList<ArrayList<Integer>> left = new ArrayList<ArrayList<Integer>>();
		ArrayList<ArrayList<Integer>> right = new ArrayList<ArrayList<Integer>>();
		int[] l2r, r2l;

		BiMatching(int n, int m) {
			l2r = new int[n];
			r2l = new int[m];
			Arrays.fill(l2r, -1);
			Arrays.fill(r2l, -1);
			for (int i = 0; i < n; ++i) {
				left.add(new ArrayList<Integer>());
			}
			for (int i = 0; i < m; ++i) {
				right.add(new ArrayList<Integer>());
			}
		}

		void addEdge(int ln, int rn) {
			left.get(ln).add(rn);
			right.get(rn).add(ln);
		}

		int matching() {
			int res = 0;
			for (int i = 0; i < left.size(); ++i) {
				if (l2r[i] != -1) continue;
				boolean[] visited = new boolean[right.size()];
				for (int j = 0; j < left.get(i).size(); ++j) {
					if (dfs(left.get(i).get(j), visited)) {
						l2r[i] = left.get(i).get(j);
						r2l[left.get(i).get(j)] = i;
						++res;
						break;
					}
				}
			}
			return res;
		}

		boolean dfs(int rn, boolean[] visited) {
			int l = r2l[rn];
			if (l == -1) {
				return true;
			}
			visited[rn] = true;
			for (int i = 0; i < left.get(l).size(); ++i) {
				int r = left.get(l).get(i);
				if (visited[r]) continue;
				if (dfs(r, visited)) {
					r2l[r] = l;
					l2r[l] = r;
					return true;
				}
			}
			return false;
		}
	}

}

Measured memory_bytes: 61260
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000000

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

  int n; cin >> n;
  vector< vector<int> > f(n, vector<int>(n, MAX));
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int v, c; cin >> v >> c;
      f[u][v] = c;
    }
  }

  vector<int> d(n,MAX);
  vector<bool> used(n, false);
  d[0] = 0;
  while(true){
    int t = -1;
    for(int i = 0; i < n; i++){
      if(!used[i] && (t == -1 || d[t] > d[i])) t = i;
    }
    if(t == -1) break;
    used[t] = true;

    for(int i = 0; i < n; i++){
      d[i] = min(d[i], d[t] + f[t][i]);
    }
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
n = int(input())
a = [int(i) for i in input().split()]

count = 0
for i in range(n):
  if a[i] % 2 == 0:
    if a[i]%3==0 or a[i]%5==0:
      continue
    else:
      count += 1
      break
      
if count == 0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def argsort(li, key=None, reverse=False):
    return [i for _, i in sorted(
        [(a, i) for i, a in enumerate(li)], key=(lambda t: key(t[0])) if key else None, reverse=reverse
    )]


N, M = list(map(int, sys.stdin.buffer.readline().split()))
D = list(map(int, sys.stdin.buffer.readline().split()))
VU = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N)]

for i, (v, u) in enumerate(VU):
    v -= 1
    u -= 1
    graph[v].append(u)
    graph[u].append(v)

edges = {}
colors = [None] * N
for v in argsort(D):
    d = D[v]
    if colors[v] is not None:
        continue
    for u in graph[v]:
        if colors[u] is not None:
            edges[v, u] = d
            colors[v] = not colors[u]
            break
        if D[u] == d:
            edges[v, u] = d
            colors[v] = True
            colors[u] = False
            break
    if colors[u] is None:
        print(-1)
        exit()
S = ''
for c in colors:
    S += 'B' if c else 'W'
ans = []
for v, u in VU:
    v -= 1
    u -= 1
    if (v, u) in edges:
        ans.append(edges[v, u])
    elif (u, v) in edges:
        ans.append(edges[u, v])
    else:
        ans.append(10 ** 9)

print(S)
print(*ans, sep='\n')


Measured memory_bytes: 102312
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,M;
    cin >> N >> M;
    pair<ll,ll> req[M];
    ll val[N];
    for (int i = 0; i < N; ++i) {
        val[i] = -1;
    }
    for (int i = 0; i < M; ++i) {
        ll s,c;
        cin >> s >> c;
        req[i] = make_pair(s,c);
    }
    for (int i = 0; i < M; ++i) {
        if(req[i].first == 1 && req[i].second == 0){
            if(N == 1){
                cout << 0 << endl;
            }else{
                cout << -1 << endl;
            }
            return 0;
        }
        if(val[req[i].first-1] != -1){
            if(val[req[i].first-1] != req[i].second){
                cout << -1 << endl;
                return 0;
            }
        }
        val[req[i].first-1] = req[i].second;
    }
    for (int i = 0; i < N; ++i) {
        if(val[i] == -1){
            if(i == 0){
                if(N == 1){
                    cout << 0;
                }else{
                    cout << 1;
                }
            }else{
                cout << 0;
            }
        }else{
            cout << val[i];
        }
    }
    cout << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int s = sqrt(n);
		pln(s * s);
	}

	int sqrt(int n) {
		return (int) Math.sqrt(n);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


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

int main(void)
{
    string str;
    getline(cin, str);
    for (int i = 0; i < str.length(); ++i) {
        char c = str[i];
        if ('A' <= c && c <= 'Z')
            c = (c - 'A') + 'a';
        else if ('a' <= c && c <= 'z')
            c = (c - 'a') + 'A';
        cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int a[3][3];
    zero(a);
    int s[101];
    zero(s);
    rep(i,0,3)
    {
        rep(j,0,3)
        {
            cin>>a[i][j];
        }
    }

    int n;
    cin>>n;

    rep(i,0,n)
    {
        int x;
        cin>>x;

        s[x] = 1;
    }
    int found = 0;
    rep(i,0,3)
    {
        if ( (s[a[i][0]] == 1) && (s[a[i][1]] == 1) && (s[a[i][2]] == 1) )
        {
            found = 1;
            break;
        }

        if ( (s[a[0][i]] == 1) && (s[a[1][i]] == 1) && (s[a[2][i]] == 1) )
        {
            found = 1;
            break;
        }
    }

    if ( s[a[0][0]] == 1 && s[a[1][1]] == 1 && s[a[2][2]] == 1 )
    {
        found = 1;
    }

    if ( s[a[2][0]] == 1 && s[a[1][1]] == 1 && s[a[0][2]] == 1 )
    {
        found = 1;
    }

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

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in();
    vec a(n+1),b(n+1),c(n+1);
    rep(i,n){
        int x=in();
        a[i+1]=x;
        if(1 <= i+1-x && i+1-x <= n)b[i+1-x]++;
    }
    ll ans=0;
    rep(i,n){
        if(1 <= i+1+a[i+1] && i+1+a[i+1] <= n){
            ans+=b[i+1+a[i+1]];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5644
/// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
    ninput = input[0].split(" ");
   
    var n = parseInt(ninput[0], 10);
    var ss = [];var tt = [];
    
    for (var f = 1; f <= n; f++) {
         sinput = input[f].split(" ");
    //  sinput = input[f].trim().split(" ");
    
          var s= sinput[0];
          var t= parseInt(sinput[1],10);
     //   console.log(s);
               ss[f-1] = s;
   //    console.log(ss);
               tt[f-1] = t;
        }
     //     console.log(ss);
      //    console.log(tt);
   
          var x =input[f];
      //    console.log(x);
       //  var ttt = tt[0]+tt[1]+tt[2];
  //console.log(ttt);

 
 
//配列内に「イチゴ」が存在するかを検索する
var cnt = ss.indexOf( x );
 
//console.log( cnt );
var r =0;
for(p = cnt+1;p<n;p++){r = r + tt[p];
          //   console.log(r);
            }
 
    console.log(r)
  
   
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 
 
 
 
 

 

Measured memory_bytes: 9420
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }

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


	ll N, M;
	cin >> N >> M;

	vll L(M), R(M);

	rep(i, M) {
		cin >> L[i] >> R[i];
	}


	ll min = *min_element(R.begin(), R.end());
	ll max = *max_element(L.begin(), L.end());


	ll ret = min - max + 1;
	if (ret < 0)ret = 0;

	cout << ret << endl;



	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;


int main(){
    vector<int> x(5);
    rep(i,5){
        cin >> x[i];
    }

    int ans = 0;
    rep(i, 5){
        if (x[i] == 0){
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

int N, Q, l, r, s[100001];
string S;

int main() {
	cin >> N >> Q >> S;
	for (int i = 0; i < N - 1; ++i) {
		if (S[i] == 'A'&&S[i + 1] == 'C') {
			++s[i + 2];
		}
	}
	for (int i = 0; i < N; ++i) {
		s[i + 1] += s[i];
	}
	for (int i = 0; i < Q; ++i) {
		cin >> l >> r;
		cout << s[r] - s[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/python3
# abc059_b

"""
Comparison
"""

def main():
    """
    大小の判定
    """

    A = int(input())
    B = int(input())
    if A > B:
        print('GREATER')
    elif A < B:
        print('LESS')
    else:
        print('EQUAL')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940