akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

class Main{
	public static void main(String[] args) throws Exception{
		MyScanner scan = new MyScanner(System.in);
		int v = scan.nextInt();
		int e = scan.nextInt();
		Group[] groups = new Group[v];
		for(int i = 0; i < v; i++) groups[i] = new Group();
		List<Branch> branches = new ArrayList<>(e);
		for(int i = 0; i < e; i++) {
			branches.add(new Branch(
				scan.nextInt(),
				scan.nextInt(),
				scan.nextInt()
			));
		}
		Collections.sort(branches);
		int result = 0;
		for(Branch _b : branches) {
			Group g1 = groups[_b.s].getGroup();
			Group g2 = groups[_b.t].getGroup();
			if(g1==g2) continue;
			Group newg = new Group();
			g1.parent = newg;
			g2.parent = newg;
			result += _b.v;
		}
		System.out.println(result);
	}
}

class Group{
	Group parent;
	Group(){
	}
	Group getGroup() {
		return (parent==null)?this:parent.getGroup();
	}
}

class Branch implements Comparable<Branch>{
	int s,t;
	int v;
	Branch(int _s, int _t, int _v) {
		s = _s;
		t = _t;
		v = _v;
	}
	@Override
	public int compareTo(Branch _b) {
		return this.v - _b.v;
	}
}

class MyScanner{
	InputStream in;
	MyScanner(InputStream _in) {
		in = _in;
	}
	int nextInt() {
		int result = 0;
try{
		int _i = in.read();
		while(_i<'0'||_i>'9') {
			_i = in.read();
		}
		while(_i>='0'&&_i<='9') {
			result *= 10;
			result += (int)(_i-'0');
			_i = in.read();
		}
		return result;
}catch(Exception e) {
	e.printStackTrace();
	return 0;
}
	}
}

Measured memory_bytes: 33384
#include <stdio.h>

int prime(int);

int main(){
  
  int n,i,j,count = 0,F = 0;
  scanf("%d",&n);
  
  int data[n];
  
  for(i = 0;i < n;i++){
    scanf("%d",&data[i]);
  }
  
  for(i = 0;i < n;i++){
    if(prime(data[i]) == 1)count++;
  }
  
  printf("%d\n",count);
  return 0;
}

int prime(int a){
  int j;
  if(a < 2) return 0;
  
  else if(a == 2)  return 1;
  
  if(a % 2 == 0)  return 0;
  
  for(j = 3;j <= a / j;j += 2)
    if(a % j == 0)   return 0;
  
  return 1;
}

Measured memory_bytes: 628
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
cnt = Counter()
for i in range(n):
    cnt[a[i]] += 1

for a in cnt:
    cnt[a] %= 2
z_o = cnt.values()

if list(z_o).count(0) % 2 == 0:
    print(len(cnt))
else:
    print(len(cnt) - 1)


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

using namespace std;

int n, k;
vector<int> w(100010);

bool isLoad(int x) {
  int i = 0;
  for (int j = 0; j < k; ++j) {
    int S = 0;
    while (S + w[i] <= x) {
      S += w[i];
      ++i;
      if (i == n) return true;
    }
  }
  return false;
}

void solve() {
  int ok = int(1e9);
  int ng = 0;
  while (abs(ok - ng) > 1) {
    int mid = ng + (ok - ng) / 2;
    if (isLoad(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << "\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> w[i];
  solve();
  return 0;
}



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

public class Main {
  private static int solve(int w, int a, int b) {
    if (a + w < b) {
      return b - a - w;
    } else if (b + w < a) {
      return a - b - w;
    } else {
      return 0;
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int w = reader.nextInt();
    int a = reader.nextInt();
    int b = reader.nextInt();
    out.println(solve(w, a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
ll N, M, Q;
vector<ll> A(Q);
vector<ll> B(Q);
vector<ll> C(Q);
vector<ll> D(Q);
ll Max=0;
void Calc(vector<ll> X){
    if(X.size()==N){
        ll Score=0;
        rep(i, Q){
            if(X[B[i]]-X[A[i]]==C[i])Score+=D[i];
        }
        Max=max(Max, Score);
    }
    else{
        ll Sz=X.size();
        ll Now=X[Sz-1];
        for(ll i=Now; i<=M; i++){
            vector<ll> Z(Sz+1);
            rep(j, Sz)Z[j]=X[j];
            Z[Sz]=i;
            Calc(Z);
        }
    }
    return;
}

int main(){
    cin>>N>>M>>Q;
  	A.resize(Q);
  	B.resize(Q);
  	C.resize(Q);
  	D.resize(Q);
    rep(i, Q){
        cin>>A[i]>>B[i]>>C[i]>>D[i];
        A[i]--; B[i]--;
    }
    rep(i, M){
        vector<ll> G={i+1};
        Calc(G);
    }
    cout<<Max<<endl;

}

Measured memory_bytes: 3632
#![allow(non_snake_case, unused_imports)]

// Input
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $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") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [u64 ;N]
    }
    let mut ans = vec![0;0];
    let n = N/2;
    if N%2==0{
        for i in 0..n{
            ans.push(A[N-1-2*i]);
        }
        for i in 0..n{
            ans.push(A[i*2]);
        }
    }else{
        for i in 0..n+1{
            ans.push(A[N-1-i*2]);
        }
        for i in 0..n{
            ans.push(A[i*2+1]);
        }
    }
    println!("{}", ans.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
}

Measured memory_bytes: 20604
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto M = readln.chomp.to!int;
    long b = 0, res;
    foreach (_; 0..M) {
        auto dc = readln.split.to!(long[]);
        int d = dc[0].to!int;
        auto c = dc[1];
        int[] at;
        while (c != 1) {
            if (c%2 == 1) at ~= d;
            c /= 2;
            res += c;
            d *= 2;
            if (d >= 10) {
                res += c;
                d = d/10 + d%10;
            }
        }
        while (!at.empty) {
            res += 1;
            d = d + at[0];
            at = at[1..$];
            if (d >= 10) {
                res += 1;
                d = d/10 + d%10;
            }
        }
        if (b == 0) {
            b = d;
        } else {
            res += 1;
            b += d;
            if (b >= 10) {
                res += 1;
                b = b/10 + b%10;
            }
        }
    }
    writeln(res);
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    union_find(int size) : data(size, -1) { }
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
signed main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> l(m);
    REP(i,n) {
        int k;
        cin>>k;
        REP(j,k) {
            int x;
            cin>>x;
            l[x-1].push_back(i);
        }
    }
    union_find uf(n);
    REP(i,m) {
        REPF(j,1,SZ(l[i])) {
            uf.unite(l[i][j-1],l[i][j]);
        }
    }
    cout<<(uf.size(0)==n?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define INF 2000000000
#define MOD 1000000007

intt gcd(intt x, intt y) {
    if (x%y == 0) return y;
    return gcd(y, x%y);
}

intt lcm(intt x, intt y) {
    return x/gcd(x, y)*y;
}

int main() {
    int n;
    scanf("%d", &n);
    intt ans = 1;
    rep(i,n) {
        intt c;
        scanf("%lld", &c);
        ans = lcm(ans, c);
    }
    printf("%lld\n", ans);
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

string S;

int main()
{
    cin >> S;
    REP(i, S.length()){
        if(i == 3) { printf("8"); }
        else { printf("%c", S[i]); }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

const int num = pow(10, 9) + 7;

int main(){
    int N;
    cin >> N;
    map<char, int> mp;
    string S;
    cin >> S;
    rep(i, N){
        mp[S[i]]++;
    }
    ll ans = 1;
    for(auto p : mp){
        ans = (ans * (p.second + 1)) % num;
    }
    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key )
      x = x->left;
    else
      x = x->right;
  }

  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key )
      y->left = z;
    else
      y->right = z;
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 18800
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string S;
  cin>>S;
  if(S=="Sunny")cout<<"Cloudy"<<endl;
  if(S=="Cloudy")cout<<"Rainy"<<endl;
  if(S=="Rainy")cout<<"Sunny"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,i,right,left,parent;
  int heap[251];

  scanf("%d",&n);
  for( i = 1 ; i < n + 1 ; i++ ){
    scanf("%d",&heap[i]);
  }


  for( i = 1 ; i < n + 1 ; i++ ){
    parent = i/2;
    left = i*2;
    right = (2*i)+1;

    printf("node %d: key = %d, ",i,heap[i]);
    if( i != 0 && i != 1 ) printf("parent key = %d, ",heap[parent]);
    if( left < n + 1 ) printf("left key = %d, ",heap[left]);
    if( right < n + 1 ) printf("right key = %d, ",heap[right]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
package main

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

func loadints(n int) []int {
	xs := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		xs[i], _ = strconv.Atoi(sc.Text())
	}
	return xs
}

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	a := loadints(n)
	sort.Ints(a)
	result := 0
	for i := 0; i < n; i++ {
		if (x >= a[i] && i < n-1) || (x == a[i]) {
			x -= a[i]
			result++
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int n,a,b,c,d,x,y;
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	if(n%a==0){
		x=n/a*b;
	}else{
		x=(n/a+1)*b;
	}
	if(n%c==0){
		y=n/c*d;
	}else{
		y=(n/c+1)*d;
	}
	if(x<y){
		printf("%d\n",x);
	}else{
		printf("%d\n",y);
	}
	return 0;
}



Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
int main()
{long long a=0,b=0;
    cin>>a>>b;
    if(b%2==0)
    {
        if(((b/2)-a)>=0)
        {
            if((2*a)-(b/2)>=0)
            {
                cout<<"Yes";
            }
            else
            cout<<"No";
        }
        else
        cout<<"No";
    }
    else
    cout<<"No";
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
int main(){
	string s;
	int ans=0;
	cin>>s;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int flg,a[1000],b[1000],c[1000],d[1000],A,B,C,D,n,i,x[1000];
	while(1){
		flg=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){	
			scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
			x[i]=4*b[i]+9*c[i]+4*d[i];
//			printf("%d\n",x[i]);
			}
		scanf("%d %d %d %d",&A,&B,&C,&D);
		for(i=0;i<n;i++){
			if(x[i]<=D&&b[i]<=A&&c[i]<=B&&d[i]<=C){
				flg=1;
				printf("%d\n",a[i]);
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxN 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
bool visited[105];
double solve(double a,double tax){
    int start=0;
    int end=100;
    int ans=0-1;
    while(start<end && start!=end){
        double  mid=start+end;
        mid=ceil(mid/2);
        debug3(start,mid,floor(mid*tax));
        if(floor(mid*tax)==a){
            ans=mid;
            return ans;
        }
        else if(floor(mid*tax)>a) end=mid-1;
        else start=mid+1;
    }
    return ans;
}

int32_t main()
{
fastio;
int t=1;
//in t;
while(t--){
    double a,b;
    cin>>a>>b;
set<int> first,second;
for(int i=1;i<=maxN;i++){
    //cout<<floor(i*0.1)<<endl;
 if(floor(i*.1)==b){first.insert(i);}
 if(floor(i*.08)==a) second.insert(i);
}
bool found=false;
int ans=INT_MAX;
for(auto itr=first.begin();itr!=first.end();itr++){
    if(second.find(*itr)!=second.end())
        ans=min(ans,*itr),found=true;
}
if(found)
cout<<ans<<endl;
else cout<<-1<<endl;
}
#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
/****** define constant end ********/
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
	if (n & 1)
	  res = res * a % mod;
	a = a * a % mod;
	n >>= 1;
  }
  return res;
}
/****** define variable start ******/
ll x;
/******* define variable end *******/
int solve() {
	cin >> x;
	long double check = (-1 + sqrt(1+8*x)) / 2;
	if(ceil(check) != floor(check)){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
		ll n = (ll)check;
		cout << n+1 << endl;
		vector<vector<ll>> ans(n+1, vector<ll>(n));
		ll num = n+1;
		REP(i, n){
			ans[0][i] = i + 1;
		}
		for(ll i = 1; i < n+1; ++i){
			REP(k, i){
				ans[i][k] = ans[k][i-1];
			}
			ll nokori = n-i;
			for(ll k = i; k < nokori + i; ++k){
				ans[i][k] = num;
				num++;
			}
		}
		REP(i, n+1){
			cout << n << " ";
			REP(j, n){
				cout << ans[i][j] <<" ";
			}
			cout << endl;
		}
	}
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 2944
s=input()
n=len(s)
ok=True
for i in range(int(n//2)):
    if s[i]!=s[n-i-1]:
        ok=False

for i in range(int((n//2)//2)):
    if s[i]!=s[n//2-i-1]:
        ok=False

for i in range(int((n//2)//2)):
    if s[n//2+1+i]!=s[n-i-1]:
        ok=False

if ok:print("Yes")
else:print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs
    int n,l,t;
    cin>>n>>l;
    t=(l+l+n-1)*n/2;
    if(l+n-1<=0) t-=(l+n-1);
    else if(l<=0) t-=0;
    else t-=l;
    cout<<t;
}

Measured memory_bytes: 256
N = input()
USA = 0
n = 0
h = 0
k = 0
for i in range(0,len(N)):
    n += int(N[i])
if n % 9 == 0:
    print("Yes")
else:
    print("No")
    # h += 1
    # n += h
    # # if n == N+1:
    #     if n % 9 == 0:


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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(b, n*a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
    return (a.second > b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}
int main()
{
     fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
       ll c=0,m,i,j,d=0,sum=0,e=0,f=0,g=0,h=0,n,maxi=0;
       cin>>n>>m;
       vector<ll> a(m);
       for(i=0;i<m;i++)
       {
           cin>>a[i];
           sum+=a[i];
       }
       if(sum>n)
       {
           cout<<-1;
       }
       else
        cout<<n-sum;




     }

}



Measured memory_bytes: 3736
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        // 主処理
        int result = Math.max(Math.max(a + b, a - b), a * b);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 25044
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
#define MOD (1e9+7)
typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
std::vector<int> Eratosthenes(const int N)
{
	std::vector<bool> is_prime(N + 1);
	for (int i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<int> P;
	for (int i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}


ll N;
int main()
{
	cin >> N;
	ll cnt = 0;
	vector<ll>p = divisor(N);
	for (ll x : p) {
		if (x == 1)continue;
		ll a = N / x;
		while (a % x == 0) {
			a = a / x;
		}
		if (a % x == 1) {
			
			cnt++;
		}
	}
	vector<ll>q = divisor(ll(N - 1));
	//for (ll y : q)cout << y << endl;
	cout << cnt + q.size()-1 << endl;
	
	
}

Measured memory_bytes: 384
#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>;
using Graph = vector<vector<int>>;

int main() {
    string s;
    cin >> s;
    int a=s[0] - '0', b=s[1] - '0', c=s[2] - '0', d=s[3] - '0';
    int n=3, sum=a;
    for(int bit = 0; bit < (1<<n); ++bit){
        if(1 & bit){
            sum+=b;
        }else{
            sum-=b;
        }if(2 & bit){
            sum+=c;
        }else{
            sum-=c;
        }if(4 & bit){
            sum+=d;
        }else{
            sum-=d;
        }
        if(sum==7){
            cout << a;
            if(1 & bit){
                cout << '+' << b;
            }else{
                cout << '-' << b;
            }
            if(2 & bit){
                cout << '+' << c;
            }else{
                cout << '-' << c;
            }
            if(4 & bit){
                cout << '+' << d << '=' << 7 << "\n";
            }else{
                cout << '-' << d << '=' << 7 << "\n";
            }
            return 0;
        }
        sum=a;
    }
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let s = Array(N + 1).fill(0);
    let sum = A.reduce((m,n)=>m+n);
    
    for(let i in A) {
        s[parseInt(i) + 1] = A[i] + s[i];
    }
    
    let costs = Infinity;
    
    for(let i=1; i<A.length; i++) {
        // console.log("A[i-1]" + A[i-1]);
        // console.log("sum - s[i]" + (sum - s[i]));
        
        costs = Math.min(costs, Math.abs(s[i] - (sum - s[i])));
    }

    console.log(costs);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 48428
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None


root = None

def insert(key):
    global root
    x = root #Tの根
    y = None #親を設定
    while x is not None:
        y = x
        if key < x.key:
            x = x.left #左の子へ移動
        else:
            x = x.right  #右の子へ移動

    if y is None: #Tが空の場合
        root = Node(key)
    elif key < y.key:
        y.left = Node(key) #keyをyの左の子にする
    else:
        y.right = Node(key) #keyをyの右の子にする

def delete(target):
    def remove_node(p,c,a):
        if p.left == c: p.left = a
        else: p.right = a
    p,c = None,root
    while c.key != target: p,c = c,c.left if target < c.key else c.right
    if c.left is None:
        remove_node(p, c, c.right)
    elif c.right is None:
        remove_node(p, c, c.left)
    elif c.right.left is None:
        c.right.left = c.left
        remove_node(p, c, c.right)
    else:
        g = c.right
        while g.left.left: g = g.left
        c.key = g.left.key
        g.left = g.left.right

# def find(key):
#     x = root
#     while x and key != x.key:
#         x = x.left if key < x.key else x.right
#     return x is None

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None # result が None ⇒ false

def inorder(node):
    return   inorder(node.left) + " "+ str(node.key) + inorder(node.right) if node else ''
def preorder(node):
    return   " " + str(node.key) + preorder(node.left) + preorder(node.right) if node else ''
input()
for e in sys.stdin:
    if e[0] == "i":
        insert(int(e[7:]))
    elif e[0] == 'f':
        if find(int(e[5:])):
            print("no")
        else:
            print("yes")
        # print(['yes','no'][find(int(e[5:]))])

    elif e[0] == 'd':
        delete(int(e[7:]))

    else:
        print(inorder(root))
        print(preorder(root))



Measured memory_bytes: 54024
def main():
    S = list(input())
    ans = 1000
    for t in [chr(ord('a')+i) for i in range(26)]:
        if S.count(t) == len(S):
            print(0)
            return
        nextS = S[:]
        count = 0
        while True:
            changed = False
            deleted = False
            nextnextS = []
            num = 0
            for i in range(len(nextS)-1):
                if nextS[i] == t or nextS[i+1] == t:
                    nextnextS.append(t)
                else:
                    # if num == 0:
                    #     deleted = True
                    #     num += 1
                    # else:
                        changed = True
                        nextnextS.append(nextS[i])
            nextS = nextnextS
            
            count += 1
            if not changed:
                if deleted:
                    count += 1
                break

            
            # print(t,nextS,count)
        ans = min(ans,count)
    print(ans)

        


main()

Measured memory_bytes: 9028
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==1&&b==1&&c==0||a==0&&b==0&&c==1){printf("Open\n");}
  else {printf("Close\n");}
  return 0;
}

Measured memory_bytes: 584
fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    let n: usize = n.trim().parse().unwrap();
    let mut v = Vec::new();
    let mut tmp = n;
    while (tmp != 0) {
        let mut i = String::new();
        std::io::stdin().read_line(&mut i).unwrap();
        let mut d: u32 = i.trim().parse().unwrap();
        v.push(d);
        tmp -= 1;
    }
    v.sort();

    let mut ans = 0;
    let mut x: usize = 0;
    loop {
        if (x == n){
            break;
        }
        if (x == 0){
            ans += 1;
        }else if (v[x-1] < v[x]){
            ans += 1;
        }
        x += 1;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
a,b,k = map(int,input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 0:
            pass
        else:
            a = a - 1
        b = b + (a // 2)
        a = a // 2
    else:
        if b % 2 == 0:
            pass
        else:
            b = b - 1
        a = a + (b // 2)
        b = b // 2

print(a,b)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long long h,w,d[1000][1000],m=1e9+7;
    string a[1001];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>a[i];
        a[i]+="#";
    }
    a[h]="#";
    for(int i=0;i<w;i++)a[h]+="#";
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j]=0;
        }
    }
    d[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='.'){
                if(a[i+1][j]=='.')d[i+1][j]=(d[i+1][j]+d[i][j])%m;
                if(a[i][j+1]=='.')d[i][j+1]=(d[i][j+1]+d[i][j])%m;
            }
        }
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<d[i][j];
        }
        cout<<endl;
    }
    */
    cout<<d[h-1][w-1]<<endl;
}


Measured memory_bytes: 9088
#include <stdio.h>

#define WHITE 0
#define BLACK 1
#define INF 10000000

int main(){

  int n,i,j,u,min,m[101][101];
  int d[101],p[101],color[101];
  
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      scanf("%d",&m[i][j]);

  for(i=1;i<=n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[1]=0;

  while(1){
    min = INF;
    for(i=1;i<=n;i++){
      if(color[i]!=BLACK && d[i]<min){
	min=d[i];
	u=i;
      }
    }
    if(min==INF)break;

    color[u]=BLACK;

    for(i=1;i<=n;i++)
      if(color[i]!=BLACK && m[u][i]!=-1 && m[u][i]<d[i]){
	p[i]=u;
	d[i] = m[u][i];
      }
  }
  u=0;
  for(i=1;i<=n;i++)u+=d[i];
  printf("%d\n",u);

  return 0;
}



Measured memory_bytes: 2052
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let s = scanner.Next()
    let f sc dc =
        function
        | 'S' -> (sc + 1), dc
        | _ -> if sc > 0 then (sc - 1), (dc + 1) else sc, dc

    Seq.fold (fun (sc, dc) x -> f sc dc x) (0, 0) s
    |> fun (_, x) -> String.length s - (x * 2)
    |> printfn "%i"

    0


Measured memory_bytes: 19668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string S;
    cin >>S;
    
    cout << S[0]<<S.size()-2<<S[S.size()-1] << endl;


    return 0;
    

}

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

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif     
	int n,k;
	cin >> n >> k;
	vector<int>x(n + 1);
	int ans = 0;
	for(int i = 0; i < k; ++i){
		int t;
		cin >> t;
		for(int j = 0; j < t; ++j){
			int to;
			cin >> to;
			x[to]++;
		}
	}
	for(int i = 1; i <= n; ++i){
		if(x[i] == 0) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3628
/*
[dwacon5th-prelims] D - Square Rotation
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;
const int MAX_D = 1000;

int N, D;
int x[MAX_N], y[MAX_N];
int c[MAX_D][MAX_D];
int s[3][MAX_D * 2 + 1][MAX_D * 2 + 1];

bool can(int q) {
    for (int a = 0; a < D; a++) {
        for (int b = 0; b < D; b++) {
            bool is_ok = true;
            is_ok = is_ok && (s[2][a + q + 1][b + q + 1] - s[2][a + q + 1][b] -
                                  s[2][a][b + q + 1] + s[2][a][b] ==
                              0);
            is_ok =
                is_ok && (s[1][a + q + 1][b + D] - s[1][a + q + 1][b + q + 1] -
                              s[1][a][b + D] + s[1][a][b + q + 1] ==
                          0);
            is_ok =
                is_ok && (s[1][a + D][b + q + 1] - s[1][a + D][b] -
                              s[1][a + q + 1][b + q + 1] + s[1][a + q + 1][b] ==
                          0);
            is_ok = is_ok &&
                    (s[0][a + D][b + D] - s[0][a + D][b + q + 1] -
                         s[0][a + q + 1][b + D] + s[0][a + q + 1][b + q + 1] ==
                     0);
            if (is_ok) {
                return true;
            }
        }
    }

    return false;
}

ll solve() {
    int p = 0;
    for (int i = 0; i < N; i++) {
        c[x[i] % D][y[i] % D]++;
    }
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < D; j++) {
            while ((p + 1) * (p + 1) < c[i][j]) {
                p++;
            }
        }
    }

    int thresh[3] = {p * p, p * (p + 1), (p + 1) * (p + 1)};
    for (int k = 0; k < 3; k++) {
        for (int i = 0; i < D; i++) {
            for (int j = 0; j < D; j++) {
                if (c[i][j] > thresh[k]) {
                    s[k][1 + i][1 + j]++;
                    s[k][1 + i + D][1 + j]++;
                    s[k][1 + i][1 + j + D]++;
                    s[k][1 + i + D][1 + j + D]++;
                }
            }
        }
    }

    for (int k = 0; k < 3; k++) {
        for (int i = 1; i <= 2 * D; i++) {
            for (int j = 0; j <= 2 * D; j++) {
                s[k][i + 1][j] += s[k][i][j];
            }
        }
        for (int i = 0; i <= 2 * D; i++) {
            for (int j = 1; j <= 2 * D; j++) {
                s[k][i][j + 1] += s[k][i][j];
            }
        }
    }

    int ng = -1, ok = D - 1;
    while (ok - ng > 1) {
        int m = (ok + ng) / 2;
        if (can(m)) {
            ok = m;
        } else {
            ng = m;
        }
    }

    ll ans = p * D + ok;
    return ans;
}

int main() {
    cin >> N >> D;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    cout << solve() << endl;

    return 0;
}


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

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;

    if(x <= w/2 && y <= h/2){
        if(x>=r && y>=r){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(x >= w/2 && y <= h/2){
        if((w-x)>=r && y>=r){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(x <= w/2 && y >= h/2){
        if(x>=r && (h-y)>=r){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(x >= w/2 && y >= h/2){
        if((w-x)>=r && (h-y)>=r){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "error" << endl;
    }
}


Measured memory_bytes: 3116
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}


int main()
{
    ll n=read();
    int ans=0;
    for(ll i=2;i*i<=n;++i){
        if(n%i==0){
            int num=0;
            while(n%i==0) num++,n=n/i;

            int l=1,r=1000,t=0;
            //printf("i:%lld num:%d\n",i,num);

            while(l<=r){
                int mid=l+r>>1;
                int res=mid*(mid+1)/2;
                if(res>num) r=mid-1;
                else t=mid,l=mid+1;
            }
            //printf("t:%d\n",t);
            ans+=t;

        }
    }
    if(n!=1) ans++;

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


Measured memory_bytes: 3764
#include <iostream>

using namespace std;

class Solution {
public:
    int Count(int N) {
        int ret = 0;
        for (int i = 1; i <= N; i++) {
            int cnt = 0;
            int tmp = i;
            while (tmp) {
                cnt++;
                tmp /= 10;
            }
            if ((cnt & 1))
                ret++;
        }
        return ret;
    }
};

int main() {
    int N;
    cin >> N;
    Solution S;
    cout << S.Count(N) << endl;
}

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

struct data{
    int p, d, t;
};

int main(){
    int l, n;
    cin >> l >> n;
    
    vector<int> comp;
    comp.push_back(0);
    comp.push_back(l);
    int p, d, t;
    vector<data> vd;
    for(int i = 0; i < n; i++){
        cin >> p >> d >> t;
        vd.push_back(data({p,d,t}));
        comp.push_back(p);
        comp.push_back(p+d);
    }
    sort(comp.begin(), comp.end());
    comp.erase(unique(comp.begin(), comp.end()), comp.end());
    auto pos = [&](int val)->int{
        return lower_bound(comp.begin(), comp.end(), val)-comp.begin();
    };
    
    int axis = comp.size();
    vector<pair<int,int>> warp[axis];
    for(int i = 0; i < n; i++){
        warp[pos(vd[i].p)].push_back({vd[i].d, vd[i].t});
    }

    vector<int> dp(axis, 1<<30);
    dp[0] = 0;
    for(int i = 0; i < axis; i++){
        for(int j = i+1; j < axis; j++){
            dp[j] = min(dp[j], dp[i] + (comp[j]-comp[i]));
        }
        for(pair<int,int> w : warp[i]){
            int next = pos(comp[i]+w.first);
            dp[next] = min(dp[next], dp[i]+w.second);
        }
    }

    cout << dp[axis-1] << endl;
    
    return 0;
}


Measured memory_bytes: 3280