akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(ll i,o,t,j,l,s,z;cin>>i>>o>>t>>j>>l>>s>>z;){
		ll res=0;
		if(i>0&&j>0&&l>0&&i%2+j%2+l%2>=2){
			i--,j--,l--;
			res+=6;
		}
		res+=i/2*4;
		res+=o*2;
		res+=j/2*4;
		res+=l/2*4;
		cout<<res/2<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n;
	int a, b;
	scanf("%d %d %d", &n, &a, &b);
	int sum =0;
	
	for (int i=1; i<=n; i++){
		int digitSum=0;
		int temp=i;
		while (temp!=0){
			digitSum = digitSum + temp%10;
			temp/= 10;
		}
		if (digitSum >=a && digitSum <= b){
			sum += i;
		}
			
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1696
let cnt = ref 0

let merge a l m r =
  let init_ary n p =
    Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i)) in
  let ai = init_ary (m - l) l in
  let aj = init_ary (r - m) m in
  let rec doit = function
    | (_, _, k) when k = r -> ()
    | (i, j, k) when ai.(i) <= aj.(j) ->
      incr cnt;
      a.(k) <- ai.(i);
      doit (i + 1, j, k + 1)
    | (i, j, k) ->
      incr cnt;
      a.(k) <- aj.(j);
      doit (i, j + 1, k + 1) in
  doit (0, 0, l)

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  Array.iteri (fun i e -> if i <> 0 then print_string " "; print_int e) a;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 19532
#include <cstdio>
#include <algorithm>
#include <vector>

#define int long long
using namespace std;
const int N=100005;

int n,m;
int x[N],a[N],poi[N],cf[N],cnt;
long long k;
int block[N],num[N],vis[N];

vector<int>q[N];

void dfs(int x,int dep)
{
    num[x]=dep;vis[x]=1;block[x]=cnt;
    q[cnt].push_back(x);
    if(!vis[poi[x]]) dfs(poi[x],dep+1);
}
signed main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&x[i]);
    for(int i=1;i<n;++i) cf[i]=x[i+1]-x[i];
    scanf("%lld%lld",&m,&k);
    for(int i=1;i<n;++i)poi[i]=i;
    for(int i=1;i<=m;++i) {scanf("%lld",&a[i]);swap(poi[a[i]],poi[a[i]-1]);}
    for(int i=1;i<n;++i) if(!vis[i]) cnt++,dfs(i,0);
    
    printf("%lld\n",x[1]);
    int now=x[1];
    for(int i=1;i<n;i++)
    {
        now+=cf[q[block[i]][(num[i]+k)%q[block[i]].size()]];
        printf("%lld\n",now);
    }
}

Measured memory_bytes: 13044
n,m,c = map(int,input().split())
bb = list(map(int, input().split()))
aa = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for a in aa:
    total = c
    for i in range(m):
        total += a[i]*bb[i]
    ans += 1 if total>0 else 0
print(ans)

Measured memory_bytes: 3060
from typing import List
import sys


def read_data(file_name: str, std_in=True):
    satisfactions_list = list()
    file = sys.stdin if std_in else open(file_name, 'r')
    days = int(file.readline().rstrip())
    satisfaction_decreases = [int(c) for c in file.readline().rstrip().split(" ")]
    for i in range(days):
        satisfactions_list.append([int(c) for c in file.readline().rstrip().split(" ")])
    if not std_in:
        file.close()
    return days, satisfaction_decreases, satisfactions_list


class Contest:
    def __init__(self, _type: int, satisfactions: List[int], satisfaction_decrease: int):
        self.dissatisfaction = 0
        self.type = _type
        self.satisfactions = satisfactions
        self.satisfaction_decrease = satisfaction_decrease

    def __getitem__(self, key: int):
        return self.satisfactions[key - 1]

    def __str__(self):
        return str(self.type)

    def __repr__(self):
        return f"Contest(_type={self.type}, satisfactions={self.satisfactions}, satisfaction_decrease={self.satisfaction_decrease})"

    def heuristic(self, day):
        return self[day] - self.dissatisfaction

    def winner(self):
        self.dissatisfaction = 0

    def loser(self):
        self.dissatisfaction -= self.satisfaction_decrease


def get_best(contests: List[Contest], day: int):
    # improve this by optimistically making everyone a loser and then going back to undo that for the winner
    best = contests[0]
    for contest in contests:
        if contest.heuristic(day) > best.heuristic(day):
            best = contest
    return best


def main(file_name="input.txt"):
    contests = list()
    days, satisfaction_decreases, satisfactions_list = read_data(file_name)
    picks = list()

    for (_type, (satisfactions, satisfaction_decrease)) in enumerate(zip(zip(*satisfactions_list), satisfaction_decreases), start=1):
        contests.append(Contest(_type, satisfactions, satisfaction_decrease))

    for day in range(days):
        best = get_best(contests, day + 1)
        for contest in contests:
            if contest.type == best.type:
                contest.winner()
                picks.append(contest)
            else:
                contest.loser()

    return "\n".join([str(pick) for pick in picks])


if __name__ == "__main__":
    print(main("input.txt"))


Measured memory_bytes: 10764
class PP

  N = 10000

  def initialize
    @ary = Array.new(N+1){-1}
    @ary[0] = @ary[1] = 0
    (2..N).each{|i|
      @ary[i] = prime(i)? 1 : 0
      (2..(N/i)).each{|j|
        @ary[i*j] = 0
      }
    }
  end

  def main
    while true
      l = gets
      break if l.nil?
      n = l.chomp.to_i
      ans = 0
      (1..n).each{|i|
        j = n-i+1
        ans += 1 if @ary[i] == 1 && @ary[j] == 1
      }
      puts ans
    end
  end

  :private
  def prime(i)
    (2..Math.sqrt(i.to_f).to_i).each{|j|
      if @ary[j] == 1
        if i%j == 0
          return false
        end
      end
    }
    return true
  end
end

def main
  pp = PP.new
  pp.main
end

main

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);
  rep(i,m) cin >> s.at(i) >> c.at(i);
  
  rep(x,1000){
    string str = to_string(x);
    int order = str.size();
    if(order != n) continue;
    
    bool flag = 1;
    rep(j,m){
      if(s.at(j) > order) {flag=0; continue;}
      if(str.at(s.at(j)-1) != c.at(j)) {flag = 0;}
    }
    if(flag){
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
l = ["AKIHABARA",
"KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR",
"KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR",
"KIHBRA","KIHBAR","KIHABR","AKIHBR",
"KIHBR"]
if s in l:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
N,M = [int(i) for i in input().split()]

like = {}
for i in range(N):
    first=True
    for i in input().split():
        if first:
            first=False
            continue
        if i in like:
            like[i] += 1
        else:
            like[i] = 1

count = 0
for k in like:
    if like[k] == N:
        count += 1

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define INF 999999999
using LL = long long;
using VI = vector<int>;
int main(){ 
  int a,b;
  cin >> a >> b;
  cout << (b%a==0?a+b:b-a) << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		HashMap<String, Var> map = new HashMap<String, Var>();
		int M = sc.nextInt();
		for (int i = 0; i < M; ++i) {
			String name = sc.next();
			int lb = sc.nextInt();
			int ub = sc.nextInt();
			map.put(name, new Var(lb, ub));
		}
		int N = sc.nextInt();
		boolean result = true;
		ArrayList<Var> stack = new ArrayList<Var>();
		for (int i = 0; i < N; ++i) {
			String elem = sc.next();
			if (elem.equals("+")) {
				Var v1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				Var v2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				Var nv = new Var();
				for (int j = 0; j <= 255; ++j) {
					if (!v1.v[j]) continue;
					for (int k = 0; k <= 255; ++k) {
						if (!v2.v[k]) continue;
						nv.v[(k + j) % 256] = true;
					}
				}
				stack.add(nv);
			} else if (elem.equals("-")) {
				Var v1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				Var v2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				Var nv = new Var();
				for (int j = 0; j <= 255; ++j) {
					if (!v1.v[j]) continue;
					for (int k = 0; k <= 255; ++k) {
						if (!v2.v[k]) continue;
						nv.v[(k - j + 256) % 256] = true;
					}
				}
				stack.add(nv);
			} else if (elem.equals("*")) {
				Var v1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				Var v2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				Var nv = new Var();
				for (int j = 0; j <= 255; ++j) {
					if (!v1.v[j]) continue;
					for (int k = 0; k <= 255; ++k) {
						if (!v2.v[k]) continue;
						nv.v[(k * j) % 256] = true;
					}
				}
				stack.add(nv);
			} else if (elem.equals("/")) {
				Var v1 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				Var v2 = stack.get(stack.size() - 1);
				stack.remove(stack.size() - 1);
				if (v1.v[0]) {
					result = false;
					break;
				}
				Var nv = new Var();
				for (int j = 0; j <= 255; ++j) {
					if (!v1.v[j]) continue;
					for (int k = 0; k <= 255; ++k) {
						if (!v2.v[k]) continue;
						nv.v[k / j] = true;
					}
				}
				stack.add(nv);
			} else if (map.containsKey(elem)) {
				stack.add(map.get(elem));
			} else {
				stack.add(new Var(Integer.parseInt(elem)));
			}
		}
		System.out.println(result ? "correct" : "error");
	}

	static class Var {
		boolean[] v = new boolean[256];

		Var(int min, int max) {
			for (int i = min; i <= max; ++i) {
				v[i] = true;
			}
		}

		Var(int num) {
			v[num] = true;
		}

		Var() {}
	}

}

Measured memory_bytes: 25840
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: u8 = read(&mut stdin_lock, &mut buf, b'\n');
    if n == 1 {
        println!("Hello World");
    } else if n == 2 {
        let a: u8 = read(&mut stdin_lock, &mut buf, b'\n');
        let b: u8 = read(&mut stdin_lock, &mut buf, b'\n');
        println!("{}", a + b);
    } else {
        unreachable!();
    }
}


Measured memory_bytes: 4352
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
using namespace std;

class BEasyLinearProgramming {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a, b, c, k;
        in >> a >> b >> c >> k;
        if (k - a <= 0) out << k << endl;
        else if (k - a - b <= 0) out << a << endl;
        else out << -k + 2*a + b << endl;
	}
};


int main() {
	BEasyLinearProgramming solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3584
import sys
from operator import itemgetter
import collections


def r(s):
    if s == 'A':
        return 'T'
    elif s == 'T':
        return 'A'
    elif s == 'G':
        return 'C'
    elif s == 'C':
        return 'G'


def main():
    input = sys.stdin.readline
    s = str(input()).strip()

    print(r(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
using namespace std;
main()
{
	int n,m;
	while(cin>>n>>m,n)
	{
		int a[10],b[10];
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=0;i<m;i++)cin>>b[i];
		int c=0;
		for(int i=0;i<n;i++)c+=a[i];
		bool f[10]={};
		for(int i=0;i<m;i++)
		{
			bool flag=true;
			for(int j=0;j<n;j++)if(!f[j]&&b[i]==a[j]){f[j]=true,flag=false;break;}
			if(flag)c+=b[i];
		}
		cout<<c<<endl;
	}
}

Measured memory_bytes: 2996
#include<iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int A, B, C, K, rem, ans;
  cin >> A >> B >> C >> K;

  if (K <= A) {
    cout << K <<endl;
  }else if (K > A+B) {
    cout << A - (K - A - B) << endl;
  }else{
    cout << A << endl;
  }


  return 0;
}


Measured memory_bytes: 3624
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)420;

int main(void) {
   ll A[3];
   cin>>A[0]>>A[1]>>A[2];
   if (A[0]+A[1]+A[2] >=22) cout<<"bust"<<endl;
   else cout<<"win"<<endl;


   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def isIsolated(g: Vector[Vector[Char]], y: Int, x: Int): Boolean = {
    if (g(y)(x) == '.') false
    else {
      val yMax = g.size
      val xMax = g(0).size
      (x - 1 < 0 || g(y)(x - 1) == '.') &&
        (x + 1 >= xMax || g(y)(x + 1) == '.') &&
        (y - 1 < 0 || g(y - 1)(x) == '.') &&
        (y + 1 >= yMax || g(y + 1)(x) == '.')
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val h,w = s.nextInt
    val g:Vector[Vector[Char]] = Vector.fill(h)(s.next.toCharArray.toVector)
    for (
      y <- 0 until h;
      x <- 0 until w
    ) {
      if (isIsolated(g, y, x)) return "No"
    }
    "Yes"
  }

  val tests = List(
    """3 3
      |.#.
      |###
      |.#.""".stripMargin -> """Yes""",
    """5 5
      |#.#.#
      |.#.#.
      |#.#.#
      |.#.#.
      |#.#.#""".stripMargin -> """No""",
    """11 11
      |...#####...
      |.##.....##.
      |#..##.##..#
      |#..##.##..#
      |#.........#
      |#...###...#
      |.#########.
      |.#.#.#.#.#.
      |##.#.#.#.##
      |..##.#.##..
      |.##..#..##.""" -> """Yes"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25424
// AOJ ALDS1_11_C Breadth First Search
// 2018.5.2 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF 0x10101010
#define MAX_V 102
int  hi[MAX_V], *to[MAX_V];
int  q[MAX_V][2]; int top, end;
int  dist[MAX_V];

void bfs(int u)
{
	int i, v, d;

	q[0][0] = u, q[0][1] = 0, dist[u] = 0, top = 0, end = 1;
	while (top != end) {
		u = q[top][0], d = q[top++][1];
		if (dist[u] < d) continue;
		for (i = 0; i < hi[u]; i++) {
			v = to[u][i];
			if (dist[v] > d+1) {
				dist[v] = d+1, q[end][0] = v, q[end++][1] = d+1;
			}
		}
	}
}

int main()
{
	int n, i, j, k, u;

	n = in();
	memset(dist, INF, n<<2);
	for (i = 0; i < n; i++) {
		u = in()-1;
		hi[u] = k = in();
		to[u] = malloc(k<<2);
		for (j = 0; j < k; j++) to[u][j] = in()-1;
	}

	bfs(0);
	for (i = 0; i < n; i++) {
		if (dist[i] == INF) dist[i] = -1;
		printf("%d %d\n", i+1, dist[i]);
	}
	return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b[1000],c=0,d=0,i=0;
  cin>>a;
  for(int k=0;k<a;k++) cin>>b[k];
  while(true){
    for(int j=0;j<a;j++){
      if(b[j]%2==0) b[j]/=2;
      else{
        d=1;
        break;
      }
    }
    
    i++;
    if(d) break;
    else c++;
  }
  cout<<c<<"\n";
}

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

vector<vector<int>> G;
int mxd = 0;
int t = 0;

void dfs(int d, int cur, int pre) {
    if(mxd < d) {
        mxd = d;
        t = cur;
    }
    for(auto p : G[cur]) if(p != pre) dfs(d+1, p, cur);
}

int Dia() {
    dfs(0, 0, 0);
    mxd = 0;
    dfs(0, t, t);
    return mxd;
}

int main() {
    int N; cin >> N;
    G.resize(N);
    rep(i, 0, N-1) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(b); G[b].push_back(a);
    }
    cout << (Dia() % 3 != 1 ? "First" : "Second") << '\n';
    return 0;
}


Measured memory_bytes: 20608
n, m = map(int,input().split())
ans = [-1] * n
flag = 1

for i in range(m):
  s, c = map(int,input().split())
  if ans[s-1] == -1 or ans[s-1] == c: #まだ値が入っていないか同じ値が
    ans[s-1] = c
  else: #同じ桁に複数の条件が重複するのはだめ
    flag = 0

if ans[0] == 0 and n != 1: #最初の桁0はダメ
  flag = 0

if flag == 0:
  print(-1)

else:
  for i in range(n):
    if ans[i] == -1:
        if i == 0 and n != 1:
            ans[i] = 1
        else:
            ans[i] = 0
    print(ans[i], end ="")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n; cin >> n;
    ll x; cin >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll cnt = 0;
    if(a.at(0) > x){
        cnt += a.at(0) - x;
        a.at(0) = x;
    } 
    for(int i = 1; i < n; i++){
        ll sum = a.at(i-1) + a.at(i);
        if(sum > x){
            cnt += (sum - x);
            a.at(i) -= sum - x;
        }
    }
    cout << cnt << endl;
    return 0;   
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] H, W;
        int i, j, k, count;

        H = new int[10000];
        W = new int[10000];

        i=0;
        while(true){
            if(i == 10000){break;}

            H[i] = sc.nextInt();
            W[i] = sc.nextInt();

            if(H[i] == 0 && W[i] == 0){break;}
            i++;
        }
        count = i;

        for(k=0;k<count;k++){

            for(j=0;j<W[k];j++){
                System.out.print("#");
            }

            System.out.println();

            for(i=1;i<H[k]-1;i++){

                System.out.print("#");
                for(j=1;j<W[k]-1;j++){
                    System.out.print(".");
                }
                System.out.print("#");
                System.out.println();

            }

            for(j=0;j<W[k];j++){
                System.out.print("#");
            }

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

}



  

 



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

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

	int length = strlen(S);
	int i = 0;
	int R_start = 0;

	for(int j = 0 ;j < strlen(S); j++){
		ans[j] = 0;
	}
	
	while(1){
		while(S[i] != 'L') i++;
		int R_last = i-1;
		int L_start = i;
		while(S[i] != 'R' && i != length) i++;
		int L_last = i-1;

		int add = 0;
		if( (R_last - R_start) % 2 == 0 ){
			ans[R_last] = ( L_last - R_start ) / 2 + 1;
			ans[L_start] = ( L_last - R_start + 1) / 2 ;
		}
		else {
			ans[R_last] = ( L_last - R_start + 1) / 2 ;
			ans[L_start] = ( L_last - R_start ) / 2 + 1;
		}

		if( i == length )break;
		R_start = i;
	}
	
	for(int i = 0; i < length; i++){
		if(i == length - 1) cout << ans[i] << endl;
		else cout << ans[i] << " ";
	}
	
}

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

int main(){
 int i,n,max,sum,t;
 sum=0;
 max=0;
 cin >> n;
 for(i=1;i<=n;i++){
    cin>>t;
    sum+=t;
    if(max<t){max=t;}
 }
 cout << sum-max/2<<endl;
 return 0;
}


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

int debug = 0;

int main()
{
    ll h;
    ll sum;
    int n, tmp;

    cin >> h >> n;
    sum=0;
    rep(i,n){
        cin >> tmp;
        sum += tmp;
    }

    if( h-sum <= 0)
        printf("Yes\n");
    else
        printf("No\n");
}

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

int main() {
  int N, M, X, toZ = 0, toN = 0, ans;
  cin >> N >> M >> X;
  for(int i = 0; i < M; i++){
    int a;
    cin >> a;
    if(a < X){
      toZ++;
    }else{
      toN++;
    }
  }
  ans = min(toZ, toN);
  cout << ans;
}


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

using namespace std;

typedef int Weight;
const Weight INF = 1e9;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int f, int t, Weight c) :
        src(f), dst(t), weight(c) {}
};
bool operator<(const Edge &a, const Edge &b) {
    return a.weight != b.weight ? a.weight > b.weight :
        a.src != b.src ? a.src < b.src : a.dst < b.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void Dijkstra(const Graph &g, int s,
              vector<Weight> &dist, vector<int> &prev) {
    int n = g.size();

    dist.assign(n, INF);
    prev.assign(n, - 1);

    dist[s] = 0;
    priority_queue<Edge> que;  // e < f <=> e.weight > f.weight

    for (que.push(Edge(-2, s, 0)); !que.empty(); ) {
        Edge e = que.top();  que.pop();
        if (prev[e.dst] != -1)
            continue;

        prev[e.dst] = e.src;
        for (auto f = g[e.dst].begin(); f != g[e.dst].end(); ++f) {
            if (dist[f->dst] > e.weight + f->weight) {
                dist[f->dst] = e.weight + f->weight;
                que.push(Edge(f->src, f->dst, e.weight + f->weight));
            }
        }
    }
}

// 始点から頂点tまでの最短経路を返す
vector<int> BuildPath(const vector<int> &prev, int t) {
    vector<int> path;
    for (int u = t; u >= 0; u = prev[u])
        path.push_back(u);
    reverse(path.begin(), path.end());

    return path;
}


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

    int n, m, a, b, c;

    cin >> n >> m;
    Graph g(n);
    vector<vector<bool>> edge(n, vector<bool>(n, false));
    for (int i = 0; i < m; ++i) {
        cin >> a >> b >> c;
        g[a - 1].push_back(Edge(a - 1, b - 1, c));
        g[b - 1].push_back(Edge(b - 1, a - 1, c));
        edge[a - 1][b - 1] = edge[b - 1][a - 1] = true;
    }

    for (int s = 0; s < n; ++s) {
        vector<Weight> dist;
        vector<int> prev;
        Dijkstra(g, s, dist, prev);

        for (int t = 0; t < n; ++t) {
            if (s == t) continue;
            auto path = BuildPath(prev, t);

            for (size_t i = 0; i + 1 < path.size(); ++i)
                edge[path[i]][path[i + 1]] = edge[path[i + 1]][path[i]] = false;
        }
    }

    int cnt = 0;
    for (int v = 0; v < n; ++v)
        for (int u = v + 1; u < n; ++u)
            if (edge[v][u]) ++cnt;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int p[200000];
int cnt[200001];

int main() {
    cin >> n;
    rep(i,n) cin >> p[i];
    rep(i,n) {
        cnt[p[i]] = cnt[p[i]-1]+1;
    }
    int ans = 0;
    rep(i,n) ans = max(ans, cnt[i+1]);
    cout << n-ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;

bool notequal(int x,int y,int z){
  if(x != y && y != z && z != x){
    return true;
  }
  return false;
}
bool isTriangle(int minX,int midX,int maxX){
  if(maxX < midX + minX){
    return true;
  }
  return false;
}

struct Li{
  int count;
  int x;
};

int main() {
  int N;
  vector<Li> L;
  cin >> N;
  int t = 0;
  for(int i = 0;i < N;++i){
    cin >> t;
    bool addf = true;
    for(int j = 0;j < L.size();++j){
      if(L[j].x == t){
        L[j].count++;
        addf = false;
        break;
      }
      if(L[j].x < t){
        Li l;
        l.x = t;
        l.count = 1;
        L.insert(L.begin() + j,l);
        addf = false;
        break;
      }
    }
    if(addf){
      Li l;
      l.x = t;
      l.count = 1;
      L.push_back(l);
    }
  }
  
  ul count = 0;
  
  for(int i = 0;i < L.size();++i){
    for(int j = i + 1;j < L.size();++j){
      for(int k = j + 1;k < L.size();++k){
        if(L[i].x >= L[j].x + L[k].x){
          break;
        }
        //cout << L[i].x << " " << L[j].x << " " << L[k].x << endl;
        count += L[i].count * L[j].count * L[k].count;
      }
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3584
N = int(input())
a = [input() for i in range(N)]
an_list = []

for i in range(N):
    for j in reversed(range(N)):
        b, c = [int(x) for x in a[i].split()]
        d, f = [int(x) for x in a[j].split()]
        an_list.append((((b - d) ** 2 + (c - f) ** 2) ** 0.5))

print(sum(an_list)/N)



Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int n,a,b,i,j;
    int p[100005]={0};
    int s[100005]={0};
    int c[100005]={0};
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    for(j=1,a=0;j<n;j++)
    {
        a+=abs(p[j]-p[j-1]);
        s[j]=a;
    }
    for(i=n,b=0;i>0;i--)
    {
        b+=abs(p[i+1]-p[i]);
        c[i]=b;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d\n",s[i-1]+c[i+1]+abs(p[i+1]-p[i-1]));
    }
}


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

int main() {
    string s;
    cin >> s;
    string ans;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    if ((a <= 12 && a > 0) && (b <= 12 && b > 0)) ans = "AMBIGUOUS";
    if ((a <= 12 && a > 0) && (b > 12 || b == 0)) ans = "MMYY";
    if ((a > 12 || a == 0) && (b <= 12 && b > 0)) ans = "YYMM";
    if ((a > 12 || a == 0) && (b > 12 || b == 0)) ans = "NA";

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

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

using namespace std;

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

int main(){
    string s;
    cin >> s;
    string o = "RUD";
    string e = "LUD";

    rep(i, s.size()){
        bool flag = false;
        if (i % 2 == 0) {
            rep(j, 3){
                if(s[i] == o[j]){
                    flag = true;
                    break;
                }
            }
        }else{
            rep(j, 3){
                if(s[i] == e[j]){
                    flag = true;
                    break;
                }
            }
        }
        if (!flag) {
            cout << "No" << endl;
            return 0;            
        }
        

    }
    cout << "Yes" << endl;
    return 0;   
}

Measured memory_bytes: 256
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 1000005
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}*/ 
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n>=3200) cout<<s;
	else cout<<"red";
	return 0;
}







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

int main(){
  int n,i,a,b,c,d,e,f,g,h;
  for(;scanf("%d",&n),n;){
    vector<pair<int,int> >v;
    for(;n--;)scanf("%d%d%d%d%d%d%d%d%d",&i,&a,&b,&c,&d,&e,&f,&g,&h),v.push_back(make_pair(a*60+b+c*60+d+e*60+f+g*60+h,i));
    sort(v.begin(),v.end());
    printf("%d\n%d\n%d\n",v[0].second,v[1].second,v[v.size()-2].second);
  }
}

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

int main() {
	int l,r,d,count=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++)
	{
	    if(i%d==0)
	    {
	        count++;
	    }
	}
	cout<<count;
	return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    char b;

    cin >> b;

    if (b == 'A')
    {
        cout << 'T';
    }
    else if (b == 'T')
    {
        cout << 'A';
    }
    else if (b == 'G')
    {
        cout << 'C';
    }
    else
    {
        cout << 'G';
    }
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
ac = [0] * n
wa = [0] * n
penalty = 0
for i in range(m):
    p, s = list(input().split())
    p = int(p)
    if s == "AC" and ac[p - 1] == 0:
        ac[p - 1] = 1
        penalty += wa[p - 1]
    if s == "WA":
        wa[p - 1] += 1
print(sum(ac), penalty)

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

int main(){
  int N,M,cnt=0,ans=0;
  cin>>N;
  ll D[N];
  for(int i=0;i<N;i++) cin>>D[i];
  cin>>M;
  ll T[M];
  for(int i=0;i<M;i++) cin>>T[i];
  sort(D,D+N);
  sort(T,T+M);
  if(N<M){
    cout<<"NO"<<endl;
    return 0;
  }
  for(int i=0;i<N;i++){
    if(T[cnt]==D[i]) cnt++;
    if(cnt==M){
      cout<<"YES"<<endl;
      return 0;
    }
    if(i==N-1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
}


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

int main() {

    int arr[3][3];
    int a, n, b;

    for (int i = 0; i < 3; i++) {
        scanf("%d", &a);
        arr[0][i] = a;
    }
    for (int i = 0; i < 3; i++) {
        scanf("%d", &a);
        arr[1][i] = a;
    }
    for (int i = 0; i < 3; i++) {
        scanf("%d", &a);
        arr[2][i] = a;
    }
    scanf("%d", &n);
    for (int j = 0; j < n; j++) {
        scanf("%d", &b);
        for (int k = 0; k < 3; k++) {
            for (int l = 0; l < 3; l++) {
                if (arr[k][l] == b) {
                    arr[k][l] = 0;
                    break;
                }
            }
        }
    }

    int isCheck = 0;
    for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
            //縦に揃う（３pt）
            if (arr[0][0] == 0 && arr[1][0] == 0 && arr[2][0] == 0) {
                isCheck = 1;
            } else if (arr[0][1] == 0 && arr[1][1] == 0 && arr[2][1] == 0) {
                isCheck = 1;
            } else if (arr[0][2] == 0 && arr[1][2] == 0 && arr[2][2] == 0) {
                isCheck = 1;
                //横に揃う（３pt）
            } else if (arr[0][0] == 0 && arr[0][1] == 0 && arr[0][2] == 0) {
                isCheck = 1;
            } else if (arr[1][0] == 0 && arr[1][1] == 0 && arr[1][2] == 0) {
                isCheck = 1;
            } else if (arr[2][0] == 0 && arr[2][1] == 0 && arr[2][2] == 0) {
                isCheck = 1;
                //斜めに揃う（2pt）
            } else if (arr[0][0] == 0 && arr[1][1] == 0 && arr[2][2] == 0) {
                isCheck = 1;
            } else if (arr[0][2] == 0 && arr[1][1] == 0 && arr[2][0] == 0) {
                isCheck = 1;
            }
        }

    }

    printf("%s", (isCheck == 1 ? "Yes" : "No"));


    return 0;
} 

Measured memory_bytes: 128
n = gets.to_i
 a = gets.split.map(&:to_i)

 ans = 0
 group = a.group_by {|i| i }
 a.uniq.sort.each {|i|
   g_cnt = group[i].count
   if i < g_cnt
     ans += g_cnt - i
   elsif i > g_cnt
     ans += g_cnt
   end
 }
 puts ans

Measured memory_bytes: 25604
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

ll X,Y;
cin >> X >> Y;
ll ans = 0;
while(X <= Y) {
    X *= 2;
    ans++;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll ans,a,c,e,f,g;
  char x,y,z;
  scanf("%lld %c.%c%c\n",&a,&x,&y,&z);
  e=x-'0',f=y-'0',g=z-'0';
  c=e*100+f*10+g;
  ans=a*c/100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1e5+5;
string t;
int main(){
	/*freopen(".gir", "r", stdin);
	freopen(".cik", "w", stdout); 
    */ios_base::sync_with_stdio(false);cin.tie(NULL);
	string s;cin >> s;int ans=0;
/*	for(int i=0;i<s.length();++i){
		if(t.compare(s[i])){
			t.clear();
			strcpy(t,s.substr(i,i+1));
		}
		else 
	}*/
	int ok=1;
	int n=s.length(),temp=0;
	for(int i=0;i<n;++i){
		if(!ok){
			ok=1;
			++ans;
		}
		else{
			if(temp!=1){
			temp=1;
			++ans;
			}
			else{
				if(s[i]==s[i-1]){
					temp=2;
					ok=0;
				}
				else {temp=1;++ans;}
			}
		}
		//cout << i << " " << " "<<temp <<" " <<ans << endl;
	}
	cout << ans << endl;
}
// if (str1.compare(str2) != 0)
// str.substr (3,5);
// strcpy (str2,str1);
	

Measured memory_bytes: 720
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
class Main{


	static final int MOD = 1000000007;


	static ArrayList<ArrayList<Pair>> map;
	static TreeMap<Integer,Integer> ans; 
	static int maxnum;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();

		String string = sc.next();
		if(n < 3200){
			System.out.println("red");
		}else{
			System.out.println(string);
		}


	}





	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
		//		if(min == data.length-1){
		//			if(data[min] > k){
		//				return min;
		//			}
		//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}

class Town{
	int index;
	int x ;
	int y;
	public Town(int index,int x,int y) {
		this.index = index;
		this.x = x;
		this.y = y;
		// TODO 自動生成されたコンストラクター・スタブ
	}


}


class Edge  implements Comparable{

	int index;
	HashSet<Integer> hen;
	HashSet<Integer> used;
	HashMap<Integer, Integer> map;
	int size;


	public Edge(int index) {
		// TODO 自動生成されたコンストラクター・スタブ
		this.index = index;
		hen = new HashSet();
		used = new HashSet<Integer>();
		map = new HashMap<Integer,Integer>();
	}

	public int compareTo(Object other) {
		Edge otherpair = (Edge)other;

		return   otherpair.hen.size() - hen.size();
	}
}

class Food implements Comparable{

	int minits;
	int score;
	double cospa;

	public Food(int from,int end,double c) {
		this.minits = from;
		this.score = end;
		this.cospa = c;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Food otherpair = (Food)other;
		int dif = Double.compare(otherpair.cospa, cospa);
		return   dif;
	}

}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int from,int end) {
		this.from = from;
		this.end = end;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  from - otherpair.from;
	}








}






Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (u == s1) {
    cout << a - 1 << " " << b;
  }
  if (u == s2) {
    cout << a << " " << b - 1;
  }
  return 0;
}

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

int main() {
  double n,k;
  int ans=0;
  cin>>n>>k;
  vector<double> p(n+1),sum(n+1);
  p[0]=0;
  sum[0]=0;
  for(int i=1; i<=n; i++) {
    cin>>p[i];
    sum[i]=p[i]+sum[i-1];
  }
  reverse(sum.begin(),sum.end());
  for(int i=0; i<n-k+1; i++){
    int x=sum[i]-sum[i+k];
    ans=max(ans,x);
  }
  cout<<setprecision(12)<<(double)(ans+k)/2;
}

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

int main() {
  int n, k ,ans = 0;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < k; i++)
  {
    ans += p[i];
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < n; i++) {
			String str = sc.nextLine();
			str = str.replaceAll("Hoshino", "Hoshina");
			System.out.println(str);
		}
	}
}


Measured memory_bytes: 17336
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,m = NextInts()
a = NextIntList()
ans = 0
for i in range(m):
    ans += a[i]
print(max(-1, n-ans))

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

//実行部
void Main()
{
  ll a, b, c; cin >> a >> b >> c;
  ll ans = 0;
  while(1)
  {
    if(c > 0&&b > 0)
    {
      ans += 2;
      c--;
      b--;
    }
    else if(b > 0)
    {
      ans += b;
      break;
    }
    else if(c > 0&&a > 0)
    {
      ans += 1;
      c--;
      a--;
    }
    else if(c > 0)
    {
      ans++;
      break;
    }
    else if(b <= 0&&c <= 0)
    {
      break;
    }
  }
  fin(ans);
}
//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i, a, b) for (ll i(a), _##i(b); i <= _##i; ++i)

#ifdef LOCAL
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) _FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
  _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1)              \
  (MACRO, __VA_ARGS__)
#define watch(x) cerr << "\033[1;32m" #x " = \033[1;34m" << (x) << "\033[0m; ";
#define debug(...)                                                             \
  cerr << "\033[2;31mLine " << __LINE__ << ": \033[0m";                        \
  FOR_EACH_MACRO(watch, __VA_ARGS__)                                           \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

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

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &x : a)
    cin >> x;
  const int MOD = 1e9 + 7;


  auto getSum = [](const vector<int> &prefixSum, int l, int r) {
    return (prefixSum[r] - (l == 0 ? 0 : prefixSum[l - 1]) + MOD) % MOD;
  };

  auto makePrefixSum = [](vector<int> &arr){
    int sum = 0;
    for(int &num : arr){
      num = (num + sum) % MOD;
      sum = num;
    }
  };

  vector<int> cur(k + 1);
  for(int i = 0; i <= a[0]; ++i){
    cur[i] = 1;
  }
  makePrefixSum(cur);

  for(int i = 1; i < n; ++i) {
    vector<int> nxt(k + 1);
    for(int j = 0; j <= k; ++j) { 
      nxt[j] = getSum(cur, max(0, j - a[i]), j);
    }
    makePrefixSum(nxt);
    swap(cur, nxt);
  }
  cout << getSum(cur, k, k) << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    
    sort(arr,arr+n,greater<int>());
    int res = 0;
    for(int i=0;i<k;i++) res+=arr[i];
    cout<<res;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

typedef vector<pair<ll,bool> > VP;

ll n,t,q;
VP a;
vi b;
vector<pair<ll,ll> > ans;

int main(){
	cin>>n>>t>>q;
	a=VP(n);
	b=vi(q);
	ans=vector<pair<ll,ll> >(n);
	for(int i=0;i<n;i++){
		int tmp;
		cin>>a[i].first>>tmp;
		if(tmp==1) a[i].second=1;
	}
	for(int i=0;i<q;i++){
		cin>>b[i];
		b[i]--;
	}
	ll stop;
	int num=-1;
	for(int i=0;i<n;i++){
		bool B=a[i].second;
		if(!i||!a[i-1].second&&B) num=i;
		if(num!=-1&&!B){
			if(a[i-1].second){
				stop=(a[i-1].first+a[i].first)/2;
				for(int j=num;j<=i;j++){
					ans[j].first=stop;
					ans[j].second=abs(a[j].first-stop);
				}
			}
			else{
				ans[i].first=stop;
				ans[i].second=abs(a[i].first-stop);
			}
		}
	}
	for(int i=0;i<q;i++){
		ll res;
		pair<ll,ll> p=ans[b[i]];
		if(p.first&&p.second<=t) res=p.first;
		else res=a[b[i]].first+((a[b[i]].second)?t:-t);
		cout<<res<<endl;
	}
}

Measured memory_bytes: 7444
import itertools
import math

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
cnt = 0
tot = 0
for arr in itertools.permutations(range(N)):
    now = XY[arr[0]]
    cnt += 1
    for i in arr[1:]:
        nex = XY[i]
        tot += math.sqrt(pow(now[0]-nex[0], 2)+pow(now[1]-nex[1], 2))
print(tot/cnt)


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

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

  if(s[0] == s[1] && s[1]==s[2] || s[1]==s[2] && s[2]==s[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }





}


Measured memory_bytes: 256