akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll a[110], b[110], c[110], d[110];

vector<PLL> edge[55];
vector<PLL> edge2[55*2500];

int value(int v, int s){
	return v*2500+s;
}

vector<ll> dijkstra(int s, vector<PLL> *edge){
	priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
	VL dist(55*2500, LINF);
	dist[s] = 0LL;
	pq.push(PLL(dist[s],s));
	while(!pq.empty()){
		auto tmp = pq.top(); pq.pop();
		int from = tmp.second;
		int d = tmp.first;
		if(dist[from]<d) continue;
		for(auto p: edge[from]){
			int to = p.first;
			int d = p.second;
			if(dist[to]>dist[from]+d){
				dist[to] = dist[from]+d;
				pq.push(PLL(dist[to],to));
			}
		}
	}
	return dist;
}


signed main(){
	int n,m,s,u,v; cin>>n>>m>>s;
	rep(i,m){
		cin>>u>>v>>a[i]>>b[i]; u--; v--;
		edge[u].PB(PLL(v,i));
		edge[v].PB(PLL(u,i));
	}
	rep(i,n) cin>>c[i]>>d[i];

	rep(i,n){
		rep(j,2500){
			int to = min(j+c[i],2499LL);
			edge2[value(i,j)].PB(PLL(value(i,to),d[i]));
			for(auto p : edge[i]){
				int to = p.first;
				int edge_ind = p.second;
				if(j<a[edge_ind]) continue;
				edge2[value(i,j)].PB(PLL(value(to,j-a[edge_ind]),b[edge_ind]));
			}
		}
	}
	chmin(s,2499);
	auto dist = dijkstra(value(0,s),edge2);
	rep(i,n){
		if(i==0) continue;
		ll ans = LINF;
		rep(j,2500) chmin(ans,dist[value(i,j)]);
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 23916
#include <bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
#define fs(i, x, y) for(int i = x;i >= y;i--)
using namespace std;
typedef long long ll;
int n, vis[300010], a[400010], ans[200010];
ll dp[400010][60], sum, d;
int main() {
    scanf("%d%lld", &n, &sum);
    d = n * sum;
    memset(vis, -1, sizeof(vis));
    ff(i, 0, n - 1) {
        scanf("%d", &a[i]);
        a[i + n] = a[i];
    }
    ff(i, 0, 2 * n - 1) {
        if(vis[a[i]] == -1) {
            vis[a[i]] = i;
            dp[i][0] = n;
        }
        else {
            dp[vis[a[i]]][0] = i - vis[a[i]];
            vis[a[i]] = i;
            dp[i][0] = n;
        }
    }
    ff(i, 1, 59) {
        ff(j, 0, n - 1) {
            if(dp[j][i - 1] == -1 || dp[(j + dp[j][i - 1] + 1) % (ll)n][i - 1] == -1) {
                dp[j][i] = -1;
            }
            else
            dp[j][i] = dp[j][i - 1] + dp[(j + dp[j][i - 1] + 1) % (ll)n][i - 1] + 1;
            if(dp[j][i] >= d)
                dp[j][i] = -1;
        }
    }
    int now = 0;
    ll up = d;
    fs(i, 59, 0) {
        if(dp[now][i] != -1) {
            if(dp[now][i] + 1 <= up) {
                up -= (dp[now][i] + 1);
                now = (dp[now][i] + now + 1) % n;
            }
        }
    }
    int s = 0;
    memset(vis, -1, sizeof(vis));
    ff(i, n - up, n - 1) {
        if(vis[a[i]] == -1) {
            vis[a[i]] = i;
            s++;
            ans[s] = a[i];

        }
        else {
            while(ans[s] != a[i]) {
                vis[ans[s]] = -1;
                s--;
            }
            vis[ans[s]] = -1;
            s--;
        }
    }
    ff(i, 1, s) {
        printf("%d ", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 192512
from sys import stdin
import sys
import math


N, M = list(map(int, stdin.readline().rstrip().split()))
H = list(map(int, stdin.readline().rstrip().split()))

A = []
for i in range(M):
    #A.append(stdin.readline().rstrip().split())
    A.append(list(map(int, stdin.readline().rstrip().split())))

#print(H)
#print(A)

m = {}

for tmp in A:
    #print(tmp)
    a, b = tmp
    #print(a)
    if H[a - 1] > H[b - 1]:
        m[b] = 0
    elif H[a - 1] < H[b - 1]:
        m[a] = 0
    else:
        m[a] = 0
        m[b] = 0

count = 0
for j in range(1, N+1):
    if m.get(j, 1) == 1:
        count += 1

print(count)


Measured memory_bytes: 98664
#include <iostream>
#include <vector>
#include <cassert>

using ll = long long;
ll INF = 1LL << 60;

int main() {
    int N, Q;
    std::cin >> N >> Q;
    std::vector<ll> A(N);
    for (auto& a : A) std::cin >> a;
    A.push_back(INF);

    for (int q = 0; q < Q; ++q) {
        ll S;
        std::cin >> S;

        int r = 0;
        ll sum = 0;  // sum = A[l]+...+A[r-1]
        ll ans = 0;
        for (int l = 0; l < N; ++l) {
            while (sum <= S) {
                sum += A[r];
                ++r;
            }
            assert(r <= N + 1);
            ans += r - l - 1;
            sum -= A[l];
        }
        std::cout << ans << std::endl;
    }
    return 0;
}



Measured memory_bytes: 4436
s=input()

c = set("ACGT")
res = 0
for i in range(0, len(s)):
    for j in range(i,len(s)):
        t = s[i:j+1]
        u = len(t)
        t = set(t)
        if t | c == c:
            res = max(res, u)

print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=n/2,j=i+1,k=1;k<=m;k++,i--,j++){
        if(n%2==0&&(j-i==n/2||j-i==n/2+1))j++;
        cout<<i<<' '<<j<<endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
	vector<int> nums;
    for(int i = 0; i < 5; ++i){
    	int x; cin >> x;
    	nums.pb(x);
    }
    int k; cin >> k;

    for(int i = 0; i < 5; ++i){
    	for(int j = 0; j < 5; ++j){
    		if(abs(nums[i] - nums[j]) > k){
    			cout << ":(" << endl;
    			return 0;
    		}
    	}
    }
    cout << "Yay!" << endl;
	return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3
import math
n = int(input())
if n == 2:
    print(1)
    exit()
# n-1の約数を全列挙か、n の約数を全部探索して、n//k*p = 1+k*qになるかを確かめる
def divisor(n):
    res = [n]
    for i in range(2,1+math.floor(math.sqrt(n))):
        if n % i == 0:
            res.append(i)
            if i != n//i:
                res.append(n//i)
    return res
ans = len(divisor(n-1))
# n の約数で全列挙
res = []
lis = divisor(n)
for i in lis:
    # n を i で割れるだけわる
    m = n
    while m % i == 0:
        m = m // i 
    if m % i == 1:
        ans += 1
        res.append(i)
        #print(m,i)
print(ans)



Measured memory_bytes: 39024
/*
-----------------------------------------------------------------------------
Author :            ---------------------------------------------------------
    UTKAR$H $AXENA  ---------------------------------------------------------
    GOOGLE          ---------------------------------------------------------
-----------------------------------------------------------------------------
*/
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fre freopen("0.in", "r", stdin), freopen("0.out", "w", stdout)
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007
#define LL signed long long int
#define ps(x) push_back(x)
#define scan(x) scanf("%d", &x)
#define print(x) printf("%d\n", x)
#define scanll(x) scanf("%lld", &x)
#define printll(x) printf("%lld\n", x)
#define boost ios_base::sync_with_stdio(0)
vector<int> G[2 * 100000 + 5];
int dead[200000 + 4];
int neigh[200000 + 3][2];
int N, M;
string S;
int f = 0;
bool check(int v) { return neigh[v][0] > 0 and neigh[v][1] > 0; }
void kill(int v) {
  // cout << "Killing " << v << endl;
  queue<int> Q;
  Q.push(v);
  while (not Q.empty()) {
    v = Q.front();
    Q.pop();
    if (dead[v] == 1)
      continue;
    dead[v] = 1;
    for (int u : G[v]) {
      neigh[u][S[v - 1] - 'A']--;
    }
    for (int u : G[v]) {
      if (dead[u] == 0 and !check(u)) {
        Q.push(u);
      }
    }
  }
}
int main() {
//  fre;
  cin >> N >> M;
  cin >> S;
  for (int i = 1; i <= M; ++i) {
    int u, v;
    scan(u);
    scan(v);
    G[u].push_back(v);
    G[v].push_back(u);
    neigh[u][S[v - 1] - 'A']++;
    neigh[v][S[u - 1] - 'A']++;
  }
  for (int i = 1; i <= N; ++i) {
    if (!check(i))
      kill(i);
  }
  for (int i = 1; i <= N; ++i)
    if (dead[i] == 0)
      f = 1;
  cout << (f ? "Yes" : "No");
}


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

#define loop(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;
struct __{__(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}__;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	int x = nxt();
	int kuy =  10 - floor(x / 200);
	cout << kuy << endl;

	return 0;
}

Measured memory_bytes: 3704
s = input()[::-1]
s += "0"
n = len(s)
dp = [[10**7 for _ in range(2)] for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
	for j in range(2):
		x = int(s[i]) + j
		for a in range(10):
			kurisagaru = False
			if a >= x:
				b = 0
			else:
				b = 10 + a - x
				kurisagaru = True
			dp[i+1][kurisagaru] = min(dp[i+1][kurisagaru], dp[i][j]+a+b)
print(dp[n][0])


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll n;

bool query(vl a) {
	cout << "?";
	for (ll x: a) cout << " " << x+1;
	cout << endl;
	string ans; cin >> ans;
	if (ans == "-1") exit(0);
	return ans == "Blue";
}

bool queryc(ll i) {
	vl v(n);
	iota(all(v),i);
	return query(v);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	if (n == 1) {
		ll res = query({0});
		cout << "! " << (res ? "BR" : "RB") << endl;
		return 0;
	}
	
	bool pref = queryc(0);

	ll lo = 0, hi = n;
	while (hi-lo > 1) {
		ll mid = (lo+hi)/2;
		if (queryc(mid) == pref) lo = mid;
		else hi = mid;
	}
	ll j = hi;

	
	vl balanced;
	balanced.resize(n-1);
	iota(all(balanced),j);

	vl res(2*n,-1);
	res[j-1] = pref;
	res[j+n-1] = !pref;
	FOR(i,0,2*n) if (i+1 < j || i >= j+n) {
		balanced.pb(i);
		res[i] = query(balanced);
		balanced.pop_back();
	}
	
	balanced.clear();
	vl need(2,n/2);
	FOR(i,0,2*n) if (res[i] != -1 && need[res[i]]) {
		balanced.pb(i), need[res[i]]--;
	}
	assert(sz(balanced) == n-1);
	
	FOR(i,j,j+n-1) {
		balanced.pb(i);
		res[i] = query(balanced);
		balanced.pop_back();
	}
	
	cout << "! ";
	FOR(i,0,2*n) cout << "RB"[res[i]];
	cout << endl;
}



Measured memory_bytes: 724
def main():
    N = int(input())
    a = [list(map(int, input().split())) for i in range(2)]
    
    ans = 0
    for i in range(N):
        ans = max(ans, sum(a[0][:i+1]) + sum(a[1][i:]))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<cstdio>

int main(){
    char x[1201];
    scanf("%[^\n]",x);
    for(int i = 0; x[i] != '\0'; i++){
        char c = x[i];
        if(65 <= c && c <= 90){
            x[i] = c + 32;
        }
        else if(97 <= c && c <= 122){
            x[i]= c - 32;
        }
    }
    printf("%s\n",x);
    return 0;
}


Measured memory_bytes: 2676
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans=0;
  string s;
  cin >> n >> s;
  ll dp[n+1][n+1];
  fill(dp[0],dp[n+1],0);
  for(ll i=n-1;i>=0;i--){
    for(ll j=n-1;j>i;j--){
      if(s[i]==s[j]){
        dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1);
        ans=max(ans,min(dp[i][j],j-i));
      }else{
        dp[i][j]=0;
      }
    }
  }
  cout <<ans<<endl;
}


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

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    if(A.size() == n+1){
        int now = 0;
        for(int i=0;i<q;i++){
            if(A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans,now);
        return;
    }


    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}


int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
}

Measured memory_bytes: 3576
def resolve():
    n=int(input())
    l = list(map(int, input().split()))
    l.sort()
    a=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            if l[i]!=l[j]:
                for k in range(j+1,n):
                    if l[k] != l[j] and l[k]<l[j]+l[i]:
                        a+=1
    print(a)
resolve()

Measured memory_bytes: 68448
h, w = map(int, input().split(" "))

if h == 1 or w == 1:
    num2 = 1
else:
    h2 = h // 2
    row = (w+1) // 2
     
    num2 = h2 * w
    if h % 2 == 1:
        num2 += row
 
print(num2)


Measured memory_bytes: 2940
N = int(input())
L = list(map(int,input().split()))
s=0
if N <=2:
  print(0)
else:
  for i in range(N):
    for j in range(N-i-1):
      for k in range(N-j-i-2):
        n1=i
        n2=i+j+1
        n3=i+j+k+2
        if L[n1] + L[n2] >L[n3] and L[n1] + L[n3] >L[n2] and L[n3] + L[n2] >L[n1] and L[n1]!=L[n2] and L[n3]!=L[n2]and L[n1]!=L[n3] :
           s+=1
            
  print(s)          

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

signed main() {
	ll n, k; string s; cin >> n >> s >> k;
	rep(i, n) {
		if (s[i] != s[k - 1]) { s[i] = '*'; }
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3516
h, w = map(int, input().split())
a = [['#' for j in range(w+2)] for i in range(h+2)]
for i in range(h):
    s = list(input())
    for j, c in enumerate(s):
        a[i+1][j+1] = c
for line in a:
    print(*line, sep='')

Measured memory_bytes: 4596
n=int(input())
al=list(map(int, input().split()))  

al.sort()
curr_ans = 1
curr_sum = al[0]
for a in al[1:]:
    if curr_sum*2 >= a:
        curr_ans += 1
        curr_sum += a
    else:
        curr_ans = 1
        curr_sum += a

print(curr_ans)

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

int main()
{
    int n;
    cin >> n;
    int a[100002], b[100002];
    int les = 1000000002, ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(b[i] < les){
            les = b[i];
            ans = b[i] + a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
;;; Utils (quoted from https://competitive12.blogspot.com/2020/03/common-lisp.html)


;; Read fixnum

(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare (inline read-byte)
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (read-byte in nil 0))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setq minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (the (integer 0 #.(floor most-positive-fixnum 10)) (* result 10))))
              (return (if minus (- result) result))))))))

;; fast read-line

(defmacro buffered-read-line (&optional (buffer-size 30) (in '*standard-input*) (term-char #\Space))
  (let ((buffer (gensym))
        (character (gensym))
        (idx (gensym)))
    `(let* ((,buffer (load-time-value (make-string ,buffer-size :element-type 'base-char))))
       (declare (simple-base-string ,buffer)
                (inline read-byte))
       (loop for ,character of-type base-char =
             ,(if (member :swank *features*)
                  `(read-char ,in nil #\Newline) ; on SLIME
                `(code-char (read-byte ,in nil #.(char-code #\Newline))))
             for ,idx from 0
             until (char= ,character #\Newline)
             do (setf (schar ,buffer ,idx) ,character)
             finally (when (< ,idx ,buffer-size)
                       (setf (schar ,buffer ,idx) ,term-char))
             (return (values ,buffer ,idx))))))


;;; invoke child process

#-swank
(unless (member :child-sbcl *features*)
  (quit
    :unix-status
    (process-exit-code
      (run-program *runtime-pathname*
                   `("--control-stack-size" "128MB"
                     "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                     "--eval" "(push :child-sbcl *features*)"
                     "--script" ,(namestring *load-pathname*))
                                                                 :output t :error t :input t))))



;-------------------
; Write code here
;-------------------



(defun solve (n a b)
  (if (> a b)
      0
      (if (= n 1)
          (if (= a b)
              1
              0)
          (let ((s_min (+ b (* (1- n) a)))
                (s_max (+ a (* (1- n) b))))
            (1+ (- s_max s_min))))))

(defun main ()
  (let ((n (read))
        (a (read))
        (b (read)))
    (princ (solve n a b))
    (fresh-line)))

(main)


Measured memory_bytes: 25620
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: usize = input();
    let a: Vec<i32> = (0..1 << n).map(|_| input()).collect();

    let mut dp = vec![(0, 0); 1 << n];
    for i in 0..1 << n {
        dp[i] = (a[i], 0);
    }
    debug!(dp);

    let max2 = |a: (i32, i32), b: (i32, i32)| {
        let mut v = [a.0, a.1, b.0, b.1];
        v.sort();
        (v[2], v[3])
    };

    for i in 0..n {
        for j in 0..1 << n {
            if (j >> i) & 1 == 1 {
                dp[j] = max2(dp[j], dp[j ^ (1 << i)]);
            }
        }
    }
    debug!(dp);

    let mut ans = vec![0; 1 << n];
    for i in 1..1 << n {
        ans[i] = std::cmp::max(ans[i - 1], dp[i].0 + dp[i].1);
    }
    with_stdout_lock(|mut w| {
        for i in 1..1 << n {
            writeln!(w, "{}", ans[i]).unwrap();
        }
    });
}


Measured memory_bytes: 11260
s = input()

if s == 'SUN':
    n = 7
elif s == 'MON':
    n = 6
elif s == 'TUE':
    n = 5
elif s == 'WED':
    n = 4
elif s == 'THU':
    n = 3
elif s == 'FRI':
    n = 2
elif s == 'SAT':
    n = 1

print(n)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<string> w(n);
    vector<string> in(n);
    vector<string> en(n);
    for(int i=0;i<n;i++){
        cin>>w[i];
        in[i] = w[i].substr(0,1);
        en[i] = w[i].substr(w[i].size()-1,1);
    }
    bool key = true;
    for(int i=0;i<n-1;i++){
        if(en[i] != in[i+1]){
            key = false;
        }
    }
    //sort(w.begin(),w.end());
    //for(int i=0;i>n-1;i++){
    //    if(w[i] == w[i+1]){
    //        key = false;
    //    }
    //}
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(w[i] == w[j]){
                key = false;
            }
        }
    }
    if(key==true){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>

using namespace std;

int main()
{
    char S[11];
    cin >> S;

    char A[9] = {'\0'};
    for(int i = 0; i < 4; i++){
        A[i] = S[i];
    }
    for(int i = 4; i < 6; i++){
        A[i] = S[i + 1];
    }
    for(int i = 6; i < 8; i++){
        A[i] = S[i + 2];
    }

    if(strcmp(A, "20190430") <= 0){
        cout << "Heisei";
    }
    else{
        cout << "TBD";
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int tc,ac,K;


int main()
{
	scanf("%d %d %d", &tc, &ac, &K);
	for (int i = 0;i < K;i++)
	{
		if (i % 2 == 0)
		{
			if (tc % 2 == 0)
			{
				tc = tc / 2;
				ac = tc + ac;
			}
			else
			{
				tc = (tc - 1) / 2;
				ac = tc + ac;
			}
		}
		else if (i % 2 == 1)
		{
			if (ac % 2 == 0)
			{
				ac = ac / 2;
				tc = tc + ac;
			}
			else
			{
				ac = (ac - 1) / 2;
				tc = ac + tc;
			}
		}
	}
	printf("%d %d", tc, ac);






	
	




	//system("pause");
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    rep(i,n){
        cout << s.at(i);
        cout << t.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
        int i,j,k;
        char a[7];

        gets(a);

        if(a[2]==a[3] && a[4]==a[5]){
            printf("Yes");
        }
        else{
            printf("No");
        }
        return 0;
}


Measured memory_bytes: 1636
h, w, m = map(int, input().split())
boms = set()
Hs = [0] * h
Ws = [0] * w
for i in range(m):
  _h, _w = map(int, input().split())
  boms.add((_h - 1, _w - 1))
  Hs[_h - 1] += 1
  Ws[_w - 1] += 1
Hmax = max(Hs)
Hcount = Hs.count(Hmax)
Wmax = max(Ws)
Wcount = Ws.count(Wmax)
Hindexs = [0] * Hcount
Windexs = [0] * Wcount
hcount = 0
wcount = 0
for i in range(h):
  if Hs[i] == Hmax:
    Hindexs[hcount] = i
    hcount += 1
for i in range(w):
  if Ws[i] == Wmax:
    Windexs[wcount] = i
    wcount += 1
if m < len(Hindexs) * len(Windexs):
  print(Hmax + Wmax)
  exit()
for hindex in Hindexs:
  for windex in Windexs:
    if (hindex,windex) not in boms: 
      print(Hmax + Wmax)
      exit()
print(Hmax + Wmax -1)

Measured memory_bytes: 134596
n,d=map(int,input().split())
x=[]
for i in range(n):
    x.append(list(map(int,input().split())))

ans=0
for i in range(n):
    for j in range(n):
        if i<j:
            tmp=0
            for k in range(d):
                tmp += (x[j][k]-x[i][k])**2
            tmp = tmp**0.5
            if tmp.is_integer():
                ans += 1
print(ans)

Measured memory_bytes: 3064
N = int(input())
T, A = list(map(int, input().split()))
for i in range(N - 1):
	t, a = list(map(int, input().split()))
	if t >= T and a >= A:
		T, A = t, a
	else:
		if T / t >= A / a:
			if T % t == 0:
				T, A = int(t * (T // t)), int(a * (T // t))
			else:
				T, A = int(t * (T // t + 1)), int(a * (T // t + 1))
		else:
			if A % a == 0:
				T, A = int(t * (A // a)), int(a * (A // a))
			else:
				T, A = int(t * (A // a + 1)), int(a * (A // a + 1))

print(T + A)

Measured memory_bytes: 3064
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	chk := true
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(read, &a)
		if a%2 == 0 {
			chk = chk && (a%3 == 0 || a%5 == 0)
		}
	}
	if chk {
		fmt.Fprintln(write, "APPROVED")
	} else {
		fmt.Fprintln(write, "DENIED")
	}
}


Measured memory_bytes: 640
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return

    data class Csf(val c: Int, val s: Int, val f: Int)

    val t = 0.until(n - 1).map {
        val (c, s, f) = intList()
        Csf(c, s, f)
    }
    buildString {
        0.until(n - 1).forEach { i ->
            val c = t[i]
            var time: Long = c.s.toLong() + c.c.toLong()
            (i + 1).until(n - 1).forEach { j ->
                val c2 = t[j]
                if (time < c2.s) {
                    time = c2.s.toLong()
                } else {
                    val m = time % c2.f
                    if (m > 0) {
                        time += (c2.f - m)
                    }
                }
                time += c2.c
            }
            appendln(time)
        }
        appendln("0")
    }.let {
        println(it.trimIndent())
    }
}


Measured memory_bytes: 43392
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;
	cin>>n;
	vi h(n);
	rep(i,n)cin>>h[i];

	int ma=0;
	int ans=0;
	rep(i,n){
		if(ma<=h[i]){
			ans++;
			ma=h[i];
		}
	}
	cout<<ans<<endl;

	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
const HASH B = 1e9 + 7;

int a, b, c, d, p;


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d >> p;
    cout << min(p * a, b + max(0, (p - c) * d)) << endl;
}

Measured memory_bytes: 3180
#include <stdio.h>

int main(){
  int a[251], i, n;

  scanf("%d",&n);

  for(i=1; i<n+1; i++)
    scanf("%d",&a[i]);

  printf("node %d: key = %d, left key = %d, right key = %d, \n",1,a[1],a[2],a[3]);
  for(i=2; i<n+1; i++){
    if(i*2<n)
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,a[i],a[i/2],a[2*i],a[2*i+1]);

    else if(i*2==n)
      printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,a[i],a[i/2],a[2*i]);

    else
      printf("node %d: key = %d, parent key = %d, \n",i,a[i],a[i/2]);

  }
  return 0;
}



Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

bool f(string S) {
    int N = S.size();
    for(int i = 0; i < N; i++) {
        if(S[i] != S[N-1-i]) return false;
    }
    return true;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    string ans = "Yes";
    if(!f(S)) ans = "No";
    if(!f(S.substr(0, ((N-1)/2)))) ans = "No";
    if(!f(S.substr((N+3)/2-1, N))) ans = "No";
    cout << ans  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(x,y)	for (i=(x);i<(y);i++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

int i,N,C[500],S[500],F[500];

using namespace std;

int main() {
	int d=0,x = 0,t = 0;
	MEMCLR(C);
	MEMCLR(S);
	MEMCLR(F);
	
	cin >> N;

	REP(0,N) {
		cin >> C[i] >> S[i] >> F[i];
	}
	while (d<N-1) {
		x=d;
		t=S[d];
		REP(d,N-1){
			t = MAX(t,S[i]);
			if (t%F[i]!=0)t+=F[i]-t%F[i];
			t+=C[i];
		}
		cout << t << endl;
		d++;
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int main() {
    string s; cin >> s;
    queue<int> bfs;
    bfs.push(0);
    bool can = false;
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    while (!bfs.empty()) {
        int t = bfs.front();
        if (t == s.size()) {
            can = true;
            break;
        }
        bfs.pop();
        for (string di : divide) {
            if (s.substr(t, di.size()) == di) {
                bfs.push(t + (int)di.size());
            }
        }
    }
    cout << (can ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<vector<P>> t(0,vector<P>(0));
vector<int> c(0);

void dfs(int x,int col){
    if(c[x]<2) return;
    c[x]=col;
    for(auto y:t[x]){
        if(y.second==0) dfs(y.first,col);
        else dfs(y.first,(col+1)%2);
    }
    return;
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    t.resize(n);
    int x,y,z;
    rep(i,n-1){
        cin>>x>>y>>z;
        x --,y --;
        z %=2;
        t[x].emplace_back(y,z);
        t[y].emplace_back(x,z);
    }
    c.resize(n,2);
    dfs(0,0);
    rep(i,n) cout<<c[i]<<endl;
}

Measured memory_bytes: 46592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final long A = sc.nextLong();
		final long B = sc.nextLong();

		int[] towns = new int[N];
		towns[0] = sc.nextInt();
		long totalWork = 0;
		for (int i = 1; i < N; i++) {
			towns[i] = sc.nextInt();
			totalWork += Math.min((towns[i] - towns[i - 1]) * A, B);
		}
		System.out.println(totalWork);
		sc.close();
	}

}


Measured memory_bytes: 50672
package main

import "fmt"

func main() {
    var N int
    fmt.Scan(&N)
    A := make([]int, N)
    for i := range A {
        fmt.Scan(&A[i])
    }

    ans := 0
    for {
        ok := true
        for _, v := range A {
            if v%2 != 0 {
                ok = false
            }
        }
        if !ok {
            break
        }

        for i := range A {
            A[i] /= 2
        }
        ans++
    }
    fmt.Println(ans)
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args){
        int h,m,s;

        Scanner sc = new Scanner(System.in);
        int sec = sc.nextInt();

        s = sec%60;
        m = (sec/60)%60;
        h = sec/60/60;
        System.out.println(h + ":" + m + ":" + s);

    }
}


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

int n,m;
int a[100005];
int b[100005];
int c[100005];
pair<int,int> d[100005];
long long ans;

int main(){

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

    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=m;i++){
        cin>>b[i]>>c[i];
        d[i].first=c[i];
        d[i].second=b[i];
    }
    sort(d+1,d+1+m);
    int p=1;
    for(int i=m;i>=1&&p<=n;i--){
        int cc=d[i].first;
        int bb=d[i].second;
        for(int j=1;j<=bb;j++){
            if(p<=n){
                a[p]=max(a[p],cc);p++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        ans+=a[i];//cout<<a[i]<<' ';
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main(void) {
	int a, b, c; char ch;
	while (1){
		scanf("%d %c %d", &a, &ch, &b);
		if (ch == '?') break;
		if (ch == '+') c = a + b;
		else if (ch == '-') c = a - b;
		else if (ch == '*') c = a*b;
		else if (ch == '/') c = a / b;
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main()
{
    long long H;
    long long sum = 0;
    long long i = 0;
    unsigned long long mask = 1;
    
    scanf("%lld", &H);
    while(H/2 || (H == 1))
    {
        sum = sum + (mask<<i);
        i++;
        H = H/2;
    }
    
    printf("%lld", sum);
    
    
    return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, K;
  cin >> N >> K;

  VL as(N);
  rep(i, N) cin >> as[i];

  rep(i, N - K) {
    string res = as[i + K] > as[i] ? "Yes" : "No";
    cout << res << "\n";
  }
}


Measured memory_bytes: 4776
#![allow(dead_code)]
use std::io::*;

fn main(){
    let a: i32 = read();
    let b: i32 = read();
    if (a + b) % 2 == 0 {
        println!("{}", (a + b) / 2)
    }else{
        println!("IMPOSSIBLE");
    }
    
}

fn upper_bound(a: &Vec<i32>, x: &i32) -> Option<usize>
{
    let mut ok: isize = a.len() as isize;
    let mut ng: isize = -1;
    if ok == 0 || a[ok as usize - 1] <= *x{
        None
    }else{
        while (ng - ok).abs() > 1{
            let mid = (ok + ng) / 2;
            if a[mid as usize] > *x{
                ok = mid;
            }else{
                ng = mid;
            }
        }
        Some(ok as usize)
    }
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val result = doTask(n)
    println(result)
}

fun doTask(n: Int):String {
    var cnt = 0

    repeat(n) {
        val (d1, d2) = readLine()!!.split(" ").map(String::toInt)
        if(d1 == d2) {
            cnt++
            if (cnt == 3) {
                return "Yes"
            }
        } else {
            cnt = 0
        }
    }
    return "No"
}

Measured memory_bytes: 37820
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
/*
ll vis[100005]={0};
ll par[100005]={0};
//map<ll,ll> mp;
ll ma=0;
void dfs(vector<ll> v1[],int x)
{
    
    vis[x]=1;
        for(auto i : v1[x])
        {
            if(vis[i]==0)
                dfs(v1,i);
        }
        
    return ;
}*/
int main()
{
    ll a,b,c,d,e,x,t,n,m,count;
    //ll ma=-1;
    t=1;
    //cin>>t;
    //string s1;
    //vector<ll> ev,od;
    //map<char,ll> mp;
    //set <char> se;
    while(t--)
    {
        
        cin>>a>>b>>c;
        d=a/(b+c);
        d=d*b;
        e=a%(b+c);
        if(e<=b) d+=e;
        else d+=b;
        cout<<d;
        
        
    }
    return 0;
}
 

Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
edges = []
for _ in range(m):
    a,b = map(int,input().split())
    edges.append((a,b))
    g[a].append(b)
    g[b].append(a)
ans = 0
for a,b in edges:
    cnct = [False for _ in range(n+1)]
    cnct[a] = True
    que = deque([])
    for k in g[a]:
        if k!=b:
            que.append(k)
    while que:
        p = que.pop()
        if cnct[p] == True:
            continue
        else:
            cnct[p] = True
            for k in g[p]:
                que.append(k)
    if cnct[b] == False:
        ans += 1
print(ans)

Measured memory_bytes: 3444
import string

n = int(input())

m = len(string.ascii_lowercase)
chars = string.ascii_lowercase[-1] + string.ascii_lowercase[:-1]
result = ''
while n:
    tmp = n%m
    result = chars[tmp] + result
    if n <= m:
        break
    n = (n-1)//m

print(result)

Measured memory_bytes: 9968
N,X = map(int,input().split())
list = list(map(int,input().split()))
diff = [abs(x-X) for x in list]

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

if len(diff) >= 2:
    gcd_val = diff[0]
    for i in diff[1:]:
        gcd_val = gcd(gcd_val,i)
    print(gcd_val)
else:
    print(diff[0])

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

int main(){
    int n,s,x;
    cin >> n;
    x=n;
    while(x!=0){
        s+=x%10;
        x/=10;
    }
    if(n%s==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k; cin >> n >> k;
    vector <int> ar(n);
    for (auto &i : ar) cin >> i;
    sort(all(ar));
	int res = 0;
	for (int i = 0; i < k; i++) {
		res += ar[i];
	}
	cout << res << endl;
    

    return 0;
}


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

int main(){
int N;
  cin>>N;
  
  bool ans=false;
  for(int i=0; i<30; i++){
   for(int j=0; j<30; j++){
    if(4*i+7*j==N){ans=true;}
   }
  }
  if(ans){cout<<"Yes";}
  else{cout<<"No";}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p;
    rep(i, n){ int tmp; cin >> tmp; p.push_back(tmp);}

    vector<int> sum;
    int tmpsum = 0;
    rep(i, n) { sum.push_back(tmpsum); tmpsum += p[i];}
    sum.push_back(tmpsum);

    int ans = 0;
    rep(i, n-k+1){
        ans = max(ans, sum[i+k] - sum[i]);
    }
     printf("%lf\n",(double)(ans + k) / 2.0);

}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int n;
  cin >> n;
  int x = n/15;
  cout << (800*n-200*x) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<int> vecint;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

#define MAX_V 200
#define INF 1e+9





int main() {
	int A, B, C, X;
	cin  >> A >> B >> C  >> X;
	ll ans = 0;
	for (int i = 0; i <= A; i++) {
		if (500 * i > X)
			continue;
		for (int j = 0; j <= B; j++) {
			int Y = X - 500 * i - 100 * j;
			if (Y < 0)
				break;
			if (Y<= 50 * C)
				ans++;


		}


	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
h = []
n.times do
  h << gets.to_i
end

h.sort!
ans = 10 ** 10
(n - k + 1).times do |i|
  d = h[i + k - 1] - h[i]
  ans = d < ans ? d : ans
end

puts ans


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int nidx=1;
int nxt[2000010][26];
int mark[2000010];
int msum[2000010];
int dp[2000010][26];

void init(int v,const string& s,int i){
  int n=s.size();
  if(i==n){
    mark[v]++;
    return ;
  }

  int c=s[i]-'a';
  if(nxt[v][c]==-1){
    nxt[v][c]=nidx++;
  }
  init(nxt[v][c],s,i+1);
}

void initdp(int v){
  if(v==-1)return ;
  rep(c,26){
    initdp(nxt[v][c]);
    if(nxt[v][c]!=-1){
      rep(dpc,26){
        if(c==dpc){
          dp[v][dpc]+=msum[nxt[v][c]];
        }else{
          dp[v][dpc]+=dp[nxt[v][c]][dpc];
        }
      }

      msum[v]+=msum[nxt[v][c]];
    }
  }
  msum[v]+=mark[v];
}

ll res;

void dfs(int v,const string& s,int i){
  int n=s.size();
  if(i==n-1){
    int c=s[i]-'a';
    res=dp[v][c];
    return ;
  }

  int c=s[i]-'a';
  dfs(nxt[v][c],s,i+1);
}

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

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

  int N;
  cin>>N;
  vector<string> S(N);
  rep(i,N){
    cin>>S[i];
    reverse(all(S[i]));
  }

  int root=0;
  rep(i,N){
    init(root,S[i],0);
  }
  initdp(root);

  ll ans=0;
  rep(i,N){
    dfs(root,S[i],0);
    ans+=res;
  }

  cout<<ans-N<<"\n";

  return 0;
}


Measured memory_bytes: 372552