akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Deque<String> name = new ArrayDeque<String>();
        Deque<Integer> time = new ArrayDeque<Integer>();
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int quantum = scan.nextInt();

        for(int i=0; i<n; i++)
        {
            name.offerLast(scan.next());
            time.offerLast(scan.nextInt());
        }

        String process_name;
        int process_time;
        int elapsed_time = 0;
        while((process_name = name.pollFirst())!=null)
        {
            process_time = time.pollFirst();
            if(process_time > quantum)
            {
                name.offerLast(process_name);
                time.offerLast(process_time - quantum);
                elapsed_time += quantum;
            }
            else
            {
                elapsed_time += process_time;
                System.out.println(process_name + " " + elapsed_time);
            }
        }
    }
}

Measured memory_bytes: 74884
#include <stdio.h>
int main()
{
	// 変数定義
	char chInput;			// 入力1文字
	char chPreInput = 0;	// 1文字前の入力
	int iSum;
	// 1行ずつ入力を繰り返す
	while (1)
	{
		// iSumの初期化
		iSum = 0;
		// 改行を読み込むまで足し続ける
		while ((chInput = getc(stdin)) != '\n')
		{
			iSum += chInput - '0';
			chPreInput = chInput;
		}
		if (iSum == 0) break;

		// 足し込んだ結果を表示する
		printf("%d\n", iSum);
	}
	return 0;
}


Measured memory_bytes: 2032
from collections import deque
n=int(input())
g=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append([b-1,c])
    g[b-1].append([a-1,c])
q,k=map(int,input().split())
qu=deque([[k-1,0]])
v=[0]*n
d=[0]*n
while len(qu)>0:
    s=qu.popleft()
    v[s[0]]=1
    for j in g[s[0]]:
        if not v[j[0]]:
            v[j[0]]=1
            d[j[0]]=s[1]+j[1]
            qu+=[[j[0],d[j[0]]]]
for i in range(q):
    x,y=map(int,input().split())
    print(d[x-1]+d[y-1])


Measured memory_bytes: 58452
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define DOW(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)

using namespace std;

int d[1000000];

int main() {
  ios::sync_with_stdio(false);
  int n, m, u, v;
  while (cin >> n >> m) {
    FOR(i, 1, n) d[i] = 0;
    FOR(i, 1, m) {
      cin >> u >> v;
      d[u]++; d[v]++;
    }
    bool sol = true;
    FOR(i, 1, n) if (d[i] % 2) sol = false;
    if (sol) cout << "YES" << endl; else cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const double PI = 3.14159265358979323846;
int main() {
    string s;
    cin >> s;
    if(s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3592
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
void solve(){
    int n;
    cin>>n;
    vi a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    sort(ALL(a)),sort(ALL(b));
    int x;
    if(n%2){
         x=b[n/2]-a[n/2]+1;
    }
    else{
        x=b[n/2-1]+b[n/2]-(a[n/2-1]+a[n/2])+1;
    }
    cout<<x<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 4780
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;
#define inf 1e4+1


int main()
{
	int n, k;
	std::cin >> n >> k;

	vector<int> a((int)n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	vector<int> dp((int)n);
	dp[0] = 0;

	for (int i = 1; i < n; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			int compID = i - j;
			if (j == 1) dp[i] = abs(a[i] - a[compID]) + dp[compID];
			else if (compID < 0) dp[i] = min((int)inf, dp[i]);
			else dp[i] = min(abs(a[i] - a[compID]) + dp[compID], dp[i]);
		}
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int i,j,k,l,n,c;
  while(scanf("%d",&n)!=EOF){
    for(i=c=0;i<10;i++){
      for(j=0;j<10;j++){
	for(k=0;k<10;k++){
	  for(l=0;l<10;l++){
	    if(i+j+k+l==n)c++;
	  }
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 596
S = input()

def solve(S):
    if len(S) < 26:
        return S + min(set(chr(ord('a') + i) for i in range(26)) - set(S))
    for i in range(len(S) - 1, 0, -1):
        if S[i - 1] < S[i]:
            return S[:i - 1] + min(s for s in S[i:] if s > S[i - 1])
    return "-1"

print(solve(S))


Measured memory_bytes: 3060
import sys
readline = sys.stdin.buffer.readline

N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, readline().split())
    lb = 1 << i
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (N + 1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

MOD = 10**9 + 7
x = (MOD + 1) // 2
power_inv = [1] * (N + 100)
for i in range(1, N + 100):
    power_inv[i] = power_inv[i - 1] * x % MOD

size = [1] * (N + 1)
p_size = [N - 1] * (N + 1)
prod = [1] * (N + 1)
coef = [1] * (N + 1)
for v in order[::-1]:
    p = parent[v]
    x = size[v]
    size[p] += x

ans = 0
for i in size[2:]:
    ans += 1 - power_inv[i] - power_inv[N - i] + power_inv[N]
    ans %= MOD
ans = ans - N * power_inv[1] + 1 - power_inv[N]
ans %= MOD

print(ans)


Measured memory_bytes: 64120
#include<stdio.h>

int main(){
  int A[100];
  int flag,j,temp,N,s;
  int i = 0,a = 0;

  scanf("%d",&N);

  for(i = 0; i <= N-1; i++) scanf("%d",&A[i]);
  
  flag = 1;

  while(flag){
    flag = 0;
    for(j = N-1; 1 <= j; j--){
      if(A[j] < A[j-1]){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	flag = 1;
	a++;
      }
    }
  }

  for(s = 0; s <= N-1; s++){
    if(s > 0) printf(" ");
    printf("%d",A[s]);
  }
  printf("\n");
  printf("%d\n",a);

   return 0;
   
}

  



Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define inf 2e18
using namespace std;
typedef long long ll;
typedef pair<ll,ll>p;
int main()
{
    //freopen("in.txt", "r", stdin);
    ll n;
    cin>>n;
    ll mn=inf;
    ll a=n,b=1;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
           if(abs(n/i-i)<mn){
            mn=abs(n/i-i);
            a=n/i;
            b=i;
           }
        }
    }
    a--;
    b--;
    cout<<a+b<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i,j,a,count,k=0;

    scanf("%d",&a);

    for(i=1;i<=a;i++){
        count = 0;
        for(j=1;j<=i;j++){
            if(0 == i%2){
                break;
            }
            if(0 == i%j){
                count++;
            }
        }
        if(count == 8){
            k++;
        }
    }

    printf("%d\n",k);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int par[200000];
int rrank[200000];
void init(int n){
for (int i=0;i<n;i++){
par[i]=i;
rrank[i]=0;
}}
int find(int x){
if (par[x]==x) return x;
else return par[x]=find(par[x]);
}
void unite(int x,int y){
x=find(x);
y=find(y);
if (x==y) return;
if (rrank[x]<rrank[y]) par[x]=y;
else {par[y]=x;
if (rrank[x]==rrank[y]) rrank[x]++;}}
bool same(int x,int y){
return find(x)==find(y);}

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  init(n);
  vector<int> a(n,1),c(n,0);
  rep(i,m){
    int f,g;
    cin >> f >> g;
    f--;
    g--;
    unite(f,g);
    a[f]++;
    a[g]++;
  }
  vector<vector<int>> b(n,vector<int>(0));
  rep(i,k){
    int f,g;
    cin >> f >> g;
    f--;
    g--;
    b[f].push_back(g);
    b[g].push_back(f);
  }
  rep(i,n){
    c[find(i)]++;
  }
  rep(i,n){
    int u=0;
    rep(j,b[i].size()){
      if (same(i,b[i][j])) u++;
    }
    cout << c[find(i)]-a[i]-u << " ";
  }
  cout << endl;
}


Measured memory_bytes: 7552
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let c11: isize = iterator.next().unwrap().parse().unwrap();
    let c12: isize = iterator.next().unwrap().parse().unwrap();
    let c13: isize = iterator.next().unwrap().parse().unwrap();
    let c21: isize = iterator.next().unwrap().parse().unwrap();
    let c22: isize = iterator.next().unwrap().parse().unwrap();
    let c23: isize = iterator.next().unwrap().parse().unwrap();
    let c31: isize = iterator.next().unwrap().parse().unwrap();
    let c32: isize = iterator.next().unwrap().parse().unwrap();
    let c33: isize = iterator.next().unwrap().parse().unwrap();

    let a1: isize = 0;
    let b1: isize = c11 - a1;
    let b2: isize = c12 - a1;
    let b3: isize = c13 - a1;

    if (c21 - b1) == (c22 - b2) && (c22 - b2) == (c23 - b3)
        && (c31 - b1) == (c32 - b2) && (c32 - b2) == (c33 - b3) {
        return String::from("Yes");
    }

    return String::from("No");
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    string S; cin >> S;
    bool a = false, b = false;
    REP(i, 3){
        if(S[i] == 'A') a = true;
        else b = true;
    }
    cout << ((a&b) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
int t[24][3]={
{1,2,3},{1,3,5},{1,5,4},{1,4,2},
{2,1,4},{2,4,6},{2,6,3},{2,3,1},
{3,1,2},{3,2,6},{3,6,5},{3,5,1},
{4,1,5},{4,5,6},{4,6,2},{4,2,1},
{5,1,3},{5,3,6},{5,6,4},{5,4,1},
{6,2,4},{6,4,5},{6,5,3},{6,3,2}
},i,j,a,b,f,n,N[100][7];
h(x,y){
for(a=0;a<24;a++)
if(N[x][1]==N[y][t[a][0]]&&
   N[x][2]==N[y][t[a][1]]&&
   N[x][3]==N[y][t[a][2]]&&
   N[x][4]==N[y][7-t[a][2]]&&
   N[x][5]==N[y][7-t[a][1]]&&
   N[x][6]==N[y][7-t[a][0]])
   f=1;
 return 0;
}
main(){
    for(scanf("%d",&n),i=0;i<n;i++)
        for(j=1;j<7;scanf("%d",&N[i][j]),j++);
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
            h(i,j);
    printf("%s\n",f==1?"No":"Yes");
}

Measured memory_bytes: 1860
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long A = sc.nextLong();
			final int X = Integer.parseInt(sc.next().replace(".", ""));
			
			System.out.println(A * X / 100);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32760
n = int(input())

from collections import defaultdict

m = defaultdict(lambda: 0)

for a in range(1, n + 1):
  s = str(a)
  f = int(s[0])
  l = int(s[-1])
  m[(f, l)] += 1

ans = 0
for b in range(1, n + 1):
  s = str(b)
  f = int(s[0])
  l = int(s[-1])
  ans += m[(l, f)]

print(ans)


Measured memory_bytes: 3444
fun main(arg: Array<String>) {
    val (N, K) = listOfInt()
    val e = listOfInt(1)
    val s = IntArray(N + 1)
    for (n in 0 until N) s[n + 1] = s[n] + e[n]
    var ans = 0
    for (n in 0 .. N - K) {
        ans = Math.max(ans, s[n + K] - s[n])
    }
    println(ans.toDouble() / 2.0)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 61636
# ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# これもなかなか早い
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)らしいが
# not in があるのでO(n K log n)では？
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


from heapq import heapify, heappop, heappush, heappushpop


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap


heap = []  # ヒープといっても順序を工夫したただのリスト

q = PriorityQueue(heap)
q.push((-(A[0] + B[0] + C[0]), 0, 0, 0))

considered = set()
ans = []
for k_th in range(1, K+1):
    heap_max, i, j, k = q.pop()
    ans.append(-heap_max)
    for di, dj, dk in zip([1, 0, 0], [0, 1, 0], [0, 0, 1]):
        i_new, j_new, k_new = i + di, j + dj, k + dk
        if i_new >= X or j_new >= Y or k_new >= Z:
            continue
        if (i_new, j_new, k_new) in considered:
            continue
        considered.add((i_new, j_new, k_new))
        q.push((-(A[i_new] + B[j_new] + C[k_new]), i_new, j_new, k_new))


print(*ans, sep='\n')


Measured memory_bytes: 5232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String[] sarr = sc.next().split(",");
			double[] x = new double[8];
			for(int i=0;i<8;i++) {
				x[i] = Double.valueOf(sarr[i]);
			}
			Vector2[] r = new Vector2[4];
			for(int i=0;i<4;i++) {
				r[i] = new Vector2(x[i*2],x[i*2+1]);
			}
			int sign = 0;
			boolean flag = true;
			for(int i=0;i<4;i++) {
				Vector2 r2 = r[(i+2)%4];
				Vector2 r1 = r[(i+1)%4];
				Vector2 r0 = r[i];
				double cross = r2.subtract(r1).cross(r1.subtract(r0));
				if (sign * cross < 0) {
					flag = false;
					break;
				}else if(sign == 0){
					sign = cross < 0 ? -1 : cross > 0 ? 1 : 0;
				}
			}
			System.out.println(flag ? "YES" : "NO");
		}
	}

}
class Vector2 {
	public double x;
	public double y;
	public Vector2(double x,double y) {
		this.x = x;
		this.y = y;
	}
	public double dot(Vector2 v) {
		return this.x*v.x+this.y*v.y;
	}
	public double cross(Vector2 v) {
		return this.x*v.y-this.y*v.x;
	}
	public double norm() {
		return Math.sqrt(this.x*this.x+this.y*this.y);
	}
	public Vector2 normalize() {
		return divide(norm());
	}
	public Vector2 add(Vector2 v) {
		return new Vector2(x+v.x,y+v.y);
	}
	public Vector2 subtract(Vector2 v) {
		return new Vector2(x-v.x,y-v.y);
	}
	public Vector2 multiply(double k) {
		return new Vector2(x*k,y*k);
	}
	public Vector2 divide(double k) {
		return new Vector2(x/k,y/k);
	}
	public String toString() {
		return "(" + this.x + "," + this.y + ")";
	}
}

Measured memory_bytes: 17188
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

char toupr(char c)
{
    return (c - 0x20);
}

int main()
{
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    cout << toupr(s1[0]) << toupr(s2[0]) << toupr(s3[0]) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<long long> calc_divisor(long long n) {//約数列挙
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<int> div(1000100,0);
    rep(i,n){
        div[v[i]]++;
    }
    int ans = 0;
    rep(i,n){
        bool ok = 1;
        //cout << v[i] << "tern" << endl;
        for(auto u : calc_divisor(v[i])){
            if(div[u]>0 && u != v[i]){
                //cout << u << endl;
                ok = 0;
                break;
            }
        }
        if(div[v[i]] > 1) ok = 0;
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8008
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
	int W, B;
	cin >> W >> B;

	vector<vector<bool>> board(100, vector<bool>(100));

	REP(i, 100) {
		REP(j, 50) {
			board[i][j] = true;
			board[i][j+50] = false;
		}
	}

	W--;
	B--;

	REP(i, 50) {
		REP(j, 25) {
			if (W > 0) {
				W--;
				board[2 * i][2 * j] = false;
			}
			if (B > 0) {
				B--;
				board[2 * i+1][2 * j+50+1] = true;
			}
		}
	}

	cout << "100 100" << endl;

	REP(i, 100) {
		REP(j, 100) {
			if (board[i][j]) {
				cout << "#";
			}
			else {
				cout << ".";
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int num = Integer.parseInt(in.nextLine());
    List<Integer> weis = new ArrayList<>();
    while(in.hasNext()) {
      weis.add(Integer.parseInt(in.next()));
    }
    int a = 0;
    int b = 0;
    if ((num & 1) == 1) {
      b += weis.get(num / 2);
    }
    for (int i = 0; i < num / 2; i++) {
      a += weis.get(i);
      b += weis.get(num - 1 - i);
    }
	boolean left = a > b;
    int index = num / 2 - 1;
    int ans;
    if (a > b) {
      while (a > b) {
        index--;
        a -= weis.get(index + 1);
        b += weis.get(index + 1);
      }
      ans = (b - a) < (a + weis.get(index + 1) * 2 - b) ? b - a : a + weis.get(index + 1) * 2 - b;
    } else if (a == b) {
      ans = 0;
    } else {
      while (a < b) {
        index++;
        a += weis.get(index);
        b -= weis.get(index);
      }
      ans = (a - b) < (b + weis.get(index) * 2 - a) ? a - b : b + weis.get(index) * 2 - a;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b, c; cin >> a >> b >> c;
	a -= b;
	cout << max(c - a, 0) << endl;
	return 0;
}

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

int main(void) {
    string alpha = "abcdefghijklmnopqrstuvwxyz";
    string C; cin >> C;
    int pos = alpha.find(C);
    cout << alpha[pos + 1] << endl; 
}

Measured memory_bytes: 3608
package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	taka := moster{
		hp:  A,
		atk: B,
	}
	aoki := moster{
		hp:  C,
		atk: D,
	}
	fmt.Printf(battle(&taka, &aoki))
}

type moster struct {
	hp  int
	atk int
}

func battle(taka, aoki *moster) string {
	// taka lose
	t := taka.hp / aoki.atk
	if taka.hp%aoki.atk != 0 {
		t++
	}
	// aoki lose
	a := aoki.hp / taka.atk
	if aoki.hp%taka.atk != 0 {
		a++
	}
	if t >= a {
		return "Yes"
	}
	return "No"
}


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


// map<pair<long long,long long>,long long> mp;
long long N;
long long maxKVal(vector<long long> &value,vector<long long> &weight, long long w,long long start,vector<vector<long long>> &dp )
{

    if(start==N-1 )
    {
    // cout<<N<<" "<<start<<endl ;
    // cout<<w<< " "<<weight[start]<<endl;
        if(w>=weight[start])
        {
            // cout<<"BOYO"<<endl;
            return value[start];
            
        }
        else
        {
            return 0;
        }
    }

    // pair<long long,long long> p=make_pair(w,start);

    if(dp[start][w]!=-1)
    {
        // cout<<"start "<<start<<" " <<w<<endl;
        // cout<<"BAM REUSE!!!"<<endl;
        // cout<<dp[start][w]<<endl;
        return dp[start][w];
    }
    long long with=0;
    long long without=0;

    long long ans=0;
    if(w>=weight[start] && start<N)
    {
        with=value[start]+maxKVal(value,weight,w-weight[start],start+1,dp);
        // cout<<"With :"<<with<<" Start :"<<start<<" W:" <<w-weight[start]<<endl;
        
    }
    without=maxKVal(value,weight,w,start+1,dp);

    ans=max(with,without);

    dp[start][w]=ans;

    return ans;

}


int main()
{
    long long n;
    long long w;
    cin>>n>>w;
    N=n;
    vector<long long> value(n);
    vector<long long> weight(n);
    long long mw=-1;

    for(long long x=0;x<n;x++)
    {
        long long a,b;
        cin>>a>>b;
        value[x]=b;
        weight[x]=a;
        if(mw<a)
        {
            mw=a;
        }
    }
    vector<vector<long long>> dp(n,vector<long long>(w+1,-1));
        // for(long long x=0;x<n;x++)
        // {
        //     for(long long y=0;y<mw;y++)
        //     {
        //         cout<<dp[x][y]<<" ";
        //     }
        //     cout<<endl;
        // }

    // for(long long x=0;x<n;x++)
    // {
    //     cout<<value[x]<<" "<<weight[x]<<endl;
    // }

    // cout<<endl;
    long long ans=maxKVal(value,weight,w,0,dp);

    cout<<ans;   
}

Measured memory_bytes: 79488
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i,n){
        int m;
        cin >> m;
        if(m%2==0){
            if(m%3==0||m%5==0){
                continue;
            }
            else{
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";

    return 0;
}

Measured memory_bytes: 3644
n,c = gets.split.map(&:to_i)

x = []
n.times {x << gets.split.map(&:to_i)}
x.sort!{|a,b| a[0] <=> b[0]} #small s -> large s

rec = [] #recoder
ch_rec = Array.new(c+1) #which recoder recoding i channel

x.each do |s,t,ch|
    if ch_rec[ch] && rec[ch_rec[ch]][0] <= s #able to recode same ch
        rec[ch_rec[ch]][0] = t
    else
        j = true

        rec.each_with_index do |rec_e,index|
            if rec_e[0] < s #able to recode
                ch_rec[rec_e[1]] = nil
                ch_rec[ch] = index
                rec[index] = [t,ch]
                j = false
                break
            end
        end

        if j #cannot recode, add recoder
            rec << [t,ch]
            ch_rec[ch] = rec.size - 1
        end
    end
end

puts rec.size

Measured memory_bytes: 10600
#include <bits/stdc++.h>
#define rall(v) rbegin(v),rend(v)

using namespace std;
typedef long long ll;
const ll N = 100000;

ll n,v;
map<ll,ll> cnt[2];
vector<pair<ll,ll> > ac[2];
signed main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> v;
		cnt[i&1][v]++;
	}
	for(auto p:cnt[0])ac[0].emplace_back(p.second,p.first);
	for(auto p:cnt[1])ac[1].emplace_back(p.second,p.first);
	sort(rall(ac[0]));
	sort(rall(ac[1]));
	if(ac[0][0].second != ac[1][0].second){
		cout << n - ac[0][0].first - ac[1][0].first << '\n';
	}else{
		ll res = 0;
		if(ac[1].size() >= 2)res = max(res,ac[0][0].first+ac[1][1].first);
		if(ac[0].size() >= 2)res = max(res,ac[0][1].first+ac[1][0].first);
		if(ac[0].size() < 2 && ac[1].size() < 2)res = n/2;
		cout << n-res << '\n';
	}
}

Measured memory_bytes: 8824
A,B,C,D,E,F = list(map(int, input().split()))

W = [ 100*A*x + 100*B*y for x in range(0,31) for y in range(0,31) if 0 < (100*A*x + 100*B*y) <= F]
S = [ C*x + D*y for x in range(0,3001) for y in range(0,3001) if 0 < (C*x + D*y) <= F]

dense = 0
sugar = 0
mass = 100*A
for w in W:
    for s in S:
        if ((w + s) <= F and s <= (w*E/100) and dense*(s+w) < s):
            dense = s/(s+w)
            sugar = s
            mass = s+w
print(mass,sugar)


Measured memory_bytes: 12456
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
// constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(string, s);
    while(!s.empty()){
        if(s.size() >= 5 && s.substr(s.size() - 5) == "dream") s.erase(s.end() - 5, s.end());
        else if(s.size() >= 7 && s.substr(s.size() - 7) == "dreamer") s.erase(s.end() - 7, s.end());
        else if(s.size() >= 5 && s.substr(s.size() - 5) == "erase") s.erase(s.end() - 5, s.end());
        else if(s.size() >= 6 && s.substr(s.size() - 6) == "eraser") s.erase(s.end() - 6, s.end());
        else{
            Cout("NO"); return 0;
        }
    }
    Cout("YES");
}


Measured memory_bytes: 512
def main():
    n = int(input())
    h = [int(n) for n in input().split()]
    ans = 0
    for i in range(n):
        for j in range(i):
            if h[j] > h[i]:
                break
        else:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
	int i=0,xi,yi,a,N;
	int wl,wr,hu,hd,W,H;
    scanf("%d %d %d",&W,&H,&N);
     wl=0,hd=0,wr=W,hu=H;
    for(i=0;i<N;i++)
    {
    	scanf("%d %d %d",&xi,&yi,&a);
    	if(a==1)
    	{
    		if(xi>=wl)
    		wl=xi;
		}
		else if(a==2)
		{
			if(xi<=wr)
			wr=xi;
		}
		else if(a==3)
		{
			if(yi>=hd)
			hd=yi;
			
		}
		else
		{
			if(yi<=hu)
			hu=yi;
		}
		
	}
	if((wl>=wr)||(hd>=hu))
	{
		printf("0");
	}
	else
	printf("%d",(hu-hd)*(wr-wl));
	return 0;
}

Measured memory_bytes: 128
class Dictionary
  DNA = [''] + %w(A C G T)

  def initialize n
    @size = 100000
    @container = Array.new(@size)
  end
  attr_accessor :ret

  def exec command, str = ''
    case command
    when 'insert' then insert str
    when 'find'   then puts(find?(str) ? 'yes' : 'no')
    else raise '??????'
    end
  end

  #private

  def insert str
    #puts "#{str} : #{hash(str)}"
    if @container[hash(str)].nil?
      @container[hash(str)] = LinkList.new str
    else
      group = @container[hash(str)]
      found = group.has? str
      group.insert(str) unless found
    end
  end

  def find? str
    linked_list = @container[hash(str)]
    return false if linked_list.nil?

    linked_list.has?(str)
  end

  def hash str

    return str.hash % @size
    # ?¶??´???´???????£? (????????????)
    # AGCT -> 4?????° -> 10?????°???????????????
    #base = DNA.size
    #size = str.size
    #sum = 0
    #str.chars.each.with_index {|c, index|
    #  # ????????????4?????°??§??¨?????????
    #  n = get_dna_index c
    #  # ?????????????????????10?????°?????????
    #  # (??? ** ??????????????????) * ???
    #  # ?????????????????????10?????°???????????¨????¶????
    #  sum += (base ** (size - index)) * n
    #}

    #sum % @size
  end

  def get_dna_index char
    DNA.index char
  end

  # ??????????????\???????????????????´?????????????????????????
  class LinkList

    def initialize first_value
      @first = Node.new first_value, nil
    end

    def insert key
      new_node = Node.new key, @first
      @first = new_node
    end

    def has? key
      current = @first
      until current.nil?
        if current.key == key
          return true
        else
          current = current.next
        end
      end
      false
    end

    # ????????????????????¨?????¢?????????
    class Node
      def initialize key, next_node
        @key = key
        @next = next_node
      end
      attr_accessor :key, :next
    end
  end
end

def main size, commands
  dic = Dictionary.new size.to_i
  commands.each{|raw_command|
    command, str = raw_command.split ' '
    dic.exec(command, str)
  }
  #puts dic.ret.join "\n"
  #dic.container.each {|pii| p pii}
end

array = STDIN.read.split(/\n/)
size = array.shift

main(size, array)

Measured memory_bytes: 171060
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    int res = 0;
    for (int i = 0; i < n; i++) {
        set<int> s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        res += s.size() - 1;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    var num = 0
    if(s[0] == '1') {
        num += 1
    }
    if(s[1] == '1') {
        num += 1
    }
    if(s[2] == '1') {
        num += 1
    }
    print(num)
}

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

int main (){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    
    if(e-a>k)
    cout <<":(" <<endl;
    else 
    cout << "Yay!" <<endl;



    
}

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

const int MX = 10000000;
bool sieve[MX];

void makeSieve() {
    memset(sieve, false, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<MX; ++i) {
        if ( ! sieve[i]) {
            for (int j=i*i; j<MX; j+=i) {
                sieve[j] = true;
            }
        }
    }
}

int main() {
    makeSieve();
    int a, d, n;
    while (cin >> a >> d >> n, (a || d || n)) {
        int c = 0;
        for (int x=a; ; x+=d) {
            if ( ! sieve[x]) {
                c ++;
                if (c == n) {
                    cout << x << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 10932
#include <algorithm>
#include <cstdio>
typedef long long lld;
const lld INFN = 3e11+5;
const int MAXN = 305;
lld dp[MAXN][MAXN];
int  H[MAXN];
int K, N;

void init() {
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i][j] = INFN;
    }
  }
}

lld solve() {
  dp[0][0] = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= i; ++j) {
      lld val = INFN;
      for (int k = 0; k < i; ++k) {
        lld prev = dp[k][j-1];
        if (prev == INFN) continue;
        if (H[i] > H[k]) {
          prev += (H[i] - H[k]);
        }
        val = std::min(prev, val);
      }
      dp[i][j] = val;
    }
  }
  lld ret = INFN;
  for (int i = N-K; i <= N; ++i) {
    ret = std::min(dp[i][N-K], ret);
  }
  return ret;
}

int main() {
  scanf(" %d%d", &N, &K);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &H[i]);
  }
  H[0] = 0;
  init();
  printf("%lld\n", solve());
  return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	p := make([]int, N)
	for i := range p {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	sum := 0
	for i := 0; i < K; i++ {
		sum += p[i]
	}
	fmt.Println(sum)

}


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

int main() {
    long long N;
    cin >> N;
    int result = 1000000000;
    for(int i = 1; i <= sqrt(N); i++) {
        int A = i;
        if(N % A != 0) {
            continue;
        }
        int B = N / A;
        int A_degit = 0;
        int B_degit = 0;
        while(A != 0) {
            A /= 10;
            A_degit++;
        }
        while (B != 0) {
            B /= 10;
            B_degit++;
        }
        
        int F = max(A_degit, B_degit);
        result = min(result, F);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline bool isprime(int x) {
    for(int i = 2; i * i <= x; ++i) if(x % i == 0) return false;
    return true;
}
int main() {
	int n; cin >> n;
	int tmp, cnt = 0;
	rep(i, 0, n) {
		cin >> tmp;
		if(isprime(tmp)) ++cnt;
	}
	P(cnt);
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    int R,S,P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    int ans = 0;
    vector<bool> score_getable(N,true);
    rep(i,N){
        if (T[i] == 'r') ans += P;
        if (T[i] == 's') ans += R;
        if (T[i] == 'p') ans += S;
    }
    rep(i,N - K){
        if (T[i] == T[i + K]){
            if (score_getable[i]){
                score_getable[i + K] = false;
                if (T[i] == 'r') ans -= P;
                if (T[i] == 's') ans -= R;
                if (T[i] == 'p') ans -= S;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

char x[10][10],y[10][10];
int main(){
    ll h,w,k,ans=0;;
    cin>>h>>w>>k;
    rep(i,0,h){
        rep(j,0,w){
            cin>>x[i][j];
            y[i][j]=x[i][j];
        }
    }
    for(int mask = 0; mask < (1 << h); mask++){
        
        for(int mask2 = 0; mask2 < (1 << w); mask2++){
            rep(i,0,h){
             rep(j,0,w){
                y[i][j]=x[i][j];
             }
             }
            rep(i,0,h)if(mask&(1<<i))rep(j,0,w)y[i][j]='a';
            rep(i,0,w)if(mask2&(1<<i))rep(j,0,h)y[j][i]='a';
            ll tmp=0;
            rep(i,0,h){
                rep(j,0,w){
                    if(y[i][j]=='#')tmp++;
                }
            }
            if(tmp==k)ans++;
    }
    }
    cout<<ans;
}




Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=100001;
int p=1000000007;
int main()
{
  long long n,k,t,i,j,nn,res=0;
  long long f[N_MAX],d[N_MAX],ff[N_MAX];
  cin >> n >> k;
  fill(f+1,f+k+1,1);
  for(i=1;i<=k;i++)
    ff[i]=i;
  nn=n;
  while(nn>0){
    for(i=1;i<=k;i++){
      if(nn%2==1){
        f[i]*=ff[i];
        f[i]%=p;
      }
      ff[i]*=ff[i];
      ff[i]%=p;
    }
    nn/=2;
  }
  for(i=k;i>=1;i--){
    t=k/i;
    d[i]=f[t];
    for(j=2;j*i<=k;j++){
      d[i]-=d[j*i];
      if(d[i]<0)
        d[i]+=p;
    }
    res+=(d[i]*i)%p;
    res%=p;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5516
#include<bits/stdc++.h>
using namespace std;
int arr[11];
int main()
{
  int n,maxn=0,maxn_p=0,m=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {  
  	scanf("%d",&arr[i]);
    if(maxn<arr[i])
    {
      maxn=arr[i];
      maxn_p=i;
    }  
  }
  for(int i=0;i<n;i++)
  {
    if(maxn_p==i)
      m+=maxn/2;
    else
      m+=arr[i];
  }
  printf("%d",m);
  return 0;
}  

Measured memory_bytes: 256
input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
T = input[0].split(" ");
N = Number(T[0]);
Q = Number(T[1]);
S = input[1].split("");
ans = "";
SS = new Array(N);
for(i = 0; i < N; i++){
    SS[i] = (i === 0) ? 0 : SS[i-1];
    if(S[i] === 'A'){
        if(S[i+1] === "C"){
            i++;
            SS[i] = SS[i-1]+1;
        }
    }
}
for(i = 2; i < Q + 2; i++){
    J = input[i].split(" ");
    m = Number(J[0])-1;
    M = Number(J[1])-1;
    a = SS[M]-SS[m];

    if(i == 2) ans += a;
    else ans += "\n"+a;
}
console.log(ans)

Measured memory_bytes: 53968
#include <iostream>
#include <vector>
#include <tuple>
#include <string>

int main(){
  int N,M;
  std::cin >> N >> M;

  std::vector<int> wa_arr(N), ac_arr(N);
  int n_wa = 0, n_ac = 0;

  for(int i = 0; i < M; i++){
    int p;
    std::string S;
    std::cin >> p >> S;
    p--;
    if(S == "AC"){
      if(ac_arr[p] == 1) continue;
      n_ac++;
      n_wa += wa_arr[p];
      ac_arr[p] = 1;
    }else{
      wa_arr[p]++;
    }
  }

  std::cout << n_ac << " " << n_wa << std::endl;

  return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int data[3],i,j,asc;
	scanf("%d %d %d",&data[0],&data[1],&data[2]);
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<3;j++)
		{
			if(data[i]>data[j])
			{
				asc=data[i];
				data[i]=data[j];
				data[j]=asc;
			}
		}
	}
	printf("%d %d %d\n",data[0],data[1],data[2]);
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;


ll dp[3010][3010];
vector<ll> v;

ll score( int l, int r){
    if( r < l )
        return 0;
    if( l == r )
        return v[l];
    if( dp[l][r] != -1 )
        return dp[l][r];

    ll ans1 = 0, ans2 = 0;
    ans1 =  v[l] + min(score(l+2, r), score(l+1, r-1));
    ans2 =  v[r] + min(score(l+1, r-1), score(l, r-2));
    dp[l][r] = max(ans1, ans2);
    return dp[l][r];
}

int main(){
   
   for(int i=0; i<3010; i++){
        for(int j=0; j<3010; j++)
            dp[i][j] = -1; 
   }
   ll n,x, sum=0;
   cin>>n;

   for(int i=0; i<n; i++){
        cin>>x;
        v.push_back(x);
        sum += x;
   }
   ll ans = 2*score(0, n-1)-sum; 
   cout<<ans<<endl;
}

Measured memory_bytes: 74508