akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node {
    int parent;
    int left,right;
};

struct Node T[MAX];
int n, D[MAX];



void print(int u){
    int i,c;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("depth = %d, ",D[u]);


    if(T[u].parent == NIL) printf("root, ");
    else if(T[u].left == NIL) printf("leaf, ");
    else   printf("internal node, ");

    printf("[");
    for(i=0, c=T[u].left; c!=NIL; i++, c=T[c].right){
        if(i) printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}
// 再帰的に深さを求める
void rec(int u, int p){
    D[u]=p;
    if(T[u].right !=NIL) rec(T[u].right, p); // 右の兄弟に同じ深さを設定
    if(T[u].left!=NIL) rec(T[u].left, p+1); // 最も左の子に自分の深さ+1を設定
}

int main(){
    int i,v,l,c,d,r;
    scanf("%d",&n);

       for(i=0; i<n; i++)
           T[i].parent = T[i].left=T[i].right=NIL;

    for( i=0; i<n; i++){
        scanf("%d%d",&v,&d);

    for(int j=0; j<d; j++){
        scanf("%d",&c);
        if(j==0) T[v].left=c;
        else T[l].right=c;
        l=c;
        T[c].parent = v;
    }
    }
    for(i=0;i<n;i++){

        if(T[i].parent == NIL) r=i;
    }
    rec(r,0);


   for(int i=0; i<n; i++) print(i);
    return 0;
}



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

vector<int> input;

void push(int n) {
    input.push_back(n);
}

int pop() {
    int n = input[input.size()-1];
    input.pop_back();
    return n;
}

int main() {
    string line;
    getline(cin, line);

    vector<string> s;
    while (true) {
        int pos = line.find(" ");
        if (pos == string::npos) { // 最後
            s.push_back(line);
            break;
        }
        s.push_back(line.substr(0, pos));
        line = line.substr(pos+1, line.size()-pos-1);
    }

    for (int i=0; i<s.size(); i++) {
        if (s[i] == "+" || s[i] == "-" || s[i] == "*") {
            int val1 = pop();
            int val2 = pop();
            int val;
            if (s[i] == "+") val = val2 + val1;
            else if (s[i] == "-") val = val2 - val1;
            else if (s[i] == "*") val = val2 * val1;
            push(val);
        } else {
            int n = atoi(s[i].c_str());
            push(n);
        }
    }

    cout << input[0] << endl;

    return 0;
}



Measured memory_bytes: 3204
#include <iostream>

using namespace std;

long K, ans, stock = 0;

int gcd(long a, long b) {
	while (b != 0) {
		stock = b;
		b = a % b;
		a = stock;
	}
	return a;
}

int main() {
	cin >> K;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				ans += gcd(gcd(i, j), k);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3192
def dfs(i, cost, skill):
    if i == n:
        if min(skill) >= x:
            return cost
        else:
            return INF
    updated_skill = [0] * m
    updated_cost = cost + C[i]
    for j in range(m):
        updated_skill[j] = skill[j] + A[i][j]
    return min(dfs(i + 1, cost, skill), dfs(i + 1, updated_cost, updated_skill))
    # return dfs(i + 1, updated_cost, updated_skill)
    # return dfs(i + 1, cost, skill)

    # skill1 = A[1][0] + A[2][0] + A[3][0]
    # skill2 = A[1][1] + A[2][1] + A[3][1]


    # return xxxxxxxxxxxxx


INF = float('inf')

n, m, x = map(int, input().split())
C = []
A = []

# n = 3
# m = 3
# x = 10
# C = [60, 70, 50]
# A = [
#     [2, 2, 4], [8, 7, 9], [2, 3, 9]
# ]

for _ in range(n):
    li = list(map(int, input().split()))
    C.append(li[0])
    A.append(li[1:])
# print(C)
# print(A)

min_cost = dfs(0, 0, [0] * m)
if min_cost == INF:
    print('-1')
else:
    print(min_cost)


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	
	std::vector<int> dp(n, 1000000001);
	dp[0] = 0;
	for (int i = 0; i + 1 < n; i++) {
		dp[i + 1] = std::min(dp[i + 1], dp[i] + std::abs(a[i] - a[i + 1]));
		if (i + 2 < n) dp[i + 2] = std::min(dp[i + 2], dp[i] + std::abs(a[i] - a[i + 2]));
	}
	std::cout << dp.back() << std::endl;
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
mozi = input()
a_list = []
for i in range(n):
    if mozi[i] == 'W':
        a_list.append(0)
    else:
        a_list.append(1)
r_count = sum(a_list)
print(r_count - sum(a_list[0:r_count]))

Measured memory_bytes: 12384
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(long long i=0;i<(ll)(n);i++)
using namespace std;
ll gcd(ll a,ll b){
    if(a<b){
      ll t=a;
      a=b;
      b=t;
    }
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  return ((ll)(a*b))/gcd(a,b);
}
int main(){
  //cout<<lcm(10000,100001)<<endl;
  ll n,m;
  cin>>n>>m;
  string s,t;
  cin>>s>>t;
  ll ans=lcm(n,m);

  ll N=ans/n;
  ll M=ans/m;
  rep(i,n){
    if ((i*N)%M!=0) continue;
    ll j=(i*N)/M;
      //cout<<s[i]<<","<<t[j]<<endl;
      if (s[i]!=t[j]){
        cout<<-1<<endl;
        return 0;
      }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 1010;

char s[N];
int main()
{
    scanf("%s", s);

    int len = strlen(s);
    bool fN = false, fS = false, fE = false, fW = false;
    for (int i = 0; i < len; i ++ )
        if(s[i] == 'N') fN = true;
        else if(s[i] == 'S') fS = true;
        else if(s[i] == 'E') fE = true;
        else fW = true;
    if(!fN && !fS) fN = fS = true;
    if(!fE && !fW) fE = fW = true;
    
    if(fN && fS && fE && fW)
        puts("Yes");
    else
        puts("No");
    
    return 0;
}

Measured memory_bytes: 3624
try:
    S = list(input())
    T = list(input())
    t = len(T)
    candidate = []
    for i in range(len(S)):
        tmp = S[i:i+t]
        for j in range(len(tmp)):
            if tmp[j] == T[j] or '?' == tmp[j]:
                pass
            else:
                break
        else:
            candidate.append(S[0:i]+T+S[i+t:len(S)])
    for i in range(len(candidate)):
        l = list(candidate[i])
        for j in range(len(l)):
            if l[j] == '?':
                l[j] = 'a'
        candidate[i]=l
    candidate = list(filter(lambda x:len(x)==len(S),candidate))
    candidate.sort()
    for x in candidate[0]:
        print(x,end='')
    print()
except:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    sc.close();
    
    String ans = S.replaceAll("hi", "");
    System.out.println(ans.length() == 0 ? "Yes" : "No");
  }
}


Measured memory_bytes: 22100
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]

# Greatest Common Divisor(Euclidean algorithm)


def gcd(x: int, y: int) -> int:
    if x < y:
        x, y = y, x
    while y > 0:
        r = x % y
        x, y = y, r
    return x


def main():
    n, k = input_int_list()
    A = input_int_list()
    A_max = max(A)
    # Aの最大値よりkが大きい場合は不可
    if k > A_max:
        print("IMPOSSIBLE")
        return

    A_gcd = A[0]
    for a in A:
        A_gcd = gcd(A_gcd, a)

    if k % A_gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 84404
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
 
const int MAXV = 200;
const int MAXM = 6;
const int INF = 1<<28;
int M, N, K, D, V;
int cal[MAXM];
int G[MAXV][MAXV];
 
void wf() {
  for(int k = M; k < V; ++k) {
    for(int i = 0; i < V; ++i) {
      for(int j = 0; j < V; ++j) {
	G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}
 
int main() {
  while(cin >> M >> N >> K >> D && (M|N|K|D)) {
    for(int i = 0; i < M; ++i) cin >> cal[i];
    fill(G[0], G[MAXV], INF);
    for(int i = 0; i < MAXV; ++i) G[i][i] = 0;
    V = M + 2 + N;
    int src = M;
    int dst = M+1;
    while(D--) {
      int v[2];
      for(int i = 0; i < 2; ++i) {
	int &a = v[i];
	char c;
	cin >> c;
	if(c == 'C') {
	  cin >> a;
	  --a;
	} else if(c == 'L') {
	  cin >> a;
	  --a;
	  a += M+2;
	} else if(c == 'H') {
	  a = src;
	} else if(c == 'D') {
	  a = dst;
	}
      }
      int d;
      cin >> d;
      G[v[0]][v[1]] = min(G[v[0]][v[1]], d);
      G[v[1]][v[0]] = min(G[v[1]][v[0]], d);
    }
 
    wf();
    vector<int> id;
    for(int i = 0; i < M; ++i) id.push_back(i);
    id.push_back(dst);
 
    int res = INF;
    do {
      int p = M;
      int c = 0;
      for(int i = 0; i < id.size(); ++i) {
	int np = id[i];
	if(G[p][np] == INF) {
	  c = INF;
	  break;
	}
	c += G[p][np]*K;
	if(np == dst) break;
	c -= cal[np];
	p = np;
      }
      res = min(res, c);
    } while(next_permutation(id.begin(), id.end()));
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1372
A, B, C, X, Y = list(map(int, input().strip().split()))
costmin = 5e9
for i in range(100001):
	cost = 0
	cost += i*C*2
	if X > i:
		cost += A*(X-i)
	if Y > i:
		cost += B*(Y-i)
	if cost < costmin:
		costmin = cost
print(costmin)

Measured memory_bytes: 3064
#include <iostream>
#include <set>

using namespace std;
#define int long long 

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

	int ans = 1;
	for(int i = 0;i < n;i++){
		if(i == 0){
			ans *= k; 
		}else{
			ans *= (k - 1); 			
		}
	}	
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a = in.nextLong();
		long b = in.nextLong();
		int c = in.nextInt();
		int d = in.nextInt();
		long cd = (long)c * (long)d / gcd(c,d);
		long ans_a = (a-1)/c + (a-1)/d - (a-1)/cd;
		long ans_b = b/c + b/d - b/cd;
		System.out.println(b-a+1-ans_b+ans_a);
		in.close();

	}
	
	//return gcd O(logN)
	public static int gcd(int num1,int num2) {
		if(num2==0) return num1;
		else return gcd(num2,num1%num2);
	}

}


Measured memory_bytes: 22868
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=10010;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)b - *(long long int*)a;
}
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}

int main(){
	int n, len, x, y;
	int ans=0;
	int bnuma[2][2]={};
//	long long int  a[N];
	char b[20];
	cin>>b;

	rep(i, strlen(b)){
		if(b[i]=='x')ans++;
	}
	if(ans<=7)printf("YES\n");
	else printf("NO\n");

//	cout<<(n-2)*180<<endl;
//		memset(b, '\0', sizeof(b));初期化
//    len = strlen(s);文字列長さ

}


Measured memory_bytes: 256
#include<stdio.h>
#define N 20
#define Q 200
int n,A[N],q,m[Q];
int S[N],bef;
int solve(int,int);

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    if(solve(0,m[i])) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  if(A[i]==m) return 1;
  else if(i+1 == n) return 0;
  else if(solve(i+1,m-A[i])||solve(i+1,m))return 1;
  else return 0;
}

Measured memory_bytes: 580
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	string s;
    cin>>s;
    sort(all(s));
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2])cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long int ll;
ll power(ll x,ll n)
{
	if(x==0) return 1;
	ll a=x,b=1;
	while(n)
	{
		if(n&1) b=((b%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n=n/2;
	}
	return b%mod;
}
ll inv(ll a,ll b){
	return (a*power(b,mod-2)%mod)%mod;
}
int main()
{

	// freopen("testcase1.txt","r",stdin);
	// freopen("output1.txt","w",stdout);

	ll s1=0,s2=0,i,n,t;
	// cin>>t;
	t=1;
	while(t--)
	{	
		s1=s2=0;
		cin>>n;
		ll a[n+2];
		for(i=0;i<n;i++)
			cin>>a[i];
		for(i=0;i<n;i++)
			s1=(s1%mod+a[i]%mod)%mod;
		// cout<<s1<<endl;
		for(i=0;i<n;i++)
			s2=(s2+((a[i]%mod)*((s1-a[i])%mod))%mod+mod)%mod;
		cout<<inv(s2,2)%mod<<endl;}
}

Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    char a;
    cin>>a;
    if(a <= 'Z' && a >= 'A'){
        cout<<"A";
    } 
    else{
        cout<<"a";
    }
    return 0;
}


Measured memory_bytes: 3584
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:i64 = read();
    let an:Vec<i64> = read_vec();
    let ans = (-100..101).fold(1e10 as i64,|y,x|{
        let sum:i64 = an.iter().map(|z| (z-x).abs().pow(2) ).sum();
        std::cmp::min(sum,y)
    });
    println!("{}",ans);
}


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

int main(){
  vector<int> a(201);
  int n;
  cin>>n;
  REP(i,n) cin>>a.at(i);
  int count=INT_MAX,c=0;
  
  REP(i,n){
    while(a.at(i)%2==0 && a.at(i)!=0){
      a.at(i)/=2;
      c++;
    }
    count=min(count,c);
    c=0;
  }
  cout<<count<<"\n";
//  REP(i,n) cout<<a.at(i)<<" ";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	string s;
	cin>>s;
	int w = 0;
	int l = 0;
	for(int i=0; i<s.size();i++){
		if(s[i]=='o'){
			w++;
		}else{
			l++;
		}
	}
	if(w+(15-w-l) >7){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [input() for _ in [0]*n]
if len(set(l)) != n:
    print('No')
else:
    for i in range(n-1):
        if l[i][-1] != l[i+1][0]:
            print('No')
            break
        else:
            continue
    else:
        print('Yes')


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    bool flag = true;
    for (int i = 0; i < S.size(); i++) {
        auto s = S[i];
        if (i % 2 == 1 && ! (s == 'L' || s == 'U' || s == 'D'))
            flag = false;
        else if (i % 2 == 0 && ! (s == 'R' || s == 'U' || s == 'D'))
            flag = false;
    }
    cout << (flag ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val scan = new java.util.Scanner(System.in)
  val in = scan.next.toInt
  val ss = for (i <- (1 to 10).toList) yield math.pow(6, i).toInt
  val ns = for (i <- (1 to 10).toList) yield math.pow(9, i).toInt
  val ms = 1 :: ss ::: ns

  val memo = Array.fill(ms.length+1, 100001)(100001)
  memo(0)(0) = 0
  for ((i, n) <- (1 to ms.length).zip(ms); l <- 0 to 100000) {
    memo(i)(l) = if (l-n >= 0) math.min(memo(i-1)(l), memo(i)(l-n) + 1) else memo(i-1)(l)
  }
  println(memo(ms.length)(in))
}

Measured memory_bytes: 40004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int L = ni();
        int R = ni();
        int d = ni();
        long ans = 0;
        for (int i = L; i <= R; i++) {
            if(i%d==0)ans++;
        }
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main() {
	string S, T;
	cin >> S >> T;
	vector<vector<int>> dp(S.size()+1, vector<int>(T.size()+1));
	
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < T.size(); j++) {
			if (S[i] == T[j]) {
				dp[i+1][j+1] = dp[i][j] + 1;
			}
			else if (dp[i+1][j] >= dp[i][j+1]) {
				dp[i+1][j+1] = dp[i+1][j];
			}
			else {
				dp[i+1][j+1] = dp[i][j+1];
			}
		}
	}

	string ans;
	int i = S.size() - 1;
	int j = T.size() - 1;
	while(i>=0 && j>=0) {
		if (S[i] == T[j]) {
			ans += S[i];
			i--;
			j--;
		}
		else if (dp[i+1][j+1] == dp[i+1][j]) {
			j--;
		}
		else {
			i--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}


Measured memory_bytes: 35584
#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;
int64_t dp[200][10][2];
int func(int i, int k, int over) {

    if (i == S.size()) {
        return k == 0 ? 1 : 0;
    }
    auto& memo = dp[i][k][over];
    if (memo != -1) {
        return memo;
    }


    for (int i = 1; i < 10; i++)
    {

    }

}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> S;

    return 0;
}
#endif


#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::vector<int> vec;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (size_t i = 0; i < N; i++)
    {
        int a;
        in >> a;
        vec.push_back(a);
    }
    std::sort(all_range(vec));
    auto iter = std::unique(all_range(vec));
    if (iter != vec.end()) {
        out << "NO" << endl;
    }
    else {
        out << "YES" << endl;
    }

    return 0;
}
#endif


Measured memory_bytes: 1400
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
     static int dx[]={1,-1,0,0};
      static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  // int n=sc.nextInt(), k=sc.nextInt();  
  // int s=sc.nextInt(), t=sc.nextInt(); 
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
   
    out.println((a<=c && c<=b) ? "Yes":"No");
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 23124
sk = ['R','U','D'];sg = ['L','U','D']
S = list(input())
flg = 'Yes'
for i in range(len(S)):
  if i%2 == 0:
    if sk.count(S[i]) == 0:
      flg = 'No'
      break
  else:
    if sg.count(S[i]) == 0:
      flg = 'No'
      break
print(flg)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	int A[n], sum=0;
	for(int i=0; i<n; i++){
		cin>>A[i];
		sum+=A[i];
	}
	float term=float(1/float(4*m))*sum;
	int k=0;
	// cout<<term<<" ";
	for(int i=0; i<n; i++)
		if(A[i]>=term)
			k++;
	if(k>=m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A)
n1, n2 = B[-1], B[-2]
if n1 == n2:
    for i in range(N):
        print(n1)
else:
    for n in A:
        print(n2 if n == n1 else n1)


Measured memory_bytes: 14112
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner n=new Scanner(System.in);
		double a=n.nextDouble();
		double b=a*a*Math.PI;
		double c=a*2*Math.PI;
		System.out.printf("%.6f %.6f",b,c);
	}
}

Measured memory_bytes: 18892
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <map>

template <typename T>
void read(T& x)
{
    x = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar());
    for (; isdigit(c); x = x * 10 + (c ^ 48), c = getchar());
}

int main()
{
    std::ios::sync_with_stdio(0);
    std::string s = "";
    std::cin >> s;
    for (int i = s.length(); i; --i)
        putchar('x');
    putchar('\n');
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll hcf(ll a,ll b)
{
  if(a==0)
  return b;
  else
  return hcf(b%a,a);
}
int main() 
{
	ll n,i,j,k,val=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)
    {
      for(k=1;k<=n;k++)
      {
          val+=hcf(k,hcf(i,j));
      }
    }
  }
  cout<<val;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
const int maxn=300100;
int ai[maxn];
int n;

bool check(int l,int r){
    int minx=n+10,maxx=0;
    for(int i=l;i<=r;i++){
        minx=min(minx,ai[i]);
        maxx=max(maxx,ai[i]);
    }
    if(minx<l||maxx>r) return true;
    int x1=0,x2=0;
    for(int i=l;i<=r;i++){
        if(ai[i]!=i){
            if(ai[i]>i){
                if(x1<ai[i]) x1=ai[i];
                else return true;
            }else{
                if(x2<ai[i]) x2=ai[i];
                else return true;
            }
        }
    }
    return false;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&ai[i]);
    for(int i=1;i<=n;i++){
        if(ai[i]!=i){
            int x;
            for(x=i;ai[x+1]==x+1&&ai[x+2]!=x+2;){
                x+=2;
            }
            x=min(x,n);
            //cout<<i<<"   "<<x<<endl;
            if(check(i,x)) return puts("No"),0;
            i=x;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int a, p;

    cin >> a >> p;

    p += a * 3;
    int res = p / 2;

    cout << res << endl;

 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	if (S == "SUN") cout << 7;
	if (S == "MON") cout << 6;
	if (S == "TUE") cout << 5;
	if (S == "WED") cout << 4;
	if (S == "THU") cout << 3;
	if (S == "FRI") cout << 2;
	if (S == "SAT") cout << 1;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace EDPC
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int W = int.Parse(input[1]);

            long[,] wv = new long[N, 2];
            for (int i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split(' ');
                wv[i, 0] = long.Parse(input[0]);
                wv[i, 1] = long.Parse(input[1]);
            }

            long[,] dp = new long[N + 10, W + 10];
            for (int i = 0; i <= W; i++)
            {
                dp[0, i] = 0;
            }

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j <= W; j++)
                {
                    if (0 <= j - wv[i, 0])
                    {
                        dp[i + 1, j] = Math.Max(dp[i, j], dp[i, j - wv[i, 0]] + wv[i, 1]);
                    }
                    else
                    {
                        dp[i + 1, j] = dp[i, j];
                    }
                }
            }

            Console.WriteLine(dp[N, W]);

        }
    }
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;

  for(int i = 0; i < a; ++i)
  {
    if(s[i] == '-')
    {
      cout << "No" << endl;
      return 0;
    }
  }
  if(s[a] != '-')
  {
    cout << "No" << endl;
    return 0;
  }
  for(int i = a+1; i < a+b+1; ++i)
  {
    if(s[i] == '-')
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main(){
    int n, i;
    long long c = 0;
    cin >> n;
    int a[n][2];
    for(i=0; i<n; i++){
        cin >> a[i][0] >> a[i][1];
    }
    for(i=n-1; i>=0; i--){
        if((a[i][0]+c)%a[i][1] != 0){
            c += (long long)a[i][1] - (a[i][0]+c)%a[i][1];
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ABC127C
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NM = CIN.LongArray();
            long N = NM[0];
            long M = NM[1];
            long[] L = new long[M];
            long[] R = new long[M];
            for (int i = 0; i < M; i++)
            {
                long[] LR = CIN.LongArray();
                L[i] = LR[0];
                R[i] = LR[1];
            }

            long MostL = -1;
            long MostR = N;

            for (int i = 0; i < M; i++)
            {
                MostL = Math.Max(MostL, L[i]);
                MostR = Math.Min(MostR, R[i]);
            }

            if (MostL > MostR)
            {
                Console.WriteLine(0);
                return;
            }

            Console.WriteLine(MostR - MostL + 1);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 18016
import scala.io.StdIn._


object Main extends App {
  implicit class Pipe[T](x: T) {
    def |>[U](f: T => U) = f(x)
  }

  readLine().split(" ").map(_.toInt).product |> { x =>
    if(x % 2 == 0) println("Even")
    else println("Odd")
  }
}

Measured memory_bytes: 25416
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  int n, x;
  cin >> n >> x;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  sort(a, a + n);

  int count = 0;
  ll sum = 0;
  for(int i = 0; i < n; i++){
    sum += a[i];
    if(sum <= x) ++count;
  }
  if(sum < x) --count;

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m, c, ans=0, x=0, fake=0;
	cin >> n >> m >> c;
	int a[m+1];
	for(int i=1;i<=m;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		ans=0;
		for(int i=1;i<=m;i++)
		{
			cin >> x;
			ans+=x*a[i];
		}
		if((ans+c)>0)fake++;
	}
	cout<<fake<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;

    if (n >= 1000) cout << "ABD" << endl;
    else cout << "ABC" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int l;
  cin >> l;

  vector<vector<int>> nxt(21, vector<int>(n, 0));
  rep(j, n) {
    int idx = upper_bound(x.begin(), x.end(), x[j] + l) - x.begin();
    idx--;
    nxt[0][j] = idx;
  }
  rep(i, 20) {
    rep(j, n) {
      nxt[i + 1][j] = nxt[i][nxt[i][j]];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);

    int ans = inf, res = 0;
    repr(i, 20) {
      if (nxt[i][a] >= b) chmin(ans, res + (1 << i));
      else {
        res += (1 << i);
        a = nxt[i][a];
      }
    }
    cout << ans << '\n';
  }


  




  
  return 0;
}

Measured memory_bytes: 12160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int count=0;
		for(int i=0;i<N-2;i++) {
			if(S.charAt(i)=='A' && S.charAt(i+1)=='B' && S.charAt(i+2)=='C') {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  l = []
  for i in range(-1, 102):
    l.append(i)
  for i in p:
    l.remove(i)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  print(ans)


Measured memory_bytes: 9196
def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans)
main()

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int a,b,c,d;
int ans,cnt;
int main()
{
	cin>>a>>b>>c>>d;
	if (a<=b)
		ans+=a;
	else
		ans+=b;
	if (c<=d)
		cnt+=c;
	else
		cnt+=d;
	cout<<ans+cnt<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 504
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)


MY_NAMESPACE(ABC169D)
vector<pll> prime_factorize(ll number)
{
	vector<pll> res;
	for (ll divisor = 2; divisor * divisor <= number; divisor++)
	{
		if (number % divisor != 0)
			continue;
		ll exponent = 0;
		while (number % divisor == 0)
		{
			number /= divisor;
			exponent++;
		}
		res.emplace_back(make_pair(divisor, exponent));
	}
	if (number != 1)
		res.emplace_back(make_pair(number, 1));
	return res;
}

int main()
{
	ll n;
	cin >> n;
	auto div_exps = prime_factorize(n);
	int res = 0;
	for (auto div_exp : div_exps)
	{
		ll exponent = div_exp.second;
		int i = 1;
		while (exponent > 0)
		{
			exponent -= i++;
			if (exponent >= 0)
				res++;
		}
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_


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

int main() {
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 1e18;
    for (ll i = 0; i <= max(x,y)*2; i++) {
        ans = min(ans, max(0LL, (x - i / 2)) * a + max(0LL, (y - i / 2)) * b + i * c);
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for(auto& a : A){
        cin >> a;
    }
    reverse(A.begin(), A.end());
    for(int ii=0; ii<n; ii++){
        if(ii!=0) cout << " ";
        cout << A[ii];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3084
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = 1

if all([i > 0 for i in a]):
  for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
      ans = -1
      break

  print(ans)

else:
  print(0)


Measured memory_bytes: 21712
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        int[] s = new int[5];
        for (int i = 0; i < 5; i++) s[i] = NextInt();
        int k = NextInt();
        Console.WriteLine((s.Max()-s.Min() > k? ":(":"Yay!"));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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


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

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


int main()
{
    ll X;
    cin >> X;
    ll money = 100;
    ll count = 0;
    while (X > money)
    {
        money += money / 100;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    ll n;
    cin >> n;
    ll mxdivi = 1;
    for(ll i = 2; i*i<=n; i++) {
        if (n%i == 0) mxdivi = i;
    }
    ll ans = mxdivi + n / mxdivi - 2;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3620
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int k;
string s;
main() {
  file("threesum");
  ios;
  cin >> k >> s;
  if (s.size() <= k) cout << s;
  else {
    cout << s.substr(0, k) << "...";
  }
  return 0;
}
/**

*/


Measured memory_bytes: 3652
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
 
#define ll long long
#define ull unsigned long long
#define ui unsigned int
 
using namespace std;
 
int N;
ll M;
ll a[100005];
ll lcm = 1;
 
ll get_gcd(ll a, ll b)
{
	if (a % b == 0) return b;
	return get_gcd(b, a % b);
}
 
int main()
{
	scanf("%d %lld", &N, &M);
	
	bool ans = true;
 
	for (int i = 0; i < N; ++i)
	{
		scanf("%lld", &a[i]);
		a[i] >>= 1;
 
		lcm = lcm * a[i] / get_gcd(lcm, a[i]);
		if (lcm > 1e9) ans = false;
	}
 
	if (ans)
	{
		for (int i = 0; i < N; ++i)
		{
			if (((lcm / a[i]) & 1LL) == 0)
			{
				ans = false;
				break;
			}
		}
	}
 
	if (ans) printf("%lld\n", (M / lcm + 1) / 2);
	else printf("0\n");
 
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main(void)
{
	int h,m,s,a,S;
	scanf("%d",&S);
	h=S/3600;
	a=S-(h*3600);
	m=a/60;
	s=a-(m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll N_MAX = 100005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    sort(A.begin(), A.end());
    vector<ll> B(N, 0);
    REP(i, N) B[i] = combination(i, K-1);

    ll res = 0;
    REP(i, N){
    	ll tmp = B[i] * A[i];
        /*
    	if(tmp<0){
    		ll kai = (abs(tmp)/mod);
    		tmp += (kai+2) * mod;
    	}
        tmp %= mod;
        */
    	tmp = ((tmp%mod)+mod)%mod;
    	res += tmp;
    	res %= mod;
    }

    REP(i, N){
    	ll tmp = B[N-i-1] * A[i];
        /*
    	if(tmp<0){
    		ll kai = (abs(tmp)/mod);
    		tmp += (kai+2) * mod;
    	}
        tmp %= mod;
        */
    	tmp = ((tmp%mod)+mod)%mod;
    	//tmp = (tmp+mod)%mod;
    	res -= tmp;
    	res = (res+mod)%mod;
    }
    cout << res << endl;
    //cout << B << endl;

    return 0;
}

Measured memory_bytes: 4224