akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
	int n;
	double res;
	while (cin >> n) {
		if (n == -1) break;
		res = n / 2.0;

		while (1) {
			res -= (res*res*res - n) / (3 * res*res);
			if (fabs(res*res*res - n) < 0.00001 * n) break;
		}
		printf("%.6lf\n", res);
	}
	return 0;
}

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

long long fone(long long n) {
	if (n <= 0) return 0;
	if (n % 4 == 3) return 0;
	return fone(n - 1) ^ n;
}

int main()
{
	long long A, B;
	cin >> A >> B;

	cout << (fone(A-1) ^ fone(B)) << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	ans := 0
	for i := 0; i < N; i++ {
		l, r := getInt(), getInt()
		ans += r - l + 1
	}
	out(ans)
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> V(N);
  for (int i=0; i<N; i++) {
    cin >> V[i];
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  long long S=0;
  for (int i=K; i<N; i++) {
    S+=V[i];
  }
  cout << S << endl;
}

Measured memory_bytes: 4844
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)


s = input()
if(s[2] == s[3] and s[4] == s[5]):
	print('Yes')
else:
	print('No')


Measured memory_bytes: 6248
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;




int main(){
    LL x,y;cin >> x >> y;
    if(abs(x-y)<=1) puts("Brown");
    else puts("Alice");
    return 0;
}



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

int main() {
	string s; cin >> s;
	set<char> se;
	for (int i = 0; i < (int)s.size(); i++) {
		se.insert(s[i]);
	}
	if ((int)se.size() == (int)s.size())
		cout << "yes" << endl;
	else
		cout << "no" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
//Graph I - Depth First Search
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

//WHITE -> ????¨?????????????
//GRAY  -> ?¨????????????????(?¨?????????????????¨???????????????????????????????????????§???????????????)
//BLACK -> ?¨??????????????????????(????¨???????????????????????????????????????????)

int n, M[N][N];
int color[N];//?????????????¨??????¶???
int d[N];//????????????
int f[N];//????????????
int tt;//time stamp

//?????°???????????±???????????¢?´¢
void dfs_visit( int u )
{
	int v;
	color[u] = GRAY;
	d[u] = ++tt;//??????????¨????
	for( v = 0; v < n; v++ ){
		if( M[u][v] == 0 ) continue;
		if( color[v] == WHITE ){
			dfs_visit( v );
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;//?¨?????????????
}
void dfs()
{
	//??¨???????????????color???WHITE????¨????
	for( int u = 0; u < n; u++ ) color[u] = WHITE;
	tt = 0;
	for( int u = 0; u < n; u++ ){
		//????¨??????? u ?????°??????????§?????????¨????????±???????????¢?´¢
		if( color[u] == WHITE ) dfs_visit( u );
	}
	for( int u = 0; u < n; u++ ){
		cout << u + 1 << " " << d[u] << " " << f[u] << endl;
	}
}
int main()
{
	int u;//???????????????
	int k;//??????u?????£??\?????????????????????
	int v;//??????u????¬???°

	cin >> n;

	for( int i = 0; i < n; i++ ){
		for( int j = 0; j < n; j++ ){
			M[i][j] = 0;
		}
	}
	for( int i = 0; i < n; i++ ){
		cin >> u >> k;
		u--;
		for( int j = 0; j < k; j++ ){
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	dfs();
	return 0;
}

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

int main(void){
    int x, y, z;
    cin >> x >> y >> z;

    int cnt = 0;
    int residue = x;

    //first 

    residue = residue -2 * z - y;
    cnt++;

    while(residue >= y + z){
        residue =  residue - z - y;
        cnt++; 
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,m;
	cin>>n>>m;
	vector<ll> vec(n+1,0);
	for(ll i=1;i<=n;i++){
		cin>>vec[i];
	}
	vector<vector<ll> > vec2(n+1);
	map<ll,ll> map;
	for(ll i=1;i<=m;i++){
		ll u,v;
		cin>>u>>v;
		vec2[u].push_back(vec[v]);
		vec2[v].push_back(vec[u]);
	}
	
	for(ll i=1;i<=n;i++){
		sort(vec2[i].begin(),vec2[i].end());
		reverse(vec2[i].begin(),vec2[i].end());
	}
	
	for(ll i=1;i<=n;i++){
		if(vec2[i].size()==0||vec[i]>vec2[i][0]){
			map[i]=1;
		}
	}
	cout<<map.size()<<endl;
}


Measured memory_bytes: 14328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++)cin >> v[i];
  sort(v.begin(),v.end());
  double a=1.0*v[0];
  for(int i=1;i<N;i++){
    a=(a+1.0*v[i])/2.0;
  }
  printf("%.7f",a);
}

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

int main(){
	int A[5][4][11], n;
	for(int i=1; i <=4; i++){
		for(int j = 1; j<=3; j++){
			for(int k=1; k<=10; k++){
				A[i][j][k] = 0;
			}
		}
	}

	cin >> n;
	for(int i=0; i<n; i++){
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		A[b][f][r] +=v;
	}

	for(int f=1; f<=4; f++){
		if(f >1) cout << "####################\n";
		for(int b=1; b<=3; b++){
			for(int r=1; r<=10; r++){
				cout << " " << A[f][b][r];
			}
			cout << endl;
		}
	}
}


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

int main() {
	int n; cin >> n;
	map<int, int>a;
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp; a[tmp]++;
	}
	int ans = a.size();
	cout << (a.size() % 2 == 0 ? ans - 1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;

signed main(){
    string S;
    cin >> S;
    if(S.size()==2){
        cout << S << endl;
    }else{
        cout << S[2]<<S[1]<<S[0] << endl;
    }
    
    return 0;
}   


Measured memory_bytes: 256
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      long n = Long.parseLong(f.readLine());
      
      long cur = 100;
      int i = 0;
      while(cur < n){
         i++;
         cur = cur+cur/100;
      }
      
      out.println(i);
      
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

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

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

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;

void compute(ll n,int e){
  ll remain = n;
  int cnt = 0;
  while( remain && cnt+1 < e ) {
      remain /= 2;
      ++cnt;
  }
  if( remain ) {
    if( remain+(ll)cnt <= 50LL ) {
      cnt = cnt + (int)remain;
    } else {
      cnt = 50;
    }
  }
  cnt = min(cnt,50);

  cout << cnt << endl;
}

int main(){
  ll n ;
  cin >> n;
  if( n == 0 ) cout << 0 << endl;
  else {
    int cnt = 0;
    while( n ){
      n >>= 1;
      ++cnt;
    }
    cout << cnt << endl;
  } return 0;
  int T;
  cin >> T;
  while( T-- ) {
    ll N;
    int E;
    cin >> N >> E;
    compute(N,E);
  }
  return 0;
}

Measured memory_bytes: 1160
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}
#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let mut v = read_vec::<i64>();
    if v[0] % 2 == 0 || v[1] % 2 == 0 || v[2] % 2 == 0 {
        println!("0");
    } else {
        v.sort();
        println!("{}", v[0] * v[1]);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#define min(x, y) ((x) < (y) ? (x) : (y))
int nums[40];

void dfs(int x, int y, int z){
  int i;
  if(x == 0){
    int first = 0;
    for(i = 0;i < z;i++){
      if(first == 1)putchar(' ');
      printf("%d", nums[i]);
      first = 1;
    }
    puts("");
    return ;
  }
  for(i = y; i >= 1;i--){
    nums[z] = i;
    dfs(x - i, min(i, x - i), z + 1);
  }
}

int main(){
  while(1){
    int n;
    scanf("%d", &n);
    if(n == 0)return 0;
    dfs(n, n, 0);
  }
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int dp[n];
	dp[0]=0;
	for(int i=1;i<k&&i<n;i++){
		int m=INT_MAX;
		for(int j=0;j<i;j++){
			m=min(dp[j]+abs(a[j]-a[i]),m);	
		}
		dp[i]=m;
	}
	for(int i=k;i<n;i++){
		int m=INT_MAX;
		for(int j=i-1;i-j<=k&&j>=0;j--){
			m=min(dp[j]+abs(a[j]-a[i]),m);	
		}
		dp[i]=m;
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#gcd関数の定義
def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y, x%y)
 
N = int(input())
A = list(map(int, input().split()))
 
#累積gcdの計算
left_gcd = [A[0]]
a = A[0]
for i in range(1,N-1):
  a = gcd(a, A[i])
  left_gcd.append(a)
 
right_gcd = [A[N-1]]
b = A[N-1]
for k in range(N-2, 0, -1):
  b = gcd(b, A[k])
  right_gcd.append(b)
 
#i番目の数字以外の最大公約数を格納
ans_gcd = [right_gcd[N-2], left_gcd[N-2]]
 
for p in range(N-2):
  ans_gcd.append(gcd(left_gcd[p], right_gcd[N-p-3]))
 
#最大公約数の最大値を出力
print(max(ans_gcd))


Measured memory_bytes: 14400
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,h;
	cin>>n>>h;
	vector<ll> a(n);
	vector<ll> b(n);
	REP(i,n) cin>>a[i]>>b[i];
	sort(ALL(a));
	sort(ALL(b));
	ll buf=a[n-1];
	ll ans=INF*INF;
	ll sum=0;
	REP(i,n) {
		sum+=b[n-1-i];
		ll tmp=i+1;
		if(sum<h) {
			tmp+=(h-sum-1)/buf+1;
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


inline void transpose(vector<string> &a) {

    int n = a.size();
    if (n == 0) return;
    int m = a[0].size();
    vector<string> b(m, string(n, ' '));
    fori (i, n) fori (j, m) b[j][i] = a[i][j];
    a = b;
}


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

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


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}


const int N = 1009;
const ll M = 1e9 + 7;
string mat[N];
ll dp[N][N];


void smain() {

    dp[0][0] = 1;
    int n, m;
    cin >> n >> m;
    fori (i, n) cin >> mat[i];
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
        if (i + j == 0) continue;
        if (i - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % M;
        if (j - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % M;
        if (mat[i][j] == '#') dp[i][j] = 0;
    }
    cout << dp[n - 1][m - 1];
}

Measured memory_bytes: 9216
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::cin >> N;
	double a = 0;
	for (auto i : boost::irange(0, N))
	{
		double x;
		std::cin >> x;
		a += 1 / x;
	}
	std::cout << 1 / a << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())

# Mの約数Pのうち、M // P >= Nとなるものの最大値

ans = 0
for i in range(1,int(M ** 0.5) + 1):
  if M % i == 0:
    p = M // i
    if i >= N:
      if ans < p:
        ans = p
    if p >= N:
      if ans < i:
        ans = i

print(ans)


Measured memory_bytes: 3188
N,M=map(int,input().split())
r=[0]+[10**9]*(2**N-1)
for i in range(M):
    a,_=map(int,input().split())
    c=map(int,input().split())
    x=0
    for e in c:
        x+=1<<(e-1)
    for j in range(2**N):
        r[x|j]=min(r[x|j],r[j]+a)
print(r[-1] if r[-1]<10**9 else -1)

Measured memory_bytes: 3188
s = (input())

n = len(s)
if n % 2 == 0:
    s1 = [x for x in s[0:(int(n/2))]]
    s2 = [x for x in s[(int(n/2)):n]]
    #print(s1)
    #print(s2)

    num = 0
    for i in range(int(n/2)):
        #print(s1[i])
        #print(s2[int(n/2)-i-1])
        if s1[i] != s2[int(n/2)-i-1]:
            num += 1
    print(num)
else:
    s1 = [x for x in s[0:(int((n-1)/2))]]
    s2 = [x for x in s[(int((n+1)/2)):n]]

    num = 0
    for i in range(int(n/2)):
        if s1[i] != s2[int(n/2)-i-1]:
            num += 1
    print(num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;


const ll MOD = 998244353;

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

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

int main() {
    int N, K;
    cin >> N >> K;
    
    vec<int> L(K), R(K);
    rep(i, K) cin >> L[i] >> R[i];
    
    vec<mint> dp(N+1,0);
    dp[1] = 1;
    dp[2] = -1;

    for(int i=1;i<=N;++i){
        dp[i] += dp[i-1];
        rep(j,K){
            int l = L[j];
            int r = R[j];
            if(i+l >N) continue;
            dp[i+l]+=dp[i];
            if(i+r+1 >N) continue;
            dp[i+r+1]-=dp[i];
        }
    }
    cout << dp[N] << '\n';
}


Measured memory_bytes: 4844
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int a = in.nextInt();
            int b = in.nextInt();
            int k = in.nextInt();
            for (int i = Math.min(a,b); i >= 1; i--) {
                if (a % i == 0 && b % i == 0){
                    k--;
                }
                if (k == 0){
                    k = i;
                    break;
                }
            }
            out.println(k);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


Measured memory_bytes: 24788
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

class UnionFind {
public:
	vector < ll > par;
	vector < ll > siz;
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}
	bool unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}
	bool same(ll x, ll y) {
		return root(x) == root(y);
	}
	ll size(ll x) {
		return siz[root(x)];
	}
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(m), b(m), c(k), d(k), fri(n, 0), bl(n, 0);
    UnionFind uf(n);
    rep(i, m){
        cin >> a[i] >> b[i];
        uf.unite(a[i]-1, b[i]-1);
        fri[a[i]-1]++;
        fri[b[i]-1]++;
    }
    rep(i, k){
        cin >> c[i] >> d[i];
        if(uf.same(c[i]-1, d[i]-1)){
            bl[c[i]-1]++;
            bl[d[i]-1]++;
        }
    }
    rep(i, n){
        cout << uf.size(i) - fri[i] - bl[i] - 1 << " ";
    }
}


Measured memory_bytes: 4736
#include <cstdio>
	#include <iostream>
	using namespace std;
	#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
	#define rep(x,to) rep2(x,0,to)
	int n;

	int main() {
		cin >> n;
		int i = 1;
		while(n > i) {
			++i;
			if(i % 3 == 0) cout <<  " " << i;
			else  {
				int x = i;
				while(x) {
					if (x % 10 == 3) {
						cout << " " << i;
						break;
					}
					x /= 10;
				}
			}
		}
		cout << endl;
		return 0;
	}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm> 
#include <cmath>
//#include <bitset>
//#include <deque>
#include <iterator>
#include <map> 
//#include <queue>
//#include <stack>
#include <string>
#include <vector>
#include <array>
//#include <tuple>
#include <unordered_map>
//#include <unordered_set>

using namespace std;

typedef long long ll;
struct __{__(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}__; 



int main() {
	ll n;
	cin >> n;
	if (n <= 6) {
		cout << 1;
		return 0;
	}
	if (n <= 11) {
		cout << 2;
		return 0;
	}
	cout << 2 * (n / 11) + ((n % 11 != 0)?((n % 11 > 6)?2:1):0);
} 











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

int main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
	}
	int ans = 0;
	for (int i = 1; i <= 100; i++) {
		int cur = 0;
		for (int j = 0; j < n; j++) {
			if (cur == 0 && h.at(j) >= i) {
				cur = 1;
				ans++;
			}
			else if (h.at(j) < i) cur = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define endl "\n"
#define int long long

int32_t main()
{
      ios::sync_with_stdio(false);
      cin.tie(0); 
      int n,w;
      cin>>n>>w;
      vector<vector<int> > dp(n+1, vector<int> (1e5+7, 1e13)), v(n+1, vector<int> (2)); 
      for(int i = 0; i < n; i++) {
            cin>>v[i+1][0]>>v[i+1][1];
      }
      // dp[i][j] --> gives value while choosing ith item, and value contributed is j.
      // optimally we have to select maximum value out of minimum weigth possible hence min
      dp[0][0] = 0;
      for(int i = 1; i <= n; i++) {
            for(int j = 0; j <= 1e5+6; j++) {
                  if(j-v[i][1]<0){
                        dp[i][j] = dp[i-1][j];
                        continue;
                  }

                  dp[i][j] = min(dp[i-1][j-v[i][1]]+ v[i][0], dp[i-1][j]);
            }
      }
      int ans = 0;
      for(int i = 0; i <= 1e5 + 6; i++) {
            for(int j = 0; j <= n; j++) {
                  if(dp[j][i]<=w && dp[j][i]>0){
                        ans = max(ans,i);
                  }
            }
      }
      
      cout<<ans<<endl;
      return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int x, y;
    cin >> x >> y;
    if (y-2*x>=0 && (y-2*x)%2==0 && 4*x-y>=0) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
	int H,W,i,j;
	int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
	int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
	scanf("%d%d",&H,&W);
	char s[H][W+1];
	for(i=0;i<H;i++)scanf("%s",s[i]);
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(s[i][j] == '.'){
				int c = 0;
				for(int k=0;k<8;k++){
					int ni = i + dy[k];
					int nj = j + dx[k];
					if(ni < 0 || H <= ni) continue;
					if(nj < 0 || W <= nj) continue;
					if(s[ni][nj] == '#') c++;
				}
				s[i][j] = '0' + c;
				
			}
		}
	}
	
	
	
	for(i=0;i<H;i++)printf("%s\n",s[i]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  string s; cin >> s;

  cout << s[0] << s[1] << s[2] << endl;

  return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int dp[200005];

int ost1[200005];
int ost2[200005];

int main() {
	dp[0] = 0;
	for (int i=1 ; i<=200000 ; i++) {
		dp[i] = 1 + dp[i%__builtin_popcount(i)];
	}
	int n;
	scanf("%d", &n);
	string s;
	cin >>s;
	int cnt = 0;
	for (int i=0 ; i<n ; i++) {
		cnt += (s[i] == '1');
	}
	int m = cnt-1;
	int v = cnt+1;
	int o1 = 0;
	int o2 = 0;
	for (int i=n-1 ; i>=0 ; i--) {
		if (i == n-1) {
			ost1[i] = 1;
			ost2[i] = 1;
		} else {
			if (m) ost1[i] = 2*ost1[i+1]%m;
			ost2[i] = 2*ost2[i+1]%v;
		}
		if (s[i] == '1') {
			if (m) o1 = (o1 + ost1[i])%m;
			o2 = (o2 + ost2[i])%v;
		}
	}
	//cout <<o1<<"   "<<o2<<endl;
	for (int i=0 ; i<n ; i++) {
		if (s[i] == '1') {
			if (!m) printf("0\n");
			else {
				int o = o1 - ost1[i];
				if (o<0) o+=m;
				printf("%d\n", 1+dp[o]);
			}
		} else {
			int o = o2 + ost2[i];
			if (o>=v) o-=v;
			//cout <<"o = "<<o<<endl;
			printf("%d\n", 1+dp[o]);
		}
	}
	return 0;
}

Measured memory_bytes: 6248
program main
	implicit none
    real(8)::W,H,x,y,k
    integer::b
    read(*,*)W,H,x,y
    k=W*H*0.5
    if(2*x==W .and. 2*y==H) then
    b=1
    else 
    b=0
    end if
print*,k,b
end program

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
 
int main(){
    int temp;
    vector<vector<int>> c(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c.at(i).at(j);
        }
    }
    int a[3];
    int b[3];
    a[0] = 0;
    for(int j = 0; j < 3; j++){
        b[j] = c[0][j];
    }
    a[1] = c[1][0]-b[0];
    a[2] = c[2][0]-b[0];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(c[i][j] != a[i]+b[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

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

bool f[51][51];
int w, h;
int dx[8] = { 0, 0, -1,  1, -1,  1, -1,  1};
int dy[8] = {-1, 1,  0,  0, -1, -1,  1,  1};

void dfs(int x, int y) {
	if(!f[y][x]) return;
	f[y][x] = 0;
	for (int i = 0; i < 8; i++) {
		if (x + dx[i] < w && y + dy[i] < h
			 && x + dx[i] >= 0 && y + y + dy[i] >= 0)
			dfs(x + dx[i], y + dy[i]);
	}
}

int main()
{	
	int n;
	
	while (cin >> w >> h, w) {
		n = 0;
		
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> f[i][j];
			}
		}
		
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (f[i][j]) {
					n++;
					dfs(j, i);
				}
			}
		}
		
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
import copy
N = int(input())
A = []
m = 0
S = 0
for i in range(N):
    a = int(input())
    A.append(a)
    if m < a:
        s = m
        m = a
    elif s < a:
        s = a

c = []
mL = 0
mR = 0
# m = 0


for i, a in enumerate(A):
    # print(a)
    if a == m:
        print(s)
    else:
        print(m)
    # if i == 0:
    #     mR = max(A[i + 1 :])
    #     print(mR)
    # elif i == len(A) - 1:
    #     mL = max(A[0: i])
    #     print(mL)
    # else:
    #     mL = max(A[0: i])
    #     mR = max(A[i + 1 :])
    #     m = max(mL, mR)
    #     print(m)
    

Measured memory_bytes: 17300
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string s1="",s2="";
    for(int i=1;i<=b;i++) s1+=(char)(a+'0');
    for(int i=1;i<=a;i++) s2+=(char)(b+'0');
    if(s1<s2) cout<<s1;
    else cout<<s2;
}


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

int main()
{
    long long N, X;
    cin >> N >> X;
    if (N == X) 
    {
        cout << 3 * N << endl;
        return 0;
    }


    long long ans = N;
    long long l = min(X, N - X);
    long long L = N - 2 * l;

    ans += l;
    while (L % l != 0)
    {
        ans += (L / l) * l * 2;
        ans += l + L%l;

        long long LL = L;
        L = l - L % l;
        l = LL%l;
    }
    ans += L * 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
c = list(list(input()))

#仕切りの右側の赤石の数rr
#仕切りの左側の赤石の数rl
rr, rl = c.count("R"), 0

#全ての石の色が同じ場合
if rr == 0 or rr == N:
  print(0)
  exit()

#仕切りの右側の白石の数wr
#仕切りの左側の白石の数wl
wr, wl = N - rr, 0

for i in range(N + 1):
  if i == 0:
    ans = min(rr, wr)
    continue

  if c[i-1] == "R":
    rr -= 1
    rl += 1
  else:
    wr -= 1
    wl += 1

  if rr >= wl:
    ans = min(ans, rr)
  else: ans = min(ans, wl)

print(ans)

Measured memory_bytes: 12060
#include <stdio.h>
#include <stdlib.h>
#define N 45

int F[N];
int fib(int);

int main(){
  int n,i;

  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}

int fib(int n){
if(n==0 || n==1){
  return F[n]=1;
 }
 if(F[n]!=NULL){
   return F[n];
 }
return F[n]=fib(n-2)+fib(n-1);
}

Measured memory_bytes: 596
/**
 * ナップザック問題
 * @link http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp
 */
fun main(args: Array<String>) {
    Main.init()

    Main.execute()

    Main.display()
}

class Main {
    companion object {

        private val DEFAULT_VALUE = 0

        private val matrix = arrayListOf<IntArray>()

        private var maxWeight: Int = 0
        private var itemNum: Int = 0


        private lateinit var itemList: List<Item>

        fun init() {
            val (inputItemNum, inputMaxWeight) = readLine()!!.split(" ")
            itemNum = inputItemNum.toInt()
            maxWeight = inputMaxWeight.toInt()

            itemList = List(itemNum) {
                val (value, weight) = readLine()!!.split(" ")
                Item(weight = weight.toInt(), value = value.toInt())
            }

            // matrixを準備
            for (index in 1..itemNum) {
                matrix.add(this.getEmptyMatrixRow())
            }
        }

        private fun getEmptyMatrixRow(): IntArray {
            return IntArray(maxWeight + 1) {
                DEFAULT_VALUE
            }
        }


        fun execute() {
            /**
             * matrixを走査
             */
            var round = 0
            while (itemList.lastIndex >= round) {
                val item = itemList[round]

                val currentRound = matrix[round]
                val previewRound =
                    if (round == 0) this.getEmptyMatrixRow() else matrix[round - 1]


                for (weight in 0 until currentRound.size) {

                    val valueWhenNone = previewRound[weight]

                    if (weight - item.weight < 0) {
                        currentRound[weight] = valueWhenNone
                        continue
                    }

                    val valueWhenAdded = previewRound[weight - item.weight] + item.value

                    if (valueWhenAdded > valueWhenNone) {
                        currentRound[weight] = valueWhenAdded
                    } else {
                        currentRound[weight] = valueWhenNone
                    }
                }
                round++
            }
        }

        fun display() {
            // 最大の値を出力
            println(matrix.last().max())
        }
    }
}

data class Item(val weight: Int, val value: Int)


Measured memory_bytes: 35508
N = gets.to_i
s = gets.chomp

mod = 1_000_000_007

b = Array.new(N,0)
ans = 1
i = 0
j = 0
while i < N do
  
  if s[i] == s[i+1]
    i += 1
    b[j] = 2
  else
    b[j] = 1
  end
  i += 1
  j += 1
  ans += 1
end

# p b

ans = 1
N.times do |i|
  
  break if b[i] == 0
  
  if i == 0
    
    if b[i] == 1
      ans *= 3
    else
      ans *= 6
    end
  else
    
    k = 0
    if b[i] == 1 && b[i-1] == 1
      k = 2
      # p ?1
    elsif b[i] == 1 && b[i-1] == 2
      k = 1
      # p ?2 # ok
    elsif b[i] == 2 && b[i-1] == 1
      k = 2
      # p ?3
    else
      k = 3
      # p ?4
    end
    
    ans = ans * k % mod
  end
end
  
puts ans

Measured memory_bytes: 3836
# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

N, M = map(int, input().split())
S = input()
T = input()

l = lcm(N, M)

ans = {}
flag = True

for i in range(N):
    now = (l // N) * i + 1
    ans[now] = S[i]

for i in range(M):
    now = (l // M) * i + 1
    if now in ans:
        if ans[now] != T[i]:
            flag = False
            break

if flag:
    print(l)
else:
    print(-1)



Measured memory_bytes: 49904
#include<stdio.h>
int main(){
    int a[4][14],n,i,j;
    scanf("%d",&n);
     
    for(i=0;i<4;i++){
        for(j=0;j<14;j++){
            a[i][j]=0;
        }
    }
     
    scanf("%*c");
    for(i=0;i<n;i++){
        char b;
        int c;
        scanf("%c %d\n",&b,&c);
        if(b=='S'){
            a[0][c]=1;
        }else if(b=='H'){
            a[1][c]=1;
        }else if(b=='C'){
            a[2][c]=1;
        }else if(b=='D'){
            a[3][c]=1;
        }
    }
     
    char pattern[] = {'S','H','C','D'};
    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            if(a[i][j]==0){
                printf("%c %d\n",pattern[i],j);
            }
        }
    }
     
    return 0;
}

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

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

        int N = Integer.parseInt(sc.next());
        sc.close();

        long sum = 0;
        for (int i = 0; i < N; i++) {
            sum += i;
        }

        out.printf("%d\n", sum);
        out.flush();
    }
}


Measured memory_bytes: 21844
//****immortal_ak****
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define int long long
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
clock_t time_p = clock();
void rtime() { time_p = clock() - time_p; cerr << "Time Taken : " << fixed << (float)(time_p) / CLOCKS_PER_SEC << "\n";}
bool isPrime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}

 
signed main()
{
  int t,N;
	 cin>>N;
	 string s;
	 set<string>m;
	 for(int i=0;i<N;i++)
	 {
	 	cin>>s;
	 	m.insert(s);
	 } 
	 cout<<m.size()<<"\n";
rtime();
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    RPT0(i, N) cin >> H[i];

    sort(ALL(H));
    lint total = 0;
    RPT0(i, N - K) total += H[i];

    cout << total << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int>moji(3);
  for(int i=0;i<3;i++){
  cin>>moji.at(i);
  }
  sort(moji.begin(),moji.end());
  cout<<(moji.at(1)-moji.at(0))+(moji.at(2)-moji.at(1))<<endl;
}

Measured memory_bytes: 256
N,*A=`dd`.split.map &:to_i
x,y=[A,A.reverse].map{|_|
	t=[]
	r=[c=0]
	_.each_with_index{|a,i|
		b=a
		q=1
		while !t.empty?&&t[-1][0]<b
			x,d,n=t.pop
			(c+=n*2;x*=4;d*=4)while x<b
			b=d
			q+=n
		end
		t<<(t.empty? ? [a,0,q] : [a,b,q])
		r<<c
	}
	r
}
p (0..N).map{|i|x[i]+i+y[-1-i]}.min

Measured memory_bytes: 39180
# -*- coding: utf-8 -*-
"""
Created on Sat Nov  3 09:19:07 2018

@author: sk
"""

     
      
b, c = map(int, input().split())
     
s=0.5*(b+c)
     
d = int(s)
    
if s-d > 0:
    v=int(d+1)
else :
    v=int(d)
print(v)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<int> VI;

int n,m,a,b;
int cnt[100005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d %d",&a,&b);
		cnt[a]++;
		cnt[b]++;
	}
	for(int i=1;i<=n;i++)
		if(cnt[i]%2 != 0)
		{
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <set>

using namespace std;
typedef long long LL;

const int maxn = 100000 + 5;
vector<int> neighbor[maxn];
int N, a,b;
bool hasfound = false;
bool visited[maxn];
int parent[maxn];
int sstep = 0, cnt = 0;

void dfs(int node, int step)
{
	if (node == N)
	{
		hasfound = true;
		sstep = step;
	}
	if (hasfound)
		return;

	for (int i = 0; i < neighbor[node].size(); i++)
	{
		int nei = neighbor[node][i];
		if (!visited[nei])
		{
			parent[nei] = node;
			visited[nei] = true;
			dfs(nei, step + 1);
			if (hasfound)
				return;
			visited[nei] = false;
		}
	}
}

void dfsss(int node)
{
	for (int i = 0; i < neighbor[node].size(); i++)
	{
		int nei = neighbor[node][i];
		if (!visited[nei])
		{
			visited[nei] = true; cnt++;
			dfsss(nei);
		}
	}
}

int main()
{
	cin >> N;
	while (2 == scanf("%d%d", &a, &b))
	{
		neighbor[a].push_back(b);
		neighbor[b].push_back(a);
	}

	memset(visited, false, sizeof(visited));
	memset(parent, -1, sizeof(parent));
	hasfound = false;

	visited[1] = true;
	dfs(1, 1);
	sstep--;

	sstep = (sstep - 1) / 2;
	int pa = N;
	for (int i = 0; i < sstep; i++)
		pa = parent[pa];
	
	memset(visited, 0, sizeof(visited));
	visited[parent[pa]] = true;
	cnt = 0;
	dfsss(pa);
	int fen = N - cnt;
	if (fen > cnt && cnt != 0)
		cout << "Fennec\n";
	else
		cout << "Snuke\n";
	return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

int d[50][50];
int sum[3][50];
int c[600][600];

int main(){
    int n, C;
    cin >> n >> C;
    for (int i = 1; i <= C; i++){
        for (int j = 1; j <= C; j++){
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> c[i][j];
        }
    }

    for (int i = 1; i <= C; i++){
        for (int h = 0; h < n; h++){
            for (int w = 0; w < n; w++){
                sum[(h + w) % 3][i] += d[c[h][w]][i];
            }
        }
    }

    int ans = MOD;
    for (int i = 1; i <= C; i++){
        for (int j = 1; j <= C; j++){
            if (i == j) continue;
            for (int k = 1; k <= C; k++){
                if (j == k || k == i) continue;
                ans = min(ans, sum[0][i] + sum[1][j] + sum[2][k]);
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int MAX_N = 7 + 100000;
int tn;
vector<pii> G[MAX_N*6];
///----------------------------------------------
map<pair<int,int>, int> tab;
int getid(int c,int a) {
	int ret = tab[mp(c,a)];
	if (!ret) {
		tab[mp(c,a)]=ret=++tn;
		G[a].pb(mp(tn,1));
		G[tn].pb(mp(a,1));
	}
	return ret;
}

int dis[MAX_N*6];
bool in[MAX_N*6];
queue<int> que;
int spfa(int s,int t) {
	///init
	memset(dis,-1,sizeof(dis)); dis[s]=0;
	memset(in,false,sizeof(in)); in[s]=true;
	que.push(s);
	///work
	for (; !que.empty(); que.pop()) {
		int u=que.front();
		rep(i,0,sz(G[u])) {
			pii v=G[u][i];
			if (!~dis[v.fi] || dis[v.fi] > dis[u] + v.se) {
				dis[v.fi] = dis[u] + v.se;
				if (!in[v.fi]) {
					in[v.fi]=true;
					que.push(v.fi);
				}
			}
		}
		in[u]=false;
	}
	///return
	return dis[t];
}

int main() {

	///read
	int n,m; cin>>n>>m; tn=n;
	rep(i,0,m) {
		int a,b,c; scanf("%d%d%d",&a,&b,&c);
		int ida = getid(c,a); //debug(ida);
		int idb = getid(c,b); //debug(idb);
		G[ida].pb(mp(idb,0));
		G[idb].pb(mp(ida,0));
	}
	
	///work
	int ans = spfa(1,n);
	cout << (ans>>1);


}


Measured memory_bytes: 60800
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rrep(i,n) for(int i=(int)n-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> vi;

const int base = 12*60*60;
vi memo[60][60][60];

int main(){
  vi tick(3,-1);
  rep(sec,base){
    (tick[0] += 1) %= 60;
    if(sec%60 == 0)(tick[1] += 1) %= 60;
    if(sec%720 == 0)(tick[2] += 1) %= 60;
    
    rep(i,60){
      vi tmp(3);
      rep(j,3)tmp[j] = (tick[j]+i) % 60;
      sort(all(tmp));

      memo[tmp[0]][tmp[1]][tmp[2]].push_back(sec);
    }
  }

  rep(h,60)rep(m,60)rep(s,60){
    memo[h][m][s].erase(unique(all(memo[h][m][s])),memo[h][m][s].end());
  }
  
  int n;
  while(cin >> n,n){
    vi w(3);
    vector< pair<int,int> > event;
    rep(i,n){
      cin >> w[0] >> w[1] >> w[2];
      sort(all(w));
      for(int a : memo[w[0]][w[1]][w[2]]){
	event.push_back( make_pair(a,i) );
	event.push_back( make_pair(a + base,i) );
      }
    }

    sort(all(event));

    int m = event.size()/2;
    int res_s = base, res_inv = base, nonzero = 0;
    vi cnt(n,0);

    int l = 0, r = 0;
    while(l<m){
      while(nonzero!=n){
	int id = event[r].second;
	if(cnt[id]==0)nonzero++;
	cnt[id]++; r++;
      }
      while(nonzero==n){
	int id = event[l].second;
	cnt[id]--;
	if(cnt[id]==0)nonzero--; l++;
      }

      int inv = event[r-1].first - event[l-1].first;
      if(res_inv>inv){
	res_s = event[l-1].first;
	res_inv = inv;
      }
    }
    res_inv += res_s;
    printf("%02d:%02d:%02d %02d:%02d:%02d\n",
	   res_s/3600, res_s/60%60, res_s%60,
	   res_inv/3600, res_inv/60%60, res_inv%60);
  }
}

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

int main() {
  int n, a, answer;
  answer = 1;
  cin >> n;
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  for(int i = vec.at(1); i > 1; i--) {
    a = 0;
    for(int j = 0; j < n; j++) {
      if(vec.at(j) % i != 0) {
        a++;
        if(a == 2) {
          break;
        }
      }
      if(j == n-1) {
        answer = i;
      }
    }
    if(answer != 1) {
      break;
    }
  }

  cout << answer << endl;
}

Measured memory_bytes: 640