akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    if a <= 5 {
        println!("0");
    } else if a <= 12 {
        println!("{}", b / 2);
    } else {
        println!("{}", b);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void){

	int n,max=0,sum=1;
	scanf("%d",&n);
	int h[n];
	rep(i,n){
		scanf("%d",&h[i]);
	}
	max=h[0];
	rep(i,n-1){
		if(h[i+1]>=h[i] && h[i+1]>=max) {
			sum++;
			max=h[i+1];
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B && B == C && A == C) ||
        (A != B && B != C && A != C)) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	while(true){
		int N=in();
		if(!N) break;
		vector<vector<int>> T(N+1,vector<int>(N+1,0));
		REP(i,N){
			REP(j,N){
				T[i][j] = in();
				T[N][j] += T[i][j];
				T[i][N] += T[i][j];
			}
		}
		T[N][N] = accumulate(T[N].begin(),T[N].begin()+N,0);
		REP(i,N+1){
			REP(j,N+1){
				printf("%5d",T[i][j]);
			}
			printf("\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 3192
use std::mem::swap;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

struct UnionFind {
    par: Vec<usize>,
    siz: Vec<usize>,
}

impl UnionFind {
    fn init(&mut self, n: usize) -> &mut UnionFind {
        for i in 0..n {
            self.par.push(i);
            self.siz.push(1);
        }
        self
    }

    fn find(&mut self, x: usize) -> usize {
        let ele = self.par[x];
        return if ele == x {
            x
        } else {
            self.par[x] = self.find(ele);
            self.par[x]
        };
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }

    fn unite(&mut self, x: usize, y: usize) -> bool {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x == y {
            return false;
        }
        if self.par[x] < self.par[y] {
            swap(&mut x, &mut y)
        }
        self.siz[x] += self.siz[y];
        self.par[y] = x;
        true
    }

    fn size(&mut self, x: usize) -> usize {
        let root = self.find(x);
        self.siz[root]
    }
}

fn main() {
    input!(
    n: usize,
    m: usize,
    k: usize,
    f: [[usize; 2]; m],
    b: [[usize; 2]; k]
    );
    let mut u = UnionFind { par: vec![], siz: vec![] };
    let u = u.init(n);
    let mut fc = vec![0usize; n];
    for fr in f {
        u.unite(fr[0] - 1, fr[1] - 1);
        fc[fr[0] - 1] += 1;
        fc[fr[1] - 1] += 1;
    }
    for br in b {
        if u.same(br[0] - 1, br[1] - 1) {
            fc[br[0] - 1] += 1;
            fc[br[1] - 1] += 1;
        };
    }
    for i in 0..n {
        print!("{} ", u.size(i) - fc[i] - 1)
    }
}


Measured memory_bytes: 20732
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


int keta(int x) {
	int ans = 1;
	for (; 10 <= x; x /= 10)ans++;
	return ans;
}
int solve(vector<array<int, 2>>&soinsu, int A, int B, int P) {

	if (P == soinsu.size()) {
		return max(keta(A), keta(B));
	}
	int ans = intmax;
	for (int i = 0; i <= soinsu[P][1]; i++) {
		int AA = A, BB = B;
		rep(j, i)AA *= soinsu[P][0];
		rep(j, soinsu[P][1] - i)BB *= soinsu[P][0];
		ans = min(ans, solve(soinsu, AA, BB, P + 1));
	}
	return ans;
}

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

	int N;
	cin >> N;
	vector<array<int, 2>>soinsu;

	int NN = N;
	for (int i = 2; i*i <= N; i++) {
		int x = 0;
		while (NN%i == 0) {
			x++;
			NN /= i;
		}
		if (x)soinsu.push_back({ i,x });
	}
	if (NN != 1) {
		soinsu.push_back({ NN,1 });
	}

	cout << solve(soinsu, 1, 1, 0) << endl;




	return 0;
}

Measured memory_bytes: 256
def s_in():
    return input()

S = s_in()

if len(S) == 1:
    print(1)
    exit()


lis = []
cnt = 1
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        lis.append((S[i], cnt))
        cnt = 1
else:
    lis.append((S[len(S)-1], cnt))


res = 0
idx = 0


if lis[0][0] == ">":
    res += sum(range(lis[0][1]+1))
    idx += 1

while idx < len(lis):
    if idx+1 == len(lis):
        res += sum(range(lis[idx][1]+1))
        break

    x = lis[idx][1]
    y = lis[idx+1][1]

    res += sum(range(max(x,y)+1)) + sum(range(min(x,y)))

    idx += 2


print(res)



Measured memory_bytes: 22044
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn.{readLine}
  class Team(val id:Int){
    private var loseBy:Int = 0
    private var mWinTo:List[Team] = Nil
    def decreaseLoseCount():Unit = loseBy-=1
    def loseCount:Int = loseBy
    def winTo:List[Team] = mWinTo
  }
  object Team{
    def setMatchResult(winner:Team, loser:Team):Unit = {
      winner.mWinTo = loser::winner.mWinTo
      loser.loseBy += 1
    }
  }
  val team = Array.tabulate(readLine().toInt){i ⇒ new Team(i + 1)}
  for (_ ← 0 until readLine().toInt){
    val Array(winner, loser) = readLine().split(' ').map(_.toInt)
    Team.setMatchResult(team(winner - 1), team(loser - 1))
  }
  val queue:mutable.Queue[Team] = new mutable.Queue[Team]
  queue.enqueue(team.filter(_.loseCount == 0):_*)
  var hasSomeSuspect = false
  while (queue.size != 0){
    hasSomeSuspect ||= queue.size != 1
    val top = queue.dequeue()
    queue.enqueue(top.winTo.filter { case t ⇒ t.decreaseLoseCount()
        t.loseCount == 0
    }:_*)
    println(top.id)
  }
  println(if (hasSomeSuspect) 1 else 0)
}


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

double calcBMI(double weight, double height) {
    return(weight / (height*height));
}

int main(void) {
    int no;
    double weight, height;
    vector<int> selection;
    while(scanf("%d,%lf,%lf", &no, &weight, &height) != EOF) {
        if(calcBMI(weight, height) >= 25) {
            selection.push_back(no);
        }
    }
    if(selection.size() == 0) {
        cout << "該当なし" << endl;
        return(0);
    }
    vector<int>::iterator ite;
    for(ite = selection.begin(); ite != selection.end(); ite++) {
        cout << *ite << endl;
    }
    return(0);
}

Measured memory_bytes: 1252
n,m=map(int,input().split())
one_to=set()
to_n=set()
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        one_to.add(b)
    elif b==n:
        to_n.add(a)
one_to=list(one_to)
flag=False
for i in range(len(one_to)):
    if one_to[i] in to_n:
        flag=True
        break
print("POSSIBLE" if flag else "IMPOSSIBLE")

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

    using namespace std;

    int main()
    {
        int n;
        cin >> n;
        int a[n+1];
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        if(a[1] == a[n]) {
            if(a[1] == n-1 || a[1]*2 <= n) {
                cout << "Yes";
            }
            else {
                cout << "No";
            }
        }
        else if(a[n] - a[1] == 1) {
            int i = 1;
            while(a[i] == a[i+1])
                i ++;
            int j = n - i;
            if(a[1] >= i && 2*(a[n]-i) <= j) {
                cout << "Yes";
            }
            else {
                cout << "No";
            }
        }
        else {
            cout << "No";
        }
        return 0;
    }


Measured memory_bytes: 640
#include <stdio.h>

int proc_x[2] = {1, 0};
int proc_y[2] = {0, 1};

int done[128][128][3][2];
int memo[128][128][3][2];

int num(int w, int h, int x, int y, int angle, int turn)
{
	int r, u;
	
	if (done[x][y][angle][turn]){
		return (memo[x][y][angle][turn]);
	}
	
	if (x == w && y == h){
		return (1);
	}
	
	if (x > w || y > h){
		return (0);
	}
	
	done[x][y][angle][turn] = 1;
	
	if (angle == 2){
		memo[x][y][angle][turn] = (num(w, h, x + 1, y, 0, 0) + num(w, h, x, y + 1, 1, 0)) % 100000;
		
		return (memo[x][y][angle][turn]);
	}
	
	if (turn == 0) {
		memo[x][y][angle][turn] = (num(w, h, x + proc_x[angle], y + proc_y[angle], angle, 0)
		+ num(w, h, x + proc_x[!angle], y + proc_y[!angle], !angle, 1)) % 100000;
		return (memo[x][y][angle][turn]);
	}
	
	memo[x][y][angle][turn] = num(w, h, x + proc_x[angle], y + proc_y[angle], angle, 0) % 100000;
	
	return (memo[x][y][angle][turn]);
}

int main(void)
{
	int w, h;
	int i, j, k, l;
	
	while (1){
		scanf("%d %d", &w, &h);
		
		if (!w && !h){
			break;
		}
		
		for (i = 0; i < 128; i++){
			for (j = 0; j < 128; j++){
				for (k = 0; k < 3; k++){
					for (l = 0; l < 2; l++){
						done[i][j][k][l] = 0;
						memo[i][j][k][l] = 0;
					}
				}
			}
		}
		
		printf("%d\n", num(w, h, 1, 1, 2, 0));
	}
	
	return (0);
}

Measured memory_bytes: 1384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
	cout << (max(a,40)+max(b,40)+max(c,40)+max(d,40)+max(e,40))/5 << endl;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	int A[110];
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	A[N + 1] = 0;
	int ans = 0;
	int zr = 0;
	for (int i = 1; i <= N + 1; i++) {
		if (A[i] == 0) {
			ans = max(ans, i - zr);
			zr = i;
		}
	}
	if (ans == 0) {
		cout << N + 1 << endl;
	} else {
		cout << ans << endl;
	}
}


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

int main(void){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    int c = 0;
    for(int i = 0; i <= N - 3; i++){
        int temp[3];
        temp[0] = A[i];
        temp[1] = A[i+1];
        temp[2] = A[i+2];
        sort(temp,temp+3);
        if(temp[1] == A[i+1]){
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#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() {
  ll n;
  cin >> n;
  int ans = 0;
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  for(auto p: ret) {
    int i = 1;
    int m = 1;
    while(p.second>=m) {
      i++;
      m += i;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int n,m;
	int x;
	cin >> n >> m >> x;
	int a[n];
	int cos = 0;
	int cos2 = 0;
	bool f = false;//is left
	LOOP(i,m){
		cin >> a[i];
	}
	LOOP(i,m){
		if(f==false){

		}
		if(a[i]<x){
			cos++;
		}else{
			cos2++;
		}
	}
	cout << min(cos,cos2) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int H_1,H_2,M_1,M_2,K;
  scanf("%d %d %d %d %d",&H_1,&M_1,&H_2,&M_2,&K);
  
  int T_1 = H_1*60+M_1;
  int T_2 = H_2*60+M_2;
  int Ans = T_2-T_1-K;
  printf("%d\n",Ans);
  
  return 0;
}

Measured memory_bytes: 1736
import java.util.stream.*;
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        char[][] a = IntStream.range(0, h).mapToObj(i -> scanner.next().toCharArray()).toArray(char[][]::new);
        int[][] dist = new int[h][w];
        Arrays.stream(dist).forEach(array -> Arrays.fill(array, 10000));

        for (int i = 0; i < h; i++) {
            for (int j = 0, c = 0; j < w; j++) {
                if (a[i][j] == '#') {
                    dist[i][j] = 0;

                    c = 1;
                } else if (c > 0) {
                    dist[i][j] = c;
                    c++;
                }
            }

            for (int j = w - 1, c = 0; j >= 0; j--) {
                if (a[i][j] == '#') {
                    c = 1;
                } else if (c > 0) {
                    dist[i][j] = Math.min(dist[i][j], c);
                    c++;
                }
            }
        }

        for (int i = 0; i < w; i++) {
            for (int j = 0, c = 10000; j < h; j++) {
                if (c > dist[j][i]) {
                    c = dist[j][i] + 1;
                } else {
                    dist[j][i] = c;
                    c++;
                }
            }

            for (int j = h - 1, c = 10000; j >= 0; j--) {
                if (c > dist[j][i]) {
                    c = dist[j][i] + 1;
                } else {
                    dist[j][i] = c;
                    c++;
                }
            }
        }

        System.out.println(Arrays.stream(dist).mapToInt(array -> Arrays.stream(array).max().getAsInt()).max().getAsInt());
    }
}

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

int main(){
  string S;
  cin >> S;
  if(S[0] == S[1] && S[1] == S[2]){
   cout << "Yes" << endl;
  }
  else if(S[1] == S[2] && S[2] == S[3]){
   cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3580
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), m = sc.nextInt();
		int sh = sc.nextInt() - 1, sw = sc.nextInt() - 1;
		int eh = sc.nextInt() - 1, ew = sc.nextInt() - 1;
		char[][] grid = new char[n][m];
		for (int i = 0; i < n; i++)
			grid[i] = sc.next().toCharArray();
		Deque<int[]> q = new LinkedList();
		q.add(new int[] { sh, sw });
		int[][] dist = new int[n][m];
		int INF = (int) 1e9;
		
		for(int []x:dist)
		Arrays.fill(x, INF);
		dist[sh][sw] = 0;
		while (!q.isEmpty()) {
			int[] curr = q.poll();
			int i = curr[0], j = curr[1];
			for (int di = -2; di <= 2; di++)
				for (int dj = -2; dj <= 2; dj++) {
					int i2 = i + di, j2 = j + dj;
					if (i2 < 0 || i2 >= n || j2 < 0 || j2 >= m || grid[i2][j2] != '.')
						continue;
					int c = Math.abs(di) + Math.abs(dj) == 1 ? 0 : 1;
					if (dist[i][j] + c < dist[i2][j2]) {
						dist[i2][j2] = c + dist[i][j];
						if (c == 0)
							q.addFirst(new int[] { i2, j2 });
						else
							q.addLast(new int[] { i2, j2 });

					}
				}
		}
		out.println(dist[eh][ew]==INF?-1:dist[eh][ew]);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}


Measured memory_bytes: 52552
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	as := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	dp := make([][][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([][]int, N+1)
		for j := 0; j < N+1; j++ {
			dp[i][j] = make([]int, 2)
		}
	}

	for i := 1; i < N+1; i++ {
		dp[i][i][0] = as[i]
		dp[i][i][1] = -as[i]
	}

	for r := 2; r < N+1; r++ {
		for l := r - 1; l > 0; l-- {
			dp[l][r][0] = max(
				dp[l+1][r][1]+as[l],
				dp[l][r-1][1]+as[r],
			)
			dp[l][r][1] = min(
				dp[l+1][r][0]-as[l],
				dp[l][r-1][0]-as[r],
			)
		}
	}

	fmt.Println(dp[1][N][0])
	/*
		// dump 0 (fst)
		fmt.Println("----- 0 ----")
		for i := 1; i < N+1; i++ {
			for j := 1; j < N+1; j++ {
				fmt.Print(dp[i][j][0], "\t")
			}
			fmt.Println()
		}

		// dump 1 (snd)
		fmt.Println("----- 1 ----")
		for i := 1; i < N+1; i++ {
			for j := 1; j < N+1; j++ {
				fmt.Print(dp[i][j][1], "\t")
			}
			fmt.Println()
		}
	*/
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 371732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  char a;
  cin >> a;
  if(a == 'a'){
    cout << "vowel\n";
    return 0;
  }
  if(a == 'i'){
    cout << "vowel\n";
    return 0;
  }
  if(a == 'u'){
    cout << "vowel\n";
    return 0;
  }
  if(a == 'e'){
    cout << "vowel\n";
    return 0;
  }
  if(a == 'o'){
    cout << "vowel\n";
    return 0;
  }
  cout << "consonant\n";
}

Measured memory_bytes: 3624
n, m = list(map(int, input().split()))
hlist = list(map(int, input().split()))
glist = [1]*n

for _ in range(m):
    a, b = list(map(int, input().split()))
    ah = hlist[a-1]
    bh = hlist[b-1]

    if ah>bh:
        glist[b-1] = 0
    elif ah < bh:
        glist[a-1] = 0
    else:
        glist[a-1] = 0
        glist[b-1] = 0

print(sum(glist))

Measured memory_bytes: 20044
n = int(input())
a = [int(i) for i in input().split()]

ls = [0]*n
for i in range(n-1,-1,-1):
    count = 0
    for j in range(i,n,i+1):
        count += ls[j]
    if (count + 1) % 2 == a[i]:
        ls[i] = 1
check = 0
for i in range(n):
    if ls[i] == 1:
        check += 1
    
print(check)
for i in range(n):
    if ls[i] == 1:
        print(i+1)

Measured memory_bytes: 64220
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#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 rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const long double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;

const int mod = TEN(9)+7;

int H, W, K;
int a[6][6];

signed main()
{
	cin >> H >> W >> K;

	rep(i, H) rep(j, W) {
		char c; cin >> c;
		if (c == '.') a[i][j] = 0;
		else a[i][j] = 1;
	}

	int ans = 0;

	rep(S1, 1 << H) rep(S2, 1 << W) {
		int a_c[H][W];
		rep(i, H) rep(j, W) a_c[i][j] = a[i][j];

		rep(i, H) {
			if (S1 >> i & 1) {
				rep(j, W) {
					a_c[i][j] = -1;
				}
			}
		}
		rep(i, W) {
			if (S2 >> i & 1) {
				rep(j, H) {
					a_c[j][i] = -1;
				}
			}
		}

		int counter = 0;

		rep(i, H) rep(j, W) if (~a_c[i][j]) counter += a_c[i][j];

		if (counter == K) ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3568
num1, num2, num3 = input().split(" ")
numList = [int(num1),int(num2),int(num3)]
numList.sort(reverse=True)
maxNum = numList[0]
midNum = numList[1]
minNum = numList[2]

count = 0
if maxNum % 2 == 0:
    if midNum % 2 == 0 and minNum % 2 == 0:
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
    elif midNum % 2 == 1 and minNum % 2 == 1:
        maxNum += 2
        midNum += 2
        midNum += 2
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
        count += 2
    else:
        if midNum % 2 == 0:
            maxNum += 1
            minNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
        else:
            maxNum += 1
            midNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
else:
    if midNum % 2 == 0 and minNum % 2 == 0:
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
    elif midNum % 2 == 1 and minNum % 2 == 1:
        count += (midNum - minNum) // 2
        count += (maxNum - midNum)
    else:
        if midNum % 2 == 0:
            maxNum += 1
            minNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
        else:
            maxNum += 1
            midNum += 1
            count += (midNum - minNum) // 2
            count += (maxNum - midNum)
            count += 1
print(count)



Measured memory_bytes: 3064
n = int(input().rstrip())
As = map(int, input().rstrip().split(" "))

response = "APPROVED"

for a in As:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            continue
        else:
            response = "DENIED"
            break

print(response)


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int N,A;
  cin >> N >> A;
  cout << N*N-A << endl;
}




Measured memory_bytes: 256
require "prime"
q=gets.chomp.to_i
a=Array.new(q)

q.times do |i|
  l,r=gets.chomp.split(" ").map { |e| e.to_i }
  a[i] = {"l" => l,"r" => r }
end

b = Array.new(10**5 + 1,0)

def judge_prime_numeber(n)

  a = n.prime_division
  if a.length != 1
    return false
  else
    if a[0][0] != n
        return false
    else
      return true
    end
  end
end


for i in 1..10**5 do
  if judge_prime_numeber(i) && judge_prime_numeber((i+1)/2)
    b[i] += b[i-1] + 1
  else
    b[i] += b[i-1]
  end
end

for i in 0..q-1 do
  l=a[i]["l"]
  r=a[i]["r"]
  puts b[r] - b[l-1]
end


Measured memory_bytes: 33276
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

vector<int>a[200000];

int main()
{
	int N, M;
	cin >> N >> M;
	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 8284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll k;
  cin >> k;
  vl lun;
  rep2(i, 1, 10) lun.push_back(i);
  int i = 0;
  while(lun.size() < k) {
    ll d = lun[i] % 10;
    if(d != 0) lun.push_back(lun[i] * 10 + d - 1);
    lun.push_back(lun[i] * 10 + d);
    if(d != 9) lun.push_back(lun[i] * 10 + d + 1);
    i++;
  }
  cout << lun[k - 1] << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		int count = 0;

		for(int i=0 ; i<=s.length()-3 ; i++) {
			if(s.charAt(i)=='A' && s.charAt(i+1)=='B' && s.charAt(i+2)=='C') {
				count++;
			}
		}

		System.out.println(count);

		sc.close();

	}

}


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

#define ll long long
#define mod 1000000007
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define dbg(x) cout<<#x<<" "<<x
#define sci(x) scanf("%d",&x)
#define scd(x) scanf("%lf",&x)
#define scl(x) scanf("%lld",&x)
#define pfi(x) printf("%d",x)
#define pfd(x) printf("%lf",x)
#define pfl(x) printf("%lld",x)


auto fatafat=[](){std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); return 0;}();

int minCost(int n,int k,vector<ll>& v,int indx,vector<ll>& dp)
{
    if(indx==n-1)
        return 0;
    if(dp[indx]!=1000000000)
        return dp[indx];
    
    
    for(int i=1;i<=k;i++)
    {
        if(indx+i<n)
        {
            dp[indx]=min(dp[indx],abs(v[indx]-v[indx+i]) + minCost(n,k,v,indx+i,dp));
        }
        else
            break;
    }
    
    
    // if(i+2<=n-1)
    //     dp[i]= min(abs(v[i]-v[i+1])  +minCost(n,v,i+1,dp) , abs(v[i]-v[i+2])+ minCost(n,v,i+2,dp));
    // else
    //     dp[i]= abs(v[i]-v[i+1]) +minCost(n,v,i+1,dp);
    
    return dp[indx];
    
}


int main()
{
   
    int n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    
    vector<ll> dp(n,1000000000);
    
    cout<<minCost(n,k,v,0,dp);
    
    
    
    
}

Measured memory_bytes: 11136
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;

const int SIZE = 1 << 17; // 2^17 = 131072
template<typename T>
struct segtree {
    // ?????????????????????
    T node[2*SIZE], I;

    // ????????¬????????§??? (update, query ??? 2 ???????????????)
    T (*upd_f)(T, T), (*qry_f)(T, T);

    // ???????????¨?????????????????????????????¨?????? node ??????????????§?????????
    segtree(T (*op1)(T, T), T (*op2)(T, T), T X) {
        upd_f = op1;
        qry_f = op2;
        I = X;
        fill(node, node+2*SIZE, I);
    }

    // ??´??? idx ?????? val ????????? (upd_f ?????¨?????? update)
    void update(int idx, T val) {
        idx += SIZE - 1;
        node[idx] = upd_f(node[idx], val);
        while(idx > 0) {
            // ????????¨?????? qry_f ??????????????¨?????¨????????????
            idx = (idx - 1) / 2;
            node[idx] = qry_f(node[2*idx+1], node[2*idx+2]);
        }
    }

    // ???????????? [a, b) ?????????????????¨???????????????
    // (qry_f ?????¨????????????)
    T query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return I;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        T vl = query(a, b, l, mid, 2*k+1);
        T vr = query(a, b, mid, r, 2*k+2);
        return qry_f(vl, vr);
    }
};

int upd(int a, int b) {return b;}
int fnd(int a, int b) {return min(a, b);}
int main() {
    segtree<int> seg(upd, fnd, INT_MAX);
    int N, Q; scanf("%d%d", &N, &Q);
    for(int i=0; i<Q; i++) {
        int c, x, y; scanf("%d%d%d", &c, &x, &y);
        if(c == 0) seg.update(x, y);
        else printf("%d\n", seg.query(x, y+1));
    }
    return 0;
}

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

using namespace std;

int main() {
	string s;
	getline(cin, s);
	for (auto &c: s) {
		if (c >= 'a' && c <= 'z') {
			c -= 'a';
			c += 'A';
		} else if (c >= 'A' && c <= 'Z') {
			c -= 'A';
			c += 'a';
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  int N;  cin>>N;
  vector<ll> X(N), Y(N);
  vector<P> ten(N);
  rep(i,0,N) cin>>X[i]>>Y[i];
  vector<P> v;
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  rep(i,0,N){
    rep(j,0,N){
      if(i==j) continue;
      v.pb(mp(X[j]-X[i], Y[j]-Y[i]));
    }
  }
  int n = v.size();
  ll cntmax = INF;
  rep(i,0,n){
    ll k = 0;
    rep(i2,0,N)rep(j2,0,N){
      if(i2==j2) continue;
      if(X[i2]-X[j2]==v[i].fi && Y[i2]-Y[j2]==v[i].se) k++;
    }
    chmin(cntmax, N-1-k+1);
  }
  cout<< cntmax << endl;
  return 0;
}


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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n,k;
  cin >> n >> k;
  vector<ll> neg, pos;
  ll cntzero = 0;
  rep(i,n) {
    ll a;
    cin >> a;
    if (a > 0) pos.emplace_back(a);
    else if (a < 0) neg.emplace_back(a);
    else cntzero++;
  }
  ll cntneg = neg.size();
  ll num_neg = cntneg*(n-(cntneg+cntzero));
  ll num_zero = cntzero*(n-cntzero) + cntzero*(cntzero-1)/2;
  
  if (k > num_neg && k <= num_neg+num_zero) {
    cout << 0 << endl;
    return 0;
  }
  if (k <= num_neg) {
    sort(all(neg));

    auto f = [&](ll x) {
      ll cnt = 0;
      rep(i,(int)pos.size()) { //負正
        ll d = (x-pos[i]+1)/pos[i]; //切り上げ
        cnt += lower_bound(all(neg),d+1) - neg.begin();
      }
      return cnt >= k;
    };
    
    ll ng = -1e18, ok = 0;
    while (ok - ng > 1) {
      ll mid = (ok+ng)/2;
      if (f(mid)) ok = mid;
      else ng = mid;
    }
    cout << ok << endl;
  }
  else {
    k -= num_neg + num_zero;
    sort(all(pos));
    rep(i,(int)neg.size()) {
      neg[i] *= -1;
    }
    sort(all(neg));

    auto g = [&](ll x) {
      ll cnt = 0;
      rep(i,(int)pos.size()) { //正正
        ll d = x/pos[i];
        int itr = lower_bound(all(pos),d+1) - pos.begin();
        if (i < itr) itr--; //自身を除く
        cnt += itr;
      }
      rep(i,(int)neg.size()) { //負負
        ll d = x/neg[i];
        int itr = lower_bound(all(neg),d+1) - neg.begin();
        if (i < itr) itr--; //自身を除く
        cnt += itr;
      }
      cnt /= 2; //重複分
      return cnt >= k;
    };

    ll ng = -1, ok = 1e18;
    while (ok - ng > 1) {
      ll mid = (ok + ng) / 2;
      if (g(mid)) ok = mid;
      else ng = mid;
    }
    cout << ok << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < S.length(); i++){
        if (S[i] != T[i])
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int da[]=new int[6];
        int db[]=new int[6];
        for(int i=0;i<6;i++){
            da[i]=scan.nextInt();
        }
        for(int i=0;i<6;i++){
            db[i]=scan.nextInt();
        }
        Dice diceA =new Dice(da[0],da[1],da[2],da[3],da[4],da[5]);
        Dice diceB =new Dice(db[0],db[1],db[2],db[3],db[4],db[5]);

        while(true){
            if(diceA.check(diceB)) break;
            diceB.turnN();
            if(diceA.check(diceB)) break;
            diceB.turnN();
            if(diceA.check(diceB)) break;
            diceB.turnN();
            if(diceA.check(diceB)) break;
            diceB.turnW();
            if(diceA.check(diceB)) break;
            diceB.turnE();  diceB.turnE();
            if(diceA.check(diceB)) break;
            System.out.println("No");
            System.exit(0);
        }
        System.out.println("Yes");
    }
}

class Dice{
    int top,bottom,left,right,front,back;

    Dice(int a, int b,int c,int d,int e,int f){
        top=a;
        front=b;
        right=c;
        left=d;
        back=e;
        bottom=f;
    }

    boolean check(Dice e){
        Dice tmp = e;
        if(this.top == tmp.top){
            if(this.bottom == tmp.bottom){
                for(int i = 0; i < 4; i++){
                    if(this.checkSide(tmp)) return true;
                    tmp.turnR();
                }
            }
        }
        return false;
    }

    boolean checkSide(Dice e){
       return (this.front==e.front && this.back==e.back && this.left==e.left && this.right==e.right);
    }
    void settop(int a){
        if(a==right)turnW();
        else if(a==left)turnE();
        else if(a==back)turnS();
        else if(a==front)turnN();
        else if(a==bottom){
            turnN();
            turnN();
        }
    }
    void setfront(int a){
        if(a==right)turnL();
        else if(a==left)turnR();
        else if(a==back){
            turnL();
            turnL();
        }
    }
    void turnN(){
        int tmp=top;
        top=front;
        front=bottom;
        bottom=back;
        back=tmp;
    }
    void turnS(){
        int tmp=top;
        top=back;
        back=bottom;
        bottom=front;
        front=tmp;
    }
    void turnW(){
        int tmp=top;
        top=right;
        right=bottom;
        bottom=left;
        left=tmp;
    }
    void turnE(){
        int tmp=top;
        top=left;
        left=bottom;
        bottom=right;
        right=tmp;
    }
    void turnL(){
        int tmp=front;
        front=right;
        right=back;
        back=left;
        left=tmp;
    }
    void turnR(){
        int tmp=front;
        front=left;
        left=back;
        back=right;
        right=tmp;
    }
}



Measured memory_bytes: 26448
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

ll Num9(int k){
  ll a=1;
  for(int i=1;i<k;i++){
    a*=10;
  }
  return a-1;
}

ll Ways(int dis,bool first){
  int a=10-abs(dis);
  if(first&&dis>=0)a--;
  return a;
}

ll ans;
void DFS(int k,ll d,ll cnt,bool first){
  if(k<=1){
    if(k==1&&d==0)ans+=cnt*(ll)10;
    if(k==0&&d==0)ans+=cnt;
    return;
  }
  vector<ll> v;
  ll mo=d%10;if(mo<0)mo+=10;
  if(mo==0)v.push_back(0);
  else{v.push_back(10-mo);v.push_back(0-mo);}
  for(int i=0;i<v.size();i++){
    DFS(k-2,(d-v[i]*Num9(k))/10,cnt*Ways(v[i],first),false);
  }
}
int main(){
  ll d;cin>>d;
  ans=0;
  for(int i=1;i<=18;i++){
    DFS(i,d,1,true);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N, K := sc.i(), sc.i()
	A := sc.is(N)
	//score := 1
	//for i := 0; i < K; i++ {
	//	score *= A[i]
	//}
	for i := K; i < N; i++ {
		if A[i-K] < A[i] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

// 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: 5924
import java.io.InputStream;
import java.math.BigInteger;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        List<BigInteger> A = new LinkedList<>();
        for (int i = 0; i < n; i++) A.add(BigInteger.valueOf(input .nextInt()));
        input .close();

        BigInteger lcm = A.stream().parallel()
                .reduce(BigInteger.ONE, (a, b) -> a.divide(a.gcd(b)).multiply(b));

        BigInteger ans = A.stream().parallel()
                .map(lcm::divide)
                .reduce(BigInteger::add)
                .get();

        BigInteger mod = BigInteger.valueOf(1000000007);
        System.out.println(ans.mod(mod));
    }


}


Measured memory_bytes: 194404
/**
 * @author: Mackenzie
**/

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX = 2e5 + 5;
int A[MAX];
int n, k;

int check(int x) {
    int cnt = 0;
    forn(i, n) {
        if(A[i] > x)cnt += A[i] / x;
    }
    return cnt;
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    cin >> n >> k;
    forn(i, n)cin >> A[i];
    int lo = 1, hi = 1e9;
    forn(it, 70) {
        int m = (lo + hi) / 2;
        //cout << m << endl;
        if(check(m) <= k)hi = m;
        else lo = m;
    }
    cout << hi << endl;
    return 0;
}


Measured memory_bytes: 4360