akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
    long long int N,K;
    cin >> N >> K;
    long long int zero=0,ni=0;

    for(int i=1;i<=N;i++){
        if(i%K==K/2){
            ni++;
        }else if(i%K==0){
            zero++;
        }
    }

    if(K==1){
        cout << N*N*N << endl;
    }else if(K%2==0){
        cout << zero*zero*zero + ni*ni*ni << endl;
    }else{
        cout << zero*zero*zero << endl;
    }
    
}

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

if N == 1:
    for i in range(0, 10):
        s = str(i)
        flg = True
        for q in Q:
            if s[q[0]-1] != str(q[1]):
                flg = False
        if flg:
            print(i)
            exit()
else:
    for i in range(10**(N-1), 10**N):
        s = str(i)
        flg = True
        for q in Q:
            if s[q[0]-1] != str(q[1]):
                flg = False
        if flg:
            print(i)
            exit()

print(-1)


Measured memory_bytes: 9164
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    writeln((lread() + lread()) * lread() / 2);
}


Measured memory_bytes: 256
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

R = int(input())
print(2*R*math.pi)




Measured memory_bytes: 9480
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, x, y, z;

    cin >> A >> B;

    x = A+B;
    y = A-B;
    z = A*B;

    if(x>=y && x>=z){
        cout << x << endl;
    }

    else if(y>=x && y>=z){
        cout << y << endl;
    }

    else{
        cout << z << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <string>
using namespace std;
int stateA(deque<string>& a);
int stateB(deque<string>& a);
int stateC(deque<string>& a);
int stateD(deque<string>& a);
int stateE(deque<string>& a);
int stateF(deque<string>& a);
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0){
      break;
    }
    deque<string> hoge;
    for(int i = 0; i < n; ++i){
      string tmp;
      cin >> tmp;
      hoge.push_back(tmp);
    }
    cout << stateA(hoge) << endl;
  }
  return 0;
}
int stateA(deque<string>& a){
  if(a.empty()){
    return 0;
  }
  string cur = a.front(); a.pop_front();
  if(cur == "lu"){
    return stateB(a);
  }
  else if(cur == "ru"){
    return stateC(a);
  }  
  return stateA(a);
}
int stateB(deque<string>& a){
  if(a.empty()){
    return 0;
  }
  string cur = a.front(); a.pop_front();
  if(cur == "ld"){
    return  stateA(a);
  }
  if(cur == "ru"){
    return stateD(a) + 1;
  }
  return stateB(a);
}
int stateC(deque<string>& a){
  if(a.empty()){
    return 0;
  }
  string cur = a.front(); a.pop_front();
  if(cur == "rd"){
    return stateA(a);
  }
  if(cur == "lu"){
    return stateD(a) + 1;
  }
  return stateC(a);
}
int stateD(deque<string>& a){
  if(a.empty()){
    return 0;
  }
  string cur = a.front(); a.pop_front();
  if(cur == "ld"){
    return stateE(a);
  }
  if(cur == "rd"){
    return stateF(a);
  }
  return stateD(a);
}
int stateE(deque<string>& a){
  if(a.empty()){
    return 0;
  }
  string cur = a.front(); a.pop_front();
  if(cur == "rd"){
    return stateA(a) + 1;
  }
  if(cur == "lu"){
    return stateD(a);
  }
  return stateE(a);
}
int stateF(deque<string>& a){
  if(a.empty()){
    return 0;
  }
  string cur = a.front(); a.pop_front();
  if(cur == "ld"){
    return stateA(a) + 1;
  }
  if(cur == "ru"){
    return stateD(a);
  }
  return stateF(a);
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        if (n % 2 == 0)
            System.out.println(n / 2);
        else
            System.out.println(n / 2 + 1);
    }
}


Measured memory_bytes: 21844
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools
import numpy as np

INF = 10 ** 10

N, M, X  = [int(x) for x in stdin.readline().rstrip().split()]
CA = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
CA = np.array(CA)

nums = [False, True]
buy_or_not = list(itertools.product(nums, repeat=N))

ans = INF

for bn in buy_or_not:
    tmp = CA.T
    data = np.where(bn, tmp, 0)
    data_sum = data.sum(axis=1)

    if min(data_sum[1:]) >= X:
        ans = min(ans, data_sum[0]) 

if ans != INF:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 27516
#include <stdio.h>
int main(int argc, const char * argv[]){
    int i, dice[6] = {0}, q, up, front;
    for( i = 0 ; i < 6 ; i++ ) {
        scanf("%d", &dice[i]);
    }
    scanf("%d",&q);
    for( i = 0 ; i < q ; i++) {
        scanf("%d %d",&up,&front);
        if((up == dice[5] && front == dice[4])||(up == dice[4] && front == dice[0])||(up == dice[0] && front == dice[1])||(up == dice[1] && front == dice[5])){
            printf("%d\n",dice[2]);
        }
        else if((up == dice[0] && front == dice[2])||(up == dice[2] && front == dice[5])||(up == dice[5] && front == dice[3])||(up == dice[3] && front == dice[0])){
            printf("%d\n",dice[4]);
        }
        else if((up == dice[5] && front == dice[1])||(up == dice[1] && front == dice[0])||(up == dice[0] && front == dice[4])||(up == dice[4] && front == dice[5])){
            printf("%d\n",dice[3]);
        }
        else if((up == dice[0] && front == dice[3])||(up == dice[3] && front == dice[5])||(up == dice[5] && front == dice[2])||(up == dice[2] && front == dice[0])){
            printf("%d\n",dice[1]);
        }
        else if((up == dice[2] && front == dice[1])||(up == dice[1] && front == dice[3])||(up == dice[3] && front == dice[4])||(up == dice[4] && front == dice[2])){
            printf("%d\n",dice[5]);
        }
        else{
            printf("%d\n",dice[0]);
        }
    }
    return 0;
}


Measured memory_bytes: 2040
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 201000
using namespace std;
int n, D1[N_], D2[N_], MD, C[N_], DD[N_];
long long po[N_], D[N_][3], Mod = 998244353;
vector<int>E[N_];
void DFS(int a, int pp, int *d) {
	for (auto &x : E[a]) {
		if (x == pp)continue;
		d[x] = d[a] + 1;
		DFS(x, a, d);
	}
}
void Add_Edge(int a, int b) {
	E[a].push_back(b);
	E[b].push_back(a);
}
void Del_Edge(int a, int b) {
	int sz = E[a].size();
	for (int i = 0; i < sz; i++) {
		if (E[a][i] == b) {
			swap(E[a][i], E[a][sz - 1]);
			E[a].pop_back();
			return;
		}
	}
}
void Go(int a, int pp) {
	vector<int>T;
	for (auto &x : E[a]) {
		if (x == pp)continue;
		Go(x, a);
		T.push_back(x);
	}
	if (T.empty()) {
		if (DD[a] == MD) {
			D[a][0] = 2, D[a][1] = 1;
		}
		else {
			D[a][0] = 3;
		}
		return;
	}
	D[a][0] = 1, D[a][1] = 0, D[a][2] = 0;
	for (auto &x : T) {
		long long d0 = D[a][0] * D[x][0];
		long long d1 = D[a][0] * D[x][1] + D[a][1] * D[x][0];
		long long d2 = D[a][0] * D[x][2] + D[a][1] * (D[x][1] + D[x][2]) + D[a][2] * (D[x][0] + D[x][1] + D[x][2]);
		D[a][0] = d0 % Mod, D[a][1] = d1 % Mod, D[a][2] = d2 % Mod;
	}
	D[a][0] = (D[a][0] * 3 + D[a][1] * 2 + D[a][2] * 2) % Mod;
}
int main() {
	int i, mid;
	scanf("%d", &n);
	for (i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	D1[1] = 0;
	DFS(1, 0, D1);
	int Mx = -1, a = -1, b = -1;
	for (i = 1; i <= n; i++) {
		if (Mx < D1[i])Mx = D1[i], a = i;
	}
	D1[a] = 0;
	DFS(a, 0, D1);
	Mx = -1;
	for (i = 1; i <= n; i++) {
		if (Mx < D1[i])Mx = D1[i], b = i;
	}
	D2[b] = 0;
	DFS(b, 0, D2);
	if (Mx % 2 == 1) {
		int t1, t2;
		for (i = 1; i <= n; i++) {
			if (D1[i] + D2[i] == Mx) {
				if (D1[i] == Mx / 2) {
					t1 = i;
				}
				if (D2[i] == Mx / 2) {
					t2 = i;
				}
			}
		}
		Del_Edge(t1, t2); Del_Edge(t2, t1);
		n++;
		Add_Edge(t1, n); Add_Edge(t2, n);
		D1[a] = 0, D2[b] = 0;
		DFS(a, 0, D1);
		DFS(b, 0, D2);
		Mx = D1[b];
	}
	MD = 1e9;
	for (i = 1; i <= n; i++) {
		if (max(D1[i], D2[i]) < MD) {
			MD = max(D1[i], D2[i]);
			mid = i;
		}
	}
	DFS(mid, 0, DD);
	po[0] = 1;
	for (i = 1; i <= n; i++)po[i] = po[i - 1] * 3 % Mod;
	long long dd[3] = { 1,0,0 };
	for (auto &x : E[mid]) {
		Go(x, mid);
		long long g = (D[x][0] - D[x][1] - D[x][2] + Mod + Mod) % Mod;
		long long dd0 = dd[0] * g;
		long long dd1 = dd[0] * D[x][1] + dd[1]* g;
		long long dd2 = dd[1] * D[x][1] + dd[2] * g;
		dd[0] = dd0%Mod, dd[1] = dd1 % Mod, dd[2] = dd2 % Mod;
	}
	printf("%lld\n", dd[2]);

}

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


int main(){
    int n;//intは16bit(2^16-1=65535)まで
    long long d;
    cin >> n >> d;
    vector<long long> x(n),y(n);
    int cnt=0;
    for (int i=0;i<n;++i){
        cin >> x[i] >> y[i];
        if (sqrt(x[i]*x[i]+y[i]*y[i])<=d){
            cnt++;
        }
    }
    cout << cnt <<endl;
}

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

int N;
pair<int, int> A[200000];
bool S[200000];

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    int a; cin >> a; A[i] = make_pair(a, i);
  }
  sort(A, A + N);
  for(int i = 0; i < N / 2; ++i) {
    S[A[i].second] = true;
  }
  for(int i = 0; i < N; ++i) {
    cout << (S[i] ?  A[N / 2].first : A[N / 2 - 1].first) << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int A,B,C; cin >> A >> B >> C;
	if(A == B) cout << C << endl;
	else if(B == C) cout << A << endl;
	else cout << B << endl;

	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	}
}


Measured memory_bytes: 21716
mod = 10**9+7
n,a,b = [int(i) for i in input().split()]
k = min(n,2*(10**5))
import sys
sys.setrecursionlimit(100000000)
def pow_k(a,n,mod):
    if n == 0:
        return 1
    if n % 2 ==0:
        return pow_k(a*a % mod,n//2,mod)
    else:
        return a * pow_k(a,n-1,mod) % mod
def modinv(a, mod):
    return pow(a, mod-2, mod)
def combination_list(n, mod):
    lst = [1]
    for i in range(1, k+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst
ans = pow_k(2,n,mod)
cmb = combination_list(n,mod)
ans -=1
ans -= cmb[a]
if ans < 0:
    ans += mod
ans -= cmb[b]
if ans <0:
    ans += mod
print(ans)

Measured memory_bytes: 11128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;


struct Toshi {
    string name;
    int value;
    int index;
};

bool pairToshi(const Toshi& firstElof, const Toshi& secondElof)
{
    return firstElof.name < secondElof.name;
}

typedef pair<int, int> Pr;

int main() {
    int N; cin >> N;
    vector<Toshi> R(N);

    string toshi;
    int value;

    for(int i=0; i<N; i++) {
        cin >> toshi >> value;
        struct Toshi t;
        t.name = toshi;
        t.index = i+1;
        t.value = value;
        R[i] = t;
    }

    sort(R.begin(), R.end(), pairToshi);


    priority_queue<Pr> A;
    string now_toshi = R[0].name;
    for(int i=0; i<N; i++) {
        if(now_toshi != R[i].name) {
            while(A.size() > 0) {
                cout << A.top().second << endl;
                A.pop();
            }
        }
        A.push(make_pair(R[i].value, R[i].index));
        now_toshi = R[i].name;
    }

    while(A.size() > 0) {
        cout << A.top().second << endl;
        A.pop();
    }

    return 0;
}



Measured memory_bytes: 256
import heapq

def main():
    n = int(input())
    vList = list(map(int, input().split()))
    vDict1 = {}
    vDict2 = {}
    for i in range(len(vList)):
        if i%2 == 0:
            vDict1[vList[i]] = vDict1.get(vList[i], 0) + 1
        else:
            vDict2[vList[i]] = vDict2.get(vList[i], 0) + 1
    v1List = list(vDict1.items())
    v2List = list(vDict2.items())
    if len(vDict1) == 1 and len(vDict2) == 1:
        if v1List[0][0] == v2List[0][0]:
            print(n//2)
        else:
            print(0)
        return
    if len(v1List) == 1:
        v1Max= heapq.nlargest(1, v1List, key=lambda v1: v1[1])
    else:
        v1Max, v1snd = heapq.nlargest(2, v1List, key=lambda v1: v1[1])
    if len(v2List) == 1:
        v2Max = heapq.nlargest(1, v2List, key=lambda v2: v2[1])
    else:
        v2Max, v2snd = heapq.nlargest(2, v2List, key=lambda v2: v2[1])
    if len(vDict1) == 1:
        if v2Max[0] == v1Max[0]:
            print(n//2-v2snd[1])
        else:
            print(n//2-v2Max[1])  
        return   
    if len(vDict2) == 1:
        if v1Max[0] == v2Max[0]:
            print(n//2-v1snd[1])
        else:
            print(n//2-v1Max[1]) 
        return
    if v1Max[0] == v2Max[0]:
        if v1snd[1] <= v2snd[1]:
            print(n-v1Max[1]-v2snd[1])
        else:
            print(n-v1snd[1]-v2Max[1])
        return
    print(n-v1Max[1]-v2Max[1])

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 20508
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        string T = cin.next();
        char[] cs = S.ToCharArray();
        Array.Sort(cs);
        S = new string(cs);
        char[] ct = T.ToCharArray();
        Array.Sort(ct);
        Array.Reverse(ct);
        T = new string(ct);
        if (S.CompareTo(T) < 0) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
    
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13408
#include<stdio.h>
long long d[234567], c[234567];
int main(int argc, char const *argv[]) {
  int M;
  scanf("%d", &M);
  for (int i = 0; i < M; i++) scanf("%lld %lld", d+i, c+i);
  long long len = 0; // number of digits
  long long sum = 0; // sum of digits
  for (int i = 0; i < M; i++) {
    len += c[i];
    sum += d[i] * c[i];
  }
  long long reduce = (sum-1) / 9;
  printf("%lld\n", reduce + len - 1);
  return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t root(vector<int64_t>& g, int64_t v) {
    if (g[v] != v) {
        g[v] = root(g, g[v]);
    }

    return g[v];
}

void merge(vector<int64_t>& g, int64_t v, int64_t u) {
    g[root(g, v)] = root(g, u);
}

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> g(n);
    iota(g.begin(), g.end(), 0L);

    auto b = a;
    for (auto _ : irange(0L, m)) {
        int64_t x, y;
        cin >> x >> y;

        int64_t tmp = min(b[root(g, x)], b[root(g, y)]);
        merge(g, x, y);
        b[root(g, x)] = tmp;
    }

    int64_t c = n - m;
    if (n < 2 * (c - 1)) {
        cout << "Impossible" << endl;
        return 0;
    }

    if (c == 1) {
        cout << 0 << endl;
        return 0;
    }

    int64_t ans = 0;
    vector<int64_t> r;
    for (auto i : irange(0L, n)) {
        if (b[root(g, i)] == a[i]) {
            b[root(g, i)] = 1L << 40;
            ans += a[i];
        } else {
            r.push_back(a[i]);
        }
    }

    sort(r.begin(), r.end());
    for (auto i : irange(0L, 2 * (c - 1) - c)) {
        ans += r[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		
		int even = K / 2;
		int odd = (K+1) / 2;
		
		System.out.println(even * odd);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n,x,s=0;
	scanf("%d",&n);
	for(i=1; i<=n; i++)
	{
		if(i%2==0) continue;
		x=0;
		for(j=1; j<=n; j++)
			if(i%j==0) x++;
		if(x==8) s++;
	}
	printf("%d",s);


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,k,t,r,ny,nx,x[100],y[100];
  int X[]={0,1,0,-1,0,2,0,-2,0,3,0,-3};
  int Y[]={1,0,-1,0,2,0,-2,0,3,0,-3,0};
  char xx,yy,m[15][15]={0};
  scanf("%d",&n);//printf("%d\n",n);
  for(i=0;i<n;i++){
    for(j=t=0;j<8;j++)scanf(" %s",m[j+3]+3);
    //for(j=0;j<8;j++)printf("%s\n",m[j+3]+3);printf("b");
    scanf(" %c %c",&xx,&yy);//printf("a\n");
    x[0]=xx-'0'+2;
    y[0]=yy-'0'+2;
    m[y[0]][x[0]]='0';//printf("%d %d\n",y[0],x[0]);
    for(r=1;r-t;t++){
      for(k=0;k<12;k++){
	ny=y[t]+Y[k];
	nx=x[t]+X[k];
	if(m[ny][nx]=='1'){
	  m[ny][nx]='0';
	  y[r  ]=ny;
	  x[r++]=nx;
	}
      }
    }
    printf("Data %d:\n",i+1);
    for(j=0;j<8;j++)printf("%s\n",m[j+3]+3);
  }
  return 0;
}

      

Measured memory_bytes: 608
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

pairToList :: (a, a) -> [a]
pairToList (x,y) = [x,y]

main = do
  [n, m, x] <- getIntList
  bs <- getIntList
  print $ minimum(map length (pairToList (span (<x) bs)))

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

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

    vector<ll> S(N+1);
    S[0] = 0;
    for (int i = 0; i < N; i++) {
        S[i+1] = S[i] + A[i];
    }
    map<ll,ll> B;
    for (int i = 0; i < N+1; i++) {
        if(B.count(S[i])){
            B[S[i]]++;
        }
        else{
            B[S[i]] = 1;
        }
    }
    ll ans = 0;
    for (int i = 0; i < N+1; i++) {
        ans += B[S[i]] * (B[S[i]] - 1) / 2;
        B[S[i]] = 0;
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 18656
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	runes := []rune(s)

	for i := 0; i < 3; i++ {
		if strings.Count(s, string(runes[i])) != 2 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> Good(M, 0);
    for(int i = 0; i < N; i++){
        int K;
        cin >> K;
        vector<int> A(K);
        for(int j = 0; j < K; j++) cin >> A[j];
        for(int j = 0; j < K; j++) Good[A[j] - 1]++;
    }
    int count = 0;
//    for(int x : Good) cout << x << endl;
    for(int x : Good) if(x == N) count++;
    cout << count << endl;
}


Measured memory_bytes: 3540
num = list(map(int, input().split(' ')))
mylist = [1, 3, 5, 7, 8, 10, 12]
ans = 0
for i in num:
    if i in mylist:
        ans += 1
    elif i == 2:
        ans += 3

if ans == 0 or ans == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    vll H(N);
    REP(i, N) cin >> H[i];

    vll m[N];

    REP(i, M) {
        int a, b; cin >> a >> b;
        a--; b--;

        m[a].pb(b);
        m[b].pb(a);
    }

    int ans = 0;
    REP(i, N) {
        bool f = true;
        for(auto e: m[i]) {
            if (H[i] <= H[e]) f = false;
        }

        if (f) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 9800
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> cand1(n);
    vector<int> cand2(n);
    for(int i = 0; i < n; i++){
        cin >> cand1[i];
    }
    for(int i = 0; i < n; i++){
        cin >> cand2[i];
    }

    int maxcount = 0;
    for(int i = 0; i < n; i++){
        bool flag = true;
        int counter = 0;
        for(int j = 0; j < n; j++){
            if(flag){
                counter += cand1[j];
                if(j == i){
                    counter += cand2[j];
                    flag = false;
                }
            } else {
                counter += cand2[j];
            }
        }
        maxcount = max(maxcount, counter);
    }
    cout << maxcount << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
	private static final String CRLF = System.lineSeparator();
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(br.readLine());
        int[] A = new int[N];
        StringBuilder sb = new StringBuilder();
        int i=0;
        for(String s: br.readLine().split(" ")){
        	A[i++] = Integer.parseInt(s);
        }
        intArrayToString(A,sb);
        for(i=1; i<N; i++){
        	int v = A[i];
        	int j = i-1;
        	while(j>=0 && A[j]>v) {
        		A[j+1] = A[j];
        		j--;
        	}
        	A[j+1] = v;
            intArrayToString(A,sb);	
        }
        out.print(sb.toString());
        out.flush();
    }
	private void intArrayToString(int[] a, StringBuilder sb) {
		for(int i=0; i<a.length; i++) {
			if (i>0)
				sb.append(" ");
			sb.append(a[i]);
		}
        sb.append(CRLF);
	}
	
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

Measured memory_bytes: 25860
from heapq import heappush, heappop

N = int(input())
a = [int(x) for x in input().split()]

left = sorted(a[:N])
max_left = [sum(left)]

right = sorted([-x for x in a[-N:]])
min_right = [sum(right) * -1]

for i in range(N, 2 * N):
    j = 3 * N - i - 1

    heappush(left, a[i])
    v = heappop(left)
    max_left.append(max_left[-1] - v + a[i])

    heappush(right, a[j] * -1)
    v = heappop(right) * -1
    min_right.append(min_right[-1] - v + a[j])

ans = float('-inf')
for l, r in zip(max_left, min_right[::-1]):
    ans = max(l - r, ans)
print(ans)


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

using namespace std;
#define PI 3.14159265358979

const long double eps = 1.0e-18;

long double mysqrtl(long double x)
{
  long double a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}

long double COS(long double x){
long double t;
long double y;
int n;

y = 1.0;
t = 1.0;
n = 1;

while( 1 ){
t = -t*x*x/((2*n)*(2*n-1));
if(fabs(t)<=0.000000001) break;
y = y + t;
n++;
}
return y;
}

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double complex = cosl(((h * 60.000000000000 - 11.000000000000 * m) / 360.000000000000) * PI);
  long double ans2 = (a * a) + (b * b) - 2.000000000000 * (a * b) * complex;
  long double ans = sqrt(ans2);
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){

    string x,y,z;           cin>>x>>y>>z;
    ll i=0,j=0,k=0,sz1=x.size(),sz2=y.size(),sz3=z.size();
    char c='a';
    while(1){
        if(c=='a'){
            if(i>=sz1)      return cout<<"A",0;
            c=x[i++];
        }
        if(c=='b'){
            if(j>=sz2)      return cout<<"B",0;
            c=y[j++];
        }
        if(c=='c'){
            if(k>=sz3)      return cout<<"C",0;
            c=z[k++];
        }
    }

    return 0;
}

Measured memory_bytes: 256
<?php
$input = trim(fgets(STDIN));
$len = strlen($input);

for ($i = 0; $i < $len; $i++) {
  $currentChar = $input[$i];
  if ($i % 2 === 0 && $currentChar === 'L' ||
      $i % 2 === 1 && $currentChar === 'R'
     ) {
    echo 'No';
    return;
  }
}

echo 'Yes';

Measured memory_bytes: 4728
import java.util.Scanner;

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

	public static void solve(Scanner s) {
		char[] sa = s.next().toCharArray();
		char[] sb = s.next().toCharArray();
		char[] sc = s.next().toCharArray();

		char next = 'a';
		int ia = 0;
		int ib = 0;
		int ic = 0;

		while (true) {

			switch (next) {
			case 'a':
				if (ia < sa.length) {
					next = sa[ia];
				}
				ia++;
				break;
			case 'b':
				if (ib < sb.length) {
					next = sb[ib];
				}
				ib++;
				break;
			case 'c':
				if (ic < sc.length) {
					next = sc[ic];
				}
				ic++;
				break;
			}

			if (ia == sa.length + 1) {
				System.out.println("A");
				break;
			} else if (ib == sb.length + 1) {
				System.out.println("B");
				break;
			} else if (ic == sc.length + 1) {
				System.out.println("C");
				break;
			}
		}
	}
}

Measured memory_bytes: 9812
#include <stdio.h>

int main(void){
	int H, W;
	int m, n;

	do{
	scanf("%d%d", &H, &W);
	if(H == 0 && W == 0) break;
	for(m = 0; m < H; m++){
		for(n = 0; n < W; n++){
			printf("#");
		}

		printf("\n");
	}
	printf("\n");
	} while (H != 0 || W != 0);

	return 0;
}

Measured memory_bytes: 1800
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S;
int main() {
	cin>>S;

	for(int i=0;i<S.size();i++){
		if(i%2==0)cout<<S[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  int ans;
  cin >> A >> B;
  for(int i = 1; i < 4; i++){
    if(A != i && B != i){
      ans = i;
    }
  }
  cout << ans << endl;
  }
    

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> height(N);
    vector<ll> good(N,1);
    rep(i,N){
        cin>>height[i];
    }
    int a,b;
    rep(i,M){
       cin>>a>>b; 
       if(height[a-1]<=height[b-1]){
           good[a-1]=0;
       }
       if(height[b-1]<=height[a-1]){
           good[b-1]=0;
       }   
       
    }
    int ans=0;
    rep(i,N){
        ans+=good[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4816
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=1e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,f[N],g,a[N],ans;
vvi S;
vvi prime_vector_sieve(){
  vvi prime(N);
  for(int i = 2;i < N; ++i)if(prime[i].empty())
        for(int j = i; j < N; j += i){
            prime[j].push_back(i); 
        }
  return prime;
}
void solve(){
  cin>>n;
  rep(i,1,n)cin>>a[i];g=a[1];
  rep(i,1,n){
    g=__gcd(g,a[i]);
    // rep(j,2,sqrt(a[i])){
    //   if((a[i]%j)==0){
    //     f[j]++;
    //     if(j!=(a[i]/j))f[a[i]/j]++;
    //   }
    //   f[a[i]]++;
    // }
    for(auto j:S[a[i]])f[j]++;
  }
  rep(i,1,N-1)if(f[i]>1)ans=1;
  if(ans==0){cout<<"pairwise coprime";return;}
  if(g==1){cout<<"setwise coprime";return;}
  cout<<"not coprime";return;
}
int32_t main()
{
  ibs;cti;
  S=prime_vector_sieve();
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

long long int mmc(int a, int b) {
  std::vector<long> v;
  int tmp = 2, tmp1;
  while(a>1 || b>1) {
    tmp1 = tmp;
    if(a % tmp == 0 || b % tmp == 0) {
      v.push_back(tmp);
      tmp = 2;
    } else ++tmp; 
    if(a % tmp1 == 0) a /= tmp1;
    if(b % tmp1 == 0) b /= tmp1;
  }
  long long int result = 1;
  for(auto it: v) {
    result *= it; 
  }
  return result;
}

int main() {
  int a, b;
  long long int c;
  std::cin >> a >> b;
  c = mmc(a, b);
  std::cout << c; 
  return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n, sum = 0;
    cin >> h >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a.at(i);
        sum += a.at(i);
    }
    if (h > sum)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
string S;
int  K;
cin >> S;
cin >> K;
vector<string> sub;
for(int i = 0;i<S.size();i++){
	for(int j = 1; j<=5;j++){
		sub.push_back(S.substr(i,j));
	}
}

set<string> st;
for(int i = 0; i< sub.size();i++){
st.insert(sub[i]);
}
auto itr  = st.begin();
for(int i = 0;i<K-1;i++){
	itr++;
}
cout << *itr << endl;
}

Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	ll n, d;
	cin >> n >> d;

	ll ans = 0;
	for (ll i=0; i<n; i++)
	{
		ll a, b; cin >> a >> b;
		if (a*a+b*b <= d*d)
			ans++;
	}
	cout<<ans<<"\n";

	return 0;
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    ini(n);
    vi tmp;
    multiset<int> morty;
    int rick  = 0 ;
    FOR(i,0,31){
        int x = pow(2,i);
        tmp.push_back(x);
    }
    FOR(i,0,n){
        ini(x);
        morty.insert(x);
    }
    while(morty.size()!=0){
        int x1 = *morty.rbegin();
        morty.erase(prev(morty.end()));
        int tmp1 = *upper_bound(all(tmp),x1)-x1;
        if(morty.find(tmp1)!=morty.end()){
            rick++;
            morty.erase(morty.find(tmp1));
        }

    }
    out(rick);
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 9600
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define Temp template<typename T>
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
Temp inline void chkmin(T &x,T y){if(y<x)x=y;}
Temp inline void chkmax(T &x,T y){if(y>x)x=y;}
Temp inline void read(T &x){
	x=0;T w=1,ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
	x=x*w;
}
const int maxn=100+10;
char a[2][3];
int main(){
	for(Rint i=0;i<2;i++){
		for(Rint j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	for(Rint i=0;i<2;i++){
		for(Rint j=0;j<3;j++){
			if(a[i][j]!=a[1-i][2-j]){
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

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

def gcd(a, b):
    if a < b:
        b, a = a, b
    if b == 0:
        return a
        
    while a % b != 0:
        a %= b
        a, b = b, a

    return b

L = [0] * (N+1)
R = [0] * (N+2)

for i in range(1, N+1):
    ind = N+1-i
    L[i] = gcd(L[i-1], A[i-1])
    R[ind] = gcd(R[ind+1], A[ind])

ret = []
for i in range(1, N+1):
    ret.append(gcd(L[i], R[i+1]))

print(max(ret))


Measured memory_bytes: 67564
#include <iostream>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define moda 998244353
#define pi 3.14159265358979323846
#define io ios::sync_with_stdio(0); cin.tie(0);
#define debug cout<<"f\n";
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(), x.rend()

int main()
{

int n;
cin>>n;
int act[3][n];

for(int i = 0 ; i < n ; i++)
{
    for(int j = 0 ; j < 3 ; j++)
    {
        cin>>act[j][i];
    }
}

int dp[3][n];

for(int i = 0 ; i < n ; i++)
{
    for(int j = 0 ; j < 3 ; j++)
    {
        dp[j][i] = 0;
    }
}

for(int i = 0 ; i < n ; i++)
{
    for(int j = 0 ; j < 3 ; j++)
    {
        if(i == 0)dp[j][i] = act[j][i];
        else
        {
            if(j == 0)dp[j][i] = act[j][i] + max(dp[1][i - 1], dp[2][i - 1]);
            else if(j == 1)dp[j][i] = act[j][i] + max(dp[0][i - 1], dp[2][i - 1]);
            else dp[j][i] = act[j][i] + max(dp[0][i - 1], dp[1][i - 1]);
        }
    }
}

cout<<max(max(dp[0][n - 1], dp[1][n - 1]), dp[2][n - 1]);

return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn= new Scanner(System.in);
        int x = stdIn.nextInt();
        long a=0;
        for(int i=1;i<=x;i++){
            if(i%3==0||i%5==0)continue;
            a=a+i;
        }
        System.out.println(a);
    }
}


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

int main(){

	double r, shu, men;
	cin >> r;
	shu = 2 * r * 3.14159265358979323846264338327950288419716939937510;
	men = r * r * 3.14159265358979323846264338327950288419716939937510;
	cout << fixed << men << " " << fixed << shu << endl;
	
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    cin >> A;
    vector<pair<int, int>> leftMin(N), rightMax(N);
    multiset<int> ans;
    int temp = inf;
    for (int i = 0; i < N; i++) {
        temp = min(temp, A[i]);
        leftMin[i].first = temp;
        if (temp == A[i]) leftMin[i].second = i;
        else leftMin[i].second = leftMin[i - 1].second;
    }
    temp = 0;
    for (int i = N - 1; i >= 0; i--) {
        temp = max(temp, A[i]);
        rightMax[i].first = temp;
        if (temp == A[i]) rightMax[i].second = i;
        else rightMax[i].second = rightMax[i + 1].second;
    }
    for (int i = 0; i < N - 1; i++) {
        int profit = (T / 2) * rightMax[i + 1].first - (T / 2) * leftMin[i].first;
        if (i >= 1) if (leftMin[i].first == leftMin[i - 1].first) continue;
        // cout << profit << endl;
        ans.insert(profit);
    }
    auto itr = ans.end();
    --itr;
    cout << ans.count(*itr) << endl;

}


Measured memory_bytes: 6528
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let d: i64 = sc.read();
    let xy = sc.read_pairs::<i64>(n);

    let mut ans = 0usize;
    for (x, y) in xy.into_iter() {
        if x * x + y * y <= d * d {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 3988
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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; }

using ll = long long;

std::string N;

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

  rep( i, N.size() )
  {
    if( N[i] == '7' )
    {
      std::cout << "Yes" << std::endl;

      return 0;
    }
  }

  std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 3040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int M = scanner.nextInt();
        int D = scanner.nextInt();
        if(D < 22){
            System.out.println(0);
        } else {
            int count = 0;
            for(int i = 22; i <= D; i++){
                int d1 = i % 10;
                int d2 = i / 10;
                if(d1 >= 2 && d1 * d2 <= M){
                    count++;
                }
            }
            System.out.println(count);

        }

    }
}


Measured memory_bytes: 25044