akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using p = pair<int, int>;
using P = pair<ll, ll>;
using pq = priority_queue<int>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int C(int x, int y) {
	return (x + y - 1) / y;
}
int main() {
	int n, m;
	cin >> n >> m;
	V a(n);
	int sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(all(a));
	reverse(all(a));
	int B = C(sum, (4 * m));
	bool flag = true;
	rep(i, m) {
		if (a[i] < B) flag = false;
	}
	puts((flag) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop, heappushpop, heapify, heapreplace
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#ここから書き始める
n, p = map(int, input().split())
a = factorization(p)
# print("a =", a)
ans = 1
for i in a:
    if i[1] >= n:
        ans *= i[0] ** (i[1] // n)
print(ans)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  vector<vector<llong>> A(3, vector<llong>(3));
  llong N;
  vector<llong> b;

  for (int h = 0; h < 3; ++h) {
    for (int w = 0; w < 3; ++w) {
      cin >> A[h][w];
    }
  }
  cin >> N;
  b.resize(N);
  for (auto &in: b) {
    cin >> in;

    for (int h = 0; h < 3; ++h) {
      for (int w = 0; w < 3; ++w) {
        if (A[h][w] == in) {
          A[h][w] = 0;
        }
      }
    }
  }

  bool ok = false;
  for (int i = 0; i < 3; ++i) {
    ok |= A[i][0] == A[i][1] && A[i][1] == A[i][2] && A[i][2] == 0;
    ok |= A[0][i] == A[1][i] && A[1][i] == A[2][i] && A[2][i] == 0;    
  }
  ok |= A[0][0] == A[1][1] && A[1][1] == A[2][2] && A[2][2] == 0;
  ok |= A[2][0] == A[1][1] && A[1][1] == A[0][2] && A[0][2] == 0;

  cout << (ok ? "Yes": "No") << endl;

  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
keys = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N
for key in keys:
    if left < key[0]:
        left = key[0]
    if key[1] < right:
        right = key[1]
if right < left:
    print(0)
else:
    print(right - left + 1)

Measured memory_bytes: 27448
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	last := map[int]int{}

	dbl := makeGrid(64, n)
	for i := n - 1; i >= 0; i-- {
		last[aa[i]] = i + n
	}
	for i := n - 1; i >= 0; i-- {
		dbl[0][i] = int64(last[aa[i]] + 1 - i)
		last[aa[i]] = i
	}
	for i := 1; i < 64; i++ {
		for j := 0; j < n; j++ {
			if math.MaxInt64-dbl[i-1][j] <= dbl[i-1][(int64(j)+dbl[i-1][j])%int64(n)] {
				continue
			}
			dbl[i][j] = dbl[i-1][j] + dbl[i-1][(int64(j)+dbl[i-1][j])%int64(n)]
		}
	}
	p := 0
	var d int64
	d = int64(n) * int64(k)
	for d >= dbl[0][p] {
		for i := 60; i >= 0; i-- {
			if d >= dbl[i][p] {
				d -= dbl[i][p]
				p = p + int(dbl[i][p]%int64(n))
				p %= n
			}
		}
	}
	stack := make([]int, 0)
	m := map[int]int{}
	for i := p; d > 0; i++ {
		d--
		if m[aa[i%n]] == 0 {
			m[aa[i%n]] = 1
			stack = append(stack, aa[i%n])
			continue
		}
		l := len(stack)
		for stack[l-1] != aa[i%n] {
			delete(m, stack[l-1])
			stack = stack[:l-1]
			l--
		}
		delete(m, stack[l-1])
		stack = stack[:l-1]
	}
	if len(stack) == 0 {
		fmt.Fprintln(writer, "")
		return
	}
	for i := 0; i < len(stack); i++ {
		fmt.Fprintln(writer, stack[i])
	}
}

func makeGrid(h, w int) [][]int64 {
	index := make([][]int64, h, h)
	data := make([]int64, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 141228
drawRect :: Int -> Int -> IO ()
drawRect 0 w = do
               putStrLn ""
               return ()
drawRect h w = do
  putStrLn . take w . repeat $ '#'
  drawRect (h-1) w

main = do
  l <- getLine
  let (h:w:_) = map read . words $ l
  if h == 0 && w == 0 then return ()
  else do
    drawRect h w
    main

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n / 100 + (n % 100) / 10 + (n % 10) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i;
    int n, x=0, newx=0;
    char s[105]={};
    
    scanf("%d",&n);
    scanf("%s",s);
    
    for(i=1;i<=n;i++)
    {
        if(newx<x)  newx=x;
        if(s[i-1]=='I') x++;
        else if(s[i-1]=='D') x--;
        if(newx<x)  newx=x; 
    }
    printf("%d",newx);
    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int ans = 0;
    while(x<=y) {
        y /= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric> 
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
///////////////////////////////////////////////////////////////////////

int n, v;
vector<int> P, Q;

bool check(vector<int>& T, vector<int>& temp) {
    for (int i = 0; i < T.size(); ++i) {
        if (T[i] != temp[i]) return false;
    }
    return true;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &v);
        P.push_back(v);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &v);
        Q.push_back(v);
    }
    vector<int> temp;
    for (int i = 1; i <= n; ++i) temp.push_back(i);

    int p = 0, q = 0, i = 1;
    do {
        if (check(P, temp)) p = i;
        if (check(Q, temp)) q = i;
        if (p != 0 && q != 0) break;
        i++;
    } while(next_permutation(temp.begin(), temp.end()));
    printf("%d\n", abs(p - q));
}

Measured memory_bytes: 256
n,x = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)

# if n == 1
#   puts (x - xs[0]).abs
#   exit
# end

tmp = [(x - xs[0]).abs]
n.times do |i|
  break if xs[i+1].nil?
  tmp << (xs[i] - xs[i+1]).abs
end

ans = tmp.reduce(&:gcd)
puts ans


Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cin >> a.at(i).at(j);
  }
  
  bool check;
  
  //行のチェック
  for (int i = 0; i < h; i++) {
    check = true;
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '#') check = false;
    }
    if (check) {
      for (int j = 0; j < w; j++) a.at(i).at(j) = '0';
    }
  }
  
  //列のチェック
  for (int j = 0; j < w; j++) {
    check = true;
    for (int i = 0; i < h; i++) {
      if (a.at(i).at(j) == '#') check = false;
    }
    if (check) {
      for (int i = 0; i < h; i++) a.at(i).at(j) = '0';
    }
  }
  
  int count;
    
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) != '0') cout << a.at(i).at(j);
    }
    //すべて白でない行のみ改行する
    count = 0;
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '0') count++;
    }
    if (count != w) cout << endl;
  }
 
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 200007
using namespace std;
int main() {
  fastio;
  string s, t;
  cin >> s >> t;
  ll n = s.length(), m = t.length();
  ll dp[n + 1][m + 1];
  for (ll i = 0; i <= n; ++i) {
    for (ll j = 0; j <= m; ++j) {
      if (i == 0 or j == 0)
        dp[i][j] = 0;
      else if (s[i - 1] == t[j - 1])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  string lcs = "";
  ll i = n, j = m;
  while (i > 0 and j > 0) {
    if (s[i - 1] == t[j - 1]) {
      lcs += s[i - 1];
      --i, --j;
    } else if (dp[i - 1][j] > dp[i][j - 1])
      --i;
    else
      --j;
  }
  reverse(lcs.begin(), lcs.end());
  cout << lcs;
}

Measured memory_bytes: 74016
def main():
    number_of_slimes = int(input())
    slime_list = list(input())

    print(len(remove_adjacent(slime_list)))
    # print(len(remove_adjacent(slime_list)))

def remove_adjacent(li):
    n1  = []
    n1.append(li[0])

    for i in range(1,len(li)):
        if li[i] != li[i-1]:
            n1.append(li[i])
    return n1

main()


Measured memory_bytes: 4648
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool used[70]={};
  int now=0;
  while(1){
    if(now<=c&&c<=now+a){
      cout<<c<<endl;
      break;
    }
    if(used[(now+a)%60]){
      cout<<-1<<endl;
      break;
    }
    used[(now+a)%60]=true;
    now+=(a+b);
    if(now>c)
      c+=60;
  }
  return 0;
}



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

using namespace std;

int getParent(vector<int> &parent, int x)
{
    if (parent[x] < 0)
        return x;
    return parent[x] = getParent(parent, parent[x]);
}

void uniteParent(vector<int> &parent, int a, int b)
{
    a = getParent(parent, a);
    b = getParent(parent, b);
    if (a == b)
        return;
    if (a > b)
        swap(a, b);
    // 항상 a < b
    parent[a] += parent[b];
    parent[b] = a;
}

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> parent(n + 1, -1);

    int a, b;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        uniteParent(parent, a, b);
    }

    int cnt = 0;
    for (int i = 1; i < n + 1; i++)
    {
        cnt = max(cnt, -parent[i]);
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a[3][3];
    rep(i,3){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    vector<vector<bool>> check(3, vector<bool> (3, false));
    int n; cin >> n;
    rep(i,n){
        int b; cin >> b;
        rep(i,3){
            rep(j,3){
                if(a[i][j] == b){
                    check[i][j] = true;
                }
            }
        }
    }
    rep(i,3){
        if(check[i][0] == true && check[i][1] == true && check[i][2] == true){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(j,3){
        if(check[0][j] == true && check[1][j] == true && check[2][j] == true){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(check[0][0] == true && check[1][1] == true && check[2][2] == true) {
        cout << "Yes" << endl;
            return 0;
    }
    if(check[2][0] == true && check[1][1] == true && check[0][2] == true) {
        cout << "Yes" << endl;
            return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX = 1e5 + 50 ;
const ll oo = 1e16;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , q , ans; string s ;
int t[101000] , sum[101000];

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

    cin >> n >> q ;
    cin >> s ;
    for(int i = 0 ; i < n - 1 ; ++i)
            if(s[i] == 'A' && s[i + 1] == 'C')
                t[i + 1] = 1 ;


    for(int i = 1 ; i < n ; ++i)
        sum[i] += t[i] + sum[i - 1];

    for(int i = 0 ; i < q ; ++i){
        int lo , hi ;
        cin >> lo >> hi ;
        --lo; --hi;
        cout << sum[hi] - sum[lo] << '\n';



    }


     return 0;
}


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

using namespace std;



int main(){
    int n;
    cin >> n;
    int arr[n];
    int co = 0;
    for(int i = 0; i< n; i++) {
        cin >> arr[i];
        co += arr[i];
    }
    if(co%n > (n+1)/2) co = co/n+1;
    else co = co/n;
    int res = 0;
    for(int i = 0; i< n; i++){
        res += (arr[i] - co)*(arr[i] - co);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n;
  int k[10000]={};
  int cnt=0,ex=0;

  while(1)
    {
      cin >> n;
      if(n == 0)break;
      
      for(int i=0;i < n;i++)
	{
	  cin >> k[i];
	  if(k[i] <= 1)cnt++;
	  if(k[i] == 0)ex++;
	}
      if(cnt == n)
	{
	  cout << "NA" << endl;
	}
      else
	{
	  cout << n+1-ex << endl;
	}
      ex = 0;
      cnt = 0;
    }
  return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    string s;
    cin>>s;
    int len = s.length();

    int arr[len+1];
    memset(arr,-1,sizeof(arr));

    if(s[0]=='<')
    	arr[0] = 0;
    if(s[len-1]=='>')
    	arr[len] = 0;

    for(int  i = 0;i<len;i++)
    {
    	if(s[i]=='>' && s[i+1]=='<')
    		arr[i+1] = 0;
    	if(s[i]=='<' && arr[i]!=-1)
    		arr[i+1] = arr[i]+1;    	
    }

    for(int i = len-1;i>=0;i--)
    {
    	if(s[i]=='>')
    		arr[i] = max(arr[i],arr[i+1]+1);
    }
     long long sum = 0;
    for(int  i = 0;i<=len;i++){
    	sum+=arr[i];
    	//cout<<arr[i]<<" ";
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 5788
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
string s ;
int dp[1005][1005];
int solve(int i , int j){
if(i>=j)
    return 0;
if(dp[i][j]!=-1)return dp[i][j];
int ch1=solve(i+1,j-1)+(s[i]!=s[j]);
int ch2=solve(i+1,j)+1;
int ch3=solve(i,j-1)+1;
return dp[i][j]=min({ch1,ch2,ch3});
}
int main()
{
    fast();
   int n =D(), k=D();
   int a[n+5];
   for(int i=0;i<n;++i){
    cin>>a[i];
   }
   int sum=0;
   sort(a,a+n);
   for(int i=0;i<k;++i)
    sum+=a[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<long long> T(N);
  for(int i = 0; i < N; i++){
    cin >> T.at(i);
  }
  vector<bool> P(N, true);
  for(int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    if(T.at(A - 1) > T.at(B - 1)) P.at(B - 1) = false;
    else if(T.at(A - 1) < T.at(B - 1)) P.at(A - 1) = false;
    else{P.at(A - 1) = false; P.at(B - 1) = false;}
  }
  int c = 0;
  for(int i = 0; i < N; i++){
    if(P.at(i)) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 4052
#include<stdio.h>
#include<stdlib.h>
#define N 100000
#define M 100000

typedef struct linklist{
	int data;
	struct linklist *next;
} List;

List *genList(void);
void addList(List *list, int n);
int pathLen(List *list, int n);

List *m[N+1];
int d[N+1];
int flag[N+1];

int main(void)
{
	int i;
	int numN;
	int numM;
	int dataX;
	int dataY;
	int maxlen=0;

	scanf("%d%d", &numN, &numM);
	for(i=0;i<numN+1;i++){
		m[i]=genList();
	}
	for(i=0; i<numM; i++){
		scanf("%d%d", &dataX, &dataY);
		addList(m[dataX], dataY);
	}
	for(i=1; i<=numN; i++){
		pathLen(m[i],i);
		if(d[i] > maxlen){
			maxlen = d[i];
		}else{/*noprocess*/}
	}
	printf("%d",maxlen);
	return 0;
}


List *genList(void)
{
	List *newlist = (List *)malloc(sizeof(List));
	newlist->data=0;
	newlist->next=NULL;
	return newlist;
}
void addList(List *list, int n)
{
	List *newlist = genList();
	newlist->data=n;
	while(list->next != NULL){
		list = list->next;
	}
	list->next = newlist;
}
int pathLen(List *list, int n)
{
	int ret;
	int len;
	int maxlen=0;
	if(flag[n] != 0){
		ret = d[n];
	}else{
		if(list->next == NULL){
			ret = 0;
		}else{
			while(list->next != NULL){
				list = list->next;
				len = pathLen(m[list->data],list->data);
				if(maxlen < len){
					maxlen = len;
				}else{/*noprocess*/}
			}
			ret = maxlen + 1;
		}
		d[n] = ret;
		flag[n]=1;
	}
	return ret;
}


Measured memory_bytes: 9344
def main():
    n, k, q = map(int, input().split())
    a = []
    for i in range(q):
        a.append(int(input()))

    point = [0] * n

    for i in range(q):
        # point = list(map(lambda x: x - 1, point))
        point[a[i]-1] += 1

    for i in range(n):
        if k - (q - point[i]) > 0:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 77200
N,M,Q=map(int,input().split())
table = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L,R=map(int,input().split())
    table[L][R] += 1
for i in range(1,N+1):
    for j in range(1,N+1):
        table[i][j] += table[i-1][j] + table[i][j-1] - table[i-1][j-1]
for _ in range(Q):
    p,q = map(int,input().split())
    print(table[q][q] - table[q][p-1] - table[p-1][q] + table[p-1][p-1])


Measured memory_bytes: 14824
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    int D; cin >> D;
    vector<int> C(26); vector<vector<int>> S(D, vector<int>(26));
    REP(i, 0, 26) cin >> C[i];
    REP(i, 0, D) REP(j, 0, 26) cin >> S[i][j];


    vector<int> T(D);
    REP(i, 0, D) {
        int max_idx = 0;
        REP(j, 0, 26) {
            if (S[i][max_idx] < S[i][j]) max_idx = j;
        }
        T[i] = max_idx;
    }

    vector<int> last(26, 0);
    vector<ll> ret(26, 0);
    REP(i, 0, D) {
        ret[T[i]] += S[i][T[i]];
        last[T[i]] = i + 1;
        REP(j, 0, 26) {
            ret[j] -= C[j] * (i + 1 - last[j]);
        }
    }

	auto start = std::chrono::system_clock::now();
    const ll limit = 1950*1000;

    ll best = accumulate(ALL(ret), 0LL);
    mt19937_64 mt(random_device{}());
    uniform_int_distribution<int> day(0, D - 1);
    uniform_int_distribution<int> con(0, 25);
    while (1) {
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        double elapsed = std::chrono::duration_cast<std::chrono::microseconds>(now-start).count();
        if(elapsed > limit) break;

        int d = day(mt);
        int next = con(mt);
        int prev = T[d];
        T[d] = next;
        last[prev] = 0;
        last[next] = 0;
        ll oldp = ret[prev];
        ll oldn = ret[next];
        ret[prev] = 0;
        ret[next] = 0;
        REP(i, 0, D) {
            if (T[i] == prev || T[i] == next) {
                ret[T[i]] += S[i][T[i]];
                last[T[i]] = i + 1;
            }
            ret[prev] -= C[prev] * (i + 1 - last[prev]);
            ret[next] -= C[next] * (i + 1 - last[next]);
        }
        if (best >= accumulate(ALL(ret), 0LL)) {
            T[d] = prev;
            ret[prev] = oldp;
            ret[next] = oldn;
        } else {
            best = accumulate(ALL(ret), 0LL);
        }
        // cout << best << endl;
    }
    
    for (auto t : T) cout << t + 1 << endl;
    return 0;
}

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

int main(){
  int n,m,k;
  cin >> n >> m;
  vector<int> city(n,0);
  for(int i = 0; i < 2*m; i++){
    cin >> k;
    city.at(k-1)++;
  }
  for(int i = 0; i < n; i++){
    cout << city.at(i) << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX numeric_limits<ll>::max()
#define INT_MAX numeric_limits<int>::max()
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}



int main()
{
	int T, X;
	cin >> T >> X;

	cout << (float)T / X << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	sum := 0
	bk := ""
	target := ""
	for _, v := range s {
		target += string(v)
		if bk != target {
			sum++
			bk = target
			target = ""
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 3072
from sys import stdin


def main():
    readline = stdin.readline
    readline()
    *A, = map(int, readline().split())
    *B, = map(int, readline().split())
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = pre if pre < b else b
        b -= tmp1
        tmp2 = a if a < b else b
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


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



int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

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

// AC
public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			double[] area=new double[2];
			for(int j=0; j<2; j++){
				int m=sc.nextInt();
				if(m==0){
					return;
				}
				int sum=0;
				for(int i=0; i<m-1; i++){
					int deg=sc.nextInt();
					area[j]+=Math.sin(Math.toRadians(deg))/2;
					sum+=deg;
				}
				area[j]+=Math.sin(Math.toRadians(360-sum))/2;
			}
			if(area[0]>area[1]+EPS){
				println("1");
			}else if(area[0]+EPS<area[1]){
				println("2");
			}else{
				println("0");
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
n = int(input())
s = input()
cnt = 0
narabi = []
befores = '#'
for S in s:
    if S == befores:
        cnt += 1
    else:
        narabi.append(cnt)
        befores = S
        cnt = 1
narabi.append(cnt)
if s[-1] == '#':
    narabi.append(0)
hennkann = s.count('.')
saishou = s.count('.')
hashu = 0
dot = 1
for i in range(int(len(narabi) / 2)):
    hennkann = hennkann - narabi[dot] + narabi[hashu]
    saishou = min(saishou,hennkann)
    dot += 2
    hashu += 2
print(saishou)

Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, k, tmp=0,ans=0;
	cin >> n >> k;
	n -= 2;
	bool s = n > 0;
	int r = n % 11;
	n /= 11;
	rep(i, 11) {
		rep(j, 5) {
			if (((7 * i + j + 1) * 9 + 72) % 11 == k) {
				tmp++;
			}
		}
	}
	rep(i, r) {
		rep(j, 5) {
			if (((7 * i + j + 1) * 9 + 72) % 11 == k) {
				if (s)ans++;
			}
		}
	}
	ans += tmp*n;
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(){
int n,p=0,q=0;
string str1,str2;
cin>>n;
for(int i=0;i<n;i++){
    cin>>str1>>str2;
    if(str1==str2){p++;q++;}
  else if(str1<str2){q+=3;}
  else if(str1>str2){p+=3;}
}
cout<<p<<" "<<q<<endl;
return 0;
}

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

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

Node *NIL, *root;

void insert(int key)
{
    Node *x, *y, *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    y = NIL;
    x = root;
    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }

    z->parent = y;

    if (y == NIL)
    {
        root = z;
    }
    else if (z->key < y->key)
    {
        y->left = z;
    }
    else
    {
        y->right = z;
    }
}

Node *find(int key)
{
    Node *x;
    x = root;

    while (x != NIL)
    {
        if (key < x->key)
        {
            x = x->left;
        }
        else if (key > x->key)
        {
            x = x->right;
        }
        else
        {
            break;
        }
    }

    return x;
}

// 先行順巡回
void preorder(Node *node)
{
    if (node == NIL)
        return;
    cout << " " << node->key;
    if (node->left != NIL)
        preorder(node->left);
    if (node->right != NIL)
        preorder(node->right);
}

// 中間順巡回
void inorder(Node *node)
{
    if (node == NIL)
        return;
    if (node->left != NIL)
        inorder(node->left);
    cout << " " << node->key;
    if (node->right != NIL)
        inorder(node->right);
}

void print()
{
    inorder(root);
    cout << "\n";
    preorder(root);
    cout << "\n";
}

int main()
{
    int i, m, key;
    string command;

    cin >> m;
    for (i = 0; i < m; i++)
    {
        cin >> command;
        if (command[0] == 'i')
        {
            cin >> key;
            insert(key);
        }
        else if (command[0] == 'f')
        {
            cin >> key;
            if (find(key) != NIL)
            {
                cout << "yes\n";
            }
            else
            {
                cout << "no\n";
            }
        }
        else
        {
            print();
        }
    }

    return 0;
}


Measured memory_bytes: 21932
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<ll,ll> P;
const ll MO = 1000000007;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<Pi> g1(n),g2(n);
    set<Pi> st;
    rep(i,n){
        cin>>g1[i].se>>g1[i].fi;
        st.insert(g1[i]);
    }
    rep(i,n){
        cin>>g2[i].fi>>g2[i].se;
    }
    int ans=0;
    sort(begin(g2),end(g2));
    for(auto blue:g2){
        auto red=st.lower_bound(Pi(blue.se,-1));
        if(red==begin(st)) continue;
        red--;
        while(true){
            if(red->se<blue.fi){
                ans++;
                st.erase(red);
                break;
            }
            if(red==begin(st)) break;
            red--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	cout << fixed << setprecision (18);
	ld a, b, h, w, y;
	cin >> a >> b >> h >> w;
	w /= 5;
	h += w / 12;
	ld d = abs (h - w);
	d *= 30;
	y = min(d, 360 - d);
//	cout << y << endl;
//	cout << cosl(3.141592653589793238462643383279502884197169399375105820974944 * y / 180.0) << endl;
	ld x = b * b + a * a - 2 * a * b * (cosl(3.141592653589793238462643383279502884197169399375105820974944 * y / 180.0) * 1.0);
	cout << sqrt (x);
}


Measured memory_bytes: 4144
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  

	public static void main(String[] args) {   
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int K = I.nextInt();
		double tot = (double)(N);
		double ans = 0.0;
		for (int i = 1; i <= N; i++) {
			int cur = i;
			double curprob = 1.0;
			while (cur<K) {
				curprob/=2.0;
				cur*=2;
			}
			ans+=curprob;
		}
		ans/=tot; //1/N chance of each number being rolled
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25760
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    vector<int> edge(3);
    for(int i=0; i<3; i++) cin >>edge[i];
    sort(edge.begin(), edge.end());
    if(edge[2]*edge[2] == edge[1]*edge[1]+edge[0]*edge[0]) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
// Problem : A - New Year
// Contest : AtCoder - AtCoder Beginner Contest 084
// URL : https://atcoder.jp/contests/abc084/tasks/abc084_a?lang=en
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=1;i<=(n);i++)
#define ll long long
int main(){
	int n;
	cin>>n;
	cout<<24-n+24<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define to_bin(b, n) bitset<b>(n) 
#define setBits(n) __builtin_popcountll(n) 
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int n, k;
    cin >> n >> k;
    vi in(n);
    for(auto &i : in) cin >> i;
    sort(ALL(in));
	int cnt = 0;
	for(int i = 0 ; i < k; i++) cnt += in[i];
		cout << cnt << endl;
}
  
int32_t main() {
 
    FAST;

    
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n;
long long anss= LONG_MAX;
 
 
long long b[100005]={-1};
long long  cal(int a[], int n,int j,long long ans)
{ //out<<"here";
  
  if(j>n-1){
   //   cout<<ULONG_MAX;
    return LONG_MAX; 
  }
  if(j==n-1){
     // cout<<"here";
     
    return ans;
   
  }
  long long ans1 = ans + abs(a[j+1]-a[j]);
  long long ans2 = ans + abs(a[j+2]-a[j]);
  if(b[j]==-1){
      //cout<<j<<"here"<<endl;
      if(j+2!=n){ 
      b[j]= min(cal(a,n,j+1,ans1),cal(a,n,j+2,ans2));
      }else{
          
          b[j]=cal(a,n,j+1,ans1);
      }
      
      return b[j];
  }else{
      
      return b[j];
  }
  
}
 
 
int main()
{
  int k;
  cin>>n;
  cin>>k;
  int a[n+1]={0};
  
  for(int i=0;i<n;i++){		
   		cin>>a[i];   
  }
  
  for(int i=0;i<100005;i++){
      b[i]=INT_MAX;
      
  }
  b[0]=0;
  b[1]=abs(a[0]-a[1]);
  for(int i=2;i<=n;i++){
      int l=k;
      for(int j=i-1;j>=0 && l--;j--)
      {
      b[i]= min(b[j]+abs(a[i]-a[j]),b[i]);
      }
     
      
  }
 
  
  
  cout<<b[n-1];
  
  
  
}

Measured memory_bytes: 1536
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)
      
def lcm(n,m):
  return n*m//gcd(n,m)

A,B=map(int,input().split())
print(lcm(A,B))

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


int main()
{
    int x;
    cin >> x;

    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
        
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define MAXN 505
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,d[MAXN][MAXN];
int p[MAXN*MAXN];
bool has[MAXN][MAXN];
int ans=0;
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
void update(int x,int y)
{
    has[x][y]=false;
    queue<P> que;
    que.push(P(x,y));
    while(que.size())
    {
        P p=que.front(); que.pop();
        for(int k=0;k<4;k++)
        {
            int target=d[p.F][p.S]+(has[p.F][p.S]);
            int nx=p.F+dx[k],ny=p.S+dy[k];
            if(nx>=1&&nx<=n&&ny>=1&&ny<=n&&d[nx][ny]>target)
            {
                d[nx][ny]=target;
                que.push(P(nx,ny));
            }
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n*n;i++) scanf("%d",&p[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            d[i][j]=min(min(i-1,n-i),min(j-1,n-j));
            has[i][j]=true;
        }
    for(int i=1;i<=n*n;i++)
    {
        int x=(p[i]-1)/n+1,y=(p[i]-1)%n+1;
        ans+=d[x][y];
        update(x,y);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 5944
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

char s[4], t[4];

int main()
{
  scanf("%s\n%s", s, t);
  int ans = 0;
  for (int i = 0; s[i] && t[i]; i ++)
    ans += s[i] == t[i];
  printf("%d\n", ans);

  return(0);
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "from", int, "to", int, "cost");

void main() {
    int N, M, P;
    scan(N, M, P);

    Edge[] es;
    auto adj = new int[][](N, 0);

    foreach (i ; 0 .. M) {
        int ai, bi, ci;
        scan(ai, bi, ci);
        ai--, bi--;
        ci -= P;
        es ~= Edge(ai, bi, -ci);
        adj[bi] ~= ai;
    }

    auto reachable = new bool[](N);
    reachable[N - 1] = true;

    void dfs(int v) {
        reachable[v] = true;
        foreach (u ; adj[v]) {
            if (!reachable[u]) {
                dfs(u);
            }
        }
    }

    dfs(N - 1);

    es = es.filter!(e => reachable[e.to]).array;

    debug {
        writeln(es);
    }

    auto ans = BellmanFord(N, es);

    writeln(ans == -inf6 ? -1 : max(-ans, 0));
}


auto BellmanFord(int N, Edge[] es) {
    auto dist = new long[](N);
    dist[] = inf6;
    dist[0] = 0;

    foreach (i ; 0 .. N - 1) {
        foreach (e ; es) {
            if (dist[e.from] != inf6 && dist[e.from] + e.cost < dist[e.to]) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }

    foreach (e ; es) {
        if (dist[e.from] != inf6 && dist[e.from] + e.cost < dist[e.to]) {
            return -inf6;
        }
    }

    debug {
        writeln(dist);
    }

    return dist[N - 1];
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 2684