akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

int main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];
  sort(a,a+n);
  int q=0,w=0;
  r(i,n){
    if(i%2==0)q+=a[n-i-1];
    else w+=a[n-i-1];
  }
  cout<<q-w<<endl;
}

Measured memory_bytes: 256
c=[list(map(int,input().split())) for i in range(3)]
for i in range(2):
  if c[i][0]-c[i+1][0]==c[i][1]-c[i+1][1] and c[i][2]-c[i+1][2]==c[i][1]-c[i+1][1]:
    continue
  else:
    print("No")
    exit()
print("Yes")

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

long long MOD=1000000007LL;
long long dp[2001][2001];

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> S(N);
	vector<int> T(M);
	for(auto &i:S)cin >> i;
	for(auto &i:T)cin >> i;
	
	for(int i=0;i<2001;i++)for(int j=0;j<2001;j++)dp[i][j]=0;
	for(int i=0;i<2001;i++)dp[i][0]=1;
	for(int j=0;j<2001;j++)dp[0][j]=1;

	for(int i=0;i<N;i++)for(int j=0;j<M;j++){
		if(S[i]==T[j])dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1];
		else dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j];
		dp[i+1][j+1]=(dp[i+1][j+1]+MOD)%MOD;
	}
	cout << dp[N][M] << endl;
	return 0;
}

Measured memory_bytes: 31488
class Node:
	def __init__(self):
		self.parent = -1
		self.left = -1
		self.right = -1

# T : List[Node]

def preOrder(id: int):
	left_id = T[id].left
	right_id = T[id].right
	print(" " + str(id), end="")
	if left_id != -1:
		preOrder(left_id)
	if right_id != -1:
		preOrder(right_id)

def inOrder(id: int):
	left_id = T[id].left
	right_id = T[id].right
	if left_id != -1:
		inOrder(left_id)
	print(" " + str(id), end="")
	if right_id != -1:
		inOrder(right_id)

def postOrder(id: int):
	left_id = T[id].left
	right_id = T[id].right
	if left_id != -1:
		postOrder(left_id)
	if right_id != -1:
		postOrder(right_id)
	print(" " + str(id), end="")


if __name__ == "__main__":
	n = int(input())
	T = []
	for i in range(n):
		T.append(Node())
	for i in range(n):
		id, left, right = map(int, input().split())
		T[id].left = left
		T[id].right = right
		if left != -1:
			T[left].parent = id
		if right != -1:
			T[right].parent = id

	for i in range(n):
		if T[i].parent == -1:
			root_id = i
	print("Preorder")
	preOrder(root_id)
	print("")
	print("Inorder")
	inOrder(root_id)
	print("")
	print("Postorder")
	postOrder(root_id)
	print("")


Measured memory_bytes: 5612
#include <stdio.h>
#include <string.h>
 
int Hash[244140625];
char s[13];  

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}

int getKey(){
  int sum = 0, p = 1;
  
  for(int i = 0 ; i < strlen(s) ; i++){
    sum += p*(getChar(s[i]));
    p *= 5;
  }
  return sum;
}

int main(){
  int n;
  char com[7];
 
  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,s);
 
    if(com[0] == 'i'){
      Hash[getKey()] = 1;
    }else{
      if(Hash[getKey()]){
        puts("yes");
      }else{
        puts("no");
      }
    }
  }
 
  return 0;
}


Measured memory_bytes: 19576
while True:
        a=input()
        b=a.split()
        c=int(b[0])
        d=int(b[1])
        if c==0 and d==0:
                break
        for j in range(c):
                for k in range(d):
                        if k==0 or k==d-1 or j==0 or j==c-1:
                                print("#",end="")       
                        else:
                                print(".",end="")
                print()
        print()
        



Measured memory_bytes: 7000
#include<iostream>
#include<string>
#include <stdlib.h>
#include<math.h>
using namespace std;

int main(){
        string a;
        cin >> a;
        long long  n=0;
        cin >> n;
        double s[a.length()]={};
        long long  ans[a.length()]={0};
        for (int i=0;i<a.length();i++){
                s[i]=a[i]-'0';
        }
        for (int i=0;i<a.length();i++){
                n=n-pow(s[i],5000000000000000);
                if(n<=0){
                        cout << a[i];
                        break;
                }
        }
}


Measured memory_bytes: 384
s1 = input()
s2 = input()
arra = ["-"]
arrb = ["-"]
for i in s1:
    arra.append(i)
for i in s2:
    arrb.append(i)
n1 = len(s1)
n2 = len(s2)
temparr = [0 for i in range(n2 + 1)]
dp = [temparr[::] for i in range(n1 + 1)]

for i in range(1, n1 + 1):
    for j in range(1 , n2 + 1):
        if arra[i] != arrb[j]:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left
        else:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dig = dig + 1
            #print(dig)
            
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left

# for i in dp:
#     print(i) 
ans = ""

while n2 != 0 and n1 != 0 :
    
    if arra[n1] == arrb[n2]:
        ans += arra[n1]
        n2 -= 1 
        n1 -= 1 
        continue 
    else:
        if dp[n1 - 1][n2] >= dp[n1][n2 - 1]:
            n1 -= 1 
        else:
            n2 -=1 
print(ans[::-1])
    
   
        
        

Measured memory_bytes: 145012
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  uint64_t n, x;
  cin >> n >> x;
  vector<uint64_t> v;
  for (auto i = 0; i < n; i++) {
    uint64_t a;
    cin >> a;
    v.push_back(a);
  }
  sort(begin(v), end(v));
  uint64_t child = 0;
  for (auto i = 0; i < n; i++) {
    if (x < v[i]) break;
    x -= v[i];
    child++;
  }
  if (x > 0 && child == n) child--;
  cout << child << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

vector<long long> a;

int main() {
	a.resize(3);
	cin >> a[0] >> a[1] >> a[2];

	sort(a.begin(), a.end());
	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0) {
		cout << "0" << endl;
		return 0;
	}

	cout << a[0] * a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if ((x - r >= 0) && (x + r <= W) && (y - r >= 0) && (y + r <= H)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
import math
a,b,h,m = map(int,input().split())

if m == 0:
    argm = 0
else:
    argm = 360 * (m / 60)
if h == 0:
    if m == 0:
        argh = 0
    else:
        argh = 30 * (m/60)
else:
    if m == 0:
        argh = 360 * (h / 12)
    else:
        argh = 360 * (h / 12) + 30 * (m/60)
arg = abs(argh-argm)
print((a**2 + b**2 - 2*a*b*math.cos(math.radians(arg)))**0.5)

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

int calc(set<char> &x, set<char> &y) {
    int cnt = 0;
    for (int i = 0; i < 26; i++) cnt += x.count('a' + i) && y.count('a' + i);
    return cnt;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ma = 0;
    for (int i = 0; i < n; i++) {
        string l = s.substr(0, i), r = s.substr(i);
        set<char> sl(l.begin(), l.end());
        set<char> sr(r.begin(), r.end());
        ma = max(ma, calc(sl, sr));
    }
    cout << ma << endl;
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

ll v[3005][3005], dp[3005][3005][4];
int n,m;
bool valid(int x, int y){
    return (x <= n and y <= m);
}

ll solve(int x, int y, int used){
    if(x == n and y == m)
        return (used < 3 ? v[x][y]:0);
    if(dp[x][y][used] != -1ll)
        return dp[x][y][used];
    ll ans = 0;
    if(valid(x, y+1)){
        ans = max(ans, solve(x, y+1, used));
        if(used < 3)
            ans = max(ans, solve(x, y+1, used+1) + v[x][y]);
    }
    if(valid(x+1, y)){
        ans = max(ans, solve(x+1, y, 0));
        if(used < 3)
            ans = max(ans, solve(x+1, y, 0) + v[x][y]);
    }
    return dp[x][y][used] = ans;
}

int main(){
	fastio;
    memset(dp, -1, sizeof(dp));
    int k;
    cin >> n >> m >> k;
    while(k--){
        int x, y, p;
        cin >> x >> y >> p;
        v[x][y] = p;
    }
    cout << solve(1, 1, 0) << '\n';
	return 0;
}


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

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; } //ユークリッドの互除法の実装

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for(ll i = 2; i*i <= n; ++i) {
    if(n%i) continue; //割り切れたら0を返すので、割り切れなかったらcontinueという意味.割り切れないなら以下の処理をせずにforループの更新（++i）に戻る.
    res.emplace_back(i, 0); //因数iが何乗かの組みを記録したい。初めは0乗を記録する。emplace_back(a,b)で要素を追加する。
    while (n%i == 0) { //nがiで割り切れるならば以下の処理をループ
      n /= i; //nをiで割った値をnに代入する。
      res.back().second++; //iで割るごとに乗数を表す.secondをインクリメントする。 
    }
  }
  if(n != 1) res.emplace_back(n, 1);//nが1でないならn自身を要素に追加する。1は素因数ではないので。forループでiはnまで増えることはなくnが素因数のときが見落とされるのでこのコードが必要になる
  return res;
}

int main() {
  ll a,b;
  cin >> a >> b;

  ll g = gcd(a,b);
  auto f = factorize(g);

  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main() {
  double N;
  cin >> N;
  double a = floor(N / 1.08);
  if (floor(a*1.08) == N) cout << a << endl;
  else if (floor((a+1)*1.08) == N) cout << a+1 << endl;
  else if (floor((a-1)*1.08) == N) cout << a-1 << endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
// A
fscanf(STDIN, '%d', $T);
for ($t  = 0; $t < $T; $t++) {
    fscanf(STDIN, '%d %d %d %d %d', $N, $A, $B, $C, $D);
    $memo = [0, $D];
    $ans[] = f($N);
}
echo implode(PHP_EOL, $ans);

function f($num)
{
    global $memo, $A, $B, $C, $D;

    if (isset($memo[$num])) return $memo[$num];

    $c = $num * $D;
    foreach ([[2, $A], [3, $B], [5, $C]] as $arr) {
        list($x, $X) = $arr;
        $next_num = intdiv($num, $x);
        $move = $num % $x;
        $c = min($c, $X + $move * $D + f($next_num));
        if ($move > 0) $c = min($c, $X + ($x - $move) * $D + f($next_num + 1));
    }

    $memo[$num] = $c;
    return $memo[$num];
}

Measured memory_bytes: 17256
import java.util.*;
public class Main{
    static int goo(int a,int b) {
        int yuku;
        while((yuku = a % b) != 0){
            a = b;
            b = yuku;
        }
        return b;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int all = 360;
        int koubaisuu;
        int anc;
        int yu;
        int yukuanc;

        outside:{
        if(all%A == 0){
            anc = all/A;
        }else{
            for(int i = 2;i < A;i++){
                if(A % i == 0){
                    yukuanc = goo(all,A);
                    all *= A;
                    yu = all/yukuanc;
                    anc = yu/A;
                    //System.out.println(anc);
                    break outside;
                }
            }
            all *= A;
            anc = all/A;
        }
        }
        System.out.println(anc);
    }
}

Measured memory_bytes: 35672
package main

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

func main() {
	N := nextInt()
	A := make([]int, N)

	money := 1000
	kabu := 0

	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	for i := 0; i < N-1; i++ {
		if A[i] < A[i+1] {
			// 翌日上がるなら全力で買う
			c := money / A[i]
			kabu += c
			money -= c * A[i]
		} else {
			// 下がってたら全部売る
			money += kabu * A[i]
			kabu = 0
		}
	}

	for i := N - 2; i >= 0; i-- {
		if A[i] < A[i+1] {
			money += kabu * A[i+1]
			break
		}
	}

	fmt.Println(money)
}

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

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


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

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a+b>=2*a-1 && a+b>=2*b-1) cout<<a+b<<endl;
  else if(2*a-1>a+b && 2*a-1>2*b-1) cout<<2*a-1<<endl;
  else cout<<2*b-1<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<ll> A(N);
    for(auto& x:A) cin >> x;
    sort(A.rbegin(),A.rend());
    ll ans = A[0];
    int c = N-2;
    for(int i=1;i<N;i++){
        if(c>=2){
            ans += 2*A[i];
            c -= 2;
        }else if(c==1){
            ans += A[i];
            c--;
        }
        if(!c) break;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4788
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    YES(N == M);
}

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

typedef long long LL;

inline LL read()
{
	char c=getchar();LL num=0;
	for(;!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())
		num=num*10+c-'0';
	return num;
}

const int N=1e5+5;

int n,ans;
int a[N],b[N],ta[N],tb[N];
int sa,sb,tot,date[N];
int fa[N],scc[N],cnt;

int find(int x)
{
	return fa[x]==x?fa[x]:fa[x]=find(fa[x]);
}

int main()
{
	n=read();
	for(int i=1;i<=n;++i)
		a[i]=read(),ta[i]=a[i],sa^=a[i];
	for(int i=1;i<=n;++i)
		b[i]=read(),tb[i]=b[i],sb^=b[i];
	++n,a[n]=ta[n]=sa,b[n]=tb[n]=sb;
	sort(ta+1,ta+n+1),sort(tb+1,tb+n+1);
	for(int i=1;i<=n;++i)
	{
		if(ta[i]!=tb[i])
		{
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<n;++i)
		if(a[i]!=b[i])
			scc[++cnt]=a[i],scc[++cnt]=b[i],++ans;
	if(ans==0)
	{
		cout<<0;
		return 0;
	}
	scc[++cnt]=a[n],scc[++cnt]=b[n];
	sort(scc+1,scc+cnt+1);
	cnt=unique(scc+1,scc+cnt+1)-scc-1;
	for(int i=1;i<=cnt;++i)
		fa[i]=i;
	for(int i=1,fx,fy;i<=n;++i)
	{
		if(a[i]!=b[i])
		{
			a[i]=lower_bound(scc+1,scc+cnt+1,a[i])-scc;
			b[i]=lower_bound(scc+1,scc+cnt+1,b[i])-scc;
			fx=find(a[i]),fy=find(b[i]);
			fa[fx]=fy;
		}
	}
	for(int i=1;i<=cnt;++i)
		if(fa[i]==i)
			++ans;
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 4096
#include<cstdio>
using namespace std;
int main(void)
{
	int p[8],c[16]={4,1,4,1,2,1,2,1,4,1,4,1,2,1,2,1};
	int i,j,zyun[8]={1,6,2,8,4,7,3,5},sum,mn,mi;
	while(scanf("%d",&p[0])!=EOF)	{
		for(i=1;i<8;i++)	{
			scanf("%d",&p[i]);
		}
		mn=2000000000;
		for(i=0;i<8;i++)	{
			sum=0;
			for(j=0;j<8;j++)	{
				if(p[j]>c[i+j])	sum+=p[j]-c[i+j];
			}
//			printf("i=%d sum=%d\n",i,sum);
			if(mn>sum || (mn==sum && zyun[mi]<zyun[i]))	{
				mn=sum;	mi=i;
			}
		}
		printf("%d",c[mi]);
		for(i=1;i<8;i++)	{
			printf(" %d",c[mi+i]);
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c;cin>>a>>b>>c;
  c-(a-b)>=0 ? cout<<c-(a-b)<<endl : cout<<0<<endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    cout << (N+X-1) / X * T << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int L;

    scanf("%d", &L);

    // 0<=L<=100
    if(!((1 <= L) && (L <= 1000))) return -1;

    double a, Z;

    a = (double)L;
    a = a / 3;
    Z = a * a * a;

    printf("%.12f\n", Z);

    return 0;
}

Measured memory_bytes: 128
import heapq
import sys
input = sys.stdin.readline

def main():
    N = int(input().strip())
    l = [int(i) for i in input().strip().split()]
    ans = 0
    m = max(l)
    dp = [0] * (m+1)
 
    for n in l:
        for j in range(n, m + 1, n):
            dp[j] += 1
 
    for n in l:
        if dp[n] == 1:
            ans += 1
 
    return ans
 
if __name__ == "__main__":
    print(main())


Measured memory_bytes: 32220
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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(){
  string s; cin >> s;
  string txt = "abcdefghijklmnopqrstuvwxyz";
  if(s.size() < 26){
    vi word(26);
    rep(i,s.size()) word[s[i]-'a']++;
    rep(i,26){
      if(word[i] == 0){
        s += txt[i];
        break;
      }
    }
    cout << s;
    return 0;
  }else{
    for(int i = 25; 0 <= i; i--){
      if(s[i] < s[i+1]){
        char mn = s[i+1];
        for(int j = i+1; j < 26; j++){
          if(s[j] > s[i]) chmin(mn,s[j]);
        }
        cout << s.substr(0,i)+mn;
        return 0;
      }
    }
  }
  cout << -1;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3580
use std::cmp;

const INF: i64 = 1e15 as i64;

fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };

    let n = sc.read();
    let h: Vec<i64> = sc.read_vec(n);
    let mut dp = vec![INF; n];
    dp[0] = 0;
    for i in 0..n {
        if i + 2 < n {
            dp[i + 2] = cmp::min(dp[i + 2], dp[i] + (h[i + 2] - h[i]).abs());
        }
        if i + 1 < n {
            dp[i + 1] = cmp::min(dp[i + 1], dp[i] + (h[i + 1] - h[i]).abs());
        }
    }
    println!("{}", dp[n - 1]);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
// 01/02/20 // 5:08 PM //

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = (int)1e2 + 10;
const int MAXK = (int)1e5 + 10;
const int MOD  = (int)1e9 + 7;

int n, k, a[MAXN];
int memo[MAXN][MAXK], prefix[MAXK];

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

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


    for(int i=0; i<=n; i++)            memo[i][0] = 1;
    for(int j=0; j<=min(k,a[1]); j++)  memo[1][j] = 1;

    // i = 1
    prefix[0] = memo[1][0];
    for(int j=1; j<=k; j++) prefix[j] = memo[1][j] + prefix[j-1];

    for(int i=2; i<=n; i++){

        for(int j=0; j<=k; j++){

            if(j<=a[i])
                memo[i][j] = prefix[j];
            else
                memo[i][j] = (prefix[j] - prefix[j-a[i]-1] + MOD)%MOD;

        }

        prefix[0] = memo[i][0];
        for(int j=1; j<=k; j++)
            prefix[j] = (memo[i][j] + prefix[j-1])%MOD;
    }

    cout << memo[n][k] << endl;

    return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int X;
   cin>>X;
   if(X==3)
     cout<<"YES"<<endl;
   else if(X==5)
     cout<<"YES"<<endl;
   else if(X==7)
     cout<<"YES"<<endl;
   else
     cout<<"NO"<<endl;
   return 0;
   }

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

const int maxv = 1e5 + 2, inf = 2e9;
long long w[101], dp[maxv];
int v[101];

int main(){
	int n, W;
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	fill(dp + 1, dp + maxv, inf);
	for (int i = 0; i < n; i++) {
		for (int j = maxv - 1; j >= v[i]; j--) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	for (int i = maxv - 1; i >= 0; i--) {
		if (dp[i] <= W) {
			cout << i;
			return 0;
		}
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)

using namespace std;

typedef long long ll;
using pii = pair<int, int>;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;


//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    int n;
    cin >> n;
    int x = 0;
    double s = 1.08;
    rep2(i, 1, n+1){
        if(int(double(i) * s) == n){
            x = i;
            break;
        }
    }
    if(x)
        cout << x << endl;
    else{
        cout << ":(" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,k;
const int Maxn=1e5+5;
int h[Maxn],dp[Maxn];

int main(){
	cin>>n>>k;
	rep(i,n){
		cin>>h[i];
	}
	memset(dp,INF,sizeof(dp));
	dp[0]=0;
	rep(i,n){
		for(int j=1;j<=k&&i+j<n;j++){
			chkmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

bool solve(vector<vector<int>> &e, int n, int now = 0, int par = -1, int deep = 0){
	if(deep == 2 && now == n - 1) return true;
	else if(deep == 2) return false;
	bool f = false;
	for(int next:e[now]) if(next != par) f |= solve(e, n, next, now, deep + 1);
	return f;
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<vector<int>> e(n);
	while(m--){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		e[a].emplace_back(b);
		e[b].emplace_back(a);
	}
	cout << (solve(e, n) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 12016
n = int(input())
x = list(map(int, input().split()))
s_x = sorted(x)
small_ans = s_x[n//2 - 1]
large_ans = s_x[n//2]
for i in range(n):
    if x[i] < large_ans:
        print(large_ans)
    elif x[i] > small_ans:
        print(small_ans)
    else:
        print(small_ans)

Measured memory_bytes: 104996
#include <iostream>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)

const long long INF = 10000000000LL;

class BIT {
public:
	int size_ = 1;
	vector<long long> bit;

	void init(int sz) {
		size_ = sz + 2;
		bit.resize(size_ + 2, 0);
	}
	void add(int pos, long long x) {
		pos++;
		while (pos <= size_) {
			bit[pos] += x;
			pos += (pos&-pos);
		}
	}
	long long sum(int pos) {
		long long s = 0; pos++;
		while (pos >= 1) {
			s += bit[pos];
			pos -= (pos&-pos);
		}
		return s;
	}
};

long long N, A[1 << 18], B[1 << 18], C[1 << 18], D[1 << 18];
long long Q, X[1 << 18], Y[1 << 18], U[1 << 18], V[1 << 18];
long long cl[1 << 18], cr[1 << 18], dp[1 << 18][22], dist[1 << 18], len[1 << 18], cntv;
long long ans[1 << 18];
bool used[1 << 18];
vector<int> G[1 << 17], I[1 << 17], J[1 << 17];
BIT Z;

int prevs(int pos, int x) {
	for (int i = 21; i >= 0; i--) {
		if (x >= (1 << i)) { pos = dp[pos][i]; x -= (1 << i); }
	}
	return pos;
}

int lca(int u, int v) {
	if (dist[u] > dist[v]) swap(u, v);
	v = prevs(v, dist[v] - dist[u]);
	if (u == v) return u;

	for (int i = 21; i >= 0; i--) {
		if (dp[u][i] != dp[v][i]) {
			u = dp[u][i];
			v = dp[v][i];
		}
	}
	return dp[u][0];
}

void dfs(int pos, int dep) {
	used[pos] = true; dist[pos] = dep;
	cntv++; cl[pos] = cntv;
	for (int i = 0; i < G[pos].size(); i++) {
		if (used[G[pos][i]] == true) continue;
		dp[G[pos][i]][0] = pos;
		dfs(G[pos][i], dep + 1);
	}
	cr[pos] = cntv;
}

int main() {
	scanf("%lld%lld", &N, &Q); Z.init(N + 2);
	for (int i = 1; i <= N - 1; i++) {
		scanf("%lld%lld%lld%lld", &A[i], &B[i], &C[i], &D[i]);
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
		I[C[i]].push_back(i);
	}
	for (int i = 1; i <= Q; i++) {
		scanf("%lld%lld%lld%lld", &X[i], &Y[i], &U[i], &V[i]);
		J[X[i]].push_back(i);
	}

	dfs(1, 0);
	for (int i = 1; i <= 21; i++) {
		for (int j = 1; j <= N; j++) dp[j][i] = dp[dp[j][i - 1]][i - 1];
	}
	for (int i = 1; i <= N - 1; i++) { if (dist[A[i]] > dist[B[i]]) swap(A[i], B[i]); len[B[i]] = D[i]; }
	for (int i = 1; i <= N; i++) { Z.add(cl[i], len[i]); Z.add(cr[i] + 1, -len[i]); }

	for (int i = 1; i <= N; i++) {
		for (int j : I[i]) {
			int pos = B[j];
			Z.add(cl[pos], INF - len[pos]);
			Z.add(cr[pos] + 1, len[pos] - INF);
		}
		for (int pos : J[i]) {
			int v = lca(U[pos], V[pos]);
			long long w1 = Z.sum(cl[U[pos]]);
			long long w2 = Z.sum(cl[V[pos]]);
			long long w3 = Z.sum(cl[v]);
			long long w = w1 + w2 - 2LL * w3;
			long long p1 = (w / INF), p2 = (w % INF);
			ans[pos] = 1LL * Y[pos] * p1 + p2;
		}
		for (int j : I[i]) {
			int pos = B[j];
			Z.add(cl[pos], len[pos] - INF);
			Z.add(cr[pos] + 1, INF - len[pos]);
		}
	}
	for (int i = 1; i <= Q; i++) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 66428
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define MOD 1000000007;
using namespace std;
ll k=0;
ll d[15][15];//a桁の数で bから始まる数字の個数
ll check(ll k){//k番目のルンルン数を返す
    ll c=0,ans=0;;
    rep(i,1,11){
        rep(j,1,10){
            if(c+d[i][j]>=k){//答えの数を見つけた
                ans+=j*int(pow(10,i-1));
                while(i>1){//桁が２以上なら
                    if(j==0){
                        if(k<=c+d[i-1][j-1]+d[i-1][j]){
                            ans+=(j)*int(pow(10,i-2));
                            c+=d[i-1][j-1];
                            //j=j;
                        }else{
                            ans+=(j+1)*int(pow(10,i-2));
                            c+=d[i-1][j-1]+d[i-1][j];
                            j+=1;
                        }
                    }else
                    if(j==9){
                        if(k<=c+d[i-1][j-1]){
                            ans+=(j-1)*int(pow(10,i-2));
                            j=j-1;
                        }else{
                            ans+=(j)*int(pow(10,i-2));
                            c+=d[i-1][j-1];
                            //j=j;
                        }
                    }else{
                        if(k<=c+d[i-1][j-1]){
                            ans+=(j-1)*int(pow(10,i-2));
                            j=j-1;
                        }else if(k<=c+d[i-1][j-1]+d[i-1][j]){
                            ans+=(j)*int(pow(10,i-2));
                            c+=d[i-1][j-1];
                            //j=j;
                        }else{
                            ans+=(j+1)*int(pow(10,i-2));
                            c+=d[i-1][j-1]+d[i-1][j];
                            j+=1;
                        }
                    }
                    i--;
                }
                return ans;
            }else{
                c+=d[i][j];
            }
        }
    }
    return 0;
}


int main(){
    cin>>k;
    rep(j,0,10){
        d[1][j]=1;
    }
    rep(i,2,11){
        rep(j,0,10){
            if(1<=j&&j<=8)d[i][j]=d[i-1][j-1]+d[i-1][j]+d[i-1][j+1];//先頭の数字
            if(j==0){
                d[i][0]=d[i-1][0]+d[i-1][1];
            }
            if(j==9){
                d[i][9]=d[i-1][9]+d[i-1][8];
            }
        }
    }
    puts(check(k));
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(val) cerr << "Value " << #val << " : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ld epsilon = 10e-9;
const ll nax = 2e5+5;
ll n, k, arr[nax];	
vector<ll>a, b;

int main(void){
	IOS
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	set<ll>cek;
	ll curr=1;
	while(1){
		if(cek.count(curr)) break;
		cek.insert(curr);
		a.eb(curr);
		curr=arr[curr];
	}
	cek.clear();
	curr=a[a.size()-1];
	while(1){
		if(cek.count(curr)) break;
		cek.insert(curr);
		b.eb(curr);
		curr=arr[curr];
	}
	if(k<=a.size()-1){
		cout << a[k] << '\n';
	}
	else{
		k-=a.size();
		k%=b.size();
		cout << b[(k+1)%b.size()] << '\n';
	}
}


Measured memory_bytes: 17852
import java.util.Scanner;

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(N * A < B ? N * A : B);
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int tmp = N;
		int sum = 0;
		while (tmp > 0) {
			sum += tmp % 10;
			tmp /= 10;
		}
		if (N % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<math.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;

int insu_bunkai(int M){
    int count = 0;
    for(int A = 1; A*A <= M; A++){
        if(A*A == M){
            count++;
        }else if(M % A == 0){
            count += 2;
        }
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    for(int i=1; i<N; i++){
        cnt += insu_bunkai(i);
    }
    cout << cnt << endl;
}

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

using namespace std;

char name[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

char solve(const int N, const vector<string>& S, const string& b) {
	set<int> r;
	for (int i = 0; i < N; ++i) {
		bool f = true;
		bool state = false;
		for (int j = 0; j < b.size(); ++j) {
			bool s = b[j] == '1';
			if (S[j][i] == '1') {
				state = !state;
			}
			if (state != s) {
				f = false;
				break;
			}
		}
		if (f) {
			r.insert(i);
		}
	}
//	cout << "[" << N << "," << r.size() << "]";
	return r.size() == 1 ? name[*r.begin()] : '?';
}

int main() {
	int N, M, Q;
	while (cin >> N >> M >> Q, N || M || Q) {
		vector<string> S(Q), B(Q);
		for (int i = 0; i < Q; ++i) {
			cin >> S[i] >> B[i];
		}
		for (int i = 0; i < M; ++i) {
			string b = "";
			for (int j = 0; j < Q; ++j) {
				b += B[j][i];
			}
			cout << solve(N, S, b);
		}
		cout << endl;
	}
}

Measured memory_bytes: 2384
from collections import defaultdict

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

d = defaultdict(int)
for key in S:
    d[key] += 1
    
dl = sorted(d.items(), key=lambda x: x[0], reverse=False)
Max = max(d.values())

for i in range(len(dl)):
  if dl[i][1] == Max:
    print(dl[i][0])

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

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	if (s < t) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      if(a == 2||b == 2)System.out.println("No");
      else System.out.println("Yes");
      sc.close();
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

#define MAX_NCK 101010
ll f[MAX_NCK], rf[MAX_NCK];

// (a/b)%P の場合は，(a%P)*modinv(b)%P とする
ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

bool isinit = false;

void init() {
    f[0] = 1;
    rf[0] = modinv(1);
    for(int i = 1; i < MAX_NCK; i++) {
        f[i] = (f[i - 1] * i) % MOD;
        rf[i] = modinv(f[i]);
    }
}

ll nCk(int n, int k) {
    if(!isinit) {
        init();
        isinit = 1;
    }
    ll nl = f[n]; // n!
    ll nkl = rf[n - k]; // (n-k)!
    ll kl = rf[k]; // k!
    ll nkk = (nkl * kl) % MOD;

    return (nl * nkk) % MOD;
}

int main(void) {
    
    ll n,k;
    cin>>n>>k;
    vll v(n);
    rep(i,n)cin>>v[i];
    Sort(v);
    ll ans=0;

    for(ll i=n-1;i>=0;i--){
        if(i<k-1)break;
        ans+=nCk(i,k-1)%MOD*v[i]%MOD;
        ans%=MOD;
    }
    reverse(all(v));
    for(ll i=n-1;i>=0;i--){
        if(i<k-1)break;
        ans-=nCk(i,k-1)%MOD*v[i]%MOD;
        if(ans<0)ans+=MOD;
    }
    cout<<ans%MOD<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()


void solve(){
  int n, x, y; cin >> n >> x >> y;
  vector<ll> ans(n+5);--x; --y;
  FOR(i,0,n){
    FOR(j,i+1,n){
      int tmp = 98765432;
      tmp = min(tmp, j-i);
      tmp = min(tmp, abs(x-i)+abs(y-j)+1);
      tmp = min(tmp, abs(y-i)+abs(x-j)+1);
      ans[tmp]++;
    }
  }
  FOR(k,1,n){
    cout << ans[k] << endl;
  }
}


/*
void solve(){
  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vector<pair<ll,int>> pqr(a+b+c);
  FOR(i,0,a) {cin >> pqr[i].first; pqr[i].second = 0;}
  FOR(i,0,b) {cin >> pqr[a+i].first; pqr[a+i].second = 1;}
  FOR(i,0,c) {cin >> pqr[a+b+i].first; pqr[a+b+i].second = 2;}
  sort(ALL(pqr));
  reverse(ALL(pqr));
  ll ans = 0;
  FOR(i,0,a+b+c){
    if(pqr[i].second==0){
      if(x>0) ans += pqr[i].first;
      --x;
    }
    if(pqr[i].second==1){
      if(y>0) ans += pqr[i].first;
      --y;
    }
    if(pqr[i].second==2){
      bool used = false;
      if(x>0) {ans += pqr[i].first; used = true;x--;}
      if(y>0 && !used) {ans += pqr[i].first; used = true;y--;}
    }
  }
  cout << ans << endl;
}
*/

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<(n);++i)
const ll MOD=1e9+7;

struct StronglyConnectedComponents{
    vector<vector<int>> G,rG,C,T;
    vector<int> vs,cmp,used;
    StronglyConnectedComponents(int n):G(n),rG(n),cmp(n),used(n){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        rG[v].emplace_back(u);
    }
    void dfs(int v){
        used[v]=1;
        for (int u:G[v]) if(!used[u]) dfs(u);
        vs.emplace_back(v);
    }
    void rdfs(int v,int k){
        used[v]=1;
        cmp[v]=k;
        C[k].emplace_back(v);
        for (int u:rG[v]) if (!used[u]) rdfs(u,k);
    }
    int build(){
        int n=G.size();
        for (int i=0;i<n;++i) if (!used[i]) dfs(i);
        fill(used.begin(),used.end(),0);
        int k=0;
        for (int i=n-1;i>=0;--i){
            if (!used[vs[i]]){
                C.emplace_back(),T.emplace_back();
                rdfs(vs[i],k++);
            }
        }
        for (int v=0;v<n;++v) for (auto u:G[v]){
            if (cmp[v]!=cmp[u]) T[cmp[v]].emplace_back(cmp[u]);
        }
        for (int i=0;i<k;++i){
            sort(T[i].begin(),T[i].end());
            T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
        }
        return k;
    }
    int operator[](int i) const{
        return cmp[i];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V,E,Q; cin >> V >> E;
    StronglyConnectedComponents SCC(V);
    rep(i,E){
        int s,t; cin >> s >> t;
        SCC.add_edge(s,t);
    }
    cin >> Q;
    SCC.build();
    rep(i,Q){
        int u,v; cin >> u >> v;
        cout << (SCC[u]==SCC[v]) << endl;
    }
}


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

int main() {
    string S;
    cin >>S;
    if(S.at(0)==S.at(1) || S.at(1)==S.at(2) || S.at(2)==S.at(3)){
        cout <<"Bad"<<endl;
    }
    else cout <<"Good" <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N;
vector<int> v;
vector<int> dp;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	cin >> N;
	v.resize(N);
	dp.resize(N);
	fill(all(dp), 0);
	
	for(int i = 0; i < N; i++) {
		cin >> v[i];
	}
	
	for(int i = 1; i < N; i++) {
		if(i == 1) dp[i] = abs(v[i] - v[i-1]) + dp[i-1];
		else dp[i] = min(abs(v[i] - v[i-1]) + dp[i-1], abs(v[i] - v[i-2]) + dp[i-2]);
	}
	
	cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubbleSort(struct Card C[], int);
void selectionSort(struct Card C[], int n);
void print(struct Card C[], int n);
int isStable(struct Card C1[], struct Card C2[], int n);

int main(){
  struct Card C1[101], C2[101];
  int n, i;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubbleSort(C1, n);
  selectionSort(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}

void bubbleSort(struct Card C[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( C[j].value < C[j-1].value ){
	    t = C[j];
	    C[j] = C[j-1];
	    C[j-1] = t;
      }
    }
  }
}

void selectionSort(struct Card C[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( C[j].value < C[mini].value )
        mini = j;
    }
    t = C[i];
    C[i] = C[mini];
    C[mini] = t;
  }
}

void print(struct Card C[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", C[i].suit, C[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}


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

int main(){
    int d;
    cin >> d;
    string stg;
    switch (d)
    {
        case 25:
            stg = "Christmas";
            break;
        case 24:
            stg = "Christmas Eve";
            break;
        case 23:
            stg = "Christmas Eve Eve";
            break;
        case 22:
            stg = "Christmas Eve Eve Eve";
            break;
        default:
            break;
    }
    cout << stg << endl;
}

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


int main(){
int s=0,t=0;
vector<int> a(4),b(4);
for(int i=0;i<4;i++)cin>>a[i];

for(int i=0;i<4;i++)cin>>b[i];

for(int i=0;i<4;i++)s+=a[i];
for(int i=0;i<4;i++)t+=b[i];
cout<<max(s,t)<<endl;

}



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

using namespace std;

int main()
{
	int n, p[100];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int ans = 0;
	for (int i = 1; i <= 100; i++)
	{
		int cnt = 0;
		for (int j = 0; j < n; j++)
			if (p[j] >= i)
				cnt++;
		if (i <= cnt)
			ans = i;
	}
	cout << ans << endl;

	return 0;
}



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

typedef long long ll;
const int N = 200054;

int n;
int l[N], r[N], o[N];

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void down(int &x, const int y) {x > y ? x = y : 0;}
inline ll min(const ll x, const ll y) {return x < y ? x : y;}

int main() {
	int i, c, x, y, *li, *ls, *ri, *rs;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) scanf("%d%d", &x, &y), std::tie(l[i], r[i]) = std::minmax(x, y);
	std::tie(li, ls) = std::minmax_element(l, l + n),
	std::tie(ri, rs) = std::minmax_element(r, r + n),
	std::iota(o, o + (n + 1), 0), x = *ls, l[n] = c = y = INT_MAX,
	std::sort(o, o + n, [] (const int x, const int y) {return l[x] < l[y];});
	for (i = 0; i < n; ++i) up(x, o[i][r]), down(y, o[i][r]), down(c, x - min(y, o[i + 1][l]));
	printf("%lld\n", min(ll(*rs - *li) * c, ll(*ls - *li) * (*rs - *ri)));
	return 0;
}

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

int main()
{
    int N;
    bool flag = true;
    map < int , int > mp;

    cin >> N;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if(mp.find(A) == mp.end()) mp[A] = 1;
        else mp[A]++;
    }
    int M;
    cin >> M;
    for(int i = 0; i < M; i++) {
        int A;
        cin >> A;
        if(mp.find(A) == mp.end() || mp[A] == 0) flag = false;
        else mp[A]--;
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;

    return (0);
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i= 0; i< n; i++){
        cin >> h.at(i);
    }
   
   sort(h.begin(),h.end());
   reverse(h.begin(),h.end());
   ll count = 0;
   if(k >=n){
       cout << 0 << endl;
       return 0;
   }else{
       for(int i= k; i< n; i++){
           count += h.at(i);
       }
       cout << count << endl;
       return 0;
   }
}



Measured memory_bytes: 1792