akhauriyash/Code-Regression huggingface dataset:
//
//AtCoder Beginner Contest 152
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<vector<ll>> tbl(10, vector<ll>(10,0));
    REP(i,n){
        ll top = i+1;
        ll btm = top%10;
        while(top/10!=0){
            top /= 10;
        }
        tbl[top][btm]++;
    }

    ll ans = 0;
    FOR(i,1,9)FOR(j,1,9){
        ans += tbl[i][j] * tbl[j][i];
    }

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


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

int main() {
	int dy[31] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	int a,b;
	cin >> a >> b;
	if(dy[a] == b)
		cout << "1";
	else
		cout << "0";
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()

    def make(S0, S1) -> str:
        rec = S0+S1
        for i in range(1, N-1):
            if S[i] == "o" and rec[i] == "S":
                rec = rec + rec[i-1]
            elif S[i] == "o" and rec[i] == "W":
                if rec[i-1] == "S":
                    rec = rec + "W"
                else:
                    rec = rec + "S"
            elif S[i] == "x" and rec[i] == "S":
                if rec[i-1] == "S":
                    rec = rec + "W"
                else:
                    rec = rec + "S"
            elif S[i] == "x" and rec[i] == "W":
                rec = rec + rec[i-1]

        return rec

    def checker(rec) -> bool:
        for i in range(N-1):
            if S[i] == "o" and rec[i] == "S":
                if rec[i-1] != rec[i+1]:
                    return False
            elif S[i] == "o" and rec[i] == "W":
                if rec[i-1] == rec[i+1]:
                    return False
            elif S[i] == "x" and rec[i] == "S":
                if rec[i-1] == rec[i+1]:
                    return False
            elif S[i] == "x" and rec[i] == "W":
                if rec[i-1] != rec[i+1]:
                    return False
        if S[N-1] == "o" and rec[N-1] == "S":
            return rec[N-2] == rec[0]
        elif S[N-1] == "o" and rec[N-1] == "W":
            return rec[N-2] != rec[0]
        elif S[N-1] == "x" and rec[N-1] == "S":
            return rec[N-2] != rec[0]
        elif S[N-1] == "x" and rec[N-1] == "W":
            return rec[N-2] == rec[0]

    for S0, S1 in (("S", "S"), ("S", "W"), ("W", "S"), ("W", "W")):
        rec = make(S0, S1)
        if checker(rec):
            print(rec)
            break
    else:
        print(-1)


if __name__ == '__main__':
    main()


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

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

void solve()
{
	int k;
	cin >> k;
	ll ans = 0;
	for(int a = 1; a <= k; ++a )
	{
		for(int b = 1; b <= k; ++b )
		{
			int gcd_ab = gcd(a, b);
			for(int c = 1; c <= k; ++c )
			{
				ans += gcd(gcd_ab, c);
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3608
N, x = map(int, input().split())
a = list(map(int, input().split()))

res = 0
if a[0] > x:
    res += a[0]-x
    a[0] = x
for i in range(1,N):
    if a[i-1]+a[i] > x:
        tmp = a[i]+a[i-1]-x
        a[i] -= tmp
        res += tmp
print(res)



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

void coco(vector<int>& v) {
    size_t n = v.size();
    vector<pair<int, int>> t(n);
    for (int i = 0; i < n; i++) {
        t[i] = { v[i], i };
    }
    sort(t.begin(), t.end());
    int k = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && t[i].first != t[i - 1].first) k++;
        v[t[i].second] = k;
    }
}

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

    int n;
    cin >> n;

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

    coco(a);

    int r = 0;
    for (int i = 0; i < n; i += 2) {
        r += a[i] % 2;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))
ans = 0
while True:
    c = 1
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] /= 2
        else:
            c = 0
            break
    if c == 0:
        break
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

ll fact[MAX], fact_inv[MAX];

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

void prepare_comb_mod(ll n){
	fact[0] = 1;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  string S; cin >> S;
  if(S.size() == 2) cout << S;
  else{
    rep(i, 0, 3){
      cout << S[2 - i];
    }
    cout << endl;
  }
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int K, dp[101][4][2];
  memset(dp, 0, sizeof(int) * 101 * 4 * 2);
  dp[0][0][0] = 1;
  cin >> s >> K;
  for(int i = 0; i < s.length(); i++) {
    int d = s[i] - '0';
    for(int j = 0; j < 4; j++)
      for(int k = 0; k < 2; k++)
        for(int n = 0; n < 10; n++) {
          int ni = i + 1, nj = j, nk = k;
          if(n) nj++;
          if(nj > K) continue;
          if(!k) {
            if(n > d) continue;
            if(n < d) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
  }
  cout << dp[s.length()][K][1] + dp[s.length()][K][0] << '\n';
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int si=s.size();
  si-=8;
  rep(i,si){
    cout<<s[i];
  }
  cout<<'\n';
  return(0);
}


Measured memory_bytes: 256
N = list(input())
len = len(N)
num = 0
for i in range(0, len, 1):
    cnt = 1
    for j in range(i + 1, len, 1):
        if (N[i] != N[j]):
            break
        else:
            cnt += 1
    num = max(num, cnt)
print("Yes" if 3 <= num else "No")


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const double eps=1e-8;
typedef pair<double,double> p;

double dist(p a, p b)
{
    return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
}

double size(p a)
{
    return sqrt(a.fi*a.fi+a.se*a.se);
}

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<p> v(n);
        rep(i,n) scanf(" %lf %lf", &v[i].fi, &v[i].se);

        int ans=1;
        //select 2 points
        rep(i,n)rep(j,i)
        {
            double d=dist(v[i],v[j]);
            if(d>2.0) continue;

            double r=sqrt(1.0 - (d*d/4.0));

            double X=v[j].fi-v[i].fi, Y=v[j].se-v[i].se;

            p v1=p(X,Y);
            double v1size=size(v1);
            v1.fi/=v1size; v1.se/=v1size;
            v1.fi*=d/2; v1.se*=d/2;

            p v2;
            double v2size;
            p c;

            //2 candidate for center of circle
            //first
            int ct=0;
            v2=p(-Y,X);
            v2size=size(v2);
            v2.fi/=v2size; v2.se/=v2size;
            v2.fi*=r; v2.se*=r;

            c.fi=v[i].fi+v1.fi+v2.fi; c.se=v[i].se+v1.se+v2.se;
            assert(dist(c,v[i]));
            rep(k,n)
            {
                if(k==i || k==j) ++ct;
                else
                {
                    if(dist(c,v[k])<1.0) ++ct;
                }
            }
            ans=max(ans,ct);

            //second
            ct=0;
            v2=p(Y,-X);
            v2size=size(v2);
            v2.fi/=v2size; v2.se/=v2size;
            v2.fi*=r; v2.se*=r;

            c.fi=v[i].fi+v1.fi+v2.fi; c.se=v[i].se+v1.se+v2.se;
            assert(dist(c,v[i]));
            rep(k,n)
            {
                if(k==i || k==j) ++ct;
                else
                {
                    if(dist(c,v[k])<1.0) ++ct;
                }
            }
            ans=max(ans,ct);
        }

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

Measured memory_bytes: 3228
/*author:anshumanc007
  created on:12/01/2019
  */
#include <bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
#define MAX 100005
long long int MOD=1e9+7;
long long int INF=1e18;
long long int A[MAX]={0};
long long int B[MAX]={0};
long long int parent[MAX];
bool visited[MAX];
void initialise()
{
    long long int j;
    for(j=0;j<MAX;j++)
    {
        visited[j]=false;
        parent[j]=j;
    }
}
void dfs(vector<long long int>adj[],long long int i)
{
    long long int j;
    visited[i]=true;
    A[i]=1;
    B[i]=1;
    long long int k;
    for(auto j:adj[i])
    {
        if(!visited[j])
        {
            dfs(adj,j);
            k=(A[j]+B[j]);
            A[i]=(k*A[i])%MOD;
            B[i]=(B[i]*A[j])%MOD;
        }
    }
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,m,n,p,q,r,s,t,x,y,a,b,ans=0,cnt=0,maxi=0,mini=INF,len;
    cin>>n;
    vector<long long int>adj[n];
    initialise();
    for(i=0;i<n-1;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(adj,0);
    cout<<(A[0]+B[0])%MOD<<endl;
    
    
   
}

Measured memory_bytes: 12288
using System;
class Program
{
    static void Main(string[] args)
    {
        char[] str = Console.ReadLine().ToCharArray();
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Split(' ');
            int a = int.Parse(line[1]);
            int b = int.Parse(line[2]);
            if (line[0] == "print")
            {
                string answer = "";
                for (int j = a; j <= b; j++)
                {
                    answer += str[j].ToString();
                }
                Console.WriteLine(answer);
            }
            else if (line[0] == "replace")
            {
                char[] p = line[3].ToCharArray();
                for (int j = a; j <= b; j++)
                {
                    str[j] = p[j-a];
                }
            }
            else
            {
                char tmp;
                for (int j = a,jend = a+(b-a)/2,reverseCount = b; j <= jend; j++)
                {
                    tmp = str[j];
                    str[j] = str[reverseCount];
                    str[reverseCount] = tmp;
                    reverseCount--;
                }
            }
        } Console.ReadLine();
    }
}

Measured memory_bytes: 5916
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

ll d[100100];
const ll INF = 1e18;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<pii, ll>> v(M);
	rep(i, M) {
		int l, r;
		ll c;
		cin >> l >> r >> c;
		v.push_back(mkp(mkp(l,r), c));
	}
	sort(rall(v));
	priority_queue<pll> q;
	FOR(i,1,N+1) {
		if(i > 1) {
			while(q.size() && q.top().se < i) {
				q.pop();
			}
			if(!q.size()) {
				cout << -1 << endl;
				return 0;
			}
			d[i] = -q.top().fi;
		}

		while(v.size() && v.back().fi.fi <= i) {
			q.push(pll( -(d[i]+v.back().se),v.back().fi.se));
			v.pop_back();
		}
	}
	cout << d[N] << endl;
	return 0;
}


Measured memory_bytes: 7796
import sys
sys.setrecursionlimit(200000)


def dfs(node, dis, adj_list):

    for next, d in adj_list[node]:
        if dis[next] == float("inf"):
            dis[next] = dis[node] + d
            dfs(next, dis, adj_list)

    return


n = int(input())
adj_list = [[] for _ in range(n)]


for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj_list[a].append([b, c])
    adj_list[b].append([a, c])

q, k = map(int, input().split())

k -= 1
dis = [float("inf")] * n
dis[k] = 0
dfs(k, dis, adj_list)

for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(dis[x] + dis[y])


Measured memory_bytes: 137932
#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
	int n,k,s;
	cin>>n>>k>>s;
	if(s<=10)
	{
		int j;
		for(j=0;j<k;j++)
		  cout<<s<<" ";
		for(j=k;j<n;j++)
		  cout<<(s+1)<<" ";
		cout<<endl;
	}
	else
	{
		int j;
		for(j=0;j<k;j++)
		  cout<<s<<" ";
		for(j=k;j<n;j++)
		{
			cout<<(s-1)<<" ";
		}
		cout<<endl;
	}
}


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

int main() {
  int N;
  cin >> N;
  long long a=2, b=1, c;
  if (N==1) cout << b << endl;
  else {
    for (int i=2; i<=N; i++){
      c = a + b;
      a = b;
      b = c;
    }
    cout << c << endl;
  }
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N;
ll ans;
string s;
int main(){
	cin >> N;
	REP(X,1,N+1){
		if(X * 108 / 100 == N){
			ans = X;
			break;
		}
	}
	if(ans == 0){
		p(":(");
	}else{
		p(ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline void finish()
{
  cout << -1 << endl;
  exit(0);
}

int main()
{
  ll n;
  cin >> n;
  ll a[100010], b[100010];
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  vector<ll> savings;  //余裕
  vector<ll> shortage; //不足分
  rep(i, n)
  {
    if (a[i] > b[i])
    {
      savings.push_back(a[i] - b[i]);
    }
    else if (a[i] < b[i])
    {
      shortage.push_back(b[i] - a[i]);
    }
  }
  sort(all(savings), greater<ll>());

  int ans = shortage.size();
  int i = 0;
  bool before_changed = false;
  for (auto &&t : shortage)
  {

    while (t > 0)
    {
      if (i == savings.size())
      {
        finish();
      }
      if (t - savings[i] < 0)
      {
        savings[i] -= t;
        t = 0;
        if (!before_changed)
          ans++;
        before_changed = true;
      }
      else if (t - savings[i] >= 0)
      {
        t -= savings[i];
        i++;
        if (!before_changed)
          ans++;
        before_changed = false;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {
  
  string S,T;
  cin >> S >> T;

  vector<int> s(26),t(26);
  for(int i = 0;i < S.size();i++) {
    int sn = S.at(i) - 'a';
    int tn = T.at(i) - 'a';
    
    s.at(sn)++;
    t.at(tn)++;
  }

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());

  for(int i = 0;i < 26;i++) {
    if(s.at(i) != t.at(i)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

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

ll solve() {
    ll N, T;
    cin >> N >> T;
    ll a;
    ll amin = 1e9+1, tmax = 0, tnum = 0;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        ll t = a - amin;
        if ( tmax < t ) {
            tmax = t;
            tnum = 1;
        } else if ( tmax == t ) {
            tnum++;
        }
        if ( amin > a ) amin = a;
    }
    return tnum;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#define MN 200000
using namespace std;
inline int 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;
}
double ans=0,R=acos(-1)*20/4;
int n,a,b,c,d,flag,top,f[MN+5],mx=0;
pair<int,int> s[MN+5];
int main()
{
	a=read();b=read();c=read();d=read();n=read();
	if(a>c) swap(a,c),swap(b,d);
	if(d<b) d=int(1e8)-1-d,b=int(1e8)-1-b,flag=1;
	ans=100.*(c-a+d-b);
	for(int i=1;i<=n;++i)
	{
		int x=read(),y=read();
		if(flag) y=int(1e8)-1-y;
		if(x>=a&&x<=c&&y>=b&&y<=d) s[++top]=make_pair(x,y);
	}
	sort(s+1,s+top+1);
	if((a==c||b==d)&&top) return 0*printf("%.12lf\n",ans-20+2*R);
	if((a==c||b==d)||!top) return 0*printf("%.12lf\n",ans);
	f[0]=-1;for(int i=1;i<=top;++i) f[i]=1e9;
	int conx=1,cony=1;
	for(int i=1;i<top;++i) conx&=(s[i].first+1==s[i+1].first),cony&=(s[i].second+1==s[i+1].second);
	conx&=(s[1].first==a&&s[top].first==c);
	cony&=(s[1].second==b&&s[top].second==d);
	for(int i=1;i<=top;++i)
	{
		int l=0,r=i-1,mid,res;
		while(l<=r)
		{
			mid=l+r>>1;
			if(f[mid]<s[i].second) res=mid,l=mid+1;
			else r=mid-1;
		}
		mx=max(mx,res+1);f[res+1]=min(f[res+1],s[i].second);
	}
	if((conx||cony)&&mx==top&&mx) ans+=R;
	printf("%.12lf\n",ans-mx*20+mx*R);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,x,y;
char f[55][55];
int rui[55][55];
int calc(int a,int b,int c,int d)
{
    return rui[b][d]-rui[a-1][d]-rui[b][c-1]+rui[a-1][c-1];
}
int dp[45][45][45][45];
int rec(int a,int b,int c,int d){
    if(dp[a][b][c][d] < 100000) 
        return dp[a][b][c][d];
    int &ret = dp[a][b][c][d];
    ret = min(calc(a,x,c,y),ret);
    ret = min(calc(a,x,y,d),ret);
    ret = min(calc(x,b,c,y),ret);
    ret = min(calc(x,b,y,d),ret);
    for(int X=x;X<=b;X++) 
    {
        for(int Y=y;Y<=d;Y++)
        {
        if(X==b && Y==d) 
            continue;
        ret = min(ret,calc(X+1,b,c,Y)+calc(a,X,Y+1,d)+rec(a,X,c,Y));
        }
    }
    
    for(int X=x;X<=b;X++) 
    {
        for(int Y=c;Y<=y;Y++)
        {
            if(X==b && Y==c) 
                continue;
            ret = min(ret,calc(X+1,b,Y,d)+calc(a,X,c,Y-1)+rec(a,X,Y,d));
        }
    }
    
    for(int X=a;X<=x;X++) 
    {
        for(int Y=y;Y<=d;Y++)
        {
            if(X==a && Y==d) 
                continue;
            ret = min(ret,calc(a,X-1,c,Y)+calc(X,b,Y+1,d)+rec(X,b,c,Y));
        }
    }
    
    for(int X=a;X<=x;X++) 
    {
        for(int Y=c;Y<=y;Y++)
        {
            if(X==a && Y==c) 
                continue;
            ret = min(ret,calc(a,X-1,Y,d)+calc(X,b,c,Y-1)+rec(X,b,Y,d));
        }
    }
    return ret;
}
int main()
{
//	freopen("haner.in","r",stdin);
//	freopen("haner.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        string str; cin>>str;
        for(int j=1;j<=m;j++)
            f[i][j] = str[j-1];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(f[i][j] == 'P')
            {
                x = i;
                y = j;
            }
            rui[i][j] = (f[i][j]=='#'?1:0);
            rui[i][j] += rui[i-1][j];
            rui[i][j] += rui[i][j-1];
            rui[i][j] -= rui[i-1][j-1];
        }
    }
    rep(i,45)rep(j,45)rep(k,45)rep(l,45)dp[i][j][k][l] = INF;
    cout << rec(1,n,1,m) << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector <long long> ans(N + 1);
  ans.at(0) = 2LL;
  ans.at(1) = 1LL;

  if (N == 1) {
    cout << ans.at(1);
  }
  else {
    for (int i = 2; i <= N; i++) {
      ans.at(i) = ans.at(i-1) + ans.at(i-2);
    }
    cout << ans.at(N) << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int main(){
  int H, i;
  int A[MAX+1];

  scanf("%d", &H);

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

  for ( i = 1; i <= H; i++ ) {
    printf("node %d: key = %d, ", i, A[i]);

    if ( i / 2 >= 1 )
      printf("parent key = %d, ", A[i/2]);
    if ( 2*i <= H )
      printf("left key = %d, ", A[2*i]);
    if ( (2*i+1) <= H )
      printf("right key = %d, ", A[2*i+1]);

    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2052
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    a=2
    b=1
    num=0
    if n==1:
        print(b)
    else:
        for i in range(n-1):
           num=a+b
           a,b=b,a+b
        print(num)
resolve()


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

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

    int num_8yaku = 0;
    int num_yaku = 2;

    for(int i = 1; i<N+1; i=i+2){
        for(int j = 3; j<i; j=j+2){
            if(i%j==0){
                num_yaku = num_yaku+1;
            }
        }
        if(num_yaku == 8){
            num_8yaku++;
        }
        num_yaku = 2;
    }

    cout << num_8yaku << endl;
    return 0;

} 


Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
using namespace std;
const int M = 1000000007;
const int N = 2e5 + 10;
int n, dp[N], s[N], c[N];
int main() {
	scanf("%d", &n); dp[0] = 1;
	for(int i = 1; i <= n; i ++) {
		scanf("%d", c + i);
		if(c[i] == c[i - 1]) {
			i --; n --;
		}
	}
	for(int i = 1; i <= n; i ++) {
		dp[i] = (s[c[i]] + dp[i - 1]) % M;
		(s[c[i]] += dp[i - 1]) %= M;
	}
	printf("%d\n", dp[n]);
	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}


class UnionFind{
private:
	std::vector<int_fast32_t> par;
	size_t n;

public:
	UnionFind(){}
	UnionFind(size_t n):n(n){
		par.resize(n, -1);
	}

	uint_fast32_t find(uint_fast32_t x){
		return par[x] < 0 ? x : par[x] = find(par[x]);
	}

	size_t size(uint_fast32_t x){
		return -par[find(x)];
	}

	void unite(uint_fast32_t x, uint_fast32_t y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(size(x) < size(y)) std::swap(x, y);
		par[x] += par[y];
		par[y] = x;
	}

	bool same(uint_fast32_t x, uint_fast32_t y){
		return find(x) == find(y);
	}
};

int32 N, M, K;
int32 c[112345];
UnionFind uf;

int32 club(int32 x){
	return c[uf.find(x)];
}

int main(void){
	memset(c, -1, sizeof c);
	cin >> N >> M >> K;
	uf = UnionFind(N);
	REP(i, K){
		int32 t, a, b;
		cin >> t >> a >> b; a--; b--;
		if(t == 1){
			if(club(a) == -1 || club(b) == -1 || club(a) == club(b)){
				if(club(a) == -1) c[a] = club(b);
				else c[b] = club(a);
				uf.unite(a, b);
			}else{
				cout << i+1 << endl;
				return 0;
			}
		}else{
			if(club(a) != -1 && club(a) != b){
				cout << i+1 << endl;
				return 0;
			}
			c[uf.find(a)] = b;
		}
	}
	cout << 0 << endl;
}



Measured memory_bytes: 4356
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{
  int N;
  cin>>N;
  vector<int> MON(N+1);
  vector<int> BRA(N);
  for (int i = 0; i < N+1; i++)
  {
    cin>>MON[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin>>BRA[i];
  }

  
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {

    ANS += BRA[i];
    MON[i] -= BRA[i];
    if(MON[i] < 0)
    {
      MON[i+1] += MON[i];
      MON[i] = 0;
    }
    if(MON[i+1] < 0)
    {
      ANS -= -1*MON[i+1];
      MON[i+1] = 0;
    }
    // DEBUG(MON);
  }

  cout<<ANS<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

int main() {
	multiset<int, greater<int>> st; int temp; 
	while (cin >> temp) st.insert(temp);
	auto itr = st.begin();
	for (int i = 0; i < 3; i++) { cout << *itr << endl; ++itr; }
	return 0;
}


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

int main(){
  int k,s;
  cin >> k >> s;
  ll count = 0;
  rep(x,k+1) {
    rep(y,k+1) {
      int z = s - x - y;
      if(x <= k && y <= k && z <= k && z >= 0) {
      //  cout << x << y << z << endl;
        count++;
      }
    }
  }

  cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> v(n, vector<int>(d));
    REP(i, n) REP(j, d) {
        cin >> v[i][j];
    }

    int cnt = 0;
    REP(i, n) REP2(j, i+1, n) {
        int diff = 0;
        REP(k, d) {
            diff += pow(v[i][k] - v[j][k], 2);
        }

        REP(k, int(diff)+1) {
            if (k * k == diff) {
                cnt++;
                break;
            }
        }
    }

    std::cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	int ans=0;
	rep(i,n){
	    int t; cin>>t;
	    ans+=__builtin_ctz(t);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int sum,i,len;
	char buf[1001];
	while(1)	{
		scanf("%s",buf);
		if(strcmp(buf,"0")==0)	break;
		len=strlen(buf);
		sum=0;
		for(i=0;i<len;i++)	{
			sum+=buf[i]-'0';
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2676
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
    fast;

  ll a,b,c,x,d,e;
  cin >> x;
  if(x>=400 && x<=599)
  {
      cout << 8<<endl;
  }
  else if(x>=600 && x<=799)
  {
      cout << "7"<<endl;
  }else if(x>=800 && x<=999)
  {
      cout <<"6"<<endl;
  }
  else if(x>=1000 &&x<=1199)
  {
      cout << "5"<<endl;
  }else if(x>=1200 &&x<=1399)
  {
      cout << "4"<<endl;
  }
  else if(x>=1400 &&x<=1599)
  {
      cout << "3"<<endl;
  }
  else if(x>=1600 &&x<=1799)
  {
      cout << "2"<<endl;
  }
  else{
    cout << "1"<<endl;
  }


}


Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC";
	else cout << "ABC";

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    
    ll N ;
    cin >> N ;
    vector<ll>d(N);
    rep(i, N) cin >> d[i] ;
    
    sort(all(d));
    
    cout << (d[N/2] - d[N/2-1]) << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;
  cin>>A>>B>>K;
  int count=0;
  for(int i=min(A,B);i>=1;i--){
    if(A%i==0&&B%i==0){
      count=count+1;
      if(count==K){
        cout<<i<<endl;
        break;
      }
      else{
      }
    }
    else{
    }
  }
}

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

using namespace std;
using namespace std::chrono;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, a;
  cin >> n >> a;
  cout << n * n - a << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class DisjointSet{
    public:
    vi rank, p;
    
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        rep(i,size)makeSet(i);
    }
    
    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }
    
    bool same(int x,int y){
        return findSet(x)==findSet(y);
    }
    
    void unite(int x,int y){
        link(findSet(x),findSet(y));
    }
    
    void link(int x,int y){
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++;
            }
        }
    }
    
    int findSet(int x){
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};

void run(){
    int n,k,l;
    cin>>n>>k>>l;
    DisjointSet road=DisjointSet(n);
    DisjointSet rail=DisjointSet(n);
    rep(i,k){
        int p,q;
        cin>>p>>q;
        p--;q--;
        road.unite(p,q);
    }
    rep(i,l){
        int r,s;
        cin>>r>>s;
        r--;s--;
        rail.unite(r,s);
    }
    map<pi,int> map;
    rep(i,n){
        map[mp(road.findSet(i),rail.findSet(i))]++;
    }
    rep(i,n){
        if(i)cout<<" ";
        cout<<map[mp(road.findSet(i),rail.findSet(i))];
    }
    cout<<endl;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m;cin>>n;
  for(long long i=1;;i++){
    if(i*i>n){
      m=i-1;
      break;
    }
  }
  for(long long i=m;;i--){
    if(n%i==0){
      long long y=n/i;
      for(long long j=1;;j++){
        y/=10;
        if(y==0){
          cout<<j<<endl;
          return 0;
        }
      }
    }
  }
}
    

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

#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
const int MOD = 1000000007;

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


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

using namespace std;

int main()
{
    int a,b,c,d=0;
    cin>>a>>b;

    for(int i=0;i<b;i++){
        cin>>c;
        d=d+c;
    }
    if (d<=a){
        cout<<a-d<<endl;
    }
    else{
        cout<<"-1"<<endl;
    }

    return 0;

}



Measured memory_bytes: 3632
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int w, h, n, x, y, a, count=0;
    cin>>w>>h>>n;
    int ans = w * h;

    bool arr[w][h];
    loop(i, 0, w){
        loop(j, 0, h){
            arr[i][j] = true;
        }
    }


    loop(i, 0, n){
        cin>>x>>y>>a;

        if(a == 1){
            loop(i, 0, x){
                loop(j, 0, h){
                    arr[i][j] = false;
                }
            }
        }
        if(a == 2){
            loop(i, x, w){
                loop(j, 0, h){
                    arr[i][j] = false;
                }
            }
        }
        if(a == 3){
            loop(i, 0, w){
                loop(j, 0, y){
                    arr[i][j] = false;
                }
            }
        }
        if(a == 4){
            loop(i, 0, w){
                loop(j, y, h){
                    arr[i][j] = false;
                }
            }
        }

    }

    loop(i, 0, w){
        loop(j, 0, h){
            if(arr[i][j])
                count++;
        }
    }

    cout<<count;



}





























Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int jank(int a){
  char s[4]="spr";
  FOR(3)if(a==s[i])return i;
}

int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  char s[2][4]={"No","Yes"};
  PRS(s[((a==b&&a!=c)||(b==c&&a!=b)||(c==a&&b!=c))]);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
int digitsum(int n,int k){
	int ans=0;
	while(n>0){
		ans+=n%k;
		n/=k;
	}
	return ans;
}
int main(){
    int n,ans=1e9;
    scanf("%d",&n);
    for(int i=0;i<=n;i++){
        int k=digitsum(i,6)+digitsum(n-i,9);
        if(k<ans)ans=k;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    string s; cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for(char c: s){
        if(c == '0') cnt0++;
        else cnt1++;
    }
    if(min(cnt0,cnt1) == 0) cout << 0 << endl;
    else cout << min(cnt0,cnt1)*2 << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)    cin >> a[i];
    if(n==1)    cout << "Yes";
    else
    {
        int f=0;
        for(int i=0;i<(n-1);i++)
        {
            if(a[i]>a[i+1]) f++;
        }
        if(f==0)    cout << "Yes";
        else
        {
            for(int i=(n-1);i>=1;i--)
            {
                if(a[i]<a[i-1]) a[i-1]--;
            }
            int d=0;
            for(int i=0;i<(n-1);i++)
            {
                if(a[i]>a[i+1]) d++;
            }
            if(d==0)    cout << "Yes";
            else    cout << "No";
        }
    }    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int mod=10007;
typedef pair<int,int> P;
 
int M,cnt;
vector<P> v[100001];
bool u[100001];
vector<int> a;
 
void dfs(int x) {
  u[x]=true;
  a.push_back(x);
  for(int i=0; i<v[x].size(); i++) {
    if(!u[v[x][i].first]) {
      M=max(M,v[x][i].second);
      dfs(v[x][i].first);
    }
  }
}
 
void solve() {
  cnt=0;
  for(int i=0; i<a.size(); i++) {
    for(int j=0; j<v[a[i]].size(); j++) {
      if(M==v[a[i]][j].second) cnt++;
    }
  }
}
 
int main() {
  int n;
  while(cin >> n && n) {
    for(int i=0; i<n; i++) {
      v[i].clear();
      int x,y;
      cin >> x >> y;
      v[i].push_back(P(x,y));
      cin >> x >> y;
      v[i].push_back(P(x,y));
    }
    int ans=1;
    memset(u,false,sizeof(u));
    for(int i=0; i<n; i++) {
      if(!u[i]) {
    M=0;
    a.clear();
    dfs(i);
    solve();
    ans*=cnt/2;
    ans%=mod;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4388
tap = input()

tap_list = list(tap)
result_list = []

for val in range(len(tap)):
	if ('R' in tap_list[val]) and (val%2 == 1) :
		result_list.insert(0,1)
	elif ('L' in tap_list[val])and (val%2 == 0) :
		result_list.insert(0,1)
	else:
		result_list.insert(0,0)

if 1 in result_list :
	print('No')	
else :
		print('Yes')
			

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)
	if A == B && A != C {
		fmt.Println("Yes")
		return
	}
	if A == C && A != B {
		fmt.Println("Yes")
		return
	}
	if B == C && A != B {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;

int Flying[8]={4,1,4,1,2,1,2,1};
int p[8];
long int num[8]={
    41412121,
    14121214,
    41212141,
    12121414,
    21214141,
    12141412,
    21414121,
    14141212,
};

int main(void)
{
    while(cin>>p[0]>>p[1]>>p[2]>>p[3]>>p[4]>>p[5]>>p[6]>>p[7]){
        int m[8]={0};
        for(int i=0; i<8; i++){
            for(int j=0; j<8; j++){
                int temp=p[j]-Flying[(j+i)%8];
                if(temp<0)temp=0;
                m[i]+=temp;
            }
        }
        int ret=0;
        int min=1000000;
        for(int i=0; i<8; i++){
            if(min>m[i]){
                min=m[i];
                ret=i;
            }else if(min==m[i] && num[ret]>num[i]){
                min=m[i];
                ret=i;
            }
            
        }
        
        //cout<<num[ret]<<endl;
        for(int i=0; i<8; i++){
            cout<<Flying[(i+ret)%8];
            if(i==7)cout<<endl;
            else cout<<" ";
        }
    }
    
}

Measured memory_bytes: 1160