akhauriyash/Code-Regression huggingface dataset:
using System;

public class Program
{
    static void Main()
    {
        for (var i = 1; i <= 9; ++i)
        {
            for (var j = 1; j <= 9; ++j)
            {
                Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            }
        }
    }
}

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


int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int cost1,cost2;
    cost1= a*x + b*y;
    int prod= min(x,y);
    cost2= prod*2*c + a*(x-prod) + b*(y-prod);
    int cost3= max(x,y)* 2*c;
    cout<< min(cost3,(min(cost1,cost2)));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	long long int n,m,p=0;
	cin >> n >> m;
	
	if(n*2 < m){
		p = n;
		p += (m-n*2) / 4;
	}
	else if(n*2 == m){
		p = n;
	}
	else{
		p = m/2;
	}
	
	cout << p << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class Main {
	static int n ;
	static int d ;
	static int MOD = (int) (1e9 +7);
	
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		//BufferedReader br = new BufferedReader(new FileReader("input.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st ;
		Scanner sc = new Scanner(System.in);
		//PrintWriter out = new PrintWriter("output.txt");
		PrintWriter out = new PrintWriter(System.out);
		st = new StringTokenizer(br.readLine());
		int H = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		char[][] s = new char[H][W];
		for(int i=0;i<H;i++)
			{
				s[i] = br.readLine().toCharArray();
			}
		int[][] dp = new int[H+1][W+1];
		for(int i=H;i>0;i--)
		{
			for(int j=W; j>0;j--)
			{
				if(s[i-1][j-1] == '#')
				{
					dp[i][j] = 0;
					continue;
				}
				
				if(i == H && j == W)
					dp[i][j] = 1;
				else if(i== H)
					dp[i][j] = dp[i][j+1];
				else if(j == W)
					dp[i][j] = dp[i+1][j];
				else
				{
					dp[i][j] = (dp[i+1][j] + dp[i][j+1])%MOD; 
				}
			}
		}
//		for(int i =0;i<H;i++)
//			{
//			for(int j=0;j<W;j++)
//			{
//				System.out.print(dp[i][j]+" ");
//			}
//			System.out.println();
//			}
//		
		System.out.println(dp[1][1]);
		out.flush();
		out.close();
		
	}
	
	
}

Measured memory_bytes: 35512
//長方形HWは中心(H/2,W/2)を通るような直線で分割することで面積を元の半分にすることができこれが
//これが小さい方の図形の最大の大きさとなる．つまり点(x,y)の座標によらず面積はH*W/2
//分割する方法が複数存在するかは点の座標が(H/2,W/2)か否かで決定

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

int main(){
    double H,W,x,y;
    cin>>H>>W>>x>>y;
    cout<<H*W/2;
    if(x==H/2&&y==W/2){
        cout<<"  "<<1;
    }else{
        cout<<"  "<<0;
    }

    return 0;
}






Measured memory_bytes: 256
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e9

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	x := next.Int()
	a := next.Int()
	b := next.Int()
	if abs(a-x) < abs(b-x) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}

}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b || b == c || c == a)
    {
        if (!(a == b && b == c && c == a))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>                                        
using namespace std;                                      
                                                          
class Cube{                                               
public:                                                   
  int f[6];                                               
  Cube(){}                                                
  void roll_z(){ roll(1,2,4,3);} // ?°´????????????90????????¢    
  void roll_y(){ roll(0,2,5,3);} // to W                  
  void roll_x(){ roll(0,1,5,4);} // to N                  
  void roll(int i,int j,int k,int l){                     
    int t = f[i];f[i] = f[j];f[j] = f[k];f[k] = f[l];f[l]\
 = t;                                                     
  }                                                       
};                                                        
                                                          
bool eq(Cube c1,Cube c2){                                 
  for(int i=0;i<6;i++)                                    
    if(c1.f[i] != c2.f[i]) return false;                  
  return true;                                            
}                                                         
                                                          
bool equal(Cube c1,Cube c2){                              
  for(int i=0;i<6;i++){                                   
    for(int j=0;j<4;j++){                                 
      if(eq(c1,c2)) return true;                          
      c1.roll_z();                                        
    }                                                     
    if(i%2==0)c1.roll_y();                                
    else c1.roll_x();                                     
  }                                                       
  return false;                                           
}                                                       
                                                          
Cube c[100]; int n;                                       
                                                          
bool check(){                                             
  for(int i=0;i<n-1;i++)                                  
    for(int j=i+1;j<n;j++) if(equal(c[i],c[j])) return fa\
lse;                                                      
      return true;                                        
}                                                         
                                                          
int main(){                                               
  cin >> n;                                               
  for(int j=0;j<n;j++){                                   
    for(int i=0;i<6;i++) cin >> c[j].f[i];                
  }                                                       
  if(check() ) cout << "Yes" << endl;                     
  else cout << "No" << endl;                              
                                                          
  return 0;                                               
} 

Measured memory_bytes: 3100
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    int k,a,b;
    cin >> k >> a >> b;
    int ap,bp;
    ap = a % k;
    bp = b % k;
    if(bp < ap || k <= b-a || ap == 0 || bp == 0){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    //--------------
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;

int ans;


int facctorialMethod(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}


int main() {
	int N;
	cin >> N;
	int x[10];
	int y[10];
	rep(i, N) {
		cin >> x[i] >> y[i];
	}

	double cnt = 0;

	rep(i, N) {
		repk(j, i + 1, N) {
			double temp = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
			// cout << i << " " << j  << " " << temp << endl;
			cnt += temp;
		}
	}

	printf("%.11lf\n", (cnt*(N - 1)*facctorialMethod(N - 2)) / (facctorialMethod(N) / 2));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
signed main(void)
{
    int K;
    cin >> K;
    cout << "50" << endl;
    for (int i = 0; i < 50; i++){
        cout << i + (i + K) / 50 << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;



int main()
{
    string s;
    cin >> s;
    int a[26];
    int n = s.size();
    for(int i = 0; i < 26; i++) a[i] = 0;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
    }else if(s.size() != 26){
        char c;
        for(int i = 0; i < n; i++){
            a[s[i]-'a']++;
        }
        for(int i = 0; i < 26; i++){
            if(a[i] == 0){
                c = 'a' + i;
                break;
            }
        }
        cout << s + c << endl;
    }else{
        string t = s;
        next_permutation(t.begin(),t.end());
        for(int i = 0; i < 26; i++){
            if(s[i] != t[i]){
                cout << t[i] << endl;
                break;
            }
            cout << s[i];
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		List<String> SListA = new ArrayList<String>();
		for(int i = 0; i < S.length(); i++) {
			SListA.add(S.substring(i, i + 1));
		}
		List<String> SListB = new ArrayList<String>(new HashSet<>(SListA));
		System.out.println(SListA.size() == SListB.size() ? "yes" : "no");
		scan.close();
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  string s,t;
  cin >> s >> t;
  string ans="";ans+=(char)('z'+1);
  for(int i=0; i<s.size()-t.size()+1; i++) {
    string r;
    rep(j,t.size()) {
      if(s[i+j]=='?') continue;
      if(s[i+j]!=t[j]) goto next;
    }
    r=s.substr(0,i)+t+s.substr(i+t.size());
    rep(j,r.size()) {
      if(r[j]=='?') r[j]='a';
    }
    ans=min(ans,r);
  next:;
  }
  if(ans[0]>'z') pr("UNRESTORABLE");
  else pr(ans);
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    // char ;
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }
    printf("%lld %lld %lld\n",c,a,b);
    return 0;
}


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

int main(int argc, char **argv)
{
	ll all;
	cin >> all;
	vector<ll> v(5);
	for (int i = 0; i < 5; ++i)
	{
		cin >> v[i];
	}
	ll m = *min_element(v.begin(), v.end());
	--all;
	std::cout << all/m + 5 << std::endl;
}

Measured memory_bytes: 256
import math
n,m = map(int,input().split())
diff = abs(n-m)
count1 = 1
count2 = 1
a = 1

if diff >= 2:
    print(0)
elif diff == 1:
    ans = math.factorial(max(n,m))
    print(ans*(ans//max(n,m))%(10**9+7))
else:
    ans = math.factorial(n)
    print(ans*ans*2%(10**9+7))


Measured memory_bytes: 5164
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	int v,w;
	ll d;
	char t;
	string name;
	bool operator<(const Data& rhs){
		if(v==rhs.v){
			if(w==rhs.w){
				if(t==rhs.t){
					if(d==rhs.d){
						return name<rhs.name;
					}
					return d<rhs.d;
				}
				return t<rhs.t;
			}
			return w<rhs.w;
		}
		return v<rhs.v;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto P=vecin(N);
	auto PP(P),NP(P);
	
	if(prev_permutation(ALL(PP))){
		REP(i,N-1){
			cout << PP[i] << ' ';
		}
		out(PP[N-1]);
	}
	REP(i,N-1){
		cout << P[i] << ' ';
	}
	out(P[N-1]);
	if(next_permutation(ALL(NP))){
		REP(i,N-1){
			cout << NP[i] << ' ';
		}
		out(NP[N-1]);
	}
	
	return 0;
}


Measured memory_bytes: 3196
s = int(input())

def f(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1
  
def a(n):
  if n == 1:
    return s
  elif n >= 2:
    return f(a(n-1))
m, p = 2, 0
while p == 0:
  for i in range(1, m):
    if a(i) == a(m):
      p += 1
  if p == 0:
    m += 1

print(m)

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

int main() {
  long long n, ans;
  cin >> n;
  long double m, b;
  cin >> m;
  long long a;
  a = (m * 100) / 100;
  m = m - a;
  m = m * 100;
  
  b = n * m / 100;
  
  ans = n * a + b;
  cout << ans;
  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    string s;
    cin >> s;
    int a = atoi(s.substr(0, 2).c_str());
    int b = atoi(s.substr(2).c_str());

    if (1 <= a && a <= 12 && (b == 0 || 13 <= b) ){
        put("MMYY");
        return 0;
    }

    if (1 <= b && b <= 12 && (a == 0 || 13 <= a)) {
        put("YYMM");
        return 0;
    }

    if ((a >= 13 || a == 0) && (b >= 13 || b == 0)) {
        put("NA");
        return 0;
    }

    put("AMBIGUOUS")

    return 0;
}

Measured memory_bytes: 3584
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
    int n, k;
    cin >> n >> k;
    vi v(n);
    rep(i, 0, n)cin >> v[i];
    sort(all(v));
    int ans = 0;
    rep(i, 0, k)ans += v[i];
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

string S[20];
bool border[20];
int cnt[20];
int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	int ans = mod;
	int p = 0;
	bool out = false;
	for (int i = 0; i < (1 << (H - 1)); i++) {
		int line = 0;
		int bit = i;
		out = false;
		for (int j = 0; j < H; j++) cnt[j] = 0;
		for (int j = 0; j < H; j++) border[j] = false;
		for (int j = 0; j < H - 1; j++) {
			int num = bit % 2;
			bit /= 2;
			if (num == 1) {
				line++;
				border[j] = true;
			}
		}
		//cout << line << " ";
		for (int j = 0; j < W; j++) {
			p = 0;
			for (int k = 0; k < H; k++) {
				if (S[k][j] == '1') cnt[p]++;
				if (border[k])p++;
			}
			for (int l = 0; l <= p; l++) {
				if (cnt[l] > K) {					//縦に切る
					line++;
					for (int n = 0; n <= p; n++) {
						cnt[n] = 0;
					}
					p = 0;
					for (int n = 0; n < H; n++) {
						if (S[n][j] == '1') cnt[p]++;
						if (border[n])p++;
					}
					for (int n = 0; n <= p; n++) {
						if (cnt[n] > K) out = true;
					}
					break;
				}
			}
			//cout << endl;
		}
		//cout << line << endl;
		if (!out) ans = min(ans, line);
	}
	cout << ans << endl;
}


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

const int maxn = 300+5;
int n;
int mem[maxn];
int dp[maxn][maxn];

void Print()
{
	cout << "SHOW" << endl;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
		{
			if(j!=n-1) printf("%d ", dp[i][j]);
			else printf("%d\n", dp[i][j]);
		}
}

int solve()
{
	for(int i = 0; i + 1 < n; i++)
		if(abs(mem[i]-mem[i+1])<=1) dp[i][i+1] = 2;

	for(int i = 3; i <= n; i++)
		for(int s = 0; s+i <= n; s++)
		{
			int e = s + i - 1;
			if(abs(mem[s]-mem[e]) <= 1 && dp[s+1][e-1] == i-2)
				dp[s][e] = i;

			for(int k = s + 1; k <= e; k++)
				dp[s][e] = max(dp[s][e], dp[s][k-1]+dp[k][e]);
		}

	return dp[0][n-1];
}

void Init()
{
	memset(mem, 0, sizeof(mem));
	memset(dp, 0, sizeof(dp));
}

bool Input()
{
	scanf("%d", &n);
	if(!n) return false;
	Init();
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &mem[i]);
	}
	return true;
}

int main()
{
	while(1)
	{	
		if(!Input()) break;
		printf("%d\n", solve());
		//Print();
	}
}


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


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

//C++14 (GCC 5.4.1)
int main() {
    int s;
    cin >>s;
    
    //-----------------------------------
    bool is=false;
    int ans=0;
    vector<int> A(1000011);
    A[0]=s;
    rep(i,1000010){
        if(A[i]==1||A[i]==2||A[i]==4){
            ans=i+4;
            break;
        }
        if(A[i]%2){
            A[i+1]=A[i]*3+1;
        }else{
            A[i+1]=A[i]/2;
        }
    }

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

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 23:33:40 2020

@author: shinba
"""

q,h,s,d = map(int,input().split())

n = int(input())

a = [4*q,2*h,s,d/2]

a.sort()

if a[0] != d/2:
    print(int(n*a[0]))

else:
    if n % 2 == 0:
        print(d*int(n/2))
    else:
        print(d*int(n/2)+int(a[1]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll cnt=0;
  ll ans=0;
  string s;
  cin>>s;
  for(ll i=0;i<s.size();i++){
  	if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T'){ans=max(ans,cnt);cnt=0;}
    else cnt++;
  }
  ans=max(ans,cnt);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
t, d = gets.chomp.split.map(&:to_r)
ta, tb = gets.chomp.split.map(&:to_r)
da, db = gets.chomp.split.map(&:to_r)
min = nil
a = 0
while true
    b = (a == 0 ? 1 : 0)
    while true
        break if da * a + db * b > d
        diff = (((ta * da * a + tb * db * b) / (da * a + db * b)) - t).abs
        min = diff if min.nil? || min > diff
        b += 1
    end
    a += 1
    break if da * a > d
end
puts min.to_f


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

double distance(double x,double y){
    return x*x+y*y;
}

void dijkstra(int s,vector<vector<pair<double,int>>> &edge,vector<double> &d){
    d[s]=0;
    vector<int> used(edge.size(),0);
    priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> q;
    int v=s;
    for(int loop=0;loop<edge.size()-1;loop++){
        used[v]=true;
        for(int i=0;i<edge[v].size();i++){
            if(!used[(edge[v][i].second)]){
                q.push(make_pair(edge[v][i].first+d[v],edge[v][i].second));
            }
        }
        for(;;){
            auto p=q.top();
            q.pop();
            if(!used[p.second]){
                v=p.second;
                d[v]=p.first;
                break;
            }

        }

    }
    return;

}
int main(){
    int xs,xt,ys,yt;
    cin>>xs>>ys>>xt>>yt;
    int n;
    cin>>n;
    vector<int> x(n),y(n),r(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>r[i];
    vector<vector<pair<double,int>>> edge(n+2);
    for(int i=0;i<n;i++){
        double dis=max(0.0,sqrt(distance(x[i]-xs,y[i]-ys))-r[i]);
        edge[n].push_back(make_pair(dis,i));
        edge[i].push_back(make_pair(dis,n));
        dis=max(0.0,sqrt(distance(x[i]-xt,y[i]-yt))-r[i]);
        edge[n+1].push_back(make_pair(dis,i));
        edge[i].push_back(make_pair(dis,n+1));
    }
    double st=sqrt(distance(xs-xt,ys-yt));
    edge[n].push_back(make_pair(st,n+1));
    edge[n+1].push_back(make_pair(st,n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
         edge[i].push_back(make_pair(max(0.0,sqrt(distance(x[i]-x[j],y[i]-y[j]))-r[i]-r[j]),j));
        }
    }
    vector<double> d(n+2,1e18);
    dijkstra(n,edge,d);
    cout<<setprecision(10)<<fixed<<d[n+1]<<endl;


}


Measured memory_bytes: 24704
#include<stdio.h>
int main()
{
	int i,a=0,b=0,c=0;
	char s[4];
	scanf("%s",s);
	for(i=0;i<3;i++){
	if(s[i]=='a') a++;
	if(s[i]=='b') b++;
	if(s[i]=='c') c++;}
	 if(a==b&&b==c&&c==1)
	 printf("Yes\n");
	 else printf("No\n");
	 return 0;


}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int a,b,c;
  int min=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){
    min=b;
    if(a>c){
      min+=c;
    }else{
      min+=a;
    }
  }else{
    min=a;
    if(b>c){
      min+=c;
    }else{
      min+=b;
    }
  }
  printf("%d",min);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  
 int n,m,l;
  
  scanf("%d",&n);
  
  m=n/10;
  l=n-m*10;
  
  switch (l){
      
    case 2:
  	case 4:
  	case 5:
 	case 7:
  	case 9: printf("hon");
      		break;
    case 0:
    case 1:
    case 6:
    case 8: printf("pon");
      		break;
    case 3: printf("bon");
    		break;
    default: break;
  }
  
  return 0;
}

Measured memory_bytes: 2120
n=int(input())
p=list(map(int,input().split()))
count=0


for i in range(n-2):
  p_3=p[i:i+3]
  if p_3[1]-p_3[0]>0:
    if p_3[2]-p_3[1]>0:
      count+=1
      
  elif p_3[1]-p_3[0]<0:
    if p_3[2]-p_3[1]<0:
      count+=1
  
print(count)

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++){
        cin >> a.at(i);
    }
    int ma = -1;
    for (int i = 0;i < n - 1;i++){
        for (int j = i;j < n;j++){
            ma = max(ma,abs(a.at(i) - a.at(j))); 
        }
    }

    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    ll ans = 0;
    int n;
    cin >> n;

    vector<ll>t(n + 2);

    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            t[j]++;
        }
        ans += i * t[i];
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 81408
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 50;
int N;
int a[MAX_N+1];

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

  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> a[i];

  int ma = -INFINT, mi = INFINT, ma_idx = 0, mi_idx= 0;
  for (int i = 1; i <= N; ++i) {
    if (ma < a[i]) {
      ma = a[i]; ma_idx = i;
    }
    if (mi > a[i]) {
      mi = a[i]; mi_idx = i;
    }
  }

  vector<Pii> ans;
  if (abs(ma) >= abs(mi)) {
    for (int i = 1; i <= N; ++i) {
      if (i == ma_idx) continue;
      ans.push_back(Pii(ma_idx, i));
    }
    for (int i = 1 ; i < N; ++i) {
      ans.push_back(Pii(i, i+1));
    }
  } else {
    for (int i = 1; i <= N; ++i) {
      if (i == mi_idx) continue;
      ans.push_back(Pii(mi_idx, i));
    }
    for (int i = N; i > 1; --i) {
      ans.push_back(Pii(i, i-1));
    }
  }

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i].fi << ' ' << ans[i].sc << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def p(F,A,s): # スコアをsにするために最小限必要な修行の回数
    res=0
    for i in range(N):
        res+=max(A[i]-s//F[i],0)
    return res

N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))

F.sort(reverse=True) # 降順で固定
A.sort() # 昇順で固定

l=0
r=max([F[i]*A[i] for i in range(N)])

while r-l>1:
    m=(l+r)//2
    if p(F,A,m)<=K:
        r=m
    else:
        l=m

if r>1 or p(F,A,0)>K:
    ans=r
else:
    ans=0

print(ans)

Measured memory_bytes: 119756
from collections import deque
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

Q = deque([A[0]])
for a in A[1:]:
    if a <= Q[0]:
        Q.appendleft(a)
    else:
        idx = bisect.bisect_left(Q,a)
        Q[idx-1] = a

print(len(Q))

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

int main() {
  int n;
  cin >> n;
  
  int happiness[n][3], dp[n][3];
  for(int i = 0; i < n; i++) cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];
  
  dp[0][0] = happiness[0][0];
  dp[0][1] = happiness[0][1];
  dp[0][2] = happiness[0][2];
  
  for(int i = 1; i < n; i++) {
  	dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + happiness[i][0];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + happiness[i][1];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + happiness[i][2];
  }
  
  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
  
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
int main(){

    string str;
    cin>>str;
    
    if(str[0]!='A'){
        cout<<"WA";
        return 0;
    }
    int countc=0;
    int cpla;
    for(int i=2;i<str.size()-1;i++){
        if(str[i]=='C'){
            countc++;
            cpla=i;
        }
    }
    if(countc!=1){
        cout<<"WA";
        return 0;
    }
   // cout<<cpla<<endl;
    for(int i=1;i<str.size();i++){

        if(i!=cpla){
            if(!(str[i]>='a'&&str[i]<='z')){
                cout<<"WA";
                return 0;
            }
        }
    }
    cout<<"AC";
    
   // cout<<str<<endl;
   // str+='h';
   // cout<<str<<endl;
   // cout<<str.size()<<endl;


return 0;
}

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

typedef long long ll;

const int N = 100 * 1000 + 20;
int x, y, a, b, c, p[N], q[N], r[N];
ll ans, tmp;
vector<int> vec;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> x >> y >> a >> b >> c;
	for (int i = 0; i < a; i++)
		cin >> p[i];
	for (int i = 0; i < b; i++)
		cin >> q[i];
	for (int i = 0; i < c; i++)
		cin >> r[i];
	sort(p, p + a, greater<int>());
	sort(q, q + b, greater<int>());
	sort(r, r + c, greater<int>());
	for (int i = 0; i < x; i++) {
		ans += p[i];
		vec.push_back(p[i]);
	}
	for (int i = 0; i < y; i++) {
		ans += q[i];
		vec.push_back(q[i]);
	}
	sort(vec.begin(), vec.end());
	ll sum1 = 0, sum2 = 0;
	for (int i = 0; i < min((int)vec.size(), c); i++) {
		sum1 += vec[i];
		sum2 += r[i];
		tmp = max(tmp, sum2 - sum1);
	}
	return cout << ans + tmp << endl, 0;
}



Measured memory_bytes: 2552
import sys
input = sys.stdin.readline

l = list(map(int, input().split()))

ans = 0
if not abs(l[1] - l[2]) % 2:
    ans = abs(l[1] - l[2]) // 2
elif abs(l[1] - l[2]) == 1:
    if l[1] < l[2]:
        if (l[1] - 1) < (l[0] - l[2]):
            ans = l[2] - 1
        else:
            ans = l[0] - l[1]
    else:
        if (l[2] - 1) < (l[0] - l[1]):
            ans = l[1] - 1
        else:
            ans = l[0] - l[2]
else:
    if l[1] < l[2]:
        if (l[1] - 1) < (l[0] - l[2]):
            ans = l[1] + (l[2] - l[1] - 1) // 2
        else:
            ans = l[0] - l[2] + 1 + (l[2] - l[1] - 1) // 2
    else:
        if (l[2] - 1) < (l[0] - l[1]):
            ans = l[2] + (l[1] - l[2] - 1) // 2
        else:
            ans = l[0] - l[1] + 1 + (l[1] - l[2] - 1) // 2

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //int t;cin>>t;while(t--)
    {
        ll i,j,k,l,m,n,a,b,c,d,cnt=0,sum=0,o=1,x,maxa=0;
        cin>>n;
        vector <int> vec;
        ll arr[n];
        for(i=0;i<n;i++)
            cin>>arr[i],maxa=max(maxa,arr[i]);
        int mark[maxa+9]={0};
         for (int i = 0; i < n; i++)
            {for (int x = arr[i]; x <= maxa; x += arr[i])
                {{mark[x]++;} }}
        for(i=0;i<n;i++)
        {
            if(mark[arr[i]]<=1)
            {
                cnt++;
            }
        }

cout<<cnt<<endl;
    }


}


Measured memory_bytes: 9104
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int n,mm=0;
    cin>>n;
    map<string,int>m;
     map<string,int>:: iterator it;
    string s;
    f(i,1,n)
    {
        cin>>s;
        m[s]++;
        mm=max(m[s],mm);
    }
    it=m.begin();
    while(it!=m.end())
    {
        if(it->second == mm)
            cout<<it->first<<endl;
       it++;
    }
}

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

int main(){
    ios_base::sync_with_stdio(false);
    int q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    long long ans=0;
    while(n>0){
        if(n>2){
            long long x= min(min(8*q,4*h),min(2*s,d));
            ans=ans+n/2*x;
            n=n%2;
        }
        if(n==1){
            ans+=min(4*q,min(2*h,s));
            n=0;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;
int N;
long long A[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    long long ret = A[1] - 1;
    long long ban = 1;
    A[1] = 1;

    for (int i = 1; i <= N; i++) {
        //std::cout << i << " " << ban << " " << ret << std::endl;
        if (A[i] <= ban) {
            // nothing to do
        } else if (A[i] == ban + 1) {
            ban++;
        } else {
            if (A[i] % (ban + 1) == 0) {
                ret += A[i] / (ban + 1) - 1;
            } else {
                ret += A[i] / (ban + 1);
            }
        }
    }

    std::cout << ret << std::endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	while(cin>>n>>m,n,m){
		int num[50]={},now=0,storn=m;
		while(1){
			if(now==n)now=0;
			if(storn>0){
				num[now]++;
				storn--;
			}
			else if(num[now]>0){
				storn=num[now];
				num[now]=0;
			}
			if(num[now]==m){
				cout<<now<<endl;
				break;
			}
			now++;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;




int main() {
    int N; cin >> N;
    vector<ll> V(N+1);
    for(int i=0; i<N; i++){
        int a; cin >> a;
        V[i+1] = V[i] + a;
    }
    
    map<ll, int>M;
    for(ll v:V)
        M[v]++;

    ll ans = 0;
    for(auto m:M)
        if(m.second >= 2) ans += (ll)m.second * (m.second - 1) / 2;

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


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

int main()
{
  int N, X; cin >> N >> X;
  int m[110]; rep(i,N) cin >> m[i];
  sort(m, m+N);
  //1種類は作る
  int massTemps = X;
  rep(i,N) massTemps -= m[i];
  //最小のグラム数でいくつ作れるかを足す
  int ans = N + massTemps / m[0];
  cout << ans << endl;
}

Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*define
*********************************/
int input_ary[ 10000 ];

/*********************************
*function
*********************************/
int main( void )
{
	int a;
	int b;
	int c;
	int loop;
	int count;

	count = 0;

	scanf( "%d %d %d", &a, &b, &c );

	for ( loop = a; loop <= b; loop++ ) {
		if ( ( c % loop ) == 0 ) {
			count++;
		}
	}
	printf( "%d\n", count );

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
const int MAX_N = 100000;
ll A[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> A[i];
  int i = 0;

  int st = 0;

  int ans = 1;

  while(i < N - 1) {
    if(st == 0) {
      if(A[i] < A[i + 1]) {
        st = 1;
      }
      if(A[i] > A[i + 1]) {
        st = -1;
      }
    }
    
    if((st == 1 && A[i] > A[i + 1]) || (st == -1 && A[i] < A[i + 1])) {
      ans++;
      st = 0;
    }
    i++;
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
int main(void) {
  int A,B,C,D,E,max;
  scanf("%d %d",&A,&B);
  C = A+B;
  D = A-B;
  E = A*B;
  max = C;
  if (max<D) {
    max = D;
  }
  if (max<E) {
    max = E;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
bool rever(int a,int b) { return a>b; }
int fpow(int b,int p,int m)
{
	if(p==0) return 1;
	int t=fpow(b,p/2,m);
	if(p%2) return t*t%m*b%m;
	return t*t%m;
}
int fpow(int b,int p)
{
	if(p==0) return 1;
	int t=fpow(b,p/2);
	if(p%2) return t*t*b;
	return t*t;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int ans=0;
	for(int i=1;i*i<=n;i++)
	{
		if(n%i!=0) continue;
		int t=n/i;
		if(t>1 && n/(t-1)==n%(t-1)) ans+=t-1;
		if(i>1 && n/(i-1)==n%(i-1)) ans+=i-1;
		//cout<<t<<" "<<i<<" "<<ans<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}










Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc141/tasks/abc141_a"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;

    if(s == "Sunny")
        cout<<"Cloudy";
    else if(s == "Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    ll n, m, k; cin >> n>>m>>k;
    vector<ll> a(n+1, 0);
    vector<ll> b(m+1, 0);
    ll ans=0;
 
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i]+=a[i-1];
    }
    for (int j = 1; j <= m; ++j) {
        cin >> b[j];
        b[j]+=b[j-1];
    }
 
    ll d=m;
    for (int l = 0; l <= n; ++l) {
        if(k < a[l]) break;
        while (b[d]>k-a[l]) d--;
        ans = max(ans, l+d);
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 6432
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    int sign = (N > 0 ? 0 : 1);
    N = abs(N);
    vector<int> vn, v;
    int n = N;
    vn.clear();
    while (n > 0) {
        if (n % 2 == 1) vn.push_back(1);
        else vn.push_back(0);
        n = n / 2;
    }
    v.clear();
    for (int i = 0; i < vn.size(); i++) {
        v.push_back(vn[i]);
        if (i % 2 == sign) continue;
        if (i % 2 == 1 - sign && vn[i] == 0) continue;
        int carry = 1;
        for (int j = i + 1; j < vn.size(); j++) {
            int v = vn[j] + carry;
            carry = v / 2;
            v = v % 2;
            vn[j] = v;
        }
        if (carry != 0) vn.push_back(1);
    }
    if (v.size() == 0) v.push_back(0);
    for (int i = v.size() - 1; i >= 0; i--) printf("%d", v[i]);

    return 0;
}


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

int main(){
  int N,X;
  cin>>N>>X;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  int ans=0;
  int place=0;
  ans++;
  for(int i=0;i<N;i++){
    place+=L.at(i);
    if(place<=X){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def func(i,K):
    od=0
    while(i*2**od<K):
        od+=1
    return 1/2**od

N,K=[int(x) for x in input().split()]
ans=0
od=0
#while(1):
#    if K//2**od==0:
#        break
#    if K//2**(od+1)>N:
#        cnt=0
#    elif K//2**od > N and K//2**(od+1)<=N:
#        cnt=N-K//2**(od+1)
#    else:
#        cnt=K//2**od-K//2**(od+1)
#    print(od,cnt)
#    ans=cnt*1/2**od*1/N
#    od+=1
#print (ans)
A = [0 for i in range(N+1)]
for i in range(1,N+1):
    A[i]=func(i,K)
print (sum(A)/N)

Measured memory_bytes: 48368
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
	// write your code here
        String s = br.readLine().trim();
        int stPo = 0;

        while (s.length() > stPo){
            int endPo5 = stPo + 5;
            int endPo6 = stPo + 6;
            int endPo7 = stPo + 7;

            if (s.length() >= stPo + 7 && s.substring(stPo,endPo7).equals("dreamer") && (s.length() < stPo+10 || ! s.substring(endPo5,endPo5+5).equals("erase"))){
                stPo += 7;

            }else if(s.length() >= stPo + 6 && s.substring(stPo,endPo6).equals("eraser") && (s.length() < stPo+10 || ! s.substring(endPo5,endPo5+5).equals("erase"))){
                stPo += 6;

            }else if (s.length() >= stPo + 5 && (s.substring(stPo,endPo5).equals("dream") || s.substring(stPo,endPo5).equals("erase"))){
                stPo += 5;

            }else{
                System.out.println("NO");
                return;
            }
        }

        System.out.println("YES");
    }

}



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

#define int long long

int a[55],b[55],c[55],d[55];

int ans=0;
int n,m,q;
void solve(int pos,vector<int> &v)
{
    if(pos==n+1)
    {
        int temp=0;
        for(int i=1;i<=q;i++)
        {
            if(v[b[i]]-v[a[i]]==c[i])
                temp+=d[i];
        }
        ans=max(ans,temp);
        return;
    }
    int st=1;
    if(v.size()!=0)
        st=v.back();
    for(int i=st;i<=m;i++)
    {
        v.push_back(i);
        solve(pos+1,v);
        v.pop_back();
    }
}

void solve(int tt)
{
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> v;
    solve(1,v);
    cout<<ans;
}

int32_t main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}

Measured memory_bytes: 3616