akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.buffer.readline

def main():
    H,W = map(int,input().split())
    point = [[0]*W for _ in range(H)]
    
    for i in range(H):
        a = list(map(int,input().split()))
        for j in range(W):
            point[i][j] += a[j]

    for i in range(H):
        b = list(map(int,input().split()))
        for j in range(W):
            point[i][j] = abs(point[i][j]-b[j])
    
    base = 3200
    dp = [[0]*W for _ in range(H)]
    dp[0][0] = (1 << (base+point[0][0])) | (1 << (base-point[0][0]))
    
    for i in range(H):
        for j in range(W):
            if j < W-1:
                dp[i][j+1] |= (dp[i][j] << point[i][j+1])
                dp[i][j+1] |= (dp[i][j] >> point[i][j+1])
            if i < H-1:
                dp[i+1][j] |= (dp[i][j] << point[i+1][j])
                dp[i+1][j] |= (dp[i][j] >> point[i+1][j])
    
    ans = dp[-1][-1] >> base
    for i in range(ans.bit_length()):
        if (ans >> i)&1:
            print(i)
            exit()
    
if __name__ == "__main__":
    main()


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll ans = 0;
  rep(i, N - 1) {
    ll f = 0;
    if (A[i] > A[i + 1]) f = A[i] - A[i + 1];
    A[i + 1] += f;
    ans += f;
  }
  cout << ans << endl;

  return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  string r="";
  for(int i = s.size()-1;i>=0;i--) r+=s[i];

  int hug = 0;
  rep(i,s.size()){
    if(s[i]!=r[i]) hug++;
  }

  hug /= 2;
  cout << hug << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b; cin >> a >> b;
  string s; cin >> s;
  bool ans = true;
  for(int i = 0; i < a+b+1; i++){
    if(i != a){
      if(!(s[i] >= '0' && s[i] <= '9')) ans = false;
    }
    else{
      if(s[i] != '-')ans = false;
    }
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
  system("pause");
}


Measured memory_bytes: 504
#include<iostream>
using namespace std;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
int main(){
	int m;
	cin >> m;
	call(m);
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> arr(N);
  for(int i=0; i<N; i++){
    cin >> arr.at(i);
  }
  int check = 0,count = 0;
  while(1){
    for(int i=0; i<N; i++){
      if(arr.at(i)%2 == 1){
        check = 1;
        break;
        }
      arr.at(i) = arr.at(i)/2;
    }
    if(check == 1){
      break;
    }
    count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{

	//input
	int n;
	cin >> n;

	vector<int> w;
	for (int i = 0; i < n; i++){
		int wi;
		cin >> wi;
		w.push_back(wi);
	}


	//calc
	int s1 = w[0];
	int s2 = 0;
	for (int i = 1; i < n; i++){
		s2 += w[i];
	}

	int ans = abs(s1 - s2);
	for (int i = 1; i < n - 1; i++){
		s1 += w[i];
		s2 -= w[i];

		if (abs(s1 - s2) < ans){
			ans = abs(s1 - s2);
		}
	}

	//ans
	cout << ans << endl;



	return 0;
}


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

int x,a,b;

int main(){
	cin>>x>>a>>b;
	int d1=abs(x-a);
	int d2=abs(x-b);
	if(d1<d2){
		cout<<"A";
	} else {
		cout<<"B";
	}
	return 0;
} 

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

int main() {

    vector<int> v;

    for(int i = 0; i <= 10000; i++) {
        int t;
        cin >> t;
        if(t == 0) {
            break;
        }
        v.push_back(t);
    }

    for(int i = 0; i < v.size(); i++) {
        cout << "Case " << i + 1 << ": " << v[i] << endl;

    }
}



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

using namespace std;

long long int arr[3][100001], n, dp[3][100001];

long long int score(int i, int prev){
	
	if(dp[prev][i]) return dp[prev][i];
	
	int x, y;
	if(prev == 0)
		x = 1, y = 2;
	else if(prev == 1)
		x = 0, y = 2;
	else
		x = 0, y = 1;
	
	if(i == n)
		dp[prev][i] = max(arr[x][i], arr[y][i]);
	else
		dp[prev][i] = max(arr[x][i] + score(i+1, x), arr[y][i] + score(i+1, y));
	return dp[prev][i];
	
}

int main(){
	cin >> n;
	for(int i=1;i<=n;i++)cin >> arr[0][i] >> arr[1][i] >> arr[2][i];
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < n; j++)
			dp[i][j] = 0;
	
  	/*
	long long int ans = 0;
	for(int k = 0; k < 3; k++){
		ans = max(ans, score(0, k));
	}
    */
	cout << score(0, 0) << endl;
}


Measured memory_bytes: 11136
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int ans = 0;
        SortedDictionary<int, int> reds = new SortedDictionary<int, int>();
        SortedDictionary<int, int> blues = new SortedDictionary<int, int>();

        for (int i = 0; i < n; i++)
        {
            int[] ab = Console.ReadLine().Split(' '). Select(int.Parse).ToArray();
            reds[ab[0]] = ab[1];
        }
        for (int i = 0; i < n; i++)
        {
            int[] cd = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            blues[cd[0]] = cd[1];
        }

        foreach (var blue in blues)
        {
            int counter = -1;
            int max = -1;
            foreach(var red in reds)
            {
                if(max < red.Value && red.Value < blue.Value && red.Key < blue.Key)
                {
                    max = red.Value;
                    counter = red.Key;
                }
            }
            if(counter != -1)
            {
                reds[counter] = -2;
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13652
a, b = map(int,input().split())

count=0

for i in range(a,b+1):
  mae=[]
  usi=[]
  for j in range(len(str(i))):
    mae.append(str(i)[j])
  for j in range(int(len(str(i))-1),-1,-1):
    usi.append(str(i)[j])
  if mae==usi:
    count+=1

print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
LL ans;
int W, H, N;
int x[1010], y[1010];
int main() {
	std::cin >> W >> H >> N;
	for (int i = 0; i < N; i++) {
		std::cin >> x[i] >> y[i];
	}
	for (int i = 1; i < N; i++) {
		LL X = x[i] - x[i - 1];
		LL Y = y[i] - y[i - 1];
		if (X*Y >= 0) {
			X = std::abs(X);
			Y = std::abs(Y);
			ans+=std::min(X, Y);
			ans += std::abs(X - Y);
		}
		else {
			ans += std::abs(X) + std::abs(Y);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


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

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

	int i;
	int max = -1, min = 1001;
	for (i = 0; i < n; i++) {
		cin >> a;
		if (a > max)max = a;
		if (a < min)min = a;
	}
	cout << max - min << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define mod(x) ((x % MOD) + MOD) % MOD
#define int long long int
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define rrep(i, a, n) for(int i = n-1; i >= a; --i)

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


void dijkstra(vector< vector<edge> >& G, vector<int>& d, int s)
{
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d.begin(), d.end(), INF);
  d[s] = 0;
  que.push(P(0, s));
  while(!que.empty()) {
    int temp_cost = que.top().first;
    int from = que.top().second;
    que.pop();
    if (d[from] < temp_cost) continue;
    for (int i = 0; i < G[from].size(); i++) {
      edge e = G[from][i];
      if (d[e.to] > d[from] + e.cost) {
        d[e.to] = d[from] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}


signed main()
{
  int N, M, S, T;
  cin >> N >> M >> S >> T;
  S--; T--;
  vector< vector<edge> > G(N, vector<edge>());
  int U, V, D;
  for (int i = 0; i < M; i++) {
    cin >> U >> V >> D;
    U--; V--;
    G[U].push_back((edge){ V, D });
    G[V].push_back((edge){ U, D });
  }


  vector<int> d(N);
  dijkstra(G, d, S);

  vector<P> list(N);
  rep(i, 0, N) {
    list[i] = make_pair(d[i], i);
  }
  sort(list.begin(), list.end());

  vector< vector<int> > dp(2, vector<int>(N, 0));
  dp[0][S] = 1; dp[1][T] = 1;

  rep(i, 0, N) {
    int idx = list[i].second;
    rep(j, 0, G[idx].size()) {
      edge e = G[idx][j];
      if (d[idx] == d[e.to] + e.cost) {
        dp[0][idx] = mod(dp[0][idx] + dp[0][e.to]);
      }
    }
  }

  rrep(i, 0, N) {
    int idx = list[i].second;
    rep(j, 0, G[idx].size()) {
      edge e = G[idx][j];
      if (d[idx] + e.cost == d[e.to]) {
        dp[1][idx] = mod(dp[1][idx] + dp[1][e.to]);
      }
    }
  }


  int ans = mod(dp[0][T] * dp[0][T]);
  rep(i, 0, N) {
    if (d[i] * 2 == d[T]) {
      ans = mod(ans - mod(mod(dp[0][i]*dp[0][i]) * mod(dp[1][i]*dp[1][i])));
    }
  }
  rep(i, 0, N) {
    rep(j, 0, G[i].size()) {
      edge e = G[i][j];
      if (d[e.to] == d[i] + e.cost && d[i]*2 < d[T] && d[e.to]*2 > d[T]) {
        ans = mod(ans - mod(mod(dp[0][i]*dp[0][i]) * mod(dp[1][e.to]*dp[1][e.to])));
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 17840
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	char ans = '0', wk;
	int F[16][16];
	while(cin >> wk)
	{
		memset(F, 0, sizeof(F));
		F[0][0] = wk - '0';
		ans = '0';


		for(int i = 0; i < 8; i++)
		{
			for(int j = 0; j < 8; j++)
			{
				if(i == 0 && j == 0)
					continue;
				cin >> wk;
				F[i][j] = wk - '0';
			}
		}

		for(int i = 0; i < 8; i++)
		{
			for(int j = 0; j < 8; j++)
			{
				if(F[i][j] && F[i][j+1] && F[i+1][j] && F[i+1][j+1])
				{
					ans = 'A';
					break;
				}
				if(F[i][j] && F[i+1][j] && F[i+2][j] && F[i+3][j])
				{
					ans = 'B';
					break;
				}
				if(F[i][j] && F[i][j+1] && F[i][j+2] && F[i][j+3])
				{
					ans = 'C';
					break;
				}
				if(F[i][j] && F[i+1][j] && F[i+1][j-1] && F[i+2][j-1])
				{
					ans = 'D';
					break;
				}
				if(F[i][j] && F[i][j+1] && F[i+1][j+1] && F[i+1][j+2])
				{
					ans = 'E';
					break;
				}
				if(F[i][j] && F[i+1][j] && F[i+1][j+1] && F[i+2][j+1])
				{
					ans = 'F';
					break;
				}
				if(F[i][j] && F[i][j+1] && F[i-1][j+1] && F[i-1][j+2])
				{
					ans = 'G';
					break;
				}
			}
			if(ans != '0')
			{
				break;
			}
		}

		cout << ans << endl;
	}
}

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

typedef long long ll;

const ll mod = 1000000007;

vector<ll> fac(1000001), ifac(1000001), inv(1000001);

ll mpow(ll x, ll n) { 
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans *= (x % mod);
		x *= (x % mod);
		n >>= 1;
	}
	return ans;
}

ll comb(ll a, ll b) { 
	if (a < b)return 0;
	ll tmp = ifac[a - b] * ifac[b] % mod;
	return tmp * fac[a] % mod;
}

int main() {
	ll x, y, m, n; cin >> x >> y;
	if ((x + y) % 3 != 0) { cout << 0 << endl; return 0; }
	m = (2 * y - x) / 3; n = (2 * x - y) / 3;
	if (m < 0 || n < 0) { cout << 0 << endl; return 0; }
	
	fac[0] = fac[1] = 1;
	ifac[0] = ifac[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 1000000; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		ifac[i] = ifac[i - 1] * inv[i] % mod;
	}
	cout << comb(m + n, n) << endl;

	return 0;
}

Measured memory_bytes: 23680
using System;

namespace A___Serval_vs_Monster
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var h = int.Parse (input[0]);
            var a = int.Parse (input[1]);
            var ans = 0;
            while (h > 0)
            {
                h -= a;
                ans++;
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 11092
a,b, = map(int, input().split() )
s = input()

x = -1 == s[0:a].find('-')
y = -1 == s[a+1:].find('-')
z = -1 != s[a]=='-'

#print((x,y,z))
print('Yes' if x and y and z else 'No')

Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
    float n,m;
	while(scanf("%f %f",&n,&m)!=EOF){
	    if(n<35.50&&m<71.0){
		    printf("AAA\n");
		}
		else if(n<37.50&&m<77.0){
		    printf("AA\n");
		}
		else if(n<40.00&&m<83.0){
		    printf("A\n");
		}
		else if(n<43.00&&m<89.0){
		    printf("B\n");
		}
		else if(n<50.00&&m<105.0){
		    printf("C\n");
		}
		else if(n<55.00&&m<116.0){
		    printf("D\n");
		}
		else if(n<70.00&&m<148.0){
		    printf("E\n");
		}
		else printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 2656
import sys
input=sys.stdin.readline

n=int(input())
a={}
for i in range(1,n+1):
    a[i]=a.get(i,int(input()))
on=1
cnt=0
flag=False
for i in range(1,n+1):
    on=a[on]
    cnt+=1
    if on==2:
        flag=True
        break
print(cnt if flag else -1)

Measured memory_bytes: 17892
#include <bits/stdc++.h>
#define ll long long
#define en "\n"
using namespace std;

const int M=1e9+7;

int a[8];

int main()
{
    ios::sync_with_stdio(false);
    int k;
    for(int i=1;i<6;i++)cin>>a[i];
    cin>>k;
    for(int i=1;i<6;i++)
    {
        for(int j=i+1;j<6;j++)
            if(abs(a[i]-a[j])>k)
            {
                cout<<":("<<endl;
                return 0;
            }

    }
    cout<<"Yay!"<<endl;
    return 0;
}


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

void cas(int i) {
    cout<<"Case "<<i<<":";
}

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

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()
#define dsc         greater<int>()

#define fef(i,a,b)    for(int i=a;i<b;i++)
#define feb(i,a,b)    for(int i=a;i>=b;i--)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        1000000007
#define INF 0x3f3f3f3f
bool sbs(const pii &a, const pii &b) {
    return (a.second < b.second);
}
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    char ch; cin>>ch;
    if(ch>='a'&&ch<='z') cout<<'a'<<endl;
    else cout<<'A'<<endl;
    End;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  bool ok = true;
  if (a[0] > 0) ok = false;
  for (int i = 1; i < n; ++i) {
    if (a[i-1] < a[i]) {
      if (a[i-1]+1 == a[i]) continue;
      else ok = false;
    }
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = 0;
  rep(i,n-1) {
    if (a[i]+1 == a[i+1]) continue;
    else ans += a[i];
  }
  ans += a[n-1];
  cout << ans << endl;
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[99999], b[99999];
vector<int> v[100000];
int f[100000], bn, wn;

int main() {
	cin >> n;
	inc(i, n - 1) { cin >> a[i] >> b[i]; a[i]--; b[i]--; }
	
	inc(i, n - 1) {
		v[a[i]].PB(b[i]);
		v[b[i]].PB(a[i]);
	}
	
	queue<pair<int, int>> b, w;
	f[0] = 1;
	f[n - 1] = -1;
	bn++;
	wn++;
	b.push(MP(0, 0));
	w.push(MP(n - 1, 0));
	inc(k, n) {
		if(b.empty() && w.empty()) { break; }
		
		while(! b.empty()) {
			auto e = b.front();
			if(e.SE != k) { break; }
			b.pop();
			inc(i, v[e.FI].size()) {
				if(f[v[e.FI][i]] == 0) { f[v[e.FI][i]] = +1; bn++; b.push(MP(v[e.FI][i], k + 1)); }
			}
		}
		
		while(! w.empty()) {
			auto e = w.front();
			if(e.SE != k) { break; }
			w.pop();
			inc(i, v[e.FI].size()) {
				if(f[v[e.FI][i]] == 0) { f[v[e.FI][i]] = -1; wn++; w.push(MP(v[e.FI][i], k + 1)); }
			}
		}
	}
	
	// cout << bn << " " << wn << endl;
	cout << (bn > wn ? "Fennec" : "Snuke") << endl;
	
	return 0;
}


Measured memory_bytes: 7040
#include<vector>
#include<iostream>

using namespace std;

const int W = 1001;
const int N = 1001; 

int table[W][N];

void solve(int n,int lim, vector<int> price, vector<int> weight){
  int maxi_p = 0,maxi_w = 0;
  for(int i = 0;i < W;i++){
    for(int j = 0;j < N;j++){
      table[i][j] = 0;
    }
  }
  
  /*
  for(int i = 0;i < n;i++){
    table[weight[i]][i] = price[i]; 
  }
  */
  table[weight[0]][0]=price[0];

  
  for(int i = 0;i <=lim;i++){
    for(int j = 1;j < n;j++){
      table[i][j] = table[i][j-1]; 
      if(i - weight[j] < 0)continue;
      table[i][j] =max(table[i - weight[j]][j-1]+price[j],table[i][j-1]);
    } 
  }

  for(int i = 0;i <= lim;i++){
    if(maxi_p < table[i][n-1]){
      maxi_p = table[i][n-1];
      maxi_w = i;
    }

    
  }
  cout << maxi_p << endl; 
  cout << maxi_w << endl;
}  

int main(){
  int count = 1;
  int lim;
  int n;
  int price,weight;  
  while(cin >> lim >> n &&lim){

    vector<int> a,b;
    int tmp;
    char damy;
    cout << "Case "<< count <<":"<<endl;
    for(int i = 0;i < n;i++){
      cin >> price >> damy >> weight;
      a.push_back(price);
      b.push_back(weight);
    }
    
    solve(n,lim,a,b);
    count++;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int K;
ll A[100000];

int main(int argc, char* argv[])
{
	scanf("%d", &K);
	for (int i = 0; i < K; i++) {
		scanf("%lld", &A[i]);
	}

	if (A[K - 1] != 2) {
		printf("-1\n");
		return 0;
	}

	ll m = 2, M = 2;
	for (int i = K - 1; i >= 1; i--) {
		ll l = m;
		ll r = M + A[i];
		ll L = (l % A[i - 1] == 0) ? (l - A[i - 1]) : (l / A[i - 1] * A[i - 1]);
		ll R = (r % A[i - 1] == 0) ? (r - A[i - 1]) : (r / A[i - 1] * A[i - 1]);
		if (L == R) {
			printf("-1\n");
			return 0;
		}
		m = (l % A[i - 1] == 0) ? l : (l / A[i - 1] * A[i - 1] + A[i - 1]);
		M = (r % A[i - 1] == 0) ? (r - A[i - 1]) : (r / A[i - 1] * A[i - 1]);
	}
	printf("%lld %lld\n", m, M + A[0] - 1);

	return 0;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  a
//
//  Created by h3037153 on 2018/01/15.
//  Copyright © 2018年 h3037153. All rights reserved.
//

#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
    return 0;
}

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

using namespace std;

const int N = 30;
 
int h, w, n;
char data[N][N];
char tmp[N][N];

void copy(){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      tmp[i][j] = data[i][j];
    }
  }
}

bool check2(){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(tmp[i][j] != '.') return false;
    }
  }
  return true;
}

bool erase(){
  bool res = false;
  bool f[N][N];
  fill(f[0], f[N], false);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(tmp[i][j] == '.') continue;
      int k;
      for(k=j;k<w&&tmp[i][j]==tmp[i][k];k++);
      if(k - j >= n) for(int l=j;l<k;l++) f[i][l] = true;
    }
  }
  for(int j=0;j<w;j++){
    for(int i=0;i<h;i++){
      if(tmp[i][j] == '.') continue;
      int k;
      for(k=i;k<h&&tmp[i][j]==tmp[k][j];k++);
      if(k - i >= n) for(int l=i;l<k;l++) f[l][j] = true;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(f[i][j]){
        tmp[i][j] = '.';
        res = true;
      }
    }
  }
  return res;
}

void fall(){
  for(int i=h-1;i>=0;i--){
    for(int j=0;j<w;j++){
      if(tmp[i][j] == '.') continue;
      int k;
      for(k=i+1;k<h&&tmp[k][j]=='.';k++);
      swap(tmp[i][j], tmp[k-1][j]);
    }
  }
}

bool check(){
 for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(data[i][j] == '.') continue;
      for(int k=-1;k<=1;k++){
        if(!k) continue;
        int ny = i;
        int nx = j + k;
        if(ny < 0 || ny >= h) continue;
        if(nx < 0 || nx >= w) continue;
        //if(data[ny][nx] == '.') continue;
        swap(data[i][j], data[ny][nx]);
        copy();
        fall();
        while(1){
          if(!erase()) break;
          fall();
        }
        if(check2()) return true;
        swap(data[i][j], data[ny][nx]);
      }
    }
  }
 return false;
}

main(){
  cin >> h >> w >> n;
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> data[i][j];
  cout << (check() ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	int a[100001];
	int count = 0;
	int x = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		count += abs(x - a[i]);
		x = a[i];
	}
	count += abs(a[n] - 0);
	a[0] = 0;
	a[n + 1] = 0;
	int ans;
	for (int i = 1; i <= n; i++) {
		ans = count;
		int bx = abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1]);
		int ax = abs(a[i - 1] - a[i + 1]);
		cout << ans - bx + ax << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
typedef long long ll;
int main() {
    ll n, tmp, t;
    ll k = 0;
    ll ans = 0;
    cin >> n;
    ll v[n];
    v[0] = 0;
    for(ll i=1;i<n+1;i++) {
        cin >> tmp;
        if (i==1) {
            v[1] = tmp;
        } else {
            v[i] = v[i-1] + tmp;
        }
    }
    map<ll,ll> m;
    for(ll i=0;i<n+1;i++) {
        m[v[i]]++;
    }
    for(auto i : m) {
        t = i.second;
        ans += t * (t-1)/2;
    }
    cout << ans << endl;
}
// 1 4 0 4
// 0 1 4 1 3 1


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

int main() {

  int x  = 0;
  int y = 0;
  bool sol = false;
  cin >> x >> y;
  rep(i,x + 1)
  {
    if((i * 4 + (x - i) * 2) == y )
    {
      sol = true;
      break;
    }
  }
  if(sol)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 1005
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},dis[mex][mex],n,m;
string mat[mex];
queue< pii > q; 

inline bool ok(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m);
}

inline void dfs(int x,int y,int val)
{
    dis[x][y]=val;
    for(int i=0;i<4;i++){
        int a=x+dx[i],b=y+dy[i];
        if(ok(a,b) && mat[a][b]!='#' && dis[a][b]==-1){
            dfs(a,b,val);
            q.push(mp(a,b));
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m;
    int a,b,c,d; cin>>a>>b>>c>>d;
    a--; b--; c--; d--;
    for(int i=0;i<n;i++) cin>>mat[i];
    q.push(mp(a,b));
    fill(dis,-1); dis[a][b]=0;
    while(!q.empty()){
        pii p=q.front(); q.pop();
        dfs(p.ff,p.ss,dis[p.ff][p.ss]);
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int x=p.ff+i,y=p.ss+j;
                if(ok(x,y) && mat[x][y]!='#' && dis[x][y]==-1){
                    dis[x][y]=dis[p.ff][p.ss]+1;
                    q.push(mp(x,y));
                    dfs(x,y,dis[x][y]);
                }
            }
        }
    }
    cout<<dis[c][d]<<endl;
}

Measured memory_bytes: 12652
import sys
input = sys.stdin.readline

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

start = k-q
A = [start]*n

for _ in range(q):
    num = int(input()) - 1
    A[num] += 1

for a in A:
    if a > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 6584
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cctype>
using namespace std;

class dice {
public:
	int face[7];
	int get;

	dice(int x[]) {
		for (int i = 1; i <= 6; i++)
			face[i] = x[i];
	}

	void round(string x) {
		for (int i = 0; i < x.size(); i++) {
			switch (x[i]) {
			case 'E':
				get = face[1];
				face[1] = face[4];
				face[4] = face[6];
				face[6] = face[3];
				face[3] = get;
				break;
			case 'W':
				get = face[1];
				face[1] = face[3];
				face[3] = face[6];
				face[6] = face[4];
				face[4] = get;
				break;
			case 'N':
				get = face[1];
				face[1] = face[2];
				face[2] = face[6];
				face[6] = face[5];
				face[5] = get;
				break;
			case 'S':
				get = face[1];
				face[1] = face[5];
				face[5] = face[6];
				face[6] = face[2];
				face[2] = get;
				break;
			}
		}
	}
};

int main() {
	int facef[7];
	string operate;

	for (int i = 1; i <= 6; i++) {
		cin >> facef[i];
	}

	dice dice1(facef);

	cin >> operate;

	dice1.round(operate);

	cout << dice1.face[1] << endl;

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
  int N, ans = 0;
  cin >> N;
  vector<int> A(N);
 
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
 
  while (true){
    for (int i=0; i<N; i++){
      if (A[i] % 2) {
      	cout<< ans <<endl;
	return 0;
      }
      else{
	A[i] /= 2;
      }
    }
    ans++;
  }
}

Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def resolve():
  N, M = map(int, input().split(" "))
  connections = UnionFind(N)
  for _ in range(M):
    A, B = map(int, input().split(" "))
    A -= 1
    B -= 1
    connections.union(A, B)
  print(len(connections.roots()) - 1)

if __name__ == "__main__":
  resolve()

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll A;
  string B;
  cin >> A >> B;
  //Bから小数点を除くことで100倍の値にする
  B.erase(1,1);
  ll num_b = stoi(B);
  ll ans = A * num_b;
  //Bが100倍になっているので100で割る
  ans /= 100;
  cout << ans << "\n";
}


Measured memory_bytes: 3636
#136
n = int(input())
res = 0

for i in range(1,len(str(n))+1):
    if i % 2 == 1:
        if n >= 10 ** i:
            res += (10 ** i) - 10 ** (i - 1)
        else:
            res += n - (10 ** (i -1) - 1)
print(res)

Measured memory_bytes: 3060
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long a = parseLong(sc.next());
		long b = parseLong(sc.next());
		sc.close();
		out.println(a*b/gcm(a,b));
	}
	public static long gcm(long a, long b) {
		long tmp;
		while((tmp=a%b)!=0) {
			a=b;
			b=tmp;
		}
		return b;
	}
}


Measured memory_bytes: 22100
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const double PI = acos(-1);  // PI = 3.141593...

struct Dice {
    int up, front, right, left, back, down;
    Dice(int _up, int _front, int _right, int _left, int _back, int _down) 
    :up(_up), front(_front), right(_right), left(_left), back(_back), down(_down) 
    {}
    void east() {
        int tmp = this->up;
        this->up = this->left;
        this->left = this->down;
        this->down = this->right;
        this->right = tmp;
    }
    void west() {
        int tmp = this->up;
        this->up = this->right;
        this->right = this->down;
        this->down = this->left;
        this->left = tmp;
    }
    void south() {
        int tmp = this->up;
        this->up = this->back;
        this->back = this->down;
        this->down = this->front;
        this->front = tmp;
    }
    void north() {
        int tmp = this->up;
        this->up = this->front;
        this->front = this->down;
        this->down = this->back;
        this->back = tmp;
    }
    void toRight() {
        int tmp = this->front;
        this->front = this->left;
        this->left = this->back;
        this->back = this->right;
        this->right = tmp;
    }
    void print() {
        printf("up: %d, down: %d, front: %d, back: %d, left: %d, right: %d\n"
        , this->up, this->down, this->front, this->back, this->left, this->right);
    }
};

int main() {
    int up, front, right, left, back, down;
    int q, q1, q2;
    cin >> up >> front >> right >> left >> back >> down;
    Dice dice(up, front, right, left, back, down);
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> q1 >> q2;
        if(dice.left == q1 || dice.right == q1) dice.toRight();
        while(dice.up != q1) dice.south();
        while(dice.front != q2) dice.toRight();
        cout << dice.right << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin >> n;
    ll ans = (n/500) * 1000 + (n % 500) - n % 5;
    cout << ans << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;
    t = 1;
    /*cin >> t;*/
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, N) A[i] = -1;
  rep(i, M) {
    int S, C;
    cin >> S >> C;
    --S;
    if (A[S] == -1) A[S] = C;
    else if (A[S] != C) {
      puts("-1");
      return 0;
    }
  }
  if (N == 1) {
    if (A[0] == -1) {
      puts("0");
      return 0;
    } else {
      cout << A[0] << '\n';
      return 0;
    }
  }
  if (A[0] == -1) A[0] = 1;
  else if (A[0] == 0) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i < N; i++) {
    if (A[i] == -1) A[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    cout << A[i];
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int x,y,z,j,sum;
	sum = j = 0;
	scanf("%d %d %d",&x,&y,&z);
	for(;;){
		sum = sum + z;
		sum = sum + y;
		j++;
		if(sum == x-z) { printf("%d\n",j);break;}
		else if(sum < x-z) {;}
			 else {printf("%d\n",j-1);break;}
	}
}

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

#define rep(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define int long long

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (100001)
#define MAX (1000000000000000000LL)
using namespace std;

signed main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	ans += n * (s[0] - '0') * 100;
	ans += n * (s[2] - '0') * 10;
	ans += n * (s[3] - '0') * 1;
	ans = ans / 100;
	cout << ans << endl;
}

Measured memory_bytes: 3580
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll 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;
}
const double eps=1e-13;
bool equals(double x,double y){return fabs(x-y)<eps;}
struct Point{double x,y;};
Point operator -(Point a,Point b){return (Point){a.x-b.x,a.y-b.y};}
double cross(Point a,Point b){return a.x*b.y-a.y*b.x;}
double dot(Point a,Point b){return a.x*b.x+a.y*b.y;}
void read(Point &a){a.x=read(),a.y=read();}
bool Parllel(Point p0,Point p1,Point p2,Point p3)
{
	Point v1=p1-p0,v2=p3-p2;
	return equals(cross(v1,v2),0);
}
bool Orthogonal(Point p0,Point p1,Point p2,Point p3)
{
	Point v1=p1-p0,v2=p3-p2;
	return equals(dot(v1,v2),0);
}
int main()
{
	int q=read();while(q--)
	{
		Point p0,p1,p2,p3;
		read(p0),read(p1),read(p2),read(p3);
		if(Parllel(p0,p1,p2,p3)){printf("2\n");continue;}
		if(Orthogonal(p0,p1,p2,p3)){printf("1\n");continue;}
		printf("0\n");
	}
	return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int a,b;
    cin>>a>>b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)cout<<"Alice";
    else if(a<b)cout<<"Bob";
    else cout<<"Draw";
    
	return 0;
}


Measured memory_bytes: 3616
/*
            ██        ██              ██        ██████
                    ██████                    ██    ██
        ████████    ██████    ████████      ████████
    ████        ██████████████        ████
  ██        ██████    ██    ██████        ██
██████████  ██████        ████████  ██████████
    ████████    ██████  ██████    ████████
        ████  ██    ██  ██    ██  ████
          ██  ██  ████  ████  ██  ██        ████████
          ██  ██    ██████    ██  ██          ██    ██
        ██      ██████  ██████      ██          ██████
  ██    ██          ██████          ██
        ██      ████████████████    ██
        ██    ██              ██      ██
          ██  ██    ██████    ██      ██      ████
      ██  ██  ██████      ██████        ██    ██  ██
    ████    ██                          ██    ██  ██████████
  ██  ██      ██            ██            ██  ██  ██
  ██  ██        ████      ██              ██  ██  ██
  ████            ████  ██        ██      ██████  ██████████
                ████████        ██        ████    ████
              ██    ████    ████          ████  ██  ██
              ██    ██████████            ████  ██  ██
                ██████████                  ██  ██  ██
        ██████  ██████████████████████████████████  ██
        ██  ████████  ██                    ██  ██  ████
        ██████████      ██████████████████████████    ██
          ██████        ██                  ██        ██████
                          ██                ██
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.replace(/\n/g, ' ');
  input = input.split(" ");
  var A = input[0];
  var moji  = A.split("");
  for(var i=0;i<moji.length;i++){
    var p = moji[i];
    if(p=="?"){
      if(i==0){
        if(i+1!=moji.length){
          if(moji[i+1]!="P"){
            moji[i]="P";
          }else{
            moji[i]="D";
          }
        }else{
          moji[i]="D";
        }
      }else if(i+1==moji.length){
        moji[i]="D";
      }else{
        if(moji[i-1]=="P"){
          moji[i]="D";
        }else{
          if(moji[i+1]!="P"){
            moji[i]="P";
          }else{
            moji[i]="D";
          }
        }
      }
    }
  }
  console.log(moji.join(""));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 41840
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

string s;

void solve(){
  cin >> s;
  int a=-1,z=-1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      z=i;
      break;
    }
  }
  cout << z-a+1 << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

signed main(){
    int k;
    cin>>k;
    
    priority_queue<int,vector<int>,greater<int>> pq;
    rep(i,50)pq.push(i + k/50);
    
    k%=50;
    
    cout<<50<<endl;
    rep(i,50){
        int q = pq.top();
        pq.pop();
        
        if(i<k){
            cout<<q+50-k+1<<" ";
        }
        else cout<<q-k<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
birth=[]
for i in range(M):
    p,y=map(int,input().split())
    birth.append([i,p,y])

birth.sort(key=lambda x:(x[1],x[2]))

birth[0].append(0)
cnt=0
for i in range(M-1):
    if birth[i][1]==birth[i+1][1]:
        cnt+=1
    else:
        cnt=0
    birth[i+1].append(cnt)

birth.sort(key=lambda x:x[0])
for i in range(M):
    ans=str(birth[i][1]).zfill(6)+str(birth[i][3]+1).zfill(6)
    print(ans)


Measured memory_bytes: 35484
#include<bits/stdc++.h>
using namespace std;
#define int long long
//typedef long long ll;
const int N = 1e5+7;

signed main(){

	int n,k;
	cin >> n >> k;

	if(k%2 != 0){
		int a = n/k;
		cout << a*a*a << endl;
	}
	else {
		int a = n/k;
		int b = (n + k/2)/k;
		cout << a*a*a + b*b*b << endl;
	}

  return 0;
}


Measured memory_bytes: 256
N, X = [int(num) for num in input().split()]
m_list = [int(input()) for _ in range(N)]
m_list.sort()
count = len(m_list)
X = X - sum(m_list)

if X:
  d, m = divmod(X, m_list[0])
  count = count + d
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll N,K; cin >>N>>K;
    vector<ll> A(N);
    vector<ll> list(N+1,-1);
    vector<ll> s;
    ll now = 1;
    ll c = 1, l = 0;

    for (ll i = 0; i < N; i++){
      cin >> A[i];
    }
    
    while(list[now] == -1){
      list[now] = s.size();
      s.push_back(now);
      now = A[now-1];
    }
    c = s.size() - list[now];
    l = list[now];

    if(K < l){
      cout << s[K] << endl;
    } else {
      K -= l;
      K %= c;
      cout << s[l+K] << endl;
    }
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();

        int ans = n;
        for (int i = 0; i <= n; i++)
        {
            int c = 0;
            int r = i;
            // iまでの金額を6^p円で引き出す回数
            while (r > 0)
            {
                c += r % 6;
                r /= 6;
            }
            // n - iの金額を9^p円で引き出す回数
            r = n - i;
            while (r > 0)
            {
                c += r % 9;
                r /= 9;
            }
            if (c < ans) ans = c;
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 13140