akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.M_Solutions_2020
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] abc = ReadInts();
            int a = abc[0];
            int b = abc[1];
            int c = abc[2];
            int k = ReadInt();

            int cnt = 0;
            while (a >= b)
            {
                b *= 2;
                cnt++;
            }
            while (b >= c)
            {
                c *= 2;
                cnt++;
            }

            WriteLine(cnt <= k ? "Yes" : "No");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27524
def divisors(N):
    U = int(N ** 0.5)
    res = []
    for i in range(1, U):
        if N % i == 0:
            res += [i, N // i]
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


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

int main(){
  int n; cin>>n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){cin>>vec.at(i);}
  int mini=vec.at(0),count=0;
  for(int i=0; i<n; i++){
    mini=min(vec.at(i),mini);
    if(mini==vec.at(i))count++;
  }
  cout<<count;
}










Measured memory_bytes: 1024
// 29/07/19 // 7:10 PM //

#include <iostream>
#include <cstring>

using namespace std;

#define MAXN 110
#define MAXW 100010

int n, w;
int weight[MAXN], value[MAXN];

long long memo[MAXN][MAXW];

long long knapsack(int i, int over){
    if(memo[i][over]>=0) return memo[i][over];

    if(i>n) return memo[i][over] = 0LL;

    long long take=0LL, dtake = dtake = knapsack(i+1, over);;

    if(over-weight[i]>=0)
        take = value[i] + knapsack(i+1, over-weight[i]);

    return memo[i][over] = max(dtake, take);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    memset(memo, -1, sizeof(memo));

    cin >> n >> w;

    for(int i=1; i<=n; i++)
        cin >> weight[i] >> value[i];

    cout << knapsack(1, w) << "\n";

    return 0;
}


Measured memory_bytes: 86272
import sys
# input = sys.stdin.readline()
N = int(input())
A = list(map(int,input().split()))
sum_r = 0
# print(A[0::2])
# print(A[1::2])
sum_odd = 0
sum_even = 0
for i in range(N):
    a = A[i]
    sum_r += a
    if i % 2 == 0:
        sum_odd += a
    else:
        sum_even += a

ans = ''
rolling_even = sum_even 
rolling_odd = sum_odd - A[0]
#print(sum_r,sum_even)
X_i = sum(A) - 2 * sum(A[1::2])
sys.stdout.write(str(X_i))
for i in range(N-1):
    X_i_plus_1 = 2 * A[i] - X_i
    sys.stdout.write(' ' + str(X_i_plus_1))
    X_i = X_i_plus_1
# ans += str(sum_r - 2 * rolling_even) + ' ' + str(sum_r - 2 * rolling_odd)
# sys.stdout.write(ans + ' ')
# mepo = A[1]
# mope = A[0]
# for i in range(2,N):
#     tmp = sum_r

#     if i % 2 == 0:
#         # rolling_even += A[(i-2)%N] - A[(i-1)%N]
#         mepo = A[(i-1)]
#         rolling_even += mope - mepo
#         tmp = sum_r - 2 * rolling_even
#     else:
#         mope = A[(i-1)]
#         rolling_odd += mepo - mope
#         tmp = sum_r - 2 * rolling_odd
#     sys.stdout.write(' '+str(tmp))
#     ans += ' ' + str(tmp)
# sys.stdout.write('\n')




Measured memory_bytes: 63856
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
 
long long mod = 1000000007;
const long long N=2e5+10;

long long a[N];

long long cnt[N];

int main() {
    
    long long n;
    cin>>n;
    long long sum=0;
    for(long long i=1;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
        
        sum+=a[i];
    }
    long long q;
    cin>>q;
    while(q--){
        long long B,C;
        cin>>B>>C;
        
        sum -= cnt[B]*B;
        sum += cnt[B]*C;
        cnt[C]=cnt[C]+cnt[B];
        cnt[B]=0;
        cout<<sum<<'\n';
        
    }
    
    return 0;
}


Measured memory_bytes: 5108
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


# --------------------------------------------

dp = None


def main():
    N = int(input())
    S = [input() for _ in range(N)]

    if len(set(S)) != N:
        print("No")
        return

    i = 0
    while i < len(S) - 1:
        if S[i][-1] != S[i + 1][0]:
            print("No")
            return
        i += 1
    
    print("Yes")


main()


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

int main(void)
{
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (U == S) {
        A--;
    }
    else if (U == T) {
        B--;
    }
    cout << A << " " << B << endl;
}


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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second
#define mset(x,v) memset((x),(v),sizeof(x))

typedef pair<int, int> PII;
typedef long long ll;

const int MOD = 1e9+7;

int fac[1000005],n,ans;
int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	for (int i=1;i<=1e6;i++) {
		for (int j=0;j<=1e6;j+=i) fac[j]++;
	}
	cin >> n;
	for (int i=1;i<n;i++) ans+=fac[i];
	cout << ans << "\n";
}

Measured memory_bytes: 7504
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	string s; cin >> s;
	for (int i = 0; i < 19; i++) {
		if (s[i] == ',') s[i] = ' ';
	}

	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n, k;
	cin >> n >> k;
 
	ll h[n];
	rep(i, n) cin >> h[i];
 
	ll INF = 1e13;
	ll c[n];
	rep(i, n) c[i] = INF;
	c[0] = 0;
 
	for(int i = 1; i < n; i++){
		for(int j = max(i-k, 0); j < i; j++){
			c[i] = min(c[i], c[j] + abs(h[j] - h[i]));
		}
	}
 
	cout << c[n-1] << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int num=0;

		for(int i=a;i<=b;i++){
			int man=i/10000;
			int sen=(i-man*10000)/1000;
			int jyu=(i%100)/10;
			int iti=i%10;
			if(man==iti && sen==jyu) num++;
		}

		System.out.println(num);

	}
}

Measured memory_bytes: 21844
using System;

public class Test
{
	public static void Main()
	{
	        int s=0,m=0,h=0; //s=?§?,m=???,h=??????
            s = int.Parse(Console.ReadLine());
            h = s / 3600;//???????±?????????????
            s = s % 3600; //???????§?
            m = s / 60;
            s = s % 60;
            Console.WriteLine("{0}:{1}:{2}",h,m,s);

	}
}

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,x,t;
	cin>>n>>x>>t;
	if (n%x==0)
	{
		n/=x;
	}
	else
		n=n/x+1;
	if(n!=0)
		cout<<n*t;
	else
		cout<<t;
}

Measured memory_bytes: 3612
x = int(input())

if x <= 9:
  print(x)
elif x <= 99:
  print(9)
elif x <= 999:
  print(9+(x-99))
elif x <= 9999:
  print(909)
elif x <= 99999:
  print(909+(x-9999))
elif x==100000:
  print(90909)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int s,j,m,i=0;
  int d[1000000];
  scanf("%d",&s);
  d[0]=s;
  while(i<1000000){
    i++;
    if(d[i-1]%2==0){
      d[i]=d[i-1]/2;
    }else{
      d[i]=3*d[i-1]+1;
    }
    for(j=0;j<i;j++){
      if(d[j]==d[i]){
        m=i+1;
        printf("%d\n",m);
        return;
      }
    }
  }
}

Measured memory_bytes: 128
import fractions

def devided(x):
    y = x
    devisors = 1
    for i in range(2, int((y**0.5)) + 1):
        if (x % i) == 0:
            devisors += 1
            while (x % i == 0):
                x //=  i
        else:
            continue
    if x > 1:
            devisors += 1
    return devisors

get = input().split()
A = int(get[0])
B = int(get[1])

C = fractions.gcd(A,B)

print(devided(C))

Measured memory_bytes: 5052
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
        self.links = [0] * n
        self.nodes = [1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            self.links[r1] += 1
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
            self.links[r1] += self.links[r2] + 1
            self.nodes[r1] += self.nodes[r2]
            return
        else:
            self.table[r1] = r2
            self.links[r2] += self.links[r1] + 1
            self.nodes[r2] += self.nodes[r1]
            return


n, m = map(int, input().split())
uft = UnionFind(n + 1)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uft.union(a, b)
r1, r2 = uft._root(0), uft._root(1)
for i in range(2, n):
    ri = uft._root(i)
    if r1 != ri and r2 != ri:
        uft.union(n, i)
rn = uft._root(n)
l1, l2, ln = uft.links[r1], uft.links[r2], uft.links[rn]
n1, n2 = uft.nodes[r1], uft.nodes[r2]
others = n - n1 - n2
ln -= others
add1_1 = (n1 + others) * (n1 + others - 1) // 2 - l1 - ln
add1_2 = n2 * (n2 - 1) // 2 - l2
add2_1 = n1 * (n1 - 1) // 2 - l1
add2_2 = (n2 + others) * (n2 + others - 1) // 2 - l2 - ln
print(max(add1_1 + add1_2, add2_1 + add2_2))


Measured memory_bytes: 7004
package main

import (
	"fmt"
	"strconv"
)

func month_like(s string) bool {
	i, _ := strconv.Atoi(s)
	return i > 0 && i <= 12
}

func main() {
	var s string
	fmt.Scan(&s)
	if b1, b2 := month_like(s[:2]), month_like(s[2:]); b1 && b2 {
		fmt.Println("AMBIGUOUS")
	} else if !b1 && !b2 {
		fmt.Println("NA")
	} else if b1 {
		fmt.Println("MMYY")
	} else {
		fmt.Println("YYMM")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
//keep coding
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define f0(i,n) for(int i=0;i<n;i++) 
#define f1(i,n) for(int i=1;i<=n;i++)
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define MP make_pair
#define FF first
#define SS second
#define int long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
signed main()
{
  //  OJ;
    FIO;
char c;
cin>>c;
if(c>=65 && c<=92)
    cout<<'A'<<endl;
else if(c>=97 && c<=122)
    cout<<'a'<<endl;

return 0;
   
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200005
#define MAXP 10005
#define LL long long int
LL f[2][MAXN];
char s[MAXN];
int n,prime,p;
LL ans;
map<int,int> mp;
int main()
{
    LL tmp1=1,tmp2=0;
    scanf("%d%d",&n,&p);
    scanf("%s",s+1);
    if(p!=2&&p!=5)
    {
        mp[0]++;
        for(int i=n;i>=1;i--)
        {
            tmp2=(tmp2+(s[i]-48)*tmp1)%p;
            tmp1=(tmp1*10)%p;
            ans+=mp[tmp2];
            mp[tmp2]++;
        }
    }
    else
    {
        for(int i=1;i<=n;i++)
        {
            int k=(i-1)&1;
            f[k][0]++;
            for(int j=0;j<p;j++)
            {
                if(f[k][j])f[i&1][(j*10+s[i]-48)%p]+=f[k][j];
                f[k][j]=0;
            }
            ans+=f[i&1][0];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

ll a,b,n; 

ll floor(ll N){
  ll fl1 = a*N/b;
  ll fl2 = N/b;
  ll ans = fl1-a*fl2;
  return ans;
}

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

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=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();}
	T=f?-x:x;
}

std::string a,b;

int main() {
	std::cin>>a>>b;
	int len2=b.length();
	std::string change=a+b[len2-1];
	if(change!=b) puts("No");
	else puts("Yes");
	return 0;
}

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

int main(void)
{
    int n; cin>>n;
    n %= 10;
    if(n==3) puts("bon");
    else if(n==0 || n==1 || n==6 || n==8) puts("pon");
    else puts("hon");
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	string ans = "";
	while (0 < N) {
		N--;
		int m = N % 26;
		ans = char('a' + m) + ans;
		N /= 26;
	}
	cout << ans << endl;
}







Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vector<pll> A(N);
  REP(i, N) {
    ll a;
    cin >> a;
    A[i] = make_pair(a, i);
  }
  sort(ALL(A));
  REP(i, N) cout << A[i].second + 1 << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 2432
#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;

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=modpow(2LL,n);
    ll num=1LL;
    for(ll i=n-a+1;i<=n;i++){
        num*=i;
        num%=mod;
    }
    for(ll i=1LL;i<=a;i++){
        num*=modpow(i,mod-2);
        num%=mod;
    }
    ans-=num;
    num=1LL;
    for(ll i=n-b+1;i<=n;i++){
        num*=i;
        num%=mod;
    }
    for(ll i=1LL;i<=b;i++){
        num*=modpow(i,mod-2);
        num%=mod;
    }
    ans-=num;
    ans--;
    ans%=mod;
    ans+=mod;
    ans%=mod;
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int p[123456] = {1, 1}, x;
    for (int i = 2; i <= 123444; i++) if (!p[i]) for (int j = i + i; j <= 123444; j += i) p[j] = 1;
    cin >> x;
    for (int i = x; ; i++) if (!p[i]) {
        cout << i;
        return 0;
    }
}


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll dp[10000007];
int main(){
  ll n;
  cin >> n;
  for (ll i = 1; i <= n;i++){
    for (ll j = 1; i * j <= n;j++){
      dp[i * j]++;
    }
  }
  ll sum = 0;
  for (ll i = 1; i <= n; i++){
    sum += i*dp[i];
  }
  print(sum);
}

Measured memory_bytes: 81708
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
typedef long long ll;

long long n, a, b;	ll hp[100001] = { 0 }, h[100001] = { 0 }, coun = 1, ookii = 0, ok = 1000000000, no = 0;

int chec(ll z) {
	for (int i = 0; i < n; i++)
	{
		hp[i] -= b*coun;
		if (hp[i] > 0) {
			ookii += hp[i] / a + !!(hp[i] % a);
			if (ookii > coun) {
				break;
			}
		}
	}
	if (ookii <= coun) {
		ok = coun;
	}
	else {
		no = coun;
	}
	return coun;
}

int main()
{
	cin >> n >> a >> b;
	a = a - b;

	REP(i, n) {
		cin >> h[i];
	}

	while (1) {
		REP(i, 100001) { hp[i] = h[i]; }
		ookii = 0;
		coun = (no + ok) / 2;
		if (ok - no < 2) {
			cout << ok << endl; break;
		}
		chec(coun);
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define H_MAX 50
#define W_MAX 50

int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int H,W;

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}

int main() {

  int a,b;
  cin >> a >> b;
  cout << a*b-a-b+1 << endl;
  

  return 0;
}
 


Measured memory_bytes: 256
#include <stdio.h>
int c[100];
int main()
{
  int n,i,m=0;
  while((scanf("%d",&n)) != EOF){
    c[n-1]++;
  }
  for(i=0;i<100;i++){
    if(m<c[i]) m=c[i];
  }
  for(i=0;i<100;i++){
    if(m==c[i]) printf("%d\n", i+1);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int a[100005];
bool b[100005]={0};//deng 
int main()
{
	int n,tmp=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	b[1]=1;
	int j=a[1];
	while(1){
		if(b[j]==1){
			printf("-1");
			break;
		}
		b[j]=1;
		j=a[j];
		++tmp;
		if(b[2]==1){
			printf("%d",tmp);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    int p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}//gcd

int main()
{
    int r;
    cin >> r;
    cout << 3*r*r;
}

Measured memory_bytes: 256
n,x,y=map(int,input().split())
l=[0]*n

for i in range (1,n+1):
  for j in range(i+1,n+1):
    l[min(j-i,abs(x-i)+1+abs(y-j))]+=1
    
for m in l[1:]:
  print(m)

    
    
    
    
          

Measured memory_bytes: 9284
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    ll ans=v[0];
    for(ll i=0;i<n;i++)ans=__gcd(ans,v[i]);
    cout<<ans;
}

Measured memory_bytes: 1024
def resolve():
    S = int(input())
    MOD = 10**9 + 7
    dp = [0 for _ in range(S+1)]
    if S <= 2:
        print(0)
        return
    if S < 6:
        print(1)
        return
    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    for i in range(6, S+1):
        k = 3
        while i - k >= 3:
            dp[i] += dp[i-k]
            dp[i] %= MOD
            k += 1
        dp[i] += 1
    print(dp[S])


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 64628
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var a = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var b = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var c = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(a);
        Array.Sort(b);
        var ba = new long[num];
        ba[0] = Search.LowerBound(a, b[0]);
        for (var i = 1; i < num; i++)
        {
            ba[i] = ba[i - 1] + Search.LowerBound(a, b[i]);
        }
        var result = 0L;
        for(var i = 0; i < num; i++)
        {
            var s = Search.LowerBound(b, c[i]);
            if (s != 0)
                result += ba[s - 1];
        }
        WriteLine(result);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

public class Search{
  public static int LowerBound(int[] array, int value)
    {
        var low = 0;
        var high = array.Length;
        while (high > low)
        {
            var mid = (high + low) / 2;
            if (array[mid] >= value) high = mid;
            else low = mid + 1;
        }
        return low;
    }
}

Measured memory_bytes: 38480
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int  n;
  int mt;
  vector<int> m;

  cin  >> n;
  for (int i = 0; i < n; ++i) {
    cin >> mt;
    m.push_back(mt);
  }
  // for (auto l : m) {
  //   cout << l << endl;
  // }

  int twos = 0;
  for(int i : m){
    if(i<2)
      continue;
    int lo=0;
    while(i%2 == 0){
      i=i/2;
      lo++;
    }
    // cout<<lo<<endl;
    twos+=lo;
  }
  cout<<twos<<endl;
  // int minn = *min_element(p.begin(), p.end());
  // cout << minn << endl;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split(" ")))

i = 0
c = 0
while i < n:
    if i == n - 1:
        c += 1
        break
    if a[i] == a[i+1]:
        i += 1
    elif a[i] < a[i+1]:
        while i < n - 1 and a[i] <= a[i+1]:
            i += 1
        c += 1
        i += 1
    elif a[i] > a[i+1]:
        while i < n - 1 and a[i] >= a[i+1]:
            i += 1
        c += 1
        i += 1
print(c)

Measured memory_bytes: 20296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

ll n,a,b,c,d;
str s1,s2;

int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  
  cin >> n;
  cout<<n*n*n;

 
  cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import static java.lang.System.out;

class SortingThreeNumbers {

    public static int[] sorted( int[] inputs) {
        int[] res = Arrays.copyOf( inputs, inputs.length );

        for ( int i = 0; i < res.length; i++ ) {
            for ( int j = 1; j < res.length - i; j++ ) {
                if ( res[j - 1] > res[j] ) {
                    int tmp = res[j - 1];
                    res[j - 1] = res[j];
                    res[j] = tmp;
                }
            }
        }

        return res;
    }

}

public class Main {
    public static void main( String... args) {
        Scanner scan = new Scanner( System.in);
        int[] inputs = new int[3];
        int i = 0;
        while ( scan.hasNext() ) {
            inputs[i] = scan.nextInt();
            i++;
        }

        StringBuilder output = new StringBuilder();
        for ( int num : SortingThreeNumbers.sorted( inputs ) ) {
            output.append( String.valueOf( num ) + " ");
        }
        output.deleteCharAt( output.length() - 1);
        out.println( output );
    }
}

Measured memory_bytes: 26188
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
int A[999999], W[999999];
long long merge_and_count(int l, int r) { // range [l,r)
    if (l+1 >= r) return 0; // empty
    if (l+2 == r) { // [l,r) == [l,l+1] 要素2つだけ
        if (A[l] <= A[l+1]) return 0; // 逆転はなし
        std::swap(A[l], A[l+1]);
        return 1; // 逆転一つ
    }
    int m = (l+r)/2; // [l,r) == [l,m) + [m,r)
    long long cl = merge_and_count(l, m); // 左半分を再帰的に数える
    long long cr = merge_and_count(m, r); // 右半分を再帰的に数える
    long long c = 0; // 左と右を混ぜるときの逆転数
    int i=l, j=m; // iは[l,m)を動き, jは[m,r)を動いて、
    int k=l; // 小さいものから W[k] に書き込む
    while (i<m && j<r) { // A[i]とA[j]を比べながら進む
        if (A[i] <= A[j]) W[k++] = A[i++]; // 左半分の方が小さく逆転なし
        else {
            W[k++] = A[j++];
            c += m-i; // 左半分の方が大きい、左半分で未処理の要素だけ飛び越える
        }
    }
    while (i<m) W[k++] = A[i++]; // 左半分が余った場合
    while (j<r) W[k++] = A[j++]; // 右半分が余った場合
    //assert(k == r);
    std::copy(W+l, W+r, A+l);
    return cl + cr + c;
}
int main(){
    int T,i,N;
    //PKU2299,aizu0167: バブルソートの交換回数
    //for(;scanf("%d",&N),N;printf("%lld\n",merge_and_count(0,N)))for(i=0;i<N;i++)scanf("%d",A+i);
    //hackerrank~runningtime
    scanf("%d",&N);for(i=0;i<N;i++)scanf("%d",A+i);printf("%lld\n",merge_and_count(0,N));
    //spojINVCNT,hackerrank~insertionsort
    //for(scanf("%d",&T);T--;printf("%lld\n",merge_and_count(0,N)))for(scanf("%d",&N),i=0;i<N;++i)scanf("%d",A+i);
    //codeiq432: 光線の交差数
    //for(N=0;~scanf("%d",A+N);N++);printf("%lld\n",merge_and_count(0,N));
    //codeiq838: あみだくじの最小本数
    //T=0,N=7;
    //std::vector<int>v(N);
    //std::iota(v.begin(),v.end(),1);
    //do{std::copy(v.begin(),v.end(),A);if(merge_and_count(0,N)==10)T++;}while(std::next_permutation(v.begin(),v.end()));
    //printf("%d\n",T); //573
    //kcs1009K: Nパズルの可解性
    //for(i=0;~(N=getchar());)if('0'<N&&N<'9')A[i++]=N-'0';
    //puts(merge_and_count(0,i)%2?"lmpossible":"Possible"); //"l"? lol!
}


Measured memory_bytes: 4332
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        if (a == 0) {
            System.out.println("0");
            return;
        }
        long d = a + b;
        long q = n / d;
        long r = n % d;
        long blue = (q * a) + (a < r ? a : r);
        System.out.println(blue);
    }
}

Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],sum=0;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		sum+=a[i];
	}
	cout<<sum-n;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;scanf("%d",&n);
    char s[n+1];scanf("%s",s);

    int r,g,b;r=g=b=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    int cnt=0;
    for(int i=1;i<n-1;i++){
        int dist=1;
        while(i-dist>=0&&i+dist<n){
            if(s[i-dist]!=s[i]&&s[i]!=s[i+dist]&&s[i-dist]!=s[i+dist])
                cnt++;
            dist++;
        }
    }
    long long ans;
    ans=r*g;
    ans*=b;
    ans-=cnt;
    printf("%lld\n",ans);
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main()
{
    ll n;
    cin >> n;
    ll cnt = 0;
    ll temp10 = 1, temp9 = 1, temp8 = 1;

    while (cnt < n)
    {
        temp10 *= 10;
        temp10 %= mod;
        temp9 *= 9;
        temp9 %= mod;
        temp8 *= 8;
        temp8 %= mod;
        cnt++;
    }
    ll ans=(temp10 - temp9 -temp9 + temp8) % mod ;
    ans=(ans+mod)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main(){

    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++){

        if(s[i] == '?'){
            if(s[i-1] == 'P'){
                s[i] = 'D';
            }
            else if(s[i+1] == 'D'){
                s[i] = 'P';
            }
            else if(s[i+1] == '?'){
                s[i] = 'P';
                s[i+1] = 'D';
            }
            else
            {
                s[i] = 'D';
            }
            
        }

    }

    cout << s;

    return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	ll a, b, n;
	cin >> a >> b >> n;
	if (b > n) {
		cout << a * n / b << endl;
	}
	else {
		cout << a * (b - 1) / b << endl;
	}
}

Measured memory_bytes: 3624
import sys
n = int(input())
heights = list(map(int, input().split()))

for i in range(1, n):
    if heights[i - 1] <= heights[i] - 1:
        heights[i] -= 1
    elif heights[i - 1] == heights[i]:
        pass
    else:
        print('No')
        sys.exit()

print('Yes')
    


Measured memory_bytes: 14252
for i in range (10000):
    a,op,b=input().split()
    if op == "?":
        break
    a=int(a)
    b=int(b)
    if op == "+":
        print(int(a+b))
    if op == "-":
        print(int(a-b))
    if op == "*":
        print(int(a*b))
    if op == "/":
        print(int(a/b))


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
/**  '' "\n" ^ **/


//typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
            // tree_order_statistics_node_update>
//    new_data_set;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int k;
    cin>>k;
    n--;
    for(int i=k-n;i<=k;i++){
            cout<<i;ps();
    }
    for(int i=k+1;i<=n+k;i++){
            cout<<i;ps();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int dp[MAXn];
int main(){
  IOS();
  int n;
  cin>>n;
  int k = 0;
  REP(i,n){
    int x;
    cin>>x;
    dp[x] = dp[x-1]+1;
  }
  REP1(i,n) chkmax(k,dp[i]);
  cout<<n-k<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define lvi vector<long long>
#define pi pair<int,int>
#define lpi pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define ll long long 
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mod1 1000000000000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>multiordered_set;
ll int pw(ll int a, ll int b,ll md) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2,md);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
vector<int> pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.push_back(p);
}
bool cmp(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    if(a.first==b.first)return a.second<b.second;
    return a.first>b.first;
}
ll int gcd(ll int a,ll int b)
{
    if(!a)return b;
    return gcd(b%a,a);
}
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 
map<int,int>pa;
int find(int i){
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}     
void join(int i,int j){
    int a=find(i);
    int b=find(j);
    if(b>=a)pa[b]=a;
    else pa[a]=b;
}               
int ddx[]={-1,-1,-1,0,1,1,1,0};
int ddy[]={-1,0,1,1,1,0,-1,-1};
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int main()
{
    faltu;
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        int cnt=0;
        int mn=t.length();
        for(int i=0;i<s.length();i++)
        {
            cnt=0;
            int ind=i+t.length();
            if(ind>s.length())break;
            for(int j=i;j<ind;j++){
            if(s[j]!=t[j-i])cnt++;}
            mn=min(mn,cnt);
        }
        cout<<mn<<endl;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<int,int> P;

int main()
{
    int N;
    cin >> N;
    vector<int> x,y;
    x.resize(N);
    y.resize(N);
    rep(i,N){
        cin >> x[i] >> y[i];
    }
    
    ld dist=0.;
    rep(i,N){
        rep(j,N){
            dist+=sqrtf((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    dist/=N;
    cout << setprecision(10) <<dist << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String s = sc.nextLine();
		String p = sc.nextLine();

		boolean contain = false;

		if(s.contains(p)) {
			contain = true;
		}

		for(int i = 1;i<p.length();i++) {
			String end = p.substring(0,i);
			String start = p.substring(i);
			if(s.endsWith(end)){
				if(s.startsWith(start)) {
					contain = true;
				}
			}
		}

		if(contain) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}






	}
}


Measured memory_bytes: 26268
n = int(input())
A = list(map(int, input().split()))

MAX_N = max(A)+1
cnt = [0] * MAX_N 

for a in A:
  for i in range(a, MAX_N, a):
    if cnt[i] <= 2: cnt[i] += 1

ans = 0
for a in A:
  if cnt[a] == 1: ans += 1
print(ans)

Measured memory_bytes: 32376
#include <iostream>

int main()
{
  int A, B;
  scanf("%d", &A, sizeof(A));
  scanf("%d", &B, sizeof(B));
  
  int C, D, E;
    C = 2*A-1;
  	D = 2*B-1;
  	E = A + B;
  
  if(A >= B + 1)
  {
    printf("%d", C);
  }
  else
  {
    if(B >= A + 1)
    {
      printf("%d", D);
    }
    else
    {
      printf("%d", E);
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C; cin >> A >> B >> C;
  if (A < B &&A<=C && B>= C) cout << "Yes"<< "\n";
  else if (A > B &&A>=C && B<= C) cout << "Yes"<< "\n";
  else cout << "No"<< "\n";
}

Measured memory_bytes: 256
M, D = map(int, input().split())

countUp = 0
for mon in range(2, M+1):
    #print("Mon: ", mon)
    for day in range(2, D+1):
        d10 = day // 10
        d1  = day % 10
        if d10 < 2 or d1 < 2:
            continue
        if mon == d10 * d1:
            countUp += 1
            continue

print(countUp)

Measured memory_bytes: 3060
import queue

def bfs(maze,h,w,sy,sx):
    dist=[[-1 for _ in range(w)] for _ in range(h)]
    q=queue.deque([[sy,sx]])
    dist[sy][sx]=0
    while q:
        y,x=q.popleft()
        for dy,dx in d:
            ny,nx=y+dy,x+dx
            if 0<=ny<h and 0<=nx<w and dist[ny][nx]==-1 and maze[ny][nx]!='#':
                dist[ny][nx]=dist[y][x]+1
                q.append([ny,nx])
    return max([max(i) for i in dist])

h,w=map(int,input().split())
a=[input() for _ in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]
ans=0
for sy in range(h):
    for sx in range(w):
        if a[sy][sx]!='#':
            ans=max(ans,bfs(a,h,w,sy,sx))
print(ans)

Measured memory_bytes: 9608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var ca = T.ToCharArray();
		int N = T.Length;
		for(int i=0;i<N;i++) if(ca[i] == '?') ca[i] = 'D';
		Console.WriteLine(new String(ca));
		
	}
	String T;
	public Sol(){
		T = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18168
#include <stdio.h>

int main() 
{
    int a,b,c;
    scanf("%d %d %d", &a, &b,&c);
    if((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5 )||(a==7 && b==5 && c==5))
    {
        printf("YES");
    }else printf("NO");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0 ; i < int(N);i++)
using namespace std ;
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;

const ll mod = 1'000'000'007;

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

	int sum = 0 ;
	int N ;
	cin >> N ;
	vector<int> v(N);
	int x = 0 ;
	rep(i,N){
		cin >> v[i];
	}
	rep(i,N){
		sum = (sum +((ll)v[i]*x))%mod;
		x = (x+v[i])%mod;
	}
	cout << sum << endl;

	return 0 ;
}

Measured memory_bytes: 3992