akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int n, k;
	cin >> n >> k;

	VI minus(0);
	VI plus(0);
	int temp;
	REP(i, n) {
		cin >> temp;
		if (temp < 0) {
			temp *= -1;
			minus.push_back(temp);
		}
		else {
			plus.push_back(temp);
		}
	}
	reverse(minus.begin(), minus.end());
	int ans;

	int min = pow(10, 8) * 3;
	if (plus.size() == 0) {
		ans = minus[k - 1];
	}
	else if (minus.size() == 0) {
		ans = plus[k - 1];
	}
	else {
		REP(i, plus.size()) {
			//k-i-2
			if (k - i - 2 < minus.size() && k - i - 2 > 0) {
				temp = plus[i] * 2 + minus[k - i - 2];
				if (temp < min) {
					min = temp;
				}
			}
		}
		REP(i, minus.size()) {
			//k-i-2
			if (k - i - 2 < plus.size() && k - i - 2 > 0) {
				temp = minus[i] * 2 + plus[k - i - 2];
				if (temp < min) {
					min = temp;
				}
			}
		}
		ans = min;
	}

	ANS(ans);




	return 0;
}



Measured memory_bytes: 1020
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,C,K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for(int i = 0;i < N;i++)cin >> T[i];
    sort(T.begin(),T.end());
    int cnt = 0,mini = 0;
    for(int i = 0;i < N;i++){
        if(T[i] - T[mini] > K || i - mini >= C){
            mini = i;
            cnt++; 
        }
    }
    cout << cnt + 1 << endl;
}

Measured memory_bytes: 640
n = int(input())
t = [0] * (n + 1)
x = [0] * (n + 1)
y = [0] * (n + 1)
for i in range(n):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())

can = True
for i in range(n):
    dt = t[i+1] -t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dt < dist:
        can = False
    # ここはよくわかっていない
    if dist % 2 != dt % 2:
        can = False
if can:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 17464
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,k,ans=0;
    cin>>k>>n;
    int a[n+1];
    a[0]=0;
    for (int i = 1; i <= n; ++i)
    {
        cin>>a[i]; //input
    }
    a[0]=k-a[n]+a[1]; //distance between the two houses on the two sides of the northmost point
    //cout<<a[0]<<endl;
    for (int i = 1; i < n; ++i)
    {
        a[i]=a[i+1]-a[i]; //a[i] = distance between the house at position i+1 and the house right before it
        //cout<<a[i]<<endl;
    }
    a[n]=0; //this cell still contains the distance between house n and the origin point so this does not contain distance between two houses so this is set to 0 since we have calculated distance between all adjacent pairs of houses and this need not be consisdered
    cout<<k-*max_element(a,a+n+1); //instead of setting a[n]=0, we could have just searched within (a,a+n)
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int main()
{
	int h,a;
	cin>>h>>a;
	if(h%a==0)cout<<h/a;
	else cout<<h/a+1;
	return 0;
}


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 Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int N;cin >> N;
    int H[21];
    int counter = 0;
    int ma = 0;
    rep(i,N){
        cin >> H[i];
        ma = max(ma,H[i]);
        if(ma<=H[i]){
            counter++;
        }

    }
    cout << counter << endl;
    return 0;
}

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

using ll=long long;

int cnt_digits(ll N){
 int digits=0;
 while(N>0){
   N/=10;
   digits++;
   }
  
  return digits;
}

int main(void){
   ll N;
   cin >> N;

  int ans=cnt_digits(N);

  for(ll A=1LL;A*A<=N;++A){
     if(N%A!=0) continue;
     const ll B=N/A;
     const int cur=max(cnt_digits(A),cnt_digits(B));

     if(ans>cur){
       ans=cur;
     }
   }

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



Measured memory_bytes: 3612
#include <cstdio>


int main(){
	int n;
	scanf("%d",&n);
	bool flag = 1;
	for(int i = 1;i <= n;i++){
		char t;
		scanf("%c",&t);
		if(t == 'Y') flag = 0;
	}
	if(flag) printf("Three");
	else printf("Four");
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val x = (1..N).map{
    val v = readLine()!!.split(" ").map{it.toString()}
    if(v.get(1) == "JPY") {
      v.get(0).toDouble()
    } else {
      v.get(0).toDouble() * 380000
    }
  }
  println(x.sum())
}

Measured memory_bytes: 36104
#include<iostream>
#include<cstdio>

using namespace std;

long long A,B,C,D,A1,B1,Q1,Q2,ans;
int cnt=0;

int gcd(int a,int b)
{
	if(b==0)
		return a;
	gcd(b,a%b);
}

int main()
{
	cin>>A>>B>>C>>D;
	A1=B/C-(A-1)/C;
	B1=B/D-(A-1)/D;
	Q1=C*D/gcd(C,D);
	Q2=B/Q1-(A-1)/Q1;
	ans=B-A+1-A1-B1+Q2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	n := readInt()
	a := readInt()
	b := readInt()
	fmt.Println(math.Min(float64(n*a), float64(b)))
}

func checkErr(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func toInt(s string) int {
	i, e := strconv.Atoi(s)
	checkErr(e)
	return i
}

func nextLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	var num int
	_, e := fmt.Scan(&num)
	checkErr(e)
	return num
}

func readStr() string {
	var str string
	_, e := fmt.Scan(&str)
	checkErr(e)
	return str
}

func readLineAsStr() string {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	return nextLine(scanner)
}

func readLineAsInts() []int {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	s := strings.Split(nextLine(scanner), " ")
	ints := make([]int, len(s))
	for i, str := range s {
		ints[i] = toInt(str)
	}
	return ints
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
    static int N;
    static int Q;
    static string s;
    static int[] count;

    static void Main(){
        string[] inp = Console.ReadLine().Split();
        N = int.Parse(inp[0]);
        Q = int.Parse(inp[1]);
        s = Console.ReadLine();
        count = new int[s.Length];
        bool f = s[0] == 'A';
        for (int i = 1;i < s.Length;i++){
            count[i] = count[i - 1];
            if (s[i] == 'A'){
                f = true;
                continue;
            }
            if (f && s[i] == 'C'){
                f = false;
                count[i]++;
                continue;
            }
            f = false;
        }
        for (int i = 0;i < Q;i++){
            inp = Console.ReadLine().Split();
            int l = int.Parse(inp[0]);
            int r = int.Parse(inp[1]);
            if (l == 1){
                Console.WriteLine(count[r - 1]);
                continue;
            }
            long ans = count[r - 1] - count[l - 2];
            if (s[l - 1] == 'C' && s[l - 2] == 'A')
                ans--;
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;
typedef long long ll;
ll inf = (ll)1 << 60;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    vector<ll> cost(n,inf);
    cost[0] = 0;

    for(ll i = 0; i < n; i++) {
        for(ll j = 1; j <= k; j++) {
            if(i - j >= 0) {
                cost[i] = min(cost[i], cost[i-j] + abs(v[i]-v[i-j]));
            }
        }
    }

    cout << cost[n-1] << endl;
}


Measured memory_bytes: 1792
import pprint
n = int(input())
a = [[0]*2 for i in range(n)]
memo = 0 
ahozon = 0
for i in range(n):
  a[i][0],a[i][1]=map(int,input().split())
a.sort(key=lambda x: x[1])
for j in range(n):
  if(memo<=1):
    if(a[j][1]-a[j][0]-ahozon>=0):
      ahozon+=a[j][0]
    else:
      memo +=1
if(memo>=1):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 41556
#include<stdio.h>

int main(){
    int num[6];
    int i,j,t_num;
    char *ans;
    ans = "Yay!";

    for(i=0; i<6; i++){
        scanf("%d", &num[i]);
    }

    for(i=0; i<6-2; i++){
        for(j=i+1; j<6-1; j++){
            t_num = num[j] - num[i];
                if(t_num > num[5]){
                ans = ":(";
            }
        }
    }
    printf(ans);
    return 0;
}

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

int main(){
    int K;
    cin >> K;
    if(K % 2 == 0 || K % 5 == 0) cout << -1 << endl;
    else{
        int L;
        if(K % 7 == 0) L = 9 * K / 7;
        else L = 9 * K;
        int cnt = 1;
        int mod = 10 % L;
        while(mod != 1){
            mod = mod * 10 % L;
            cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	bool OK = 0;
	for(int i = 1; i <= 9; ++i) {
		int temp = N / i;
		if(temp * i == N && temp <= 9 && temp >= 1) {
			OK = 1;
		}
	}
	if(OK) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String[] S = new String[N];
		int[] t = new int[N];
		for (int i = 0; i < N; i++) {
			S[i] = in.next();
			t[i] = in.nextInt();
		}
		String X = in.next();
		int index = -1;
		for (int i = 0; i < N; i++) {
			if (X.equals(S[i])) {
				index = i;
				break;
			}
		}
		index++;
		int ans = 0;
		for (int i = index; i < N; i++) {
			ans += t[i];
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int INF = 100000;
typedef pair<int, int> P;
int main()
{
    int x, y, z, K;
    cin >> x >> y >> z >> K;
    vector<long long> A(x), B(y), C(z);
    for (int i = 0; i < x; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < y; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < z; i++)
    {
        cin >> C[i];
    }
    priority_queue<long long> P;
    vector<long long> v;
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < y; j++)
        {
            v.push_back(A[i] + B[j]);
        }
    }
    sort(v.rbegin(), v.rend());
    for(int i=0; i<min((int)v.size(),K); i++){
        for(int j=0; j<z; j++){
            P.push(v[i]+C[j]);
        }
    }
    for (int i = 0; i < K; i++)
    {

        cout << P.top() << endl;
        P.pop();
    }
}


Measured memory_bytes: 42984
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  string s;
  cin >> s;
  string mes;
  if(s > "2019/04/30")
  {
    cout << "TBD" << endl;
  }
  else
  {
    cout << "Heisei" << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    vector <int> a(n), b(n);
    for(int& x : a)
        cin >> x;
    for(int& x: b)
        cin >> x;
    
    if(b < a) swap(a, b);
    
    int mx = 0;
    while(a != b) {
        next_permutation(a.begin(), a.end());
        mx += 1;
    }
    
    cout << mx;
    
    
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc028/tasks/agc028_a

# 問題からエスパーするとlcmが答えになる
# lcmで作れないならそれ以上伸ばしても絶対作れない
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_ints(): return list(map(int, read().split()))


from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N, M = read_ints()
S = read()[:-1]
T = read()[:-1]

L = lcm(N, M)
# 衝突する文字は各文字数をgcdで割った文字ごとに出現する
s_step = N // gcd(N, M)
t_step = M // gcd(N, M)
print(L if S[::s_step] == T[::t_step] else -1)


Measured memory_bytes: 63324
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		
		int n= sc.nextInt();
		int arr[] = new int[n+1];
		for(int i=1;i<=n;i++)
			arr[i] = sc.nextInt();
		long occ[] = new long[(int)2e5+1];
		HashMap<Integer,Long> hm = new HashMap<>();
		for(int i=1;i<=n;i++){
			occ[arr[i]]+=1;
			hm.put(arr[i],0l);
		}
		
		ArrayList<Integer> al = new ArrayList<>(hm.keySet());
		long total =0;
		int len = al.size();
		for(int i=0;i<len;i++){
			int val = al.get(i);
			long oc = occ[val];
			long temp = ((oc)*(oc-1))/2;
			hm.put(val,temp);
			total+=temp;
		}
		StringBuilder sb = new StringBuilder();
		for(int i=1;i<=n;i++){
			int val = arr[i];
			long gh =total-(occ[val]-1);
			sb.append(gh+"\n");
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 97464
#include <bits/stdc++.h>
typedef long long int ll;
#define pb         push_back
#define mp         make_pair
#define F          first
#define S          second
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define pll        pair<ll,ll>
#define pii        pair<int,int>
#define all(v)     v.begin(),v.end()
#define M          998244353
#define M2         1000000007
#define inf        100000000000000
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

bool isPrime(ll n)
{
    if(n<=1)
        return false;
    if(n<=3)
        return true;
    if(n%2==0 || n%3==0)
        return false;
    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0|| n%(i+2)==0)
            return false;
    return true;
}

int main()
{
    off;
    int n;
    ll k;
    cin>>n>>k;
    vector<int> v;
    int a;
    fl(i,0,n)
    {
        cin>>a;
        v.pb(a);
    }
    int dist[n+1];
    //memset(vis,0,sizeof(vis));
    memset(dist,-1,sizeof(dist));
    dist[1]=0;
    int last = -1;
    vector<int> tr;
    tr.pb(1);
    int i=0;
    while(dist[v[i]]==-1)
    {
        tr.pb(v[i]);
        dist[v[i]]=dist[i+1]+1;
        i=v[i]-1;
    }
    last = v[i];
    if(k<=dist[last])
        cout<<tr[k];
    else
    {
        int pos = 0;
        while(tr[pos]!=last)
            pos++;
        k-=pos;
        int t=tr.size()-pos;
        //cout<<t;
        cout<<tr[pos+(k%t)];
    }
}








Measured memory_bytes: 6340
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto& p : mp) {
        if(p.se < p.fi) ans += p.se;
        else ans += p.se - p.fi;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            map.put(i, new ArrayList<>());
        }
        for (int i = 2; i <= n; i++) {
            a[i] = sc.nextInt();
            List<Integer> list = map.get(a[i]);
            list.add(i);
            map.put(a[i], list);
        }
        for (int i = 1; i <= n; i++) {
            List<Integer> list = map.get(i);
            System.out.println(list.size());
        }
    }

}


Measured memory_bytes: 93312
#include<iostream>
#include<cstring>
#include<string>
#include<sstream>
using namespace std;
int main(){
	int n,b,ans=1;
	cin>>n>>b;
	while (n!=0&&ans<b){
		ans=ans*2;
		n--;
	}
	while(n!=0){
		ans=ans+b;
		n--;
	}
	cout<<ans;
	return 0; 
} 

Measured memory_bytes: 256
from sys import stdin

N = int(stdin.readline())

result = {}


def comb(n, r):
    up = 1
    down = 1
    for i in range(r):
        up *= n - i
        down *= i + 1
    return up // down


for _ in range(N):
    text = ''.join(sorted(stdin.readline().rstrip()))

    if text in result:
        result[text] += 1
    else:
        result[text] = 1

answer = 0
for v in result.values():
    answer += comb(v, 2)

print(answer)


Measured memory_bytes: 21956
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num =sc.nextInt();
		if(num%10==3)
			System.out.println("bon");
		else if(num%10==0||num%10==1||num%10==6||num%10==8)
			System.out.println("pon");
		else
			System.out.println("hon");
	}

}

Measured memory_bytes: 27032
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	set<int> D;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		D.insert(d);
	}

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






Measured memory_bytes: 3620
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[100005];
    //bool flag=false;
    int x,n,k=0,r,s,p,tmp_i=0,tmp_j,tmp,cnt=0;
    //ll m,ans=0;
    //char t[100005],u;
   
    cin >> k >> x;
    //for(int i=0;i<n;i++) cin >> a[i];
    //for(int i=0;i<n;i++) cin >> t[i];

    
    cout << ((500*k >= x) ? "Yes" : "No");
    //cout << ans;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


Measured memory_bytes: 256
//package Beginner121;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int m = s.nextInt();
        int c = s.nextInt();
        int[] b = new int[m];
        int[][] a = new int[n][m];
        for (int i = 0; i < m; i++) {
            b[i] = s.nextInt();
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = s.nextInt();
            }
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            int sum = c;
            for (int j = 0; j < m; j++) {
                sum += a[i][j] * b[j];
            }

            if(sum > 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21972
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;

	int len = s.size();

	int zeros = 0;

	rep(i, len)
	{
		if (s[i] == '0')
		{
			zeros++;
		}
	}

	cout << min(zeros, len-zeros) * 2<< endl;

	
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll k=30000;
    int n;
    cin>>n;
    unordered_map<int,int> mp;
    rep(i,n){

        int tmp;
        cin>>tmp;
        tmp--;
        mp[i]=tmp;
    }

    vector<ll> a(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++){
        a[i]=(i+1)*k;
        b[n-i-1]=(i+1)*k;
    }

    int prev=-1;
    for(int i=0;i<n;i++){
        a[mp[i]]+=i;
    }
    rep(i,n){
        cout<<a[i];
        cout<<(i==n-1?'\n':' ');
    }
    rep(i,n){
        cout<<b[i];
        cout<<(i==n-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin>>X;
  int P;
  for(int i=X; ;i++){
     bool a=true;
    for(int j=2;j*j<=i;j++){
     if(i%j==0){a=false;break;}
    }
      if(a){P=i; break;}
  
  }cout<<P<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#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 ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    int cnt = 0;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        if (a == b)
            cnt++;
        else
            cnt = 0;

        if (cnt >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define m_p make_pair

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;
	cin >> n;
	
	ll a[n];
	map<ll, ll> mp;
	for(int i=0 ; i<n ; ++i){
		cin >> a[i];
		mp[a[i]]++;
	}
	
	ll sum=0;
	for(auto it : mp){
		if(it.second > 1){
			sum += (it.second * (it.second-1)) / 2;
		}
	}
	
	for(int i=0 ; i<n ; ++i){
		if(mp[a[i]] > 1){
			sum -= (mp[a[i]] * (mp[a[i]]-1)) / 2;
			mp[a[i]]--;
			if(mp[a[i]] > 1){
				sum += (mp[a[i]] * (mp[a[i]]-1)) / 2;
			}
			cout << sum << "\n";
			if(mp[a[i]] > 1)sum -= (mp[a[i]] * (mp[a[i]]-1)) / 2;
			mp[a[i]]++;
			sum += (mp[a[i]] * (mp[a[i]]-1)) / 2;
		}
		else{
			cout << sum << "\n";
		}
	}
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;

int main(){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<min(a,b)+min(c,d)<<endl;
}

Measured memory_bytes: 256
///*.......................Shadman Sakib Utshob............................*///

#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define seecontent(v) cout << (#v) << " is "; for(auto x : v) { cout << x << " ";} cout << "\n\n";
#define inf             1e10
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;
#define maxn 300005

int dx[]={-1,0,1,0}; //up,right,down,left
int dy[]={0,1,0,-1};

int main()
{
    Boost;
    string s;
    ll n,i,j;
    cin>>s;
    if(s[s.size()-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<'s'<<endl;
    }

    return 0;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,M;ll L; cin >> N >> M >> L;
	ll inf = 1e18;
	VV<ll> d(N,V<ll>(N,inf)); rep(i,N) d[i][i] = 0;
	rep(i,M){
		int a,b;ll c; cin >> a >> b >> c;
		a--,b--;
		chmin(d[a][b],c);
		chmin(d[b][a],c);
	}
	rep(i,N) rep(j,N) rep(k,N) chmin(d[j][k],d[j][i]+d[i][k]);
	VV<ll> e(N,V<ll>(N,inf)); rep(i,N) e[i][i] = 0;
	rep(i,N) rep(j,N) if(i != j && d[i][j] <= L) e[i][j] = 1;
	rep(i,N) rep(j,N) rep(k,N) chmin(e[j][k],e[j][i]+e[i][k]);
	int Q; cin >> Q;
	rep(_,Q){
		int x,y; cin >> x >> y;x--,y--;
		if(e[x][y] == inf) cout << -1 << endl;
		else cout << e[x][y]-1 << endl;
	}
}


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



int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin >> x;
    ll cur = 100;
    int ans = 0;
    while (cur < x) {
        cur += cur / 100;
        ans++;
    }
    cout << ans;
    return 0;
}

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

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Reset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       (a).resize(unique(all(a)) - (a).begin())
#define bit(n, i)       (((n) >> (i)) & 1)
#define onbit(n, i)     ((n) |= (1LL << (i)))
#define offbit(n, i)    onbit((n), (i)), ((n) -= (1LL << (i)))
#define bitcount(n)     __builtin_popcountll(n)

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const ll oo = 2e9;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline bool isPrime (ll x){ if(x <= 1) return 0; if(x <= 3) return 1; if (!(x % 2) || !(x % 3)) return 0; ll s = sqrt(1.0 * x) + EPS; for(ll i = 5; i <= s; i += 6){if (!(x % i) || !(x % (i + 2))) return 0;}return 1;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int N = 3e5 + 5;

ll n, m, k;
ll a[N];

void Solve(){
    int a, b, c;
    cin >> a >> b >> c;
    int ok = 0;
    for(int i = 1; i <= 9; i++){
        if(i == a || i == b || i == c) ok++;
    }
    if(ok == 2) cout << "Yes\n"; else cout << "No\n";



}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int query = 1;
//    cin >> query;
    int start = 1000 * clock() / CLOCKS_PER_SEC;
    while(query--) Solve();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC  - start << "ms\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
int a[100010];
inline bool cmp(int a,int b){
	return a>b;
}

int main(){
	int n;read(n);
	rep(i,1,n)read(a[i]);
	sort(a+1,a+n+1,cmp);
	
	int ll=1;int rr=n;int pos=0;
	while(ll<=rr){
		int mid=(ll+rr)>>1;
		if(a[mid]>=mid){pos=mid;ll=mid+1;}
		else{rr=mid-1;}
	}	
	
	int n1=(a[pos]-pos)%2;int n2=0;
	while(a[pos+n2+1]==pos)n2++;
	n2%=2;
	if(!(n1|n2)){puts("Second");}
	else{puts("First");}	
	return 0;
}

Measured memory_bytes: 3948
#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>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

 
int main() {
    int n;
    cin >> n;
    mint res = mint(10).pow(n);
    res -= mint(2) * mint(9).pow(n);
    res += mint(8).pow(n);
    cout << res <<endl;
    return 0;
}

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

int main(){
  string S,T;
  cin>>S>>T;
  int ans=0;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

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

using namespace std;

const int INF=1<<29;

int main(){
	int n,k,c;
	string s; cin>>n>>k>>c>>s;

	auto solve=[&](){
		vector<int> res;
		int pre=-INF;
		rep(i,n) if(s[i]=='o' && pre+c<i) {
			res.emplace_back(i);
			pre=i;
		}
		return res;
	};

	vector<int> L=solve();
	if(L.size()>k) return 0;

	reverse(s.begin(),s.end());

	vector<int> R=solve();
	rep(i,R.size()) R[i]=n-R[i]-1;
	reverse(R.begin(),R.end());

	rep(i,L.size()) if(L[i]==R[i]) printf("%d\n",L[i]+1);

	return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,u,v;
    cin >> N >> u >> v;
    u--; v--;
    vector<vector<int>> edge(N,vector<int>());
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> T(N,-1),A(N,-1);
    deque<int> qT,qA;
    T[u]=0;
    qT.push_back(u);
    A[v]=0;
    qA.push_back(v);
    while(!qT.empty()){
        int now = qT.front();
        qT.pop_front();
        for(auto e:edge[now]){
            if(T[e]!=-1) continue;
            T[e] = T[now]+1;
            qT.push_back(e);
        }
    }
    while(!qA.empty()){
        int now = qA.front();
        qA.pop_front();
        for(auto e:edge[now]){
            if(A[e]!=-1) continue;
            A[e] = A[now]+1;
            qA.push_back(e);
        }
    }
    ll endnode = v;
    rep(i,N){
        if(A[endnode]<A[i]&&A[i]>T[i]){
            endnode = i;
        }
    }
    // 青木君はendnodeの1つ上に来た時に終わる
    int parenode = edge[endnode][0];
    cout << A[parenode] << endl;
    return 0;
}

Measured memory_bytes: 9492
import * as fs from 'fs';
 
const input = parseInt(fs.readFileSync("/dev/stdin", "utf8")).toString();

const fp = input.slice(-1);
 
if(new Set(['2', '4', '5', '7', '9']).has(fp)) {
  console.log('hon');
}else if(new Set(['0', '1', '6', '8']).has(fp)) {
  console.log('pon');
} else {
  console.log('bon');
}

Measured memory_bytes: 29620
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#define ll long long
//for (auto &x : a) { cin >> x; }
using namespace std;

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

    string s;
    cin >> s;
    if(s=="RRR"){
        cout << 3;
    }
    if(s=="RRS" || s=="SRR"){
        cout << 2;
    }
    if(s=="RSS" || s=="SSR" || s=="SRS" || s=="RSR"){
        cout << 1;
    }
    if(s=="SSS"){
        cout << 0;
    }
}

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

using namespace std;
const int mod = 1e9 + 7;
int qs[(int)1e5 + 5], inv[(int)1e5 + 5];
int pow(int val, int idx){
    if(idx == 0) return 1;
    if(idx == 1) return val;
    int k = pow(val, idx >> 1);
    k = (1LL * k * k) %  mod;
    if(idx & 1) k = (1LL * k * val) % mod;
    return k;
}
int main(){
    int n, pre, x;
    scanf("%d %d",&n,&pre);
    for(int i = 1; i < n;i++){
        scanf("%d", &x);
        qs[i] = qs[i-1] + x - pre;
        pre = x;
    }
    int fac = 1;
    for(int i = 1;i < n;i++){
        fac = (1LL * fac * i) % mod;
        inv[i] = i == 1 ? 1 : pow(i, mod - 2);
    }
    int ans = 0;
    for(int i = 1; i < n; i++){
        ans += (1LL * (qs[n - 1] - qs[i-1]) * (1LL * fac * inv[i] % mod)) % mod;
        ans = ans >= mod ? ans - mod : ans;
    }
    printf("%d",ans);



}


Measured memory_bytes: 1024
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, t, i, j, t1, t2, count;
    String stt, stn, art, arn;
    char[] sttc, artc;
    int[] lis;
    String[] liss;

    n = sc.nextInt(); t = sc.nextInt();
    lis = new int[n]; liss = new String[n];
    count = 0;
    stt = sc.next(); stt = sc.next();
    for(i = 0;i < n - 1;i++){
      stt = sc.next(); stn = sc.next(); art = sc.next(); arn = sc.next();
      sttc = new char[stt.length()]; artc = new char[art.length()];
      for(j = 0;j < stt.length();j++)sttc[j] = stt.charAt(j);
      for(j = 0;j < art.length();j++)artc[j] = art.charAt(j);
      t1 = readint(sttc, 0, 2) * 60 + readint(sttc, 3, 5);
      t2 = readint(artc, 0, 2) * 60 + readint(artc, 3, 5);
      if(t2 - t1 >= t){
        liss[count] = stn; lis[count++] = t2 - t1;
      }
    }
    out.println(count);
    for(i = 0;i < count;i++)out.println(liss[i] + " " + lis[i]);

    sc.close();
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res, s;
    d = 1; res = 0; s = 1;
    if(ch[l] == '-'){ s = -1; l++; }
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res * s;
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 26440
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;

public class Main {
    public static void main(final String[] args) {
        final MyScanner sc = new MyScanner();
        final long a = sc.nextLong();
        final long b = sc.nextLong();
        final long c = sc.nextLong();
        final long temp = c - a - b;
        if (0 < temp && 4 * a * b < temp * temp) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

class MyScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int pointer = 0;
    private int bufLength = 0;

    private boolean hasNextByte() {
        if (pointer < bufLength) {
            return true;
        } else {
            pointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (final IOException e) {
                e.printStackTrace();
            }
            if (bufLength <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[pointer++];
        } else {
            return -1;
        }
    }

    private static boolean isNumberChar(final int c) {
        return '0' <= c && c <= '9';
    }

    private static boolean isPrintableChar(final int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[pointer])) {
            pointer++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        final StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long num = 0;
        boolean isNegative = false;
        int b = readByte();
        if (b == '-') {
            isNegative = true;
            b = readByte();
        }
        if (!isNumberChar(b)) {
            throw new NumberFormatException();
        }
        while (true) {
            if (isNumberChar(b)) {
                num *= 10;
                num += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return isNegative ? -num : num;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        final long temp = nextLong();
        if (temp < Integer.MIN_VALUE || Integer.MAX_VALUE < temp) {
            throw new NumberFormatException();
        }
        return (int) temp;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 32560
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,K; cin>>N>>K;
    vec h(N);
    REP(i,N) cin>>h[i];
    Sort(h); Reverse(h);
    int ans = INF;
    REP(i,N-K+1){
        ans = min(ans,h[i]-h[i+K-1]);
    }
    Out(ans);
}


Measured memory_bytes: 1024
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut s = 0.0;
    for _ in 0 .. n {
        let x = get!(f64);
        s += 1.0 / x;
    }
    let ans = 1.0 / s;
    println!("{}", ans);
}

Measured memory_bytes: 4352
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

#$stdin = File.open('input.txt')

n = gi # 10**5
as = gsmi

as.map!.with_index{|a,i| a-i-1 }.sort!
if n.odd?
  b = as[n/2]
else
  begin
    b = as[n/2-1]+((as[n/2]-as[n/2-1])*(as[n/2-1]-as[0])/(as[n/2-1]-as[0]+as[-1]-as[n/2]))
  rescue ZeroDivisionError => ex
  	b = (as[n/2]+as[n/2-1])/2
  end
end
puts as.each_with_index.inject(0){|r,(a,i)| r+(a-b).abs }


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

#define ll long long

using namespace std;

int main()
{
    int m=0;
    string s;
    cin>>s;
    int n=s.size();
    int b=n-1;

    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[b-i])
        {
            cout<<"No"<<"\n";
            return 0 ;
        }

        if(i==b)
            break;
    }

    string s1="";

    for(int i=((n+3)/2)-1;i<n;i++)
    {
     s1+=s[i];
    }

     string s2="" ;

    for(int i=0;i<((n-1)/2);i++)
    {
      s2+=s[i];
    }

     int n1=s1.size();
     int n2=s2.size();
     int m1=0,m2=0;

    for(int i=0;i<n1;i++)
    {
        if(s1[i]!=s[n1-1-i])
        {
            cout<<"No"<<"\n";
            return 0 ;
        }
    }

    for(int i=0;i<n2;i++)
    {
        if(s2[i]!=s2[n2-1-i])
        {
            cout<<"No"<<"\n";
            return 0 ;
        }
    }

    cout<<"Yes"<<"\n";

         //cout<<s1<<" "<<s2<<"\n";
    return 0;
}


Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long a, long long b){
    cout << a * b / __gcd(a, b) << endl;
}


signed main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256