akhauriyash/Code-Regression huggingface dataset:
class Combination:                                      # 計算量は O(n_max + log(mod))
    def __init__(self, n_max, MOD=10 ** 9 + 7):
        self.mod = MOD
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):                     # 階乗(= n_max !)の逆元を生成
            f = f * i % MOD                             # 動的計画法による階乗の高速計算
            fac.append(f)                               # fac は階乗のリスト
        f = pow(f, MOD - 2, MOD)                          # 階乗から階乗の逆元を計算。フェルマーの小定理より、　a^-1 = a^(p-2) (mod p) if p = prime number and p and a are coprime
                                                        # python の pow 関数は自動的に mod の下での高速累乗を行ってくれる
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):                   # 上記の階乗の逆元から階乗の逆元のリストを生成（＝ facinv ）
            f = f * i % MOD
            facinv.append(f)
        facinv.reverse()

    def C(self, n, r):
        if not 0 <= r <= n: return 0                    # 範囲外という事はすなわち、そのような場合の数は無いはずなので、0を出力すればよい。（これが無いとREになる）
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[n-r] % self.mod


#############################################################
N, M = map(int, input().split())
MOD=10 ** 9 + 7
C = Combination(M, MOD)
sgn = 1
res = 0
for k in range(0, N+1):
    res += sgn*C.C(N,k)*C.P(M-k,N-k)
    res %= MOD
    sgn *= -1
print(res*C.P(M,N)%MOD)


Measured memory_bytes: 116088
fun main(args: Array<String>){
    val N = nextInt()
    val L = listOfInt().sorted()
    val D = L.map { it.toDouble()}
    var ans = 0L
    for (a in 0 until N - 2) {
        for (b in a + 1 until N - 1) {
            val ab = L[a] + L[b]
            val l = b + 1
            var r = D.binarySearch(element = ab.toDouble() - 0.1, fromIndex = l, toIndex = N - 1)
            if (r < 0) r = r.inv()
            if (ab > L[r]) r++
            val c = Math.max(0, r - l)
            ans += c
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }


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

int main() {
	int n;
	long long a;
	long long minvalue = 1000000;
	long long maxvalue = -1000000;
	long long sum = 0;

	cin >> n;

	for (int i = 0; i<n; i++) {
		cin >> a;
		if (a<minvalue) {
			minvalue = a;
		}
		if (a>maxvalue) {
			maxvalue = a;
		}
		sum += a;
	}

	cout << minvalue << " " << maxvalue << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 1168
# coding: utf-8
#Problem Name: Drawing Lots
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

w = int(raw_input())
n = int(raw_input())
change = [0 for _ in xrange(n)]
for i in xrange(n):
    change[i] = eval(raw_input())
List = range(1,w+1)
for i,j in change:
    List[i-1],List[j-1] = List[j-1],List[i-1]
for i in List:
    print i

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

typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T>
class MinPq: public priority_queue<T, vector<T>, greater<T> > {};
template <typename T>
class MaxPq: public priority_queue<T, vector<T>, less<T> > {};

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sqrti(n) (int)ceil(sqrt((double)n))
#define len(a) sizeof(a)/sizeof(a[0])
#define pcase(ca,v) cout<<"Case #"<<ca+1<<": "<<v<<'\n'
#define parity(n) (n&1)
#define even(n) parity(n)==0
#define odd(n) parity(n)==1
#define inf INT_MAX
#define infl LLONG_MAX

const ll mod=1000000007L;

void solve(){
  int s;
  cin>>s;
  if(s<3){
    cout<<0<<endl;
    return;
  }
  vector<ll> dp(s+1,0);
  dp[3]=1;
  for(int i=4; i<=s; i++){
    dp[i]=1;
    for(int j=3; j<=i; j++){
      dp[i]+=dp[i-j];
      dp[i]%=mod;
    }
  }
  cout<<dp[s]<<endl;
}

int main(){
  fastio;
  #if DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  #endif

  solve();
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef vector<double> vec;
typedef vector<vec> mat;

#define EPS (1e-9)

vec gauss_jordan(const mat&A,const vec &b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i = 0; i < n;i++)
    for(int j=0;j<n;j++)
      B[i][j]=A[i][j];
  for(int i = 0; i < n; i++)
    B[i][n]=b[i];
  for(int i = 0; i < n; i++){
    int piv=-1;
    double val=-1;
    for(int j=i;j<n;j++){
      if(val<abs(B[j][i])){
	piv=j;
	val=abs(B[j][i]);
      }
    }
    if(piv==-1||val<EPS)return vec();
    swap(B[piv],B[i]);
    double divNum=B[i][i];
    for(int j = i; j <= n; j++)
      B[i][j]/=divNum;
    for(int j = 0; j < n; j++){
      if(i==j)continue;
      double mulnum=B[j][i];
      for(int k = i; k <= n; k++)
	B[j][k]-=mulnum*B[i][k];
    }
  }
  vec res(n);
  for(int i = 0; i < n; i++)res[i]=B[i][n];
  return res;
}

const int INF=1000000000;
int n,s,g;
int qs[101];
int as[101][101];
int d[101][101];

int main(){

  while(cin>>n>>s>>g&&(n|s|g)){
    s--;g--;
    for(int i=0;i<n;i++)cin>>qs[i];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i!=j)d[i][j]=INF;
	else d[i][j]=0;
	cin>>as[i][j];
	if(as[i][j]==0)as[i][j]=INF;
	d[i][j]=min(d[i][j],as[i][j]);
      }
    }
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    if(d[s][g]==INF){
      cout<<"impossible"<<endl;
      continue;
    }
    mat A(n,vec(n,0));
    vec b(n,0);
    for(int i=0;i<n;i++){
      if(i==g){
	A[i][i]=1;
	continue;
      }
      if(d[i][g]==INF){
	A[i][i]=1;
	continue;
      }
      int cnt=0;
      int scost=0;
      for(int j=0;j<n;j++){
	if(as[i][j]==INF)continue;
	if((qs[i]&&as[i][j]+d[j][g]==d[i][g])
	   ||!qs[i]){
	  cnt++;
	  scost+=as[i][j];
	  A[i][j]=1;
	}
      }
      if(cnt!=0)b[i]=(double)scost/cnt;
      if(cnt!=0)for(int j=0;j<n;j++)A[i][j]/=(-cnt);
      A[i][i]+=1;
    }
    vec v=gauss_jordan(A,b);
    printf("%.10f\n",v[s]);
  }

  return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    int N=S.size();
    //-----------------------------------
    for(int i=N/2-1;i>=0;i--){
        bool isOK=true;
        rep(k,i){
            if( S[k]!=S[i+k] ){
                isOK=false;
                break;
            }
        }
        if(isOK){
            cout << i*2 <<endl;
            return 0;
        }
    }


    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=157;
typedef long long ll;

int n,m,ans;
int a[10005];

int c[maxn][maxn];

int t;

int main()
{
	int i,j,k;
	scanf("%d%d",&n,&m);
	scanf("%d",&k);
	for(i=1;i<=k;++i) scanf("%d",&a[i]);
	
	i=1;j=1;t=1;
	
	while(k)
	{
		
		while(a[k])
		{
			c[i][j]=k;
			a[k]--;
			
			if(i%2==1) t=1;
			else t=-1;
			
			if((t==1&&j==m)||(t==-1&&j==1))
			{
				i++;continue;
			}
			else j+=t;
		}
		
		k--;
		
	}
	
	for(i=1;i<=n;++i)
	{
		for(j=1;j<m;++j)
		  printf("%d ",c[i][j]);
		printf("%d\n",c[i][j]);
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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



int main(){
    ll N;
    string c;
    cin >> N;
    cin >> c;
    ll ans = 0;
    int a = 0, b = 0;
    rep(i,N) if(c[i] == 'R') a++;
    ans = max(a,b);


    rep(i,N){
        if(c[i] == 'W') b++;
        else a--;
        ll now = max(a,b);
        ans = min(ans,now);
    }
    cout << ans << endl;
}


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

int main () {
  int x, y;
  cin >> x >> y;
  
  int a;
  int b;
  
  a = x / 500;
  b = x - a * 500;
  
  if (b <= y) {
    cout << "Yes" << endl;
  }
  
  if (b > y) {
    cout << "No" << endl; 
  }
 
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a[4], b[4], hit=0, blow=0, i, j;
	while( scanf("%d %d %d %d",&a[0] ,&a[1] ,&a[2] ,&a[3])!=EOF ) {
		scanf("%d %d %d %d",&b[0] ,&b[1] ,&b[2] ,&b[3]);
		// Hit
		hit=0;
		for(i=0;i<4;i++) {
			if ( a[i]==b[i] ) hit++;
		}
		// Blow
		blow=0;
		for(i=0;i<4;i++) {
			for(j=0;j<4;j++) {
				if (i==j) continue;
				if (a[i]==b[j]) blow++;
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

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


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

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

    int res = 0;
    while(1){

        if(*max_element(h.begin(), h.end()) == 0){
            break;
        }

        int i = 0;
        while(i<N){
            if(h[i] == 0){
                i++;
            }else{
                res++;
                while(i < N && h[i] > 0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout<< res <<endl;
    return 0;
}

Measured memory_bytes: 3628
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n,s=NM()
l=[0]+L()
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
ans=0
mod=998244353
inv2=pow(2,mod-2,mod)
pow2n=pow(2,n,mod)
for i in range(1,n+1):
    x=l[i]
    for j in range(s+1):
        dp[i][j]=dp[i-1][j]
    for j in range(x,s+1):
        dp[i][j]+=dp[i-1][j-x]*inv2
        dp[i][j]%=mod
ans=dp[-1][-1]*pow(2,n,mod)%mod
print(ans)

Measured memory_bytes: 132448
L, R = map(lambda x: int(x),input().split(" "))
num_list = []

while L > 2019:
  L = int(L-2019)
  R = int(R-2019)

if R < 2019:
  for i in range(L,R):
    for j in range(L+1,R+1):
      num_list.append((i*j)%2019)
  print(min(num_list))
elif L <= 2019 and R >= 2019:
  print(0)

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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

const int M = 1e9 + 7;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	string k; int d; cin >> k >> d;
	vvi f(d, vi(2)); f[0][0] = 1;
	rep(i, 0, sz(k)) {
		vvi g(d, vi(2));
		rep(x, 0, d) {
			rep(c, 0, 10) (g[(x + c) % d][1] += f[x][1]) %= M;
			rep(c, 0, k[i] - '0') (g[(x + c) % d][1] += f[x][0]) %= M;
			(g[(x + k[i] - '0') % d][0] += f[x][0]) %= M;
		}
		swap(f, g);
	}
	cout << (f[0][0] + f[0][1] + M - 1) % M;
}

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

int main() {
    int n;cin >> n;
    int a[n], b[n], c[n-1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    for (int i = 1; i <= n-1; ++i) {
        cin >> c[i];
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += b[a[i]];
        if ( i != 1 && a[i] == a[i-1]+1 ) {
            ans += c[a[i-1]];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum=0;
ll n,one,two;
ll a[5];
int main() {
	for(int i=1;i<=4;i++)
		cin>>a[i];
	a[1]*=4LL;
	a[2]*=2LL;
	cin>>n;
	one=min(a[1],min(a[2],a[3]));
	two=min(a[4],one*2);
	sum=(n/2)*two+(n%2)*one;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

void solve(ll H, ll W, ll h, ll w) {
  cout << (H-h)*(W-w) << endl;
}

int main() {
  ll H;
  cin >> H;
  ll W;
  cin >> W;
  ll h;
  cin >> h;
  ll w;
  cin >> w;
  solve(H, W, h, w);
  return 0;
}


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

N=int(input())
a = list(map(int, input().split()))

dp = [[None]*(N+1) for _ in range(N+1)]
for i in range(N+1):
    dp[i][i]=0
for len in range(1,N+1):
    for i in range(N-len+1):
        j=i+len
        #print(i,j)
        if (N-len)%2==0:
            dp[i][j] = max(dp[i][j-1]+a[j-1], dp[i+1][j]+a[i])
        else:
            dp[i][j] = min(dp[i][j-1]-a[j-1], dp[i+1][j]-a[i])
#print(dp)
print(dp[0][N])

Measured memory_bytes: 165640
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>

#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, weight;

	bool operator < (const Edge& obj) const {
		return weight < obj.weight;
	}
	bool operator > (const Edge& obj) const {
		return weight > obj.weight;
	}
};

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main()
{
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	bool ok = true;
	REP(i, a) {
		if (s[i] == '-') ok = false;
	}
	if (s[a] != '-') ok = false;
	rep(i, a + 1, b + a + 1) {
		if (s[i] == '-') ok = false;
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
$input = explode(' ', trim(fgets(STDIN)));
list($X, $A, $B) = array($input[0], $input[1], $input[2]);

$result = $B - $A;
if ($result < 1) {
  echo "delicious\n";
} elseif ($result >= $X + 1) {
  echo "dangerous\n";
} else {
  echo "safe\n";
}


Measured memory_bytes: 3576
n = gets.to_i; blues = n.times.map { gets.strip }
m = gets.to_i; reds = m.times.map { gets.strip }
uniqs = blues.uniq
res = uniqs.map {|u| blues.count(u) }.zip(uniqs.map {|u| reds.count(u) }).map{|a| a.inject(:-)}.max
puts res >= 0 ? res : 0

Measured memory_bytes: 1916
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  if(a+b<10) {
    cout << a+b << endl;
  }
  else {
    cout << "error" << endl;
  }
}

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

int main() {
  vector<char> Order;
  char A,B,C ;
  cin >> A >> B >> C ;
  Order = { A , B , C } ;
  int Ans=700 ;
  for (int i = 0; i<3 ; i++ ){
    if (Order.at(i)=='o') Ans=Ans+100 ;
  }
  cout << Ans ;
}

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

int main(void)
{
	int i,run=0,point=0,out=0;
	char s[100];

	scanf("%d",&i);
	while(i!=0)
	{
		scanf("%s",s);
		if(strcmp(s,"HIT")==0)
		{
			run +=1;
			if(run==4)
			{
				run=3;
				point+=1;
			}
		}
		if(strcmp(s,"HOMERUN")==0)
		{
			point+=run+1;
			run=0;
		}
		if(strcmp(s,"OUT")==0)
		{
			out+=1;
			if(out==3)
			{
				run=0;
				out=0;
				printf("%d\n",point);
				point=0;
				i--;
			}
		}	
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  string ans;
  int a = s[0] - '0';
  int b = s[1] - '0';
  int c = s[2] - '0';
  int d = s[3] - '0';
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int t = a;
        t = (i ? t + b : t - b);
        t = (j ? t + c : t - c);
        t = (k ? t + d : t - d);

        if (t == 7) {
          cout << a << (i ? "+" : "-") << b << (j ? "+" : "-") << c << (k ? "+" : "-") << d << "=7" << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
def main():
    labels1 = list(map(int, input().split(' ')))
    labels2 = list(map(int, input().split(' ')))

    dice1 = Dice(labels1)
    dice2 = Dice(labels2)

    print('Yes' if equals(dice1, dice2) else 'No')

def equals(d1, d2):
    for i in range(4):
        for j in range(4):
            if d1.equals(d2):
                return True
            d2.toE()
        d2.toN()

    d2.toE().toN()

    for i in range(2):
        for j in range(4):
            if d1.equals(d2):
                return True
            d2.toE()
        d2.toN().toN()

    return False

class Dice:
    def __init__(self, labels):
        self.labels = labels

        self._tb = (0, 5)
        self._fb = (1, 4)
        self._lr = (3, 2)

    def toN(self):
        tb = self._tb
        self._tb = self._fb
        self._fb = tuple(reversed(tb))

        return self

    def toS(self):
        tb = self._tb
        self._tb = tuple(reversed(self._fb))
        self._fb = tb

        return self

    def toW(self):
        tb = self._tb
        self._tb = tuple(reversed(self._lr))
        self._lr = tb

        return self

    def toE(self):
        tb = self._tb
        self._tb = self._lr
        self._lr = tuple(reversed(tb))

        return self

    def get_top(self):
        return self.labels[self._tb[0]]

    def get_bottom(self):
        return self.labels[self._tb[1]]

    def get_front(self):
        return self.labels[self._fb[0]]

    def get_back(self):
        return self.labels[self._fb[1]]

    def get_left(self):
        return self.labels[self._lr[0]]

    def get_right(self):
        return self.labels[self._lr[1]]

    top    = property(get_top)
    bottom = property(get_bottom)
    front  = property(get_front)
    back   = property(get_back)
    left   = property(get_left)
    right  = property(get_right)

    def equals(self, other):
        if not (self.top == other.top and self.bottom == other.bottom):
            return False

        if not (self.front == other.front and self.back == other.back):
            return False

        if not (self.left == other.left and self.right == other.right):
            return False

        return True

    def __str__(self):
        return str([self.top, self.front, self.right, self.left, self.back, self.bottom])

if __name__ == '__main__':
    main()

Measured memory_bytes: 7896
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int dp[100005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  FOR(i,0,100005) dp[i] = 2e9;
  int ans = 0;
  FOR(i,0,n) {
    int a;cin>>a;
    int k = lower_bound(dp,dp+100005,a) - dp;
    //cout << i << " " << k << endl;
    dp[k] = a;
    ans = max(ans, k + 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)


import os
import sys
from sys import *
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()



sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
z = lambda: sys.stdin.readline().rstrip("\r\n")



def op():
    return list(map(int,z().split()))
def o():
    return int(z())
def r(x):
    if type(x)==int:
        return range(x)
    else:return range(len(x))
def kl(con,x=0):
    if x==0:print('Yes') if con else print('No')
    elif x==1:print('yes') if con else print('no')
    elif x==2:print('YES') if con else print('NO')
MOD = 1000000007
MAX=float('inf')
MIN=-float('inf')
x=z()
c=0
f=0
l1,l2=[],[]
for i in x:
    if i=='<':
        c+=1
        l1.append(c)
    else:
        c=0
        l1.append(c)
for i in x[::-1]:
    if i=='>':
        c+=1
        l2.append(c)
    else:
        c=0
        l2.append(c)
l2=l2[::-1]
ans=[]
for i in r(len(x)-1):
      ans.append(max(l1[i],l2[i+1]))
ans.insert(0,l2[0])
ans.append(l1[-1])
print(sum(ans))

Measured memory_bytes: 33180
#include<stdio.h>
int main()
{
	char s[3],w[3];
	int a,i,co=0;
	//for(i=0;i<3;i++)
	scanf("%s",&s);
	scanf("%s",&w);
	for(i=0;i<3;i++)
		if(s[i]==w[i]) co++;
	printf("%d\n",co);
}


Measured memory_bytes: 128
/*
  Fuad Ashraful Islam
  University of Asia Pacific,Bangladesh
  Date:23th April 2020
  TODO:
  https://vjudge.net/contest/338714
  http://lightoj.com/volume_showproblem.php?problem=1149
 */
#include<bits/stdc++.h>
#define dbg(x) cerr <<__LINE__<<" where "<< #x << " = " << x << endl
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb push_back

using namespace std;
template <class T>
inline void read(T &res)
{
  res = 0; bool bo = 0; char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-');
  if (c == '-') bo = 1; else res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  if (bo) res = ~res + 1;
}
template<typename T> T Abs(T x){ return x<0?-x:x; }
template<typename T>T Max(T a,T b){return a>b?a:b;}
const int N=1e5+5;
typedef long long ll;
int len,_,n,d,k,m,l,c,cs=1;

void Solve()
{
  read(n);
  set<string>st;
  while(n--)
  {
    string s;
    cin>>s;
    st.insert(s);
  }
  int ans=(int)st.size();
  cout<<ans<<"\n";
}
int main()
{
  // for(read(_);_;_--)
  Solve();
  return 0;
}

Measured memory_bytes: 19096
import numpy as np

h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))

g = [[0 for _ in range(w)] for _ in range(h)]

l = []
for i in range(n):
    l.extend([i + 1] * a[i])

l = np.array(l).reshape((h,w))
cnt = 0
for i in range(h):
    if cnt % 2 == 1:
        l[i] = np.flipud(l[i])
    cnt+=1
for i in l:
    print(*i)

Measured memory_bytes: 13276
#include <cstdio>
#include <cctype>

using namespace std;

namespace RenaMoe {

template<typename T>
inline void read(T &x) {
	x = 0; bool f = false; char in = getchar();
	while (!isdigit(in)) { if (in == '-') f = true; in = getchar(); }
	while (isdigit(in)) x = x * 10 + in - '0', in = getchar();
	x = f ? -x : x;
}

typedef long long LL;

const int N = 1e5 + 9;

struct Edge {
	int nxt, to;
};

int n, m, cnte;
LL ans;
int head[N], col[N], sum[4];
Edge e[N<<1];

inline void add_edge(int u, int v) {
	e[++cnte] = (Edge){head[u], v}, head[u] = cnte;
}

bool dfs(int u, int color) {
	col[u] = color, sum[color]++;
	for (int i = head[u], v; i; i = e[i].nxt) {
		if (!col[v=e[i].to]) {
			if (dfs(v, color^1)) return true;
		}
		else if (col[v] == color)
			return true;
	}
	return false;
}

inline void main() {
	read(n), read(m);
	for (int i = 1, u, v; i <= m; ++i)
		read(u), read(v), add_edge(u, v), add_edge(v, u);
	if (dfs(1, 2)) ans = (LL)(n - 1) * n / 2;
	else ans = (LL)sum[2] * sum[3];
	printf("%lld\n", ans - m);
}
}

int main() {
	RenaMoe::main();
	return 0;
}

Measured memory_bytes: 4224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ribhav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRGBBoxes solver = new BRGBBoxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRGBBoxes {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int r = s.nextInt();
            int g = s.nextInt();
            int b = s.nextInt();
            int n = s.nextInt();
            int count = 0;
            for (int i = 0; i <= n / r; i++) {
                for (int j = 0; j <= n / g; j++) {
                    if ((n - (i * r) - (g * j) >= 0) && (n - (i * r) - (g * j)) % b == 0) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

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

    int N;
    cin >> N;
    vector<P> a(N);
    rep(i,N){
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    
    sort(a.begin(), a.end());
    
    rep(i,N){
        cout << a[i].second << ' ';
    }

    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
#include<unordered_map>
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <cstdio>
#include <cstdlib>
#define ll long long
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define arr2dof vector  vector<vector<int>>dp(N,vector<int>(2, inf));
using namespace std;
const int N = 2e5 + 5, inf = 1e9+7 ;
const double ep = 0.0000000001;
const double pi = 3.14159265359;
const long long inff= 1e18;
	ll n, arr[100005],k;
	ll dp[100005];
	ll fun(int ind) {
		if (ind == n) {
			
			return 0;
		}
		if (dp[ind] != -1) {
			return dp[ind];
		}
	ll ans=inf;
		for (int i = 1; i <=k; i++) {
			if (ind+i<=n){
			ans = min(ans, abs(arr[ind] - arr[ind+i]) + fun(ind + i));
			
			}
		}
	return dp[ind] = ans;
	}


int main()
{
	cin >> n>>k;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
	}
	memset(dp, -1, sizeof dp);


	cout <<fun(1);
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n;
int main () {
	IOS;
	
	scanf("%d", &n);
	vd dp(n + 1);
	dp[0] = 1;
	for (int coin = 0; coin < n; coin++) {
		double p_head;
		scanf("%lf", &p_head);
		for (int i = coin + 1; i >= 0; i--) {
			dp[i] = (i == 0 ? 0 : dp[i - 1] * p_head) + dp[i] * (1 - p_head);
		}
	}
	double ans = 0;
	for (int head = 0; head <= n; head++) {
		int tail = n - head;
		if (head > tail) {
			ans += dp[head];
		}
	}
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

int T, N, M, K;
int A, B, C, D;

int main()
{
	scanf("%d", &N);
	ll res = 1;
	int die = 0;
	for(int i=1; i<=N; i++)
	{
		ll t;
		scanf("%lld", &t);
		if (t == 0) return !printf("0");

		if (res > (ll)1e18 / t) die = 1;
		if (!die) res *= t;
	}
	if (die) return !printf("-1");
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 3828
def count(a_i, day)
  cnt = 1
  while day > a_i
    day -= a_i
    cnt += 1
  end
  cnt
end

n = gets.to_i
d, x = gets.split(" ").map(&:to_i)

ret = 0
n.times do |i|
  a = gets.to_i
  cnt = count(a, d)
  ret += cnt
end

puts ret + x


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int n; cin>>n;
	vector<LL> a(n);


	LL sum = 0;
	REP(i,n){
		cin>>a[i];
		sum += a[i];
	}

	LL m = INF_LL;
	LL t = 0;
	REP(i,n){
		t += a[i];
		if(sum-t > t){
			m = min(m,(sum-t)-t);
		}
		else{
			m = min(m,t-(sum-t));
		}
	}

	cout << m << endl;




	

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
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; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

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

ll dp[100010];
int main()
{
	int N;
	cin >> N;
	for(int i = 0; i < 100010; i++) dp[i] = INF;
	dp[0] = 0;
	for(int i = 0; i < N + 5; i++)
	{
		for(int six = 1; i + six <= N; six *= 6)
		{
			chmin(dp[i + six],dp[i] + 1);
		}
		for(int nine = 1; i+ nine <= N; nine *= 9)
		{
			chmin(dp[i + nine],dp[i] + 1);
		}
		// chmin(dp[i + 1],dp[i] + 1);
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1024
import math
a,b,h,m=(int(x) for x in input().split())
h=h+m/60
rad=math.radians(min(math.fabs(h-m/5),math.fabs(12-math.fabs(h-m/5)))*360/12)
print(math.sqrt(a*a+b*b-2*a*b*math.cos(rad)))

Measured memory_bytes: 9512
#include<stdio.h>
int main()
{
  int a,b,total,i;

  while(scanf("%d%d",&a,&b)!=EOF){

    total=a+b;

    if(total<10){
      printf("1\n");
    }
    
    else if(total<100){
      printf("2\n");
    }
    
    else if(total<1000){
      printf("3\n");
    }

    else if(total<10000){
      printf("4\n");
    }

    else if(total<100000){
      printf("5\n");
    }

    else if(total<1000000){
      printf("6\n");
    }

    else if(total<10000000){
      printf("7\n");
    }
  }
    return 0;
    
  }

Measured memory_bytes: 584
#include <bits/stdc++.h>
//#include <random>
//#include <chrono>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define MotoHaiyaku ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    MotoHaiyaku
   ll n,k;
   cin>>n>>k;
   vector<ll> a(n);
   rep(i,n) cin>>a[i];
   ll l=1,r=1e9;
   while(r>l)
   {
       ll m=(l+r)/2,cur=0;
       rep(i,n) cur+=(a[i]+m-1)/m-1;
       if(cur<=k) r=m;
       else l=m+1;
   }
   cout<<l;
}


Measured memory_bytes: 4768
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solve() {
	double n;
	cin >> n;
	const double pi = 3.141592;
	cout << 2*pi*n;

}
int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solve();
}

Measured memory_bytes: 3788
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var n,m,g;

console.log(main());
function main(){
  n = o.a();
  m = o.a();
  var a = o.m(m);
  g = xArray("[]",n);
  for(var i = 0; i < m; i++){
    g[a[i][0]-1].push(a[i][1]-1);
  }
  var ans = Array(n+1);
  for(i = 0; i < n; i++){
    var u = solve(i);
    if(u && u.length < ans.length)ans = u;
  }
  if(ans.length === n+1)return -1;
  console.log(ans.length);
  return ans.join("\n");
}

function solve(v){
  var map = xArray(-1,n);
  var q = [v];
  while(q.length){
    var q2 = [];
    while(q.length){
      var t = q.pop();
      for(var V of g[t]){
        if(V === v){
          var res = [V+1];
          V = t;
          while(V !== v){
            res.push(V+1);
            V = map[V];
          }
          return res;
        }
        if(map[V] !== -1)continue;
        map[V] = t;
        q2.push(V);
      }
    }
    q = q2;
  }
}

Measured memory_bytes: 15740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n;
  cin>>n;
  string a;
  vector<string>b(15);
  int m;
  a="zabcdefghijklmnopqrstuvwxy";
  for(int i=0;n!=0;i++){
    b.at(i)=a.at(n%26);
    n=(n-1)/26;
    m=i;
  }
  for(int j=m;j>-1;j--){
  cout<<b.at(j);
  }
  cout<<endl;
}

Measured memory_bytes: 3640
import numpy as np
from collections import Counter
import fractions
import math

def main():
  n, m = map(int, input().split())
  p_list, s_list = ["a"] * m, ["a"] * m
  for i in range(m):
    p_list[i], s_list[i] = map(str, input().split())
    p_list[i] = int(p_list[i])
  pena = 0
  mon_list, pena_list = [0] * n, [0] * n
  for i in range(m):
    if s_list[i] == "AC":
      mon_list[p_list[i] - 1] = 1
    if mon_list[p_list[i] - 1] == 0:
      if s_list[i] == "WA":
        pena_list[p_list[i] - 1] += 1
  for i in range(n):
    if mon_list[i] == 1:
      pena += pena_list[i]
  ac = mon_list.count(1)
  print(ac, pena)

main()

Measured memory_bytes: 25012
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
typedef long long ll;
const int maxx=500010;
int in[maxx],clo[maxx];
vector<P> a[maxx];
void dfs(int x,int fa,int fclo){
    int cnt=0;
    for(auto t:a[x]){
        if(t.first==fa) continue;
        cnt++;
        if(cnt==fclo) cnt++;
        clo[t.second]=cnt;
        dfs(t.first,x,cnt);
    }
}
int main(){
    int n; cin>>n;
    for(int i=1;i<n;i++){
        int x,y; cin>>x>>y;
        a[x].push_back(P(y,i));
        a[y].push_back(P(x,i));
    }
    dfs(1,0,0);
    int ans=0;
    for(int i=1;i<n;i++) ans=max(ans,clo[i]);
    cout<<ans<<endl;
    for(int i=1;i<n;i++){
        cout<<clo[i]<<endl;
    }
}

Measured memory_bytes: 18048
#include <stdio.h>

#define N 100

int main(){
    int n, i, j, flg, num[N], tmp, cnt = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    
    flg = 1;
    while (flg) {
        flg = 0;
        for (j = n - 1; j >= 1; j--) {
            if (num[j] < num[j-1]) {
                tmp = num[j];
                num[j] = num[j-1];
                num[j-1] = tmp;
                flg = 1;
                cnt++;
            }
        }
    }
    
    for (i = 0; i < n - 1; i++) {
        printf("%d ", num[i]);
    }
    printf("%d\n%d\n", num[i], cnt);
    return 0;
}



Measured memory_bytes: 2104
A=list(map(int,input().split()))
S,T,X=[[int(input()) for i in range(A[j])] for j in range(3)]
def binary(a,l,):
	low=0
	high=len(l)-1
	while high-low>1:
		mid=(low+high)//2
		if l[mid]<a:
			low=mid
		else:
			high=mid
	return [l[high],l[low]]
			
for x in X:
	s=set(binary(x,S))
	t=set(binary(x,T))
	Min=20000000000
	for i in s:
		for j in t:
			Min=min(Min,min(abs(x-i),abs(x-j))+abs(i-j))
	print(Min)
	

Measured memory_bytes: 16140
S = list(input())
Q = int(input())
Q_l = []
for i in range(Q):
    Q_l.append(input().split())
rev_flg = 0
head_list =[]
tail_list = []
for i in range(Q):
    if int(Q_l[i][0]) == 1:
        rev_flg += 1
    else:
        if rev_flg % 2 == 0 and int(Q_l[i][1]) == 1:
            head_list.append(Q_l[i][2])
        elif rev_flg % 2 == 1 and int(Q_l[i][1]) == 1:
            tail_list.append(Q_l[i][2])
        elif rev_flg % 2 == 0 and int(Q_l[i][1]) == 2:
            tail_list.append(Q_l[i][2])
        else:
            head_list.append(Q_l[i][2])
head_list.reverse()
head_list.extend(S)
head_list.extend(tail_list)
if rev_flg %2 ==1:
    head_list.reverse()
print("".join(head_list))

Measured memory_bytes: 43784
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define mp make_pair
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
int main(){
	int x=0;
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		x=x^arr[i];
	}
	int f=0;
	for(int i=0;i<n;i++){
		if((x^arr[i])==arr[i])
			f=1;
	}
	if(f)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 640
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let a: f64 = splited.next().unwrap().parse().unwrap();
    let b: f64 = splited.next().unwrap().parse().unwrap();
    let x: f64 = splited.next().unwrap().parse().unwrap();

    let ans_radian = if a * a * b / 2.0 <= x {
        ((a * a * b - x) * 2.0 / (a * a * a)).atan()
    } else {
        std::f64::consts::PI / 2.0 - (2.0 * x / (a * b * b)).atan()
    };
    let ans = ans_radian * 180.0 / std::f64::consts::PI;

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        //         (
        //             br"2 2 4",
        //             br"45.0000000000
        // ",
        //         ),
        (
            br"12 21 10",
            br"89.7834636934
",
        ),
        (
            br"3 1 8",
            br"4.2363947991
",
        ),
    ];

    #[test]
    fn test_d() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cur = 1;
		int res = 0;
		while (cur < b) {
			cur = cur - 1 + a;
			res++;
		}
		System.out.println(res);
		sc.close();
	}

}


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

int main()
{

	int A, B;
	cin >> A >> B;
	int out;
	if (A >= B +1)
	{out = 2*A - 1;}
	else if (A == B)
	{out = A + B;}
	else if (B >= A +1)
	{out = 2*B -1;}	

	cout << out << "\n";
	return 0;

}

Measured memory_bytes: 256