akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;

struct eratosthenes
{
    int n;
    vector<int> f;
    vector<pair<int, int>> primes;

    eratosthenes(int n) : f(n + 1)
    {
        ll i, j;
        f[0] = f[1] = -1;
        for (i = 2; i <= n; i++)
        {
            if (!f[i])
            {
                f[i] = i;
                primes.push_back(make_pair(i, 0));
                for (j = i * i; j <= n; j += i)
                {
                    if (!f[j])
                    {
                        f[j] = i;
                    }
                }
            }
        }
    }

    vector<int> genosis(int x)
    {
        vector<int> g;

        while (x != 1)
        {
            g.push_back(f[x]);
            x /= f[x];
        }

        return g;
    }

    vector<pair<int, int>> genosiscount(int x)
    {
        vector<pair<int, int>> gc;
        vector<int> g = genosis(x);

        if (g.empty() == 1)
        {
            return {};
        }

        gc.push_back(make_pair(f[x], 0));

        for (auto &i : g)
        {
            if (gc.back().first == i)
            {
                gc.back().second++;
            }
            else
            {
                gc.push_back(make_pair(i, 1));
            }
        }

        return gc;
    }
};

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % 1000000007;
        x = (x * x) % 1000000007;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    eratosthenes a(1e6 + 1);
    int N;
    int A[10010];
    int i, j;
    ll ans = 0, B;
    ll mul = 1;

    cin >> N;

    for (i = 0; i < N; i++)
    {
        cin >> A[i];

        for (auto &j : a.genosiscount(A[i]))
        {
            for (auto &k : a.primes)
            {
                if (j.first == k.first && j.second > k.second)
                {
                    k.second = j.second;
                }

                if (j.first < k.first)
                {
                    break;
                }
            }
        }
    }

    for (auto &x : a.primes)
    {
        B = power(x.first, x.second);
        mul = mul * B % 1000000007;
    }

    for (i = 0; i < N; i++)
    {
        ll add = mul * power(A[i], 1000000005) % 1000000007;
        ans = (ans + add) % 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5368
N, M, X, Y = map(int, input().split())

xs = [int(x) for x in input().split()]
ys = [int(y) for y in input().split()]

res = False
for th in range(X+1, Y+1):
  is_up = all([x < th for x in xs ])
  is_down = all([y >= th for y in ys])
  
  #print(th, is_up, is_down)
  if is_up and is_down:
    res = True

print("No War" if res else "War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,ma,mb;
    cin>>n>>ma>>mb;
    int a[n],b[n],c[n];
    int dp[2][401][401];
    for(int i=0;i<=1;i++)for(int j=0;j<=400;j++)for(int k=0;k<=400;k++)dp[i][j][k]=1e9;
    dp[0][0][0]=0;
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=0;i<n;i++){
    	for(int j=0;j<=400;j++){
    		for(int k=0;k<=400;k++){
    			if(dp[i&1][j][k]==1e9)continue;
    			dp[(i+1)&1][j][k]=min(dp[(i+1)&1][j][k],dp[i&1][j][k]);
    			dp[(i+1)&1][j+a[i]][k+b[i]]=min(dp[(i+1)&1][j+a[i]][k+b[i]],dp[i&1][j][k]+c[i]);
    		}
    	}
    }
    int ans=1e9;
    for(int i=1;i<=400;i++){
    	for(int j=1;j<=400;j++){
    		if(i*mb==j*ma)ans=min(ans,dp[n&1][i][j]);
    	}
    }
    if(ans==1e9)ans=-1;
    cout<< ans<<endl;
    return 0;
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;



class Program
{
    static void Main(string[] args)
    {
        string str1;
        str1 = Console.ReadLine(); //標準入力
        int count = int.Parse(str1);
        
    
        if (count < 1000)
        {
            Console.WriteLine("ABC");
        }
        else
        {
            Console.WriteLine("ABD");
        }

    }


}


Measured memory_bytes: 13140
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/








int main()
{
  //IOS; /* making cin faster */
  int N;
  SCAND(N);

  int fl_ng = 1;

  REP(i,26)
    {
      REP(j,14)
	{
	  if( 4 * i + 7 * j == N )
	    {
	      fl_ng = 0;

	      break;
	      
	    }
	}
    }
  
  
  if(fl_ng)
    {
      printf("No\n");
      
    }
  else
    {
      printf("Yes\n");
      
    }
  

  

}


Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;

class Main
{
	public static void main(String args[])throws IOException
	{
		FastReader scn = new FastReader();
		long M = 1000000007L;
		
		long S = scn.nextLong();
		

		long n = S/3;
		long ans = 0;
		for(long i = 1; i <= n; i++)
		{
			long k = S - 3*i;
			ans = (ans + nCr(i, k, M))%M;
			//System.out.println(i + " " + ans);
		}
		System.out.println(ans);
	}

	public static long nCr(long n, long k, long M)
	{
		long num_factorial = 1;
		for(long i = n + k - 1; i >= n; i--)
		{
			num_factorial = (num_factorial * i)%M;
		}
		//System.out.println(num_factorial);
		long denom_factorial = 1;
		for(long i = k; i > 0; i--)
			denom_factorial = (denom_factorial * getInverseModulo(i, M))%M;

		//System.out.println(denom_factorial);

		return (num_factorial * denom_factorial)%M;
	}

	public static long getPowerModulo(long a, long p, long m)
    {   
        if(p==0)
            return 1;
 
        long temp = getPowerModulo(a, p/2, m);
        temp = (temp * temp)%m;
        if(p%2 == 0)
            return temp;
        else
            return (a * temp)%m;
 
    }

    public static long getInverseModulo(long a, long P)
    {
        return getPowerModulo(a, P-2, P);
    }

	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                {
                    st = new StringTokenizer(br.readLine()); 
                }
                catch (IOException  e) 
                {
                    e.printStackTrace(); 
                }
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            {
                str = br.readLine(); 
            }
            catch (IOException e) 
            {
                e.printStackTrace(); 
            }
            return str; 
        } 
    }
}

Measured memory_bytes: 26052
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
d, g = map(int, input().split())
pc_ls = []
for i in range(d):
    p, c = map(int, input().split())
    pc_ls.append([p, c])

ptns = []
for i in range(2 ** d):
    ptn = []
    for j in range(d):
        if ((i >> j) & 1):
            ptn.append(j)
    ptns.append(ptn)

ret = 10 ** 10

for item in ptns:
    cnt = 0
    pnt = 0
    for val in item:
        cnt += pc_ls[val][0]
        pnt += (100 * (val + 1)) * pc_ls[val][0] + pc_ls[val][1]
    left = g - pnt
    if left <= 0:
        ret = min(ret, cnt)
    else:
        for i in range(1, d + 1):
            if (d - i) in item:
                continue
            else:
                max_val = (100 * (d - i + 1)) * pc_ls[-i][0]
                if max_val < left:
                    cnt += pc_ls[-i][0]
                    left -= max_val
                else:
                    cnt += (left + 100 * (d - i + 1) -
                            1) // (100 * (d - i + 1))
                    break
        ret = min(ret, cnt)

print(ret)


Measured memory_bytes: 41840
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
int main() {
    ll N;
    cin >> N;

    vector<ll> B(N);
    for (size_t i = 0; i < N - 1; i++)
    {
        cin >> B[i];
    }

    ll sum = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (i == N - 1) {
            sum += B[i - 1];
        } else if (i == 0) {
            sum += B[i];
        } else {
            sum += min(B[i - 1], B[i]);
        }
    }
    cout << sum << endl;
}

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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> ok(n, false);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      a--;
      ok[a] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!ok[i]) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
<?php

// 読み取り
fscanf(STDIN, "%d %d", $N, $M );

// 標準入力からの入力値を変数に代入
$single_line_input = trim(fgets(STDIN));
// 取得した入力値を半角スペースで分解
$A = explode(" ", $single_line_input);

function StringToInt($s){
  return (int)$s;
}

$A = array_map("StringToInt", $A);


// 読み取り2
//$std_in = trim(fgets(STDIN));

$sum = array_sum($A);
// 処理
$counter = 0;
$flag = 1;
while (($flag==1) and ($counter < $M)) {
  $Amax = max($A);

  // 1/4M以上である
  if ($Amax >= ($sum/(4*$M))) {
    $counter++;
    $A = array_diff($A, array($Amax));
    $A = array_values($A);
  } else {
    $flag = 0;
  }
}

if($counter == $M) {
  echo "Yes";
} else {
  echo "No";
}

?>


Measured memory_bytes: 4604
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, k) = (line[0], line[1]);
    let mut counter: Vec<u64> = vec![0;n];
    for _ in 0..k{
        let _ = read_as_vec::<usize>();
        let a = read_as_vec::<usize>();
        for x in a{
            counter[x-1] += 1;
        }
    }

    println!("{}", counter.iter().filter(|x| **x == 0).count());
}


Measured memory_bytes: 2176
n,k = map(int,input().split())
mod = 10**9+7
a = 1
b = n-k+1
for i in range(k):
    ans = a*b % mod
    print(ans)
    a = a * (k-1-i)//(i+1)
    b = b * (n-k-i)//(i+2)

Measured memory_bytes: 9096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main () {
    string s; cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            exit(0);
        }
    }

    cout << "No" << endl;

}

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

using namespace std;

struct point{
	int x,y;
};

int main(){

	int m,n;
	point S;
	int x,y;
	vector<point> mm,nn;
	bool f;

	while(1){
		cin>>m;
		if(m==0) break;
		for(int i=0;i<m;i++){
			cin>>S.x>>S.y;
			mm.push_back(S);
		}

		cin>>n;
		for(int i=0;i<n;i++){
			cin>>S.x>>S.y;
			nn.push_back(S);
		}

		for(int i=0;i<m;i++){
			for(int l=0;l<n;l++){
				x=mm[i].x-nn[l].x;
				y=mm[i].y-nn[l].y;
				for(int j=0;j<m;j++){
					f=false;
					for(int k=0;k<n;k++){
						if(mm[j].x==nn[k].x+x&&mm[j].y==nn[k].y+y) f=true;
					}
					if(!f) break;
					if(j==m-1){
						cout<<-1*x<<" "<<-1*y<<endl;
						goto a;
					}
				}
			}
		}
		a:
		mm.clear();
		nn.clear();
	}

	return 0;
}

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

Measured memory_bytes: 256
($n,$k)=glob<>;$_=<>;
if($n<=$k*2){
    print$n;
    exit;
}
$f=substr($_,0,1);
$l=substr($_,-1,1);
chomp;
s/(.)(?!\1)/\1A\2/g;
@s=map{length($_)}split(A,$_);
if ($#s<=$k*2-1){
    print$n;
    exit;
}
$s[$_]+=$s[$_-1] for(1..$#s);
unshift(@s,0) if $f<1;
push(@s,$s[$#s]) if $l<1;
$L=$#s+1;
$d=($k*2+1<=$L)?$k*2+1:$L;
for ($i=0;$i<$L;$i+=2){
    $c=$s[$i];
    $c-=$s[$i-$d] if($i-$d>=0);
    $mx=($mx>$c)?$mx:$c;
}
print$mx

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

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) p[i]=i+1;
    vector<vector<int>> q;
    do{
        q.push_back(p);
    }while(next_permutation(all(p)));
    vector<int> A,B;
    int t;
    rep(_,n){cin >> t; A.push_back(t);}
    rep(_,n){cin >> t; B.push_back(t);}
    int a,b;
    rep(i,q.size()){
        if(q[i] == A) a=i;
        if(q[i] == B) b=i;
    }
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 3256
# solution

import io
nim, mike = map(int, input().split())
for i in range(nim + 1):
    for j in range(nim - i + 1):
        if i * 10000 + j * 5000 + (nim - i - j) * 1000 == mike:
            print(i, j, nim - i - j)
            exit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include <iostream>

int main(){
   int n;
   std::cin >> n;
   int p[n];
   for(int i=0; i<n; ++i)
      std::cin >> p[i];

   int ans = 0;
   for(int i=1; i<n-1; ++i){
      if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])) ++ans;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//"strings"
	"sort"
	"math"
)

var (
	//in  = bufio.NewReaderSize(os.Stdin,math.MaxInt64)
	//out = bufio.NewWriter(os.Stdout)
	in = bufio.NewScanner(os.Stdin)
	)
func init(){
	in.Buffer([]byte{}, math.MaxInt64)
	in.Split(bufio.ScanWords)
}
func main() {
	t := readInt64Slice(2)
	lakeLength := t[0]
	houses := t[1]
	housePosSlice := readFloat64Slice(int(houses))
	houseDistanceSlice := make([]float64,houses,houses)

	for i :=0 ; i < len(housePosSlice)-1; i++ {
		houseDistanceSlice[i] = housePosSlice[i+1] - housePosSlice[i]
	}

	houseDistanceSlice[houses-1] = (float64(lakeLength) - housePosSlice[houses-1]) + housePosSlice[0]
	sort.Float64s(houseDistanceSlice)
	sum := 0

	for _,val := range houseDistanceSlice[0: len(houseDistanceSlice) -1]{
		sum += int(val)
	}
	fmt.Println(sum)
}

func readInt64Slice(n int) []int64 {
	line := readStringSlice(n)
	slice := make([]int64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseInt(tmp, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)
	}
	return slice
}
func readFloat64Slice(n int) []float64 {
	line := readStringSlice(n)
	slice := make([]float64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseFloat(tmp, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)

	}
	return slice
}
func readString() string {
	in.Scan()
	return in.Text()

}
func readStringSlice(n int) []string {
	s := make([]string, n)
	for i :=0; i < n; i++{
		s[i] = readString()
	}
	return s
}
func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Printf("%#v\n", v)
	}
}

Measured memory_bytes: 8704
uses Math;
var N,Z,W,i,S,T:Longint;
begin
read(N,Z,W);
for i:=1 to N do begin
S:=T;
read(T);
end;
if N=1 then S:=abs(W-T)else S:=max(abs(S-T),abs(T-W));
writeln(S);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	bool ans=true;
	for(ll i=0;i<s.size();i++){
		if((i+1)%2!=0){
			if(s[i]=='L'){
			ans=false;
			}
		}
		else{
			if(s[i]=='R'){
				ans=false;
			}
		}
	}
	if(ans){
		cout <<"Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3600
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
int mod = 1e9+7;
int mul(int a,int b)
{
    return ((a%mod)*(b%mod))%mod;
}
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
int power(int a,int b)
{
    int res = 1;
    while(b!=0)
    {
        if(b&1)
            res = mul(res,a);
        b  = b>>1;
        a = mul(a,a);
    }
    return res;
}
int imodulo(int a)
{
    int ans = power(a,mod-2);
    return ans;
}
int sub(int a,int b)
{
    return ((a%mod)-(b%mod)+mod)%mod;
}
signed main()
{
    fast;
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int invcnt[n+1]={};
    int ch[n+1]={};
    for(int i=1;i<=n;i++)
    {
        int cnt = 0;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]<a[i])
                cnt++;
        }
        invcnt[i]+=cnt;
        cnt = 0;
        for(int j=1;j<=n;j++)
            if(a[j]<a[i])
                cnt++;
        ch[i] = cnt;
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans = add(ans,add(mul(k,invcnt[i]),mul(ch[i],(k*(k-1))/2)));
    }
    cout<<ans;
}

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

int main() {
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    char a1 = s1.at(0),a2 = s2.at(0),a3 = s3.at(0);
    a1 += 'A' - 'a';
    a2 += 'A' - 'a';
    a3 += 'A' - 'a';
    cout << a1 << a2 << a3 << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i=0; i<N; i++){
    if (i==N-1) ans += p[i]/2;
    else ans += p[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
$<.each do |line|
  stack = line.chomp.split
  #逆ポーランド記法
  n = stack.inject([]) do |s, x|
    x =~ /[0-9]/ ? s << x.to_f : s << eval(s.pop(2).join(x))
  end
  puts sprintf("%.6f", n.first + 0)
end

Measured memory_bytes: 6160
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
deque<char> q;
char s[100005], c[10];
int n;
void init(){
    scanf("%s", s);
    n = strlen(s);
    for (int i = 0; i < n; ++i)
        q.push_back(s[i]);
}
void solve(){
    int Q = read();
    int bb = 0;
    while (Q--){
        int opt = read();
        if (opt == 1) bb ^= 1;
        else {
            int ff = read() - 1;
            scanf("%s", c);
            if ((bb ^ ff) == 0) 
                q.push_front(c[0]);
            else 
                q.push_back(c[0]);
        }
    }
    if (bb){
        while (!q.empty())
            putchar(q.back()), q.pop_back();
    }else {
        while (!q.empty())
            putchar(q.front()), q.pop_front();
    }
    putchar('\n');
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 896
package main
import "fmt"
func main () {
  var s string
  fmt.Scan(&s)
  if s[0] != s[1] && s[0] != s[2] {
    if s[1] != s[2] {
      fmt.Println("Yes")
    } else {
      fmt.Println("No")
    }
  } else {
    fmt.Println("No")
  }
}
  

Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(l[II()-1])
    return


#main
if __name__ == '__main__':
    solve()


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

using namespace std;

int main(){
  int n;
  int fibn[1000];
  for(int i=0;i<1000;i++)fibn[i]=-1;
  fibn[0]=fibn[1]=1;
  scanf("%d",&n);
  for(int i=2;i<=n;i++){
    fibn[i]=fibn[i-1]+fibn[i-2];
  }
  cout << fibn[n] << endl;
  return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [(i + 1) / 2 for i in c]
e = sum(d[:b])
f = e
for i in range(a - b):
	f -= d[i]
	f += d[i + b]
	if f > e:
		e = f
print(e)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

int main() {
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0); // cin??¨cout?????£????????????
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	while (true) {
		ll n, a, s, g; cin >> n >> a >> s >> g;
		if (n == 0) break;
		vector<tuple<string, ll, ll>> path(a);
		REP(i, a) cin >> get<2>(path[i]) >> get<1>(path[i]) >> get<0>(path[i]);
		
		vector<string> d(n, "?");
		auto bellman_ford = [&]() {
			string ans;
			d[g] = "";
			for (ll loop = 0;; ++loop) {
				bool update = false;
				REP(i, a) {
					auto e = path[i];
					if (d[get<1>(e)] != "?" && (d[get<2>(e)] == "?" || d[get<2>(e)] > get<0>(e) + d[get<1>(e)])) {
						d[get<2>(e)] = get<0>(e) + d[get<1>(e)];
						update = true;
					}
				}
				if (!update) break;
				if (loop == 7 * n - 1) return d[s].size() <= 6 * n;
			}
			return true;
		};


		if (bellman_ford() && d[s] != "?") {
			cout << d[s] << endl;
		} else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

vector<int> V[20];
int N;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,20) V[i].push_back(-1),V[i].push_back(-1);
	ll ret=0;
	FOR(i,N) {
		cin>>x;
		int ma=-2;
		FOR(j,20) {
			if(x&(1<<j)) V[j].push_back(i);
			ma=max(ma,V[j][V[j].size()-2]);
		}
		ret+=i-ma;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 8896
// AOJ 1589 Unhappy Class
// 2018.4.18 bal4u

#include <stdio.h>

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int dp[45][45];
int hi[45], k[45][45], t[45][45];

int main()
{
	int N, M, L, da, i, j, lim;

	N = in(), M = in(), L = in();
	while (M--) {
		da = in(), da = da*N + in()-1;
		i = hi[da]++;
		k[da][i] = in();
		t[da][i] = in();
	}

	lim = 5*N;
	for (da = 0; da < lim; da++) for (i = 0; i <= L; i++) {
		if (i < L) {
			for (j = 0; j < hi[da]; j++) {
				int x =  dp[da][i] + t[da][j];
				if (x > dp[da+k[da][j]][i+1]) dp[da+k[da][j]][i+1] = x;
			}
		}
		if (dp[da+1][i] < dp[da][i]) dp[da+1][i] = dp[da][i];
	}
	printf("%d\n", dp[lim][L]);
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC103 B - String Roatation
// 2020.06.12

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S, T; cin >> S >> T;
  int n = S.size();
  REP(i, n){
    string tmp;
    tmp = S.substr(i, n-i) + S.substr(0, i);
    if(T == tmp){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
def solve():
    N, A, B = [int(i) for i in input().split()]
    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        print(min(N - B, A - 1) + 1 + (B - A - 1) // 2)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 61868
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll n,m,q,dlim,ulim;
int z1[N],z2[N],h1[N],h2[N];
int fa[N],t1,t2,cnt[N];
int gf(int x){return fa[x]==x?x:fa[x]=gf(fa[x]);}
void write(int p){
	puts(p?"Yes":"No");
}
int main(){
	cin>>n>>m>>q;
	for (int i=1;i<=q;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		if (c==0){
			z1[++t1]=a+1;
			z2[t1]=b+1;
		}
		else {
			h1[++t2]=a+1;
			h2[t2]=b+1;
		}
	}
	for (int i=1;i<=n;i++)fa[i]=i;
	dlim=n; 
	for (int i=1;i<=t1;i++){
		if (gf(z1[i])!=gf(z2[i]))
		fa[gf(z1[i])]=gf(z2[i]),dlim--;
	}
	for (int i=1;i<=t2;i++){
		if (gf(h1[i])==gf(h2[i])){
			printf("No\n");
			return 0;
		}
	}
	ulim=(n-dlim)+dlim*(dlim-1)/2;
	if (dlim==2){
		if (t2)write(0);
		else write(m==n-1);
		return 0;
	}
	if (t2)dlim=n;
	else dlim=n-1;
	write(dlim<=m&&m<=ulim);
	
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> x(n);
  for (ll i = 0; i < n; ++i) {
    cin >> x[i];
  }

  ll ans = 1e18+1;
  for (ll i = 1; i <= 100; ++i) {
    ll c = 0;
    for (ll j = 0; j < n; ++j) {
      c += ((x[j] - i) * (x[j] - i));
    }
    ans = min(ans, c);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    AB=[]
    BA=[]
    for i in range(N):
        a,b = MI()
        AB.append((a,b,i))
        BA.append((b,a,i))
    AB.sort(key = lambda x:x[0]+x[1],reverse = False)
    BA.sort(key = lambda x:x[0]+x[1],reverse = False)
    takahashi = 0
    aoki = 0
    eaten = set()
    for i in range(N):  
        if i&1:#青木
            a,b,c = BA.pop()
            while c in eaten:
                a,b,c = BA.pop()
            aoki += a
        else:
            a,b,c = AB.pop()
            while c in eaten:
                a,b,c = AB.pop()
            takahashi += a
        eaten.add(c)
    ans = takahashi-aoki
    print(ans)

    

    


if __name__ == '__main__':
    main()

Measured memory_bytes: 82652
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, dp[maxn], k;
int h[maxn];
main () {
	cin >> n >> k;
	forn(i, 1, n)
		cin >> h[i];
	dp[1] = 0;
	forn(i, 2, n){
		dp[i] = inf * inf;
		forn(step, 1, k){
			int j = i - step;
			if(j >= 1)
				dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n];

}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int nrc(int n)
{
    int rez=0;
    while (n)
    {
        n/=10;
        rez++;
    }
    return rez;
}
int main()
{
    int n,nr=0;
    cin >> n;
    for (int i=1;i<=n;i++)
        if (nrc(i)%2==1) nr++;
    cout << nr;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define forj(j,n) for(int j=n; j>=0; j--)
#define forx(x,v) for(auto &x:v)
#define sz(v) (int)(v).size()
#define rz(n) resize(n)
#define vec(x) vector < x >
#define vvim(n,m,v) vvi v(n, vi(m))
using int64 = long long;
using vi = vector < int >;
using vi64 = vector < int64 >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "Yes\n", no = "No\n";


void dfs(int n, vec(bool) &mark, vi v[], int i, int &x) {
	if (i > n) return;
	mark[i] = 1;
	x++;
	for (int j : v[i]) {
		if (!mark[j]) {
			dfs(n, mark, v, j, x);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code

	int n, m;
	cin >> n >> m;
	vi v[n + 1];
	for0(i, m) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	int t = 0;
	vec(bool) mark(n + 1);
	for1(i, n) {
		int x = 0;
		if (!mark[i])
			dfs(n, mark, v, i, x);
		// cout << x << nwl;
		if (x and x < n) t++;
	}
	cout << max(0, (t - 1));





	return 0;
}




Measured memory_bytes: 10836
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(#x".in", "r", stdin),freopen(#x".out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void upd(T &a, T b) { (a += b) %= MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }


signed main(){
//  file(test) ;
	int a, b, c ; scanf("%d%d%d", &a, &b, &c) ;
	if (a == b && b == c) PRINT("Yes") ;
	else PRINT("No") ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/



Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))
    count = 0
    for i in range(N):
        aa = a[i]
        while aa%2==0 and aa>0:
            aa = aa//2
            count += 1
    return count

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 4148
n=int(input())
s='abcdefghijklmnopqrstuvwxyz'
bottom=[[] for i in range(10)]
bottom[0]=['a']

def solve(n):
    num=0
    while num<n:
        num=num+1
        for base in bottom[num-1]:
            for i in s[:num+1]:
                if i!='a' and chr(ord(i)-1) not in base:break
                bottom[num].append(base+i)

solve(n-1)
#print(*bottom[n-2])
print(*bottom[n-1],sep='\n')

Measured memory_bytes: 16364
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld %lld", &x, &y);
		z = (long long)sqrt(x*y);
		if (z*z == x*y)z--;
		if (x == y)ans = 2 * z;
		else if ((z*(z + 1)) < (x*y)){
			ans = 2 * z - 1;
		}
		else ans = 2 * z - 2;
		printf("%lld\n", ans);
	}




	return 0;
}

Measured memory_bytes: 128
import itertools
N,K = input().split()
D = list(map(int,input().split()))
int_list = set(range(10))
like = list(int_list - set(D))
like.sort()
min_cost = 10**6
for e in itertools.product(like,repeat = len(N)):
    result = 0
    for i in range(len(N)):
        result += e[i] * pow(10,i)
    if int(N) <= result < min_cost:
        min_cost = result
if min_cost == 10**6:
    head = like[0] if like[0] > 0 else like[1]
    min_cost = head * pow(10,len(N))
    for i in range(len(N)):
        min_cost += like[0] * pow(10,i)
print(min_cost)

Measured memory_bytes: 3064
S = input()
x, y = map(int, input().split())

D = map(len, S.split("T"))
X, Y = {next(D)}, {0}
for i, d in enumerate(D, 1):
    if i % 2 == 0:
        X = {x + d for x in X} | {x - d for x in X}
    else:
        Y = {y + d for y in Y} | {y - d for y in Y}

if x in X and y in Y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4964
from scipy.sparse.csgraph import breadth_first_tree, breadth_first_order
from scipy.sparse import csr_matrix, coo_matrix
N, M = map(int,input().split())
A = []
B = []
for i in range(M):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    A.append(a)
    B.append(b)
D = [1] * M
csr = coo_matrix((D, (A, B)), (N, N)).tocsr()
Tcsr = breadth_first_order(csr, 0, False, True)
ans = []
for i in Tcsr[1][1:]+1:
    if i == -9998:
        print("No")
        quit()
    ans.append(i)
print("Yes")
for i in ans:
    print(i)

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

using namespace std;
const int N = 100;
bool A[N][N];
bool B[N][N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < n; j++) {
            A[i][j] = s[j] == '.' ? true : false;
        }
    }
    for (int i = 0; i < m; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            B[i][j] = s[j] == '.' ? true : false;
        }
    }
    for (int i = 0; i + m <= n; i++) {
        for (int j = 0; j + m <= n; j++) {
            bool res = true;
            for (int u = 0; u < m; u++) {
                for (int v = 0; v < m; v++) {
                    if (B[u][v] != A[i + u][j + v]) {
                        res = false;
                        break;
                    }
                }
                if (!res)
                    break;
            }
            if (res) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
string s;
ll suf1[4005],suf2[4005],suf3[4005];
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n>>s;ll len = s.size();ll ans = 0;
		if(s[len-1]=='R')suf1[len-1] = 1;else suf1[len-1] = 0;
		if(s[len-1]=='B')suf2[len-1] = 1;else suf2[len-1] = 0;
		if(s[len-1]=='G')suf3[len-1] = 1;else suf3[len-1] = 0;
		for(ll i=len-2;i>=0;i--)
		{
			suf1[i] = suf1[i+1];
			if(s[i]=='R')suf1[i]++;
		}
		for(ll i=len-2;i>=0;i--)
		{
			suf2[i] = suf2[i+1];
			if(s[i]=='B')suf2[i]++;
		}
		for(ll i=len-2;i>=0;i--)
		{
			suf3[i] = suf3[i+1];
			if(s[i]=='G')suf3[i]++;
		}

		for(ll i=0;i<len;i++)
		{
			for(ll j = i+1;j<len;j++)
			{
				if(s[i] == 'R'&&s[j]=='B')
				{
					//cout<<"HI1";
					ans += suf3[j];
					if(j+j-i<len&&s[j+j-i]=='G')ans--;
				}
				if(s[i] == 'B'&&s[j]=='R')
				{
					ans += suf3[j];//cout<<"HI2";
					if(j+j-i<len&&s[j+j-i]=='G')ans--;
				}
				if(s[i] == 'R'&&s[j]=='G')
				{
					ans += suf2[j];
					if(2*j-i<len&&s[j+j-i]=='B')ans--;
					//cout<<"HI3";
				}
				if(s[i] == 'G'&&s[j]=='R')
				{
					ans += suf2[j];//cout<<"HI4";
					if(2*j-i<len&&s[j+j-i]=='B')ans--;
				}
				if(s[i] == 'B'&&s[j]=='G')
				{
					ans += suf1[j];//cout<<"HI5";
					if(2*j-i<len&&s[j+j-i]=='R')ans--;
				}
				if(s[i] == 'G'&&s[j]=='B')
				{
					ans += suf1[j];//cout<<"HI6";
					if(2*j-i<len&&s[j+j-i]=='R')ans--;
				}
			}
		}
		cout<<ans;


}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    
}

Measured memory_bytes: 6028
#include<stdio.h>

int gcm(int a,int b);
int lcm(int a,int b);

int main(void){
  int n,a[10];
  int l;

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  l=a[0];
  for(int i=1;i<n;i++){
    if(l>a[i]){ l=lcm(l,a[i]); }
    else{ l=lcm(a[i],l); }
  }
  printf("%d\n",l);

  return 0;
}


int gcm(int a,int b){//ユークリッドの互除法
  if(b==0) return a;
  return gcm(b,a%b);
}

int lcm(int a,int b){
  return (a*b)/(gcm(a,b));
}



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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    vector<int> d;
    d={a,b,c};
    sort(d.begin(),d.end());
    cout << d[2]-d[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return

#B
def B():
    a, b = LI()
    ans = 0
    b -= 1
    while b > 0:
        b -= a - 1
        ans += 1
    print(ans)

    return

#C
def C():
    n = II()
    h = LI()
    i = 0
    ans = 0
    while i < n:
        down = i+1
        while down < n:
            if h[down - 1] >= h[down]:
                down += 1
            else:
                break
        ans = max(ans, down - i - 1)
        i = down
    print(ans)
    return

#D
def D():
    n = II()
    print(n * (n - 1) // 2)
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39408