akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	L, R, d := sc.i(), sc.i(), sc.i()
	ans := 0
	for i := 1; d*i <= R; i++ {
		if d*i >= L {
			ans++
		}
	}
	fmt.Println(ans)
}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//------------------------------

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

// a^{-1} (mod) を計算
func Inv(a int) int {
	return Pow(a, mod-2)
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1772
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int a[5001][5001] = {0};
int main() 
{

	int n,i,j;
	string s;
	cin >> n;
	cin >> s;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
		{
			if (i == j)
				continue;
			if (s[i]==s[j])
			{
				a[i + 1][j + 1] = a[i][j] + 1;
			}
		}
	int max = 0;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			if (a[i][j] > max&&(i-a[i][j])>=j)
				max = a[i][j];
		}
	cout << max;
	return 0;
}

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    ll n, d; cin >> n >> d;
    ll x, y, d2;
    ll cnt=0;
    d2=d*d;

    REP(i, n){
        cin >> x >> y;
        if(x*x+y*y<=d2){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  cout << d[n/2]-d[n/2-1] << endl;
}

Measured memory_bytes: 640
S = gets.strip
pre = S[0,2]
post = S[2,2]

def is_month(s)
  (s[0] == '0' && s[1] != '0') || (s[0] == '1' && (s[1].to_i <= 2))
end

if is_month(pre) && is_month(post)
  puts 'AMBIGUOUS'
elsif is_month(pre)
  puts 'MMYY'
elsif is_month(post)
  puts 'YYMM'
else
  puts 'NA'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#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 foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(h);
    cill(n);
    LL total = 0;
    rep(i, n){
        cill(a);
        total += a;
    }
    string ans = h <= total
            ?"Yes"
            :"No";
    co(ans);
    return 0;
}

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

int main()
{
	int N;

	cin >> N;

	char *slime = new char[N + 1];
	cin >> slime;
	int n = N;
	for (int i = 1; i < N+1; i++) {
		if (slime[i] == slime[i - 1]) {
			n--;
		}
	}

	cout << n << endl;

	delete slime;

	return 0;
}

Measured memory_bytes: 384
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

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

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


def main():
    n, m = map(int, sys.stdin.buffer.readline().split())
    U = UnionFind(n)
    for x in sys.stdin.buffer.readlines():
        a, b = map(int, x.split())
        U.union(a-1, b-1)
    print(U.group_count() - 1)


if __name__ == "__main__":
    main()


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

using namespace std;

int A,B,C,K;
long long a[1008],b[1008],c[1008];
vector<long long> ans;

int main(){
	cin>>A>>B>>C>>K;
	for(int i = 0;i<A;i++) cin>>a[i]; sort(a,a+A,greater<long long>());
	for(int i = 0;i<B;i++) cin>>b[i]; sort(b,b+B,greater<long long>());
	for(int i = 0;i<C;i++) cin>>c[i]; sort(c,c+C,greater<long long>());
	for(int i = 0;i<A;i++){
		for(int j = 0;j<B;j++){
			for(int k = 0;k<C;k++){
				if((i + 1)*(j + 1)*(k + 1) <= K) ans.push_back(a[i] + b[j] + c[k]);
				else break;
			}
		}
	}
	sort(ans.begin(),ans.end(),greater<long long>());
	for(int i = 0;i<K;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second
#define bcnt(S) __builtin_popcountll(S)

const int N = 510;
const int M = 1e9 + 7;
const int MN = 1e5 + 1000;
const double eps = 1e-10;

typedef long long ll;
typedef pair<int, int> PII;

char s[2][N];
ll dp[N][3][3];

int main ()
{
	int n, st;
	scanf("%d %s %s", &n, s[0], s[1]);
	memset(dp, 0, sizeof(dp));
	if(s[0][0] == s[1][0]){
		for(int i = 0; i < 3; i++)
			dp[0][i][i] = 1;
		st = 1;
	}else{
		for(int i = 0; i < 3; i++)
			for(int j = 0; j < 3; j++)
				if(i != j) dp[1][i][j] = 1;
		st = 2;
	}

	for(int l = st, tp; l < n; l++){
		tp = 1;
		if(s[0][l] != s[1][l]){
			l++; tp++;
		}
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(s[0][l] == s[1][l] && i != j) continue;
				if(s[0][l] != s[1][l] && i == j) continue;
				for(int i1 = 0; i1 < 3; i1++)if(i != i1){
					for(int j1 = 0; j1 < 3; j1++)if(j != j1){
						dp[l][i][j] += dp[l-tp][i1][j1];
						dp[l][i][j] %= M;
					}
				}
			}
		}
	}
	
	ll sum = 0;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			sum += dp[n-1][i][j];
			sum %= M;
		}
	}
	printf("%lld\n", sum);
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] a = new long[N];
		int count4 = 0,count2 = 0;
		for( int i=0; i<N; i++ ){
			a[i] = sc.nextLong();
			if( a[i]%4==0 ){
				count4++;
			}
			if( a[i]%4!=0 && a[i]%2==0 ){
				count2++;
			}
		}
		if( count4>=N/2 ){
			System.out.println("Yes");
		}else if( count2>=N-(count4*2) ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

typedef long long ll;

int main(){
	ll H;
	cin >> H;
	ll ans = 1;
	ll l = 1;
	while(H>1){
		ans += 2*l;
		l = l*2;
		H /= 2;
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int x , a, b;
  cin >> x >> a >> b;
  if(b<=a)
    cout << "delicious" << endl;
  else if(-a+b<=x)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;


}

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

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S == "SUN") {
		cout << 7;
	}
	else if (S == "MON") {
		cout << 6;
	}
	else if (S == "TUE") {
		cout << 5;
	}
	else if (S == "WED") {
		cout << 4;
	}
	else if (S == "THU") {
		cout << 3;
	}
	else if (S == "FRI") {
		cout << 2;
	}
	else if (S == "SAT") {
		cout << 1;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;
using ll=long long int;

ll n;

vector<ll> enum_div(ll n) {
	std::vector<ll> ret;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i != 1 && i * i != n)
				ret.push_back(n / i);

		}
	}
	return ret;
}

int main(void) {
	cin >> n;
	ll ret = 0;
	ll m;

	vector<ll> l = enum_div(n);
	for (int i = 0; i < l.size(); i++) {
		m = (n - l[i]) / l[i];
		if (m > i && n / m == n % m)
			ret += m;
	}
	cout << ret << endl;
	return 0;
}

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

typedef long long ll;

#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a, b, c, d; cin >> a >> b >> c >> d;
	int mult = 1;
	string result;
	while (true) {
		if (mult * b >= c) {
			result = "Yes";
			break;
		} else if (mult * d >= a) {
			result = "No";
			break;
		}
		mult++;
	}
	cout << result << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

vii v[100005];
int dp[3][100005];

int main()
{ios_base::sync_with_stdio(false);
int n,m;
cin>>n>>m;
rep(i,0,2)rep(j,0,100004)dp[i][j]=1e9+7;

while(m--)
{
	int x,y;
	cin>>x>>y;
	v[x].pb(y);
	//v[y].pb(x);
}

priority_queue<pair<int, pii> > q;

int s,t;
cin>>s>>t;

q.push(mp(0,mp(s,0)));

dp[0][s]=0;

while(!q.empty())
{
	pair<int,pii> p=q.top();
	q.pop();
	int dd=-p.ff,at=p.ss.ff,msk=p.ss.ss;
	//o2(msk,at);os;ol(dd);on;
	if(dp[msk][at]<dd)continue;
	tr(v[at],it)
	{
		int to=(*it);
		int m1=(msk+1)%3;
		if(dd+1<dp[m1][to])
		{
			dp[m1][to]=dd+1;
			q.push(mp(-dd-1,mp(to,m1)));
		}
	}
}

if(dp[0][t]>1e7)
{
	ol("-1");
}
else
{
	ol(dp[0][t]/3);
}

return 0;
}



Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	if(a.size()==b.size())
	{
		for(int i=0;i<a.size();i++)
		{
			cout<<a[i]<<b[i];
		}
		
	}
	else
	{
		for(int i=0;i<a.size();i++)
		{
			cout<<a[i];
			if(i<b.size())
			{
				cout<<b[i];
			}
		}
	}
}


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

int main ()
{
    int i,count=0;
   char s[4];
   cin>>s[0]>>s[1]>>s[2]>>s[3];
   if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3])
    cout<<"No"<<endl;
   else
   {
      for(i=1;i<=3;i++)
    {
        if(s[0]==s[i])
        {

            if(i==1)
            {
                if(s[2]==s[3])
                    {cout<<"Yes"<<endl;
                    break;}

                else
                    {cout<<"No"<<endl;
                    break;}
            }
            else if(i==2)
            {
                if(s[1]==s[3])
                    {cout<<"Yes"<<endl;
                    break;}

                else
                    {cout<<"No"<<endl;
                    break;}
            }
            else if(i==3)
            {
                if(s[1]==s[2])
                    {cout<<"Yes"<<endl;
                    break;}

                else
                    {cout<<"No"<<endl;
                    break;}
            }

        }
        else
        {
            count++;
        }

    }
    if(count==3)
        cout<<"No"<<endl;
   }


}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<double> v(N);
  rep(i, N) cin >> v[i];
  sort(v.begin(), v.end());
  double result = v[0];
  rep(i, N) {
    result += v[i];
    result /= 2;
  }
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

#define WEEK_MINUTES (7*24*60)

int main(void) {
	while(1) {
		int oktime[WEEK_MINUTES+10]={0};
		int oktime2[WEEK_MINUTES+10]={0};
		int s,n,t;
		int p,m;
		char weekday[10],zikan[10];
		int okw[7]={0},okt;
		int i,maxcount;
		scanf("%d%d%d%s%s%d%d",&s,&n,&t,weekday,zikan,&p,&m);
		if(weekday[0]=='N')break;
		if(weekday[0]=='A') {
			for(i=0;i<7;i++)okw[i]=1;
		} else if(weekday[0]=='S') {
			okw[weekday[1]=='u'?0:6]=1;
		} else if(weekday[0]=='M') {
			okw[1]=1;
		} else if(weekday[0]=='T') {
			okw[weekday[1]=='u'?2:4]=1;
		} else if(weekday[0]=='W') {
			okw[3]=1;
		} else if(weekday[0]=='F') { 
			okw[5]=1;
		}
		if(zikan[0]=='A')okt=0; else if(zikan[0]=='D')okt=1;
		else if(zikan[0]=='N')okt=2;
		for(i=0;i<7;i++) {
			if(okw[i]) {
				switch(okt) {
					case 0:
						oktime[i*24*60]++;
						oktime[(i+1)*24*60]--;
						break;
					case 1:
						oktime[i*24*60+6*60]++;
						oktime[i*24*60+18*60]--;
						break;
					case 2:
						oktime[i*24*60]++;
						oktime[i*24*60+6*60]--;
						oktime[i*24*60+18*60]++;
						oktime[i*24*60+24*60]--;
						break;
				}
			}
		}
		for(i=1;i<WEEK_MINUTES+10;i++)oktime[i]+=oktime[i-1]; /* imos */
		oktime2[0]=oktime[0];
		for(i=1;i<WEEK_MINUTES+10;i++)oktime2[i]=oktime2[i-1]+oktime[i]; /* ruiseki */
		maxcount=0;
		for(i=0;i<WEEK_MINUTES;i++) {
			int count=0;
			int nowtime=i;
			int st;
			for(st=0;st<m;st++) {
				int l=nowtime,r=(nowtime+s)%WEEK_MINUTES;
				if(l<r) {
					if(oktime2[r]-oktime2[l]==r-l && oktime[l])count+=n;
				} else {
					if(oktime2[r]-oktime2[0]==r && oktime[0] &&
					    oktime2[WEEK_MINUTES-1]-oktime2[l]==WEEK_MINUTES-1-l && oktime[l])count+=n;
				}
				nowtime=(nowtime+t)%WEEK_MINUTES;
			}
			if(maxcount<count)maxcount=count;
		}
		printf("%.15f\n",1.0-pow(1.0-1.0/p,maxcount));
	}
	return 0;
}

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

using namespace std;


int main() {
  #ifdef LOCAL
  freopen("sol.in", "r", stdin);
  freopen("sol.out", "w+", stdout);
  #endif
  int n, m, x, y;
  scanf("%d %d %d %d", &n, &m, &x, &y);
  int max_x = -(int) 1e9, min_y = (int) 1e9;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    max_x = max(max_x, x);
  }
  for (int i = 0; i < m; i++) {
    int y;
    scanf("%d", &y);
    min_y = min(min_y, y);
  }
  if (max_x < min_y && max(max_x, x) < min(min_y, y)) {
    puts("No War");
  } else {
    puts("War");
  }
  return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        mut s: [Chars; n],
    }
    for i in 0..n {
        s[i].reverse();
    }
    s.sort();
    // for i in 0..n {
    //     eprintln!("{} {:?}", i, s[i]);
    // }
    let mut last_index = vec![vec![-1; 26]; n];
    for i in 0..n {
        for (j, &c) in s[i].iter().enumerate() {
            let c = c as usize - 'a' as usize;
            last_index[i][c] = j as isize;
        }
    }
    // for i in 0..n {
    //     eprintln!("{:?}", last_index[i]);
    // }

    let mut prefix = vec![0; n];
    for i in 1..n {
        let mut k = 0;
        while k < s[i - 1].len() - 1 && k < s[i].len() - 1 && s[i - 1][k] == s[i][k] {
            k += 1;
        }
        prefix[i] = k;
    }
    // eprintln!("{:?}", prefix);

    // let mut debug = 0;
    // for i in 0..n {
    //     for j in 0..n {
    //         if s[i].len() >= s[j].len() {
    //             continue;
    //         }
    //         let l = s[i].len() - 1;
    //         if (0..l).all(|k| s[i][k] == s[j][k]) && (l..s[j].len()).any(|k| s[j][k] == s[i][l]) {
    //             eprintln!("{} {}", i, j);
    //             debug += 1;
    //         }
    //     }
    // }
    // eprintln!("{}", debug);

    let mut result = 0usize;
    for i in 0..n - 1 {
        let length = prefix[i + 1];
        if s[i].len() - 1 != length {
            continue;
        }
        let c = s[i][length] as usize - 'a' as usize;
        for j in i + 1..n {
            if prefix[j] < length {
                break;
            }
            if last_index[j][c] >= length as isize {
                // eprintln!("{} {}", i, j);
                result += 1;
            }
        }
    }
    // for i in 0..n {
    //     if s[i].len() == 1 {
    //         let c = s[i][0] as usize - 'a' as usize;
    //         for j in 0..i {
    //             if last_index[j][c] >= 0 {
    //                 eprintln!("{} {}", i, j);
    //                 result += 1;
    //             }
    //         }
    //     }
    // }
    //
    //
    s.reverse();
    last_index.reverse();
    let mut prefix = vec![0; n];
    for i in 1..n {
        let mut k = 0;
        while k < s[i - 1].len() - 1 && k < s[i].len() - 1 && s[i - 1][k] == s[i][k] {
            k += 1;
        }
        prefix[i] = k;
    }
    for i in 0..n - 1 {
        let length = prefix[i + 1];
        if s[i].len() - 1 != length {
            continue;
        }
        let c = s[i][length] as usize - 'a' as usize;
        for j in i + 1..n {
            if prefix[j] < length {
                break;
            }
            if last_index[j][c] >= length as isize {
                // eprintln!("{} {}", i, j);
                result += 1;
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 66584
use std::{cmp::{max, min}, collections::{BTreeMap, BTreeSet, VecDeque}};

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.parse().ok().expect("Can't Parse"));
    }
    vec
}
macro_rules! assign {
    () => {};
    ($($token:tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        assign_iter!(iter, $($token)*);
    };
}
macro_rules! assign_iter {
    ($iter:expr) =>{};
    ($iter:expr,) =>{};
    ($iter:expr, $id:ident:$t:tt $($tail:tt)*) => {
        let $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*);
    };
    ($iter:expr, mut $id:ident:$t:tt $($tail:tt)*) => {
        let mut $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        assign_iter!($iter, $($tail)*)
    };
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };

}

fn main() {
    assign!{
        n: usize
        x: i32
    }
    let mut candies = read_values::<i32>();
    let mut opperation_count = max(0i64, candies[0] as i64 - x as i64);
    candies[0] = min(x, candies[0]);
    for i in 1usize .. n {
        if candies[i] + candies[i - 1] > x {
            opperation_count += (candies[i] + candies[i - 1] - x) as i64;
            candies[i] = x - candies[i - 1];
        }
    }
    println!("{}", opperation_count);
}


Measured memory_bytes: 3480
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_n<T: FromStr>(n: u32) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

fn read_n_logic<T: FromStr>(n: u32, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

fn main() {
    let mut c = read_n::<u32>(3);
    c.sort();
    let largest = c.pop().unwrap();

    match largest == c.pop().unwrap() + c.pop().unwrap() {
        true => println!("Yes"),
        false => println!("No"),
    };
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

ll my_ceil(ll a, ll b){
  return (a + b - 1) / b;
}

ll N, A, B, C, D, E;

int main(){
  cin >> N >> A >> B >> C >> D >> E;
  cout << 5 + (my_ceil(N, min({A, B, C, D, E})) - 1) << endl;
}


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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    ll n,m,a[BIG],b[BIG],ans;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>n >>m;
    for (int i=1; i<=n; i++)
        cin >>a[i];
    while (m--) {
        int x,y;
        cin >>x >>y;
        if (a[x] > a[y])
            b[y] = 1;
        else if (a[x] < a[y])
            b[x] = 1;
        else {
            b[x] = b[y] = 1;
        }
    }

    for (int i=1; i<=n; i++)
        if (!b[i])
            ans++;

    cout <<ans;



    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(double i=1.00;i<=100000000.00;++i)
	{
		if(floor(i*0.08)==a && floor(i*0.1)==b)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;
typedef pair<int, int> P;

int N;
int A;
set<int> S;

signed main()
{
    cin >> N;
    REP(i,N) {
        cin >> A;
        if (S.find(A) == S.end()) {
            S.insert(A);
        } else {
            S.erase(A);
        }
    }

    cout << S.size() << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        cin >> v.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> c.at(i);
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(v.at(i) - c.at(i) > 0){
            sum = sum + v.at(i) - c.at(i);
        }
    }
    cout << sum << endl;
}

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

int main() {

 int N,K;
cin>>N;
cin>>K;

int A=1;
int i = 0; // カウンタ変数
while (i < N) {
if(A*2<A+K){//Aの二倍がA足すKより小さい時
A=A*2;
}
else{
A=A+K;
}
i++;
}
cout<<A<<endl;

}

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

//abc135E
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d", &n);
  int a[n],b[n];
  for(i=0; i < n; i++){
    scanf("%d",&a[i]);
    b[i]=-1;
  }
  for(i=0; i < n; i++){
    k=0;
  while(a[i]<=b[k])k++;
  b[k]=a[i];
  }
  for(i=0; i < n; i++){
    if(b[i]==-1)break;
  }
  printf("%d",i);
  return 0;
}

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

const int maxn=2e5+10;

int S,n,m,way=-1;
int La,Lp,Ra,Rp,Ans[maxn];

struct events{
	int t,a,id;
	events() {}
	events(int t,int a,int id):t(t),a(a),id(id) {}
	bool operator < (const events &e) const {return t<e.t;}
}e[maxn];

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,t,a;
	scanf("%d",&S);
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&t);
		e[i]=events(t,-1,0);
	}
	scanf("%d",&m);
	for (i=1;i<=m;i++)
	{
		scanf("%d%d",&t,&a);
		e[n+i]=events(t,a,i);
	}
	sort(e+1,e+n+m+1);

	La=0; Lp=0; Ra=S; Rp=S;
	for (i=1;i<=n+m;i++)
	{
		Lp+=way*(e[i].t-e[i-1].t);
		Rp+=way*(e[i].t-e[i-1].t);
		if (Lp<0)
		{
			if (Rp<0) La=Ra=S,Lp=Rp=0;
			else La-=Lp,Lp=0;
		}
		if (Rp>S)
		{
			if (Lp>S) La=Ra=0,Lp=Rp=S;
			else Ra-=Rp-S,Rp=S;
		}
		if (e[i].a==-1) way=-way;
		else
		{
			int tmp=Lp+e[i].a-La;
			tmp=min(tmp,Rp);
			tmp=max(tmp,Lp);
			Ans[e[i].id]=tmp;
		}
	}
	for (i=1;i<=m;i++)
		printf("%d\n",Ans[i]);
}


Measured memory_bytes: 3968
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

INF = 10**20
dp = [INF]*(N+10)
dp[0] = 0
def distance(x,y):
    return abs(h[x]-h[y])
dp[1] = distance(0,1)
for i in range(2,N):
    dp[i] = min(dp[i], dp[i-1] + distance(i-1,i))
    dp[i] = min(dp[i], dp[i-2] + distance(i-2,i))
print(dp[N-1])
    

Measured memory_bytes: 50580
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <queue>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int main()
{
    int n;
    long long m = 0;
    long long a = 0;
    long long r = 0;
    long long c = 0;
    long long h = 0;
    string str;
    cin >> n;
    REP(i, n) {
        cin >> str;
        if (str[0] == 'M')m++;
        if (str[0] == 'A')a++;
        if (str[0] == 'R')r++;
        if (str[0] == 'C')c++;
        if (str[0] == 'H')h++;
    }
    long long ans = m * a*r + m * a*c + m * a*h + m * r*c + m * r*h + m * c*h + a * r*c + a * r*h + a * c*h + r * c*h;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
local n,m=io.read("n","n")
if math.abs(n-m)>=2 then
    print(0)
else
    local dog=1
    for i=1,n do
        dog=dog*i%1000000007
    end
    local ape=1
    for i=1,m do
        ape=ape*i%1000000007
    end
    print(n==m and 2*dog*ape%1000000007 or dog*ape%1000000007)
end

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,k;
string s;

int main(){
	cin>>s>>k;
	int n=s.size();
	string t=s;
	sort(t.begin(),t.end());
	if(t[0]==t[n-1]){
		cout<<n*k/2<<endl;
		return 0;
	}
	char c=s[0];
	ll L=0,R=n-1,cnt=0;
	while(c==s[L]) L++;
	while(c==s[R]) R--;
	ll res=L/2+(n-1-R)/2+(L+n-1-R)/2*(k-1);
	cnt=1;
	for(int i=L+1;i<=R;i++){
		if(s[i-1]==s[i]) cnt++;
		else{
			res+=cnt/2*k;
			cnt=1;
		}
	}
	res+=cnt/2*k;
	cout<<res<<endl;
}

Measured memory_bytes: 256
x = int(input())

if x>=400 and x <=599:
    print("8")
elif x>=600 and x <=799:
    print("7")
elif x>=800 and x <=999:
    print("6")
elif x>=1000 and x <=1199:
    print("5")
elif x>=1200 and x <=1399:
    print("4")
elif x>=1400 and x <=1599:
    print("3")
elif x>=1600 and x <=1799:
    print("2")
elif x>=1800 and x <=1999:
    print("1")

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,a[N];
ll calc(ll mid) {
    for(int i=1;i<=n;i++) mid=mid-mid%a[i];
    return mid;
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi();
    ll l=2,r=1e18,lb=l-1;
    while(l<=r) {
        ll mid=(l+r)>>1;
        if(calc(mid)<2) lb=mid,l=mid+1;
        else r=mid-1;
    }
    l=2,r=1e18;ll rb=r+1;
    while(l<=r) {
        ll mid=(l+r)>>1;
        if(calc(mid)>2) rb=mid,r=mid-1;
        else l=mid+1;
    }
    ++lb,--rb;
    if(calc(lb)!=2) return puts("-1"),0;
    if(calc(rb)!=2) return puts("-1"),0;
    if(lb>rb) return puts("-1"),0;
    printf("%lld %lld\n",lb,rb);
    return 0;
}


Measured memory_bytes: 640
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};

int n,m,k;
int X1,Y1,X2,Y2;
string grid[1000005];

ii w[4][1000005];

priority_queue<iiii,vector<iiii>,greater<iiii> > pq;

int node(int i,int j){
	return i*m+j;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	memset(w,63,sizeof(w));
	
	cin>>n>>m>>k;
	cin>>X1>>Y1>>X2>>Y2;
	X1--,Y1--,X2--,Y2--;
	
	rep(x,0,n){
		cin>>grid[x];
	}
	
	rep(z,0,4){
		w[z][node(X1,Y1)]=ii(0,0);
		pq.push(iiii(w[z][node(X1,Y1)],ii(z,node(X1,Y1))));
	}
	
	while (!pq.empty()){
		ii weight=pq.top().fi;
		int pz=pq.top().se.fi,px=pq.top().se.se/m,py=pq.top().se.se%m;
		pq.pop();
		
		if (w[pz][node(px,py)]!=weight) continue;
		//cout<<pz<<" "<<px<<" "<<py<<endl;
		//cout<<weight.fi<<" "<<weight.se<<endl;
		
		rep(z,0,4){
			int xx=px+dx[z],yy=py+dy[z];
			if (xx<0 || n<=xx || yy<0 || m<=yy) continue;
			if (grid[xx][yy]=='@') continue;
			
			ii temp;
			if (pz==z){
				temp=weight;
				temp.se++;
			}
			else{
				temp=ii(weight.fi+(weight.se!=0),1);
			}
			
			if (temp.se==k) temp=ii(temp.fi+1,0);
			
			if (w[z][node(xx,yy)]>temp){
				w[z][node(xx,yy)]=temp;
				pq.push(iiii(w[z][node(xx,yy)],ii(z,node(xx,yy))));
			}
		}
	}
	
	ll ans=1e18;
	rep(z,0,4){
		ans=min(ans,w[z][node(X2,Y2)].fi+(w[z][node(X2,Y2)].se!=0));
	}
	
	if (ans==1e18) cout<<"-1"<<endl;
	else cout<<ans<<endl;
	
}


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

int main()
{
  string S;
  cin >> S;
  long long int K;
  cin >> K;
  int pos = 1;
  int num = 1;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) != '1')
    {
      pos = i + 1;
      num = S.at(i) - '0';
      break;
    }
    else
      continue;
  }
  if (K < pos)
    cout << 1 << endl;
  else
    cout << num << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
vector<string>v;
string s;
bool b[200];
void dfs(int d){
    if(d==s.size())v.push_back(s);
    else{
        if(s[d]=='a'||b[s[d]])dfs(d+1);
        if(!b[s[d]+1]&&s[d]!='z'){
            s[d]++;
            b[s[d]]=1;
            dfs(d+1);
            s[d]--;
            b[s[d]+1]=0;
        }
    }
}
int main(){
    while(cin>>s,s!="#"){
        memset(b,0,sizeof(b));
        v.clear();
        dfs(0);
        cout<<v.size()<<endl;
        sort(v.begin(),v.end());
        if(v.size()<=10)r(i,v.size())cout<<v[i]<<endl;
        else{
            r(i,5)cout<<v[i]<<endl;
            r(i,5)cout<<v[v.size()+i-5]<<endl;
        }
    }
}

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    bool a[n+1] = {};
    a[0] = true;
    for (int i = 4; i <= n; i++)
        if (i >= 7) a[i] = a[i-4] || a[i-7];
        else a[i] = a[i-4];
    cout << (a[n] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  int a,b,n,s,f,z=0;
  cin>>a>>b;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s>>f;
    if(a>s&&a<f || b>s&&b<f){
      z++;
    }else if(a==s || b==f){
      z++;
    }else if(a<s&&b>f){
      z++;
    }
  }
  if(z!=0){
    cout<<"1\n";
  }
  else{
    cout<<"0\n";
  }
}



Measured memory_bytes: 3104
//==========================================
// ABC139c
//
// 2019/09/01
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin >> h[i];

  vector<int> cnt(n);
  int j=0;
  for(int i=1; i<n; ++i)
  {
    if(h[i-1] < h[i])
    {
      j++;
      continue;
    }
    cnt[j]++;
  }
  sort(cnt.begin(), cnt.end(), greater<int>());
  cout << cnt[0] << endl;


  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, std::vector<long long> A) {
    sort(A.begin(), A.end());
    int ub = 1000001;
    vector<int> ban(ub);
    vector<int> used(ub);
    int ans = 0;
    rep(i, N) {
        used[A[i]]++;
        if (2 <= used[A[i]]) continue;
        loop (j, 1, 1000001) {
            auto t = A[i] * j;
            if (ub <= t) break;
            ban[t]++;
        }
    }
    rep (i, N) {
        if (ban[A[i]] == 1 && used[A[i]] == 1) ans++;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 12760
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;
string S;
vector<int> ans;

signed main(){
    cin >> N >> M >> S;
    int cnt = 0;
    rep(i, N+1){
        if(S[i] == '1') cnt++;
        else cnt = 0;
        if(cnt >= M){
            cout << -1 << endl;
            return 0;
        }
    }
    int i = N;
    while(i > 0){
        for(int j=max(0, i-M); j<i; j++){
            if(S[j] == '0'){
                ans.pb(i-j);
                i = j;
                break;
            }
        }
    }
    reverse(all(ans));
    rep(i, ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int n, ai[N], mx;
int x, y;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> ai[i];
    for (int i = 1; i <= n; ++ i) mx = max(ai[i], mx);
    for (int i = 1; i <= n; ++ i)
        if (mx == ai[i]) x ++;
        else if (mx - 1 == ai[i]) y ++;
        else {cout << "No" << endl; return 0;}
    if (y == 0)
    {
        if (mx == n - 1) {cout << "Yes" << endl; return 0;}
        if (mx * 2 <= n) {cout << "Yes" << endl; return 0;}
    }
    else
    {
        if (y + 1 <= mx && mx <= y + x / 2) {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  int X,Y;
  if (x%2==1 && x<8 || x%2==0 && x>=8){
    X=1;
  } else if (x == 2){
    X=3;
  } else {
    X=2;
  }
  if (y%2==1 && y<8 || y%2==0 && y>=8){
    Y=1;
  } else if (y==2){
    Y=3;
  } else {
    Y=2;
  }
  if (X==Y){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
import Control.Monad
import Data.Fixed
import Data.List
import Data.Monoid
import Data.Ord
import Text.Printf
 
readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y

angleFrom (x0,y0) (x,y) = atan2 (fromIntegral (y-y0)) (fromIntegral (x-x0))
dist2 (x0,y0) (x,y) = (x-x0)^2 + (y-y0)^2

convex :: [(Int,Int)] -> [(Int,Int)]
convex ps = firstP : sub firstP 0
  where
    sub p a = let np = nextP p a in if np==firstP then [] else np : sub np (angleFrom p np)
    firstP = minimumBy (comparing snd <> flip (comparing fst)) ps
    nextP p a = minimumBy (comparing (flip mod' (2*pi) . subtract a . angleFrom p) <> comparing (dist2 p)) (delete p ps)

solve :: Int -> [(Int,Int)] -> [Double]
solve 2 ps = [0.5,0.5]
solve n ps = [if p `elem` cvx then calc p else 0.0 | p <- ps]
  where
    cvx = convex ps
    calc p = fsub (cycle cvx) p
    fsub (v1:r@(v2:v3:_)) p
      | v2==p = mod' (angleFrom v3 v2 - angleFrom v2 v1) (2*pi) / (2*pi) -- [v1,v2,v3]
      | otherwise = fsub r p

main = do
    n <- getInt
    ps <- map (apply2 (,)) <$> replicateM n getInts
    forM_ (solve n ps) $ printf "%.15f\n"

Measured memory_bytes: 1020
#include <iostream>

using namespace std;
int main(){

    int a , b , x ;
    cin >>  a >> b >> x ;

    int total = a + b ;

    if (total >= x && a < x)
        cout << "YES" ;
    else if (a > x)
        cout << "NO" ;
    else if (total < x && a < x)
        cout << "NO" ;
    else if (a == x)
        cout << "YES" ;
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  bool F = 0;
  if (A == B && A != C) F = 1;
  if (A == C && A != B) F = 1;
  if (C == B && A != C) F = 1;
  
  if (F) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int mod = 1000000007;
int n;
int x[100000];
int fact[200001];
int inv[200001];
int wa[200000];

signed main() {
	int i, j;
	
	fact[0] = 1;
	for (i = 1; i <= 200000; i++) fact[i] = (i * fact[i - 1]) % mod;
	for (i = 1; i <= 200000; i++) inv[i] = powmod(i, mod - 2, mod);
	
	wa[0] = 0;
	for (i = 1; i < 200000; i++) {
		wa[i] = inv[i] * inv[i + 1] % mod;
	}
	for (i = 1; i < 200000; i++) {
		wa[i] += wa[i - 1];
		wa[i] %= mod;
	}
	
	cin >> n;
	rep(i, n) cin >> x[i];
	
	int ans = 0;
	/*rep(i, n - 1) {
		for (j = i + 1; j < n - 1; j++) {//i→jが起きる確率
			int prob = inv[j - i] * inv[j - i + 1] % mod;
			int dist = (x[j] - x[i] + mod) % mod;
			ans += prob * dist % mod;
			ans %= mod;
		}
	}*/
	
	rep(j, n - 1) {
		ans += x[j] * wa[j] % mod;
		ans %= mod;
	}
	rep(i, n - 1) {
		int res = x[i] * wa[n - 2 - i] % mod;
		ans = (ans + mod - res) % mod;
	}
	
	rep(i, n - 1) {
		ans += inv[n - 1 - i] * (x[n - 1] - x[i] + mod) % mod;
		ans %= mod;
	}
	
	ans *= fact[n - 1];
	ans %= mod;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
import java.net.SecureCacheResponse;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] list = new String[n];
        HashMap<String, Integer> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String tmpStr = sc.next();
            list[i] = tmpStr;

            if (map.containsKey(tmpStr)) {
                map.put(tmpStr, map.get(tmpStr)+1);
            } else {
                map.put(tmpStr, 1);
            }
        }

        boolean ans = true;
        for (int i = 1; i < n; i++) {
            String pre = list[i-1];
            String cur = list[i];

            if (pre.charAt(pre.length()-1) == cur.charAt(0) && map.get(cur) == 1) {
                continue;
            } else {
                ans = false;
                break;
            }
        }

        System.out.println(ans ? "Yes" : "No");
    }
}


Measured memory_bytes: 23124
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] m = new int[n];
    for(int i=0;i<n;i++){
      m[i] = sc.nextInt();
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
      x-=m[i];
      sum++;
    }
    Arrays.sort(m);
    sum+=x/m[0];
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844