akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<limits.h>

using namespace std;


int main()
{
  int low=1000000000;
  int high=-1;
  int n,i;
  scanf("%d",&n);
  int p[n];
  for(i=0;i<n;i++)
  {
      scanf("%d",&p[i]);
      if(low>p[i])
        low=p[i];
      if(high<p[i])
        high=p[i];
  }
  printf("%d\n",high-low);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N,M;
  cin >>N>>M;

  ll min,max;
  min=std::min(N,M);
  max=std::max(N,M);
  
  
for(ll i=0;i<max;i++){
       cout << min;}
  cout<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <set>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    int L, R;
    cin >> L >> R;
    int l = L % 2019;
    int r = R % 2019;
    if ((R - L) >= 2018 || l > r)
    {
        cout << 0 << endl;
    }
    else
    {
        int min = 2019;
        rep(i, l, r + 1)
        {
            rep(j, l, r + 1)
            {
                if (i == j)
                {
                    continue;
                }
                int tmp = i * j % 2019;
                if (tmp < min)
                {
                    min = tmp;
                }
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23892
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  s = new Array(n);
  for(i=0;i<n;i++){
    s[i]=input[i+1];
  }
  alf = new Array(26).fill(0);
  for(i=0;i<alf.length;i++){
    alfsub = new Array(n).fill(0);
    alf[i]=alfsub;
  }
  alf2= new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
  for(i=0;i<n;i++){
    for(j=0;j<alf2.length;j++){
      regexp = new RegExp(alf2[j],'g');
      if(s[i].match(regexp)!=null){
      alf[j][i]=s[i].match(regexp).length;
      }
    }
  }
  var ans ="";
  for(i=0;i<alf.length;i++){
    for(j=0;j<Math.min.apply(null,alf[i]);j++){
      ans+=alf2[i];
    }
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll H,W;
  cin>>H>>W;
  ll ans;
  if(H==1||W==1){
    ans=1;
  }
  else if((W*H)%2==0){
    ans=(H*W)/2;
  }

  else{
    ans=(H*W)/2+1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)

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

#define int long long

using namespace std;

signed main()
{
    int x,y=0,z,w,i;
    cin>>x;
    std::vector<int>  Size(x);
    rep(i,x){
    cin>>Size[i];
    }
    for(i=1;i<x-1;i++){
if(Size[i-1]<Size[i]&&Size[i]<Size[i+1]) {
            y++;
    }
    else if(Size[i-1]>Size[i]&&Size[i]>Size[i+1]){
            y++;
    }
    }
    cout<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	string s; cin >> s;
	ll N = s.size();
	ll O = 0, Z = 0;
	rep(i,N){
		if(s[i] == '0') Z++;
		else O++;
	}
	ll ans = 0;
	rep(i,O) ans += (i+1+1)/2;

	ll o = 0;
	ll z = 0;
	int p0 = -1;
	rep(i,N+1){
		if(i == N || s[i] == '0'){
			int n = i-p0-1;
			ans += n/2 * Z;
			if(n%2==1){
				if(p0%2 == 1){	//happy
					ans += (z+1)/2 + Z-z;
				}else{
					ans += z/2 + Z-z;
				}
			}
			p0 = i;
			z++;
		}else{
			o++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3768
A = list(map(int, input().split()))

A.sort(reverse=True)
B = A.copy()
B.sort()

ans_a = 0
ans_b = 0
for i in range(1,3):
    ans_a +=abs(A[i]-A[i-1])
    ans_b += abs(B[i]-B[i-1])
    
print(min(ans_a,ans_b))

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


int main()
{
	int n,p[55],c=0;
	cin>>n;
	for(int i=1;i<=n;++i) cin>>p[i];
	for(int i=1;i<=n;++i) {
		if(p[i]!=i) c++;
	}
	if(c==2||c==0) printf("YES");
	else printf("NO");
}

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

using namespace std;

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    
    vector<vector<int>>a(n,vector<int>(m));
    for(int fn=0;fn<n;fn++){
        for(int fm=0;fm<m;fm++){
            cin >> a.at(fn).at(fm);
        }
    }
    
    vector<vector<int>>b(m,vector<int>(l));
    for(int fm=0;fm<m;fm++){
        for(int fl=0;fl<l;fl++){
            cin >> b.at(fm).at(fl);
        }
    }
   
    vector<vector<long long>>c(n,vector<long long>(l));
    for(int fn=0;fn<n;fn++){
        for(int fl=0;fl<l;fl++){
            for(int fm=0;fm<m;fm++){
                c.at(fn).at(fl) += a.at(fn).at(fm) * b.at(fm).at(fl);
            }
        }
    }
    
    for(int fn=0;fn<n;fn++){
        for(int fl=0;fl<l;fl++){
            cout << c.at(fn).at(fl);
            if(fl != l-1){
                cout <<' ';
            }
        }
        
        cout << endl;
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void initio() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() { initio();
  int N; cin >> N;
  vector<ll> A(N), B(N); rep(i, N) cin >> A[i] >> B[i];
  ll ans = LLONG_MAX;
  ll sa = 0;
  ll sb = 0;
  rep(i, N) {
    sa += A[i];
    sb += B[i];
  }
  ans = min(ans, sa);
  ans = min(ans, sb);
  vector<int> ord(2*N);
  rep(i, 2*N) ord[i] = i;
  auto val = [&](int i) {
    return i % 2 == 0 ? A[i / 2] : B[i / 2];
  };
  sort(range(ord), [&](int i, int j) { return val(i) < val(j); });
  vector<bool> exists(N);
  ll sum = 0;
  rep(i, N) sum += val(ord[i]);
  rep(i, N) {
    exists[ord[i] / 2] = true;
  }
  if (count(range(exists), true) == N) {
    rep(i, N) {
      ll cand = sum;
      cand -= val(ord[i]);
      cand += (ord[i] / 2 == ord[N] / 2) ? val(ord[N + 1]) : val(ord[N]);
      ans = min(ans, cand);
    }
  } else {
    ans = min(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll n,m; cin>>n>>m;
	ll ans = min(n,m/2);
	n -= ans; m-=ans*2;
	if(m>0){
		ans += m/4;
	}
	cout<<ans<<endl;
	return 0;
}


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

char toLow(char ch)
{
    return ch >= 65 && ch <= 90 ? ch + 32 : ch;
}

int main()
{
    int N, K;
    cin >> N >> K;
    char S[N + 1];
    cin >> S;

    for(int i = 0; S[i] != '\0'; i++)
        if(i == K - 1)
            S[i] = toLow(S[i]);

    cout << S;

    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split())) + [0]

buy, sell = [], []
for i in range(n):
    if a[i] < a[i+1] and len(buy) - len(sell) == 0:
        buy.append(i)
    if len(buy) - len(sell) == 1 and a[i] > a[i+1]:
        sell.append(i)

cash = 1000
for i, j in zip(buy, sell):
    stock, rest = divmod(cash, a[i])
    cash = stock * a[j] + rest

print(cash)

Measured memory_bytes: 9192
a, b, h, m = list(map(int,input().split()))
r = min(abs(h*30+m*0.5-m*6), 360-abs(h*30+m*0.5-m*6))
import math
c = (a**2+b**2-2*a*b*math.cos(math.radians(r)))**0.5
print(c)

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

using namespace std;

int main() {
    int N;
    double x;
    string c;
    cin >> N;

    double ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> x >> c;
        if(c == "JPY") {
            ans += x;
        } else {
            ans += (x*380000.0);
        }
    } 

    printf("%.8lf\n", ans);   
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, K;
  cin >> N >> K;

  int x[202020];
  m0(x);
  for (int i = 1; i <= N; i++) {
    x[i % K]++;
  }

  int ans = 0;
  for (int a = 0; a < K; a++) {
    int b = (K - a) % K;
    int c = (K - a) % K;
    if ((b + c) % K != 0)
      continue;
    ans += x[a] * x[b] * x[c];
  }

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


Measured memory_bytes: 1792
import math
a,b,h,m=map(int,input().split())
tyoshin = m*6
tanshin = m*0.5 + h*30
kakudo = abs(tyoshin - tanshin)
print((a*a + b*b -2*a*b*math.cos(kakudo*math.pi/180))**0.5)

Measured memory_bytes: 9496
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn gcd(a : i64, b : i64) -> i64 {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}


fn lcm(a: i64, b : i64) -> i64 {
    return a / gcd(a, b) * b;
}

fn main() {
    let n = read_t_in_line::<i64>()[0];
    println!("{}", 
             (0..n).
             map(|_| read_t_in_line::<i64>()[0]).
             fold(1 as i64, |acc, x| lcm(acc, x)));
}


Measured memory_bytes: 4352
H, W = map(int, input().split())

a = [[0 for i in range(W + 1)] for j in range(H + 1)]

for i in range(H):
    atmp = list(map(int, input().split()))
    for j in range(W):
        a[i + 1][j + 1] = atmp[j]

count = 0
oplist = []

for i in range(1, H + 1):
    for j in range(1, W):
        if a[i][j] % 2 == 1:
            a[i][j] -= 1
            a[i][j + 1] += 1
            count += 1
            oplist.append(str(i) + ' ' + str(j) + ' '
                          + str(i) + ' ' + str(j + 1))

for i in range(1, H):
    if a[i][W] % 2 == 1:
        a[i][W] -= 1
        a[i + 1][W] += 1
        count += 1
        oplist.append(str(i) + ' ' + str(W) + ' '
                      + str(i + 1) + ' ' + str(W))

print(count)
for i in range(len(oplist)):
    print(oplist[i])


Measured memory_bytes: 16152
void main(){
	string s = readln().chomp();
	s.count('1').writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

using namespace std;

static long long NUM_S;
static long long NUM_C;

static bool can_create(long long num)
{
  if ((NUM_S - num) >= 0) {
    if (NUM_C >= 2 * num) {
      return true;
    }
  } else {
    if (NUM_C >= (2 * (num - NUM_S) + 2 * num)) {
      return true;
    }
  }

  return false;
}

int32_t main()
{
  cin >> NUM_S >> NUM_C;

  long long count = (NUM_C / 2) + 1;

  long long left = 0, right = count;
  while (true) {
    if (right <= left + 1) break;
    long long mid = (left + right) / 2;
    if (can_create(mid)) {
      left = mid;
    } else {
      right = mid;
    }
  }

  cout << left << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector <int> a;
  for (int i = 0, x; i < n; i ++)
    cin >> x, a.push_back(x);
  int ans = 1;
  for (int i = 1, f = 0; i < n; i ++) {
    if (f == 0) {
      if (a[i] < a[i - 1])
        f = 1;
      if (a[i] > a[i - 1])
        f = -1;
    } else if (f == 1) {
      if (a[i] > a[i - 1])
        ans ++, f = 0;
    } else if (f == -1) {
      if (a[i] < a[i - 1])
        ans ++, f = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
 int a[maxn];
 int n,m;
 int main()
 {
	 scanf("%d%d",&n,&m);
	 for(int i=1;i<=n;i++)
	 {
		 int x;
		 scanf("%d",&x);
		 for(int i=1;i<=x;i++)
		 {
			 int y;
			 scanf("%d",&y);
			 a[y]++;
		 }
	 }
	 int ans=0;
	 for(int i=1;i<=m;i++)
		 if(a[i]==n)
			 ans++;
	 printf("%d\n",ans);
	 return 0;
 }

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,m;
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)break;
		int q[n][m],i,j=0;
		while(j<n){
			i=0;
			while(i<m){
				scanf("%d",&q[j][i]);
				i++;
			}
			j++;
		}
		int cnt[m];
		for(i=0;i<n;i++)for(j=0;j<m;j++){
			if(!i)cnt[j] = 0;
			cnt[j] += q[i][j];
		}
		int max,maxed[m];
		for(i=0;i<m;i++)maxed[i] = 0;
		for(i=0;i<m;i++){
			if(i)printf(" ");
			max = -1;
			for(j=0;j<m;j++){
				if(!maxed[j]){
					if(max == -1)max = j;
					else if(cnt[max] < cnt[j])max = j;
				}
			}
			printf("%d",max+1);
			maxed[max] = 1;
		}
		printf("\n");
	}
}


Measured memory_bytes: 2088
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
#include <cmath>

using namespace std;
int main(void){
    int hokox[6] = {0,1,1,0,-1,-1};
    int hokoy[2][6] = {{1,0,-1,-1,-1,0},{1,1,0,-1,0,1}};
    
    int sx, sy, gx, gy, n;
    scanf("%d%d%d%d%d", &sx, &sy, &gx, &gy, &n);
    vector<pair<int,int> > kagu;
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d %d", &x, &y);
        kagu.push_back(make_pair(x, y));
    }
    int lx,ly;
    scanf("%d%d", &lx, &ly);
    int dist[300][300][6];
    for(int i=0;i<300;i++)for(int j=0;j<300;j++)for(int k=0;k<6;k++)dist[i][j][k]=10000000;
    dist[sx+150][sy+150][0] = 0;
    for(int i=0;i<n;i++)for(int j=0;j<6;j++)dist[kagu[i].first + 150][kagu[i].second + 150][j] = -1;
    priority_queue<pair<int, pair<pair<int, int>, int > > , vector<pair<int, pair<pair<int, int>, int > > >, greater<pair<int, pair<pair<int, int>, int > > > > po;
    po.push(make_pair(0, make_pair(make_pair(sx+150, sy+150), 0)));
    while(!po.empty()){
        pair<int, pair<pair<int, int>, int > > tmp = po.top();
        po.pop();
        int ang = tmp.first;
        int x = tmp.second.first.first;
        int y = tmp.second.first.second;
        int t = tmp.second.second;
        if(dist[x][y][(t+1)%6] > ang + 1){
            dist[x][y][(t+1)%6] = ang + 1;
            po.push(make_pair(ang+1, make_pair(make_pair(x,y), (t+1)%6)));
        }
        int hoko = abs((x-150)*(y-150)*t)%6;
        for(int i=0;i<6;i++){
            int nx = x + hokox[i];
            int ny = y + hokoy[abs(x-150)%2][i];
            if(abs(nx-150) <= lx && abs(ny-150) <= ly && dist[nx][ny][0] != -1){
                if(dist[nx][ny][(t+1)%6] > ang + 1 - (i==hoko)){
                    dist[nx][ny][(t+1)%6] = ang + 1 - (i==hoko);
                    po.push(make_pair(ang+1-(i==hoko), make_pair(make_pair(nx,ny), (t+1)%6)));
                }
            }
        }
        
    }
    int ans = 10000000;
    for(int i=0;i<6;i++)if(dist[gx+150][gy+150][i] < ans)ans=dist[gx+150][gy+150][i];
    if(ans == 10000000 || ans == -1)printf("-1\n");
    else printf("%d\n", ans);
    return 0;
    
}


Measured memory_bytes: 5452
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,a[111111]={};
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
	}
	LL mn=2,mx=3;
	if(a[--n]!=2){
		cout<<-1<<endl;
		return 0;
	}
	FORD(i,n,0){
		//cout<<a[i]<<" "<<mn<<" "<<mx<<endl;
		LL t=a[i];
		mn=(mn+t-1)/t*t;
		mx=mx/t*t;
		if(mx<mn){
			cout<<-1<<endl;
			return 0;
		}
		mx+=t-1;
	}
	cout<<mn<<" "<<mx<<endl;
    return 0;
}


Measured memory_bytes: 1152
n, t = map(int, input().split())
alist = list(map(int, input().split()))
minal = [alist[0]]
maxal = [alist[-1]]
for a in alist[1:]:
  if minal[-1] > a:
    minal.append(a)
  else:
    minal.append(minal[-1])

for a in alist[::-1][1:]:
  if maxal[-1] < a:
    maxal.append(a)
  else:
    maxal.append(maxal[-1])
maxal = maxal[::-1]

maxda = 0
ans = 0
prevmina, prevmaxa = None, None
for mina, maxa in zip(minal, maxal):
  if prevmina == mina and prevmaxa == maxa:
    continue
  elif maxa - mina == maxda:
    ans += 1
  elif maxa - mina > maxda:
    maxda = maxa - mina
    ans = 1
  prevmina, prevmaxa = mina, maxa

print(ans)


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

#define long long long
using namespace std;

vector<long> v;
long n;
long best, best2, best3;

bool cmp(long a, long b){
        return a > b;
}

int main(){
    scanf("%lld", &n);


    for(long i = 0, a; i < n; i++){
        scanf("%lld",&a);
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    for(auto i : v){
        auto lw = lower_bound(v.begin(), v.end(), i);
        auto up = upper_bound(v.begin(), v.end(), i);
        if(up - lw >= 2){
            if(up - lw >= 4) best3 = i;
            else best = i;
        }
    }

    for(auto i : v){
        auto lw = lower_bound(v.begin(), v.end(), i);
        auto up = upper_bound(v.begin(), v.end(), i);
        if(up - lw >= 2 && i < best) best2 = i;
    }
    long ans = max(best*best2, best3*best3);
    printf("%lld\n", ans);


    return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = A[i] - i;
  }

  map<int, int> m;
  long long ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    int b = -(A[i] + i);
    ans += m[b];
    m[B[i]]++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 21788
#include <iostream>
#include <string>
using namespace std;
int main()
{
	long long int num[26];
	long long int b = 0;
	string a;
	for(int i=0;i < 26;i++)
	{
		num[i] = 0;
	}
	cin >> a;
	long long int n = a.size();
	for(int i=0;i < n;i++)
	{
		num[a[i] - 'a']++;
	}
	for(int i=0;i < 26;i++)
	{
		if(num[i] >= 1)
		{
			b+=(num[i] * (num[i] - 1) / 2);
		}
	}
	cout << (n * (n - 1) / 2 + 1 - b) << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int break_cnt(int n)
{
  int cnt=0;
  while (n%2 != 1)
  {
    n = n/2;
    cnt++;
  }
  return cnt;
}

int main(void)
{
  int N;
  int max_num=1, max_cnt=0, cnt;

  scanf("%d",&N);

  for (int i = 1; i <= N; i++)
  {
    if(i%2 != 1){
      cnt = break_cnt(i);
      if(max_cnt<cnt)
      {
        max_cnt = cnt;
        max_num = i;
      }
    }
  }

  printf("%d\n",max_num);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

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

int main() {
    ll n; cin >> n;
    string ans = (n < 30) ? "No" : "Yes";
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int b,f,r,v;

    vector<vector<vector<int> > > N(4, vector<vector<int> >(3,vector<int>(10, 0)));
    
    for (int i=0; i<n; i++){
      cin >> b >> f >> r >> v;
      N.at(b-1).at(f-1).at(r-1) += v ;
      }
    
    for (int i=0; i<4; i++){
      for (int j=0; j<3; j++){
        for (int k=0; k<10; k++){
          cout << ' ' << N.at(i).at(j).at(k);
        }
        cout << endl;
      }
      if (i == 3) break;
      cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
ps = 51.times.map{51.times.map{0}}
(0...51).each do |i|
  ps[i][0] = 1;
  (1..i).each do |j|
    ps[i][j] = ps[i-1][j] + ps[i-1][j-1]
  end
end
n, a, b = gets.split(" ").map &:to_i
v = gets.split(" ").map &:to_i
v.sort!
i=n-a
j=n-a
while(i >= 0 && v[i] == v[n-a]) do
  i -= 1
end
while(j >= 0 && v[j] == v[n-a]) do
  j += 1
end
ans = 0
if j == n
  (a..b).each{|k| ans += ps[j-i-1][k]}
else
  ans = ps[j-i-1][j-n+a]
end
su = 0;
(n-a...n).each{|k| su += v[k]}
puts sprintf("%.9f", su.to_f/a)
puts ans

Measured memory_bytes: 3836
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n,ans,p;
ll a[100005],m,v,tmp[100005],top;
int flag[100005];
bool cmp(ll a,ll b)
{
	return a>b;
}
bool check(int pos)
{
	if(flag[pos]!=-1)return flag[pos];
	if(a[pos]==a[pos-1])return (flag[pos]=check(pos-1));
	ll r=v-p-n+pos;
	r=max(r,0ll);
	r=pos-p-r;
	top=0;
	for(int i=p;i<pos;i++)
	  tmp[++top]=a[i]-a[pos];
	ll sum=0;
	for(int i=1;i<=top;i++)
	{
		if(tmp[i]>m)return 0;
		sum+=tmp[i];
	}
	return (flag[pos]=(sum<=m*r));
}
int main()
{
	scanf("%d%lld%lld%d",&n,&m,&v,&p);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	memset(flag,-1,sizeof(flag));
	a[0]=-1;
	int l=p,r=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
	return 0;
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

#define MAX_N 1005

int main() {
  int N, H, W; scanf("%d%d%d", &N, &H, &W);
  int A, B;
  int count{};
  for (int i{}; i < N; ++i) {
    scanf("%d%d", &A, &B);
    if (A >= H && B >= W) ++count;
  }

  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

bool check(const vector<ll> &a, const int N, const int id){
    if(id == 0) return false;
    if(id == N+1) return true;

    ll tmp = a[id];
    for(int i=1; i<=N; i++){
        if(i == id) continue;
        
        if(a[i] <= 2*tmp) tmp += a[i];
        else return false;
    }

    return true;
}


int solve(const vector<ll> &a, const int N){
    int right = N+1;
    int left = 0;

    int mid;
    while(right-left > 1){
        mid = (left+right)/2;
        if(check(a, N, mid)) right = mid;
        else left = mid;
    }

    return left;
}

int main(){
    int N; cin >> N;
    vector<ll> a(N+2);
    for(int i=1; i<=N; i++) cin >> a[i];
    a[0] = -1;
    a[N+1] = pow(10, 9)+5;
    sort(a.begin(), a.end());

    cout << N - solve(a, N) << endl;

}

Measured memory_bytes: 1024
N, M = map(int, input().split())
array = []
for _ in range(M):
    tmp = list(map(int, input().split()))
    array.append(tmp)
low = array[0][0]
up = array[0][1]

flag = True
for i in range(1,M):
    if array[i][0] > up:
        flag = False
        break
    if array[i][0] > low:
        low = array[i][0]
    if array[i][1] < up:
        up = array[i][1]
    
if flag:
    print(up - low + 1)
else:
    print(0)

Measured memory_bytes: 27344
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE Strict #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L
import Data.Maybe

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> Int
solve [n] = sum . map toFizzBuzz $ [1..n]
  where
    toFizzBuzz n =
      if n `mod` 3 == 0 || n `mod` 5 == 0
        then 0
        else n

output :: Int -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
	int n,i,t=1000000000,t2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=0;i<n-1;i++)
	{
		if(abs(a[i]-a[n-1]/2)<=t)
		{
			t=abs(a[i]-a[n-1]/2);
			t2=i;
		}
	}
	printf("%d %d",a[n-1],a[t2]);
	return 0;
}

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

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    int dx = c-a;
    int dy = d-b;
    cout << c - dy << " " << d + dx << " ";
    cout << a - dy << " " << b + dx << endl;
}


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

ll N;

void solve_sub(ll pos, ll max_char, const string& s){
    if(pos == N){
        cout << s << endl;
        return;
    }

    for(ll i = 0; i <= max_char + 1; ++i){
        char c = 'a' + static_cast<char>(i);
        solve_sub(pos + 1, max(max_char, i), s + c);
    }
}

int main(){
    cin >> N;
    solve_sub(0, -1, "");
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll n;
	cin >> n;
	
	vector<ll> ans;
	bool end = false;
	
	for(ll i = 1; i <= n; ++i) {
		ll x = i * (i + 1LL) / 2LL;
		
		if( x >= n ) {
			for(ll j = i; j >= 1; j--) {
				if( j <= n ) {
					ans.push_back(j);
					n -= j;
				}
			}
			
			end = true;
		}
		
		if( end ) break;
	}
	
	for(auto& res : ans) {
		cout << res << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3712
from bisect import bisect, bisect_left

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

bi = []

for i in range(n - 1):
    if s[i:i+2] == "AC":
        bi.append(i)

for _ in range(q):
    l, r = map(int, input().split())
    answer = bisect(bi, r - 1) - bisect_left(bi, l - 1)
    if r < n and s[r - 1:r + 1] == "AC":
        answer -= 1
    print(answer)


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

def main():
    k, s = map(int, input().split())

    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            if 0 <= s - (i + j) <= k:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=2005;
const double EPS=1e-6;
const int MOD=998244353;

long long dp[SIZE*2][SIZE*2];
int r[SIZE*2],b[SIZE*2];

int main(){
	/*main function start*/
	string s;
	cin>>s;
	int n=s.size();
//	cout<<n<<endl;
	for(int i=1;i<=n;i++) if(s[i-1]=='0') r[i]=r[i-1]+2,b[i]=b[i-1]; else if(s[i-1]=='1') r[i]=r[i-1]+1,b[i]=b[i-1]+1; else r[i]=r[i-1],b[i]=b[i-1]+2;
	for(int i=n+1;i<=n*2;i++) r[i]=r[i-1],b[i]=b[i-1];
	dp[0][0]=1;
	for(int i=1;i<=n*2;i++){
//		cout<<"TEST "<<i<<" "<<b[i]<<" "<<max(i-b[i],0)<<" "<<min(i,r[i])<<endl;
		for(int j=max(i-b[i],0);j<=min(i,r[i]);j++){
			if(j>0) dp[i][j]+=dp[i-1][j-1];
			if(i!=j) dp[i][j]+=dp[i-1][j];
			dp[i][j]%=MOD;
//			cout<<dp[i][j]<<" ";
		}
//		cout<<endl;
	}
	long long ans=0;
	for(int i=0;i<=min(n*2,r[n*2]);i++){
		ans+=dp[n*2][i];
		ans%=MOD;
	}
	cout<<ans<<endl;
//	cout<<c[2][0]<<endl;
	return 0;
}


Measured memory_bytes: 123520
#include <bits/stdc++.h>
#define NMAX 2005

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll dp[NMAX];
int main()
{
    ll n;
    cin>>n;
    dp[0]=1;
    for(ll i=3;i<=n;i++){
        for(ll j=i-3;j>=0;j--)
            dp[i]=(dp[i]+dp[j])%MOD;
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 3592
// map of current possible positions -> how long to get there
// starts as {1: 0, 2:0, ... , W:0}
// When we get a new wall segment A..B
// Anything in A..B has to move right to B+1
// So erase everything in A..B, and set B+1 to whichever one is cheapest (after moving right).
// Erasing is expensive, but everything can only get erased once, and there are only W+H things
// to erase (W things we start with, and each row adds up to one more thing at B+1).
// So the amortized (average) time should be OK.
// At each row, the score is the minimum of the values, which we can store in a multiset.

#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
using ll = int64_t;

int main() {
  ll H,W;
  cin >> H >> W;
  ll INF = static_cast<ll>((H+1)*W);
  vector<ll> A(H, 0);
  vector<ll> B(H, 0);
  for(ll i=0; i<H; i++) {
    cin >> A[i] >> B[i];
  }
  map<ll,ll> M;
  multiset<ll> V;
  for(ll i=1; i<=W; i++) {
    M.insert(make_pair(i, 0));
    V.insert(0);
  }
  for(ll i=0; i<H; i++) {
    ll bp1 = INF;
    if(M.count(B[i]+1)==1) {
      bp1 = M[B[i]+1];
      V.erase(V.find(M[B[i]+1]));
    }
    while(true) {
      auto it = M.lower_bound(A[i]);
      if(it != M.end() && it->first<=B[i]) {
        bp1 = min(bp1, it->second + (B[i]+1-it->first));
        V.erase(V.find(it->second));
        M.erase(it);
      } else {
        break;
      }
    }
    if(bp1 < INF && B[i]+1<=W) {
      M[B[i]+1] = bp1;
      V.insert(bp1);
    }
    if(V.empty()) {
      cout << -1 << endl;
    } else {
      cout << ((*V.begin())+i+1) << endl;
    }
  }
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    	return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}
void solve(){
	
    ll i,j,k,l,n,m,x,y,z,r;
	string s,t;
	cin>>s>>t;
	if(s==t.substr(0,s.sz)){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	
	
	
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public class Node
	{
		public int Index{get;set;}
		public List<int> Edges{get;set;}
		public int Distance{get;set;}
		public int[] Kenpa {get;set;}
	}
	
	public class Obj
	{
		public int Index{get;set;}
		public int Count{get;set;}
		public int Ken{get;set;}
	}
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		
		var nodes = new Node[n];
		for(int i = 0; i < n; i++)
			nodes[i] = new Node(){Index=i, Edges=new List<int>(), Distance = -1, Kenpa = new int[]{-1,-1,-1}};
		
		for(int i = 0; i < m; i++)
		{
			p = Input().ToInt(-1);
			nodes[p[0]].Edges.Add(p[1]);
		}
		
		p = Input().ToInt(-1);
		var s = p[0];
		var t = p[1];

		var q = new Queue<Obj>();
		q.Enqueue(new Obj(){Index=s});
		
		while(q.Count > 0)
		{
			var obj = q.Dequeue();
			var index = obj.Index;
			var ken = obj.Ken;
			var cnt = obj.Count;
			bool cont = false;
			for(int i = 0; i < 3; i++)
			{
				if(nodes[index].Kenpa[i] != -1 && ken == i && nodes[index].Kenpa[i] <= cnt)
				{
					cont = true;
					break;
				}
			}
			if(cont) continue;
			
			nodes[index].Kenpa[ken] = cnt;
			foreach(var e in nodes[index].Edges)
			{
				//BFS(nodes, e, ken == 0 ? (cnt+1) : cnt, (ken +1) % 3);
				q.Enqueue(new Obj(){Index = e, Count = (ken == 0 ? (cnt+1) : cnt), Ken = (ken+1) % 3});
			}
		}

		Console.WriteLine(nodes[t].Kenpa[0]);
	}
	

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

int main(){
    int N,M; cin >> N >> M;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<int> B(M);
    vector<long long> C(M);
    for(int i = 0; i < M; i++) cin >> B[i] >> C[i];
    sort(A.begin(),A.end());
    vector<int> index(M);
    iota(index.begin(),index.end(),0);
    sort(index.begin(),index.end(),[&](int i,int j){
        return C[i] > C[j];
    });
    
    int cont = 0;
    for(auto i:index){
        for(int j = 0; j < B[i]; j++){
            if(A[cont] > C[i])break;
            A[cont] = C[i];
            cont++;
        }
    }
    long long sum = 0;
    for(int i = 0; i < N; i++) sum += A[i];
    cout << sum << endl;
    
    
    
    
}




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



int main() {
  int64_t N,A,B;
  cin >> N >> A >> B;
  int64_t ans = 0;
  
  ans += (N / (A+B))*A;
  
  if(N%(A+B) > A){
    ans += A;
  }else{
    ans += N%(A+B);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main (int argc, char const* argv[])
{
	int a,b,c,d,e,f,t,i;
	
	for(i=0;i<3;i++){
		scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
		t=d*60*60+e*60+f-a*60*60-b*60-c;	
		printf("%d %d %d\n",t/3600%60,t/60%60,t%60);
	}
			
		
		
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>

int main(void)
{
	int i=0;
	int j=0;

	for(i=1;i<10;i++){

		for(j=1;j<10;j++){
			
			printf("%dx%d=%d\n",i,j,i*j);

		}

	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    ll n, x;
    cin >> n >> x;

    ll sm[n+1], p[n+1];
    sm[0] = 1;
    p[0] = 1;
    for (int i = 1; i <= n; i++) {
        sm[i] = sm[i-1] * 2 + 3;
        p[i] = p[i-1] * 2 + 1;
    }

    ll ans = 0;
    for (int i = n; i >= 0; i--) {
        if (x <= sm[i]/2) {
            x -= 1;
        } else if (x == sm[i]/2 + 1) {
            ans += p[i]/2 + 1;
            break;
        } else if (x <= sm[i]-1) {
            ans += p[i]/2 + 1;
            x -= (sm[i]/2 + 1);
        } else {
            ans += p[i];
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}

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

int main(){
	int N;
	long long K;
	cin >> N >> K;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	sort(A.begin(),A.end());
	
	auto low=lower_bound(A.begin(),A.end(),0);
	auto up=upper_bound(A.begin(),A.end(),0);
	
	int nega=(int)(low-A.begin());
	int zero=(int)(up-low);
	int posi=N-(nega+zero);
	
	if(K<=(long long)nega*posi){
		//midより小さいものがK個未満であるかどうか
		long long ok=-1000000000000000000LL,ng=0;
		while(abs(ok-ng)>1){
			long long mid=(ok+ng)/2;
			long long c=0;
			for(int i=0;i<nega;i++){
				c+=(long long)(A.end()-upper_bound(A.begin(),A.end(),(-mid)/(-A[i])));
			}
			
			if(c<K)ok=mid;
			else ng=mid;
		}
		
		cout << ok << endl;
		
	}else if(K<=(long long)nega*posi+(long long)zero*(N-zero)+(long long)zero*(zero-1)/2){
		cout << "0" << endl;
	}else{
		K-=(long long)nega*posi+(long long)zero*(N-zero)+(long long)zero*(zero-1)/2;
		//midより小さいものがK個未満であるかどうか
		long long ok=1,ng=1234567890123456789LL;
		while(abs(ok-ng)>1){
			long long mid=(ok+ng)/2;
			long long c=0;
			for(int i=0;i<nega;i++){
				c+=(long long)(A.begin()-lower_bound(A.begin()+i+1,A.begin()+nega,((mid-1)/(-A[i]))*(-1)))+nega;
			}
			for(int i=N-posi;i<N;i++){
				c+=(long long)(upper_bound(A.begin()+nega+zero,A.begin()+i,(mid-1)/A[i])-A.begin())-(nega+zero);
			}
			if(c<K)ok=mid;
			else ng=mid;
		}
		
		cout << ok << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for (int i=0; i<N; i++)cin >> a[i];
    int all_xor = a[0] ^ a[1];
    for (int i=2; i<N; i++)all_xor ^= a[i];
    
    //cout << all_xor << endl;
    for (int i=0; i<N; i++){
        int ans = all_xor ^ a[i];
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4060
program main
    implicit none

    integer A,B,K,i,count
    count = 0

    read(*,*) A,B,K

    do i = max(A,B),1,-1
        if (mod(A,i)==0 .and. mod(B,i)==0)then
            count = count + 1
            if (count == K) then
                write(*,"(I0)") i
                exit 
            end if
        end if
    enddo

end program main

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int n, m, q;
vector<int> a(50);
vector<int> b(50);
vector<int> c(50);
vector<int> d(50);
vector<int> p(11);
int ans = 0;
void dfs(int u) {
    int t = 0;
    if (u == n) {
        for (int i = 0; i < q; i++) {
            if (p.at(b.at(i)) - p.at(a.at(i)) == c.at(i)) {
                t += d.at(i);
            }
        }
        ans = max(ans, t);
        return;
    }
    else {
        for (int i = min(p.at(u), m); i <= m; i++) {
            p.at(u+1) = i;
            dfs(u + 1);
        }
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
        a.at(i)--; b.at(i)--;
    }
    p.at(0) = 1;
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;

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

	int ans;
	if (count(s.begin(), s.end(), s.at(0)) == s.size()) {
		ans = 0;
	}
	else {
		ans = s.size() / 2;
	}

	for (int i = 0; i < ans; i++) {
		int d1 = i;
		int d2 = s.size();
		int p = i;
		for (int j = i + 1; j < s.size(); j++) {
			if (s.at(i) == s.at(j)) {
				d1 = max(j - p - 1 , d1);
				d2 = s.size() - 1 - j;
				p = j;
			}
		}
		ans = min(ans, max(d1, d2));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256