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

using namespace std;

int main(){

    int n;
    int y;
    cin >> n >> y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int k = n-i-j;
            if(k>=0){
                int total = 10000*k + i*5000 + j*1000;
                if(total == y){
                    cout << k << " " << i << " " << j << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>

int main() {

  int N,A,a,b,G[110][110]={0},i,j;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++) {
    scanf("%d%d",&A,&a);
    for(j=0;j<a;j++) {
      scanf("%d",&b);
      G[A][b]=1;
    }
  }
  
  for(i=1;i<=N;i++)
    for(j=1;j<=N;j++)
      printf("%d%c",G[i][j],j==N?'\n':' ');
  
  return 0;
  
}


Measured memory_bytes: 2112
import java.io.PrintWriter

@JvmField val _writer = PrintWriter(System.out, false)
fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    var (a,b,c,d) = readLine()!!.split(' ').map { it.toInt() }
    var t = true
    while(a > 0 && c > 0) {
        if (t) c -= b
        else a -= d
        t = !t
    }
    if (a <= 0) println("No")
    else println("Yes")
}


Measured memory_bytes: 36448
#include <stdio.h>
#include <stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
 
typedef struct node * Node;
 
Node root;
void insert(int);
 
void inorder (Node);
void preorder (Node);
 
 
int main(){
 
  int n,num,i;
  char command[10];
 
  scanf("%d",&n);
 
  root = NULL;
  for(i = 0 ; i < n ; i++){
 
    scanf("%s",command);
 
    if(command[0] == 'i'){//insert
      scanf("%d",&num);
      insert(num);
    }
 
    else if(command[0] == 'p'){//print
      inorder(root);
      printf("\n");
 
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}
 
 
void insert( int z){
 
  Node y = NULL;
  Node x = root;
  Node k;
 
  k = malloc(sizeof(struct node));
 
  k -> key = z;
  k -> left = NULL;
  k -> right = NULL;
 
 
  while(x != NULL){
    y = x;
    if(k -> key < x->key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
    k->parent = y;
    if(y == NULL)root = k;
    else if(k->key < y->key)y->left = k;
    else y->right = k;
}
 
 
void inorder (Node o){
  if(o->left != NULL)inorder(o->left);
  printf(" %d",o->key);
 
  if(o->right != NULL)inorder(o->right);
}
 
 
 
 
void preorder(Node o){
  printf(" %d",o->key);
 
  if(o->left != NULL)preorder(o->left);
  if(o->right != NULL)preorder(o->right);
}



Measured memory_bytes: 25164
#include<bits/stdc++.h> 
  
using namespace std; 
  
int count( int S[], int m, int n ) 
{ 
    int i, j, x, y; 
  
    // We need n+1 rows as the table  
    // is constructed in bottom up 
    // manner using the base case 0 
    // value case (n = 0) 
    int table[n + 1][m]; 
      
    // Fill the enteries for 0 
    // value case (n = 0) 
    for (i = 0; i < m; i++) 
        table[0][i] = 1; 
  
    // Fill rest of the table entries  
    // in bottom up manner  
    for (i = 1; i < n + 1; i++) 
    { 
        for (j = 0; j < m; j++) 
        { 
            // Count of solutions including S[j] 
            x = (i-S[j] >= 0) ? table[i - S[j]][j] : 0; 
  
            // Count of solutions excluding S[j] 
            y = (j >= 1) ? table[i][j - 1] : 0; 
  
            // total count 
            table[i][j] = x + y; 
        } 
    } 
    return table[n][m - 1]; 
} 
  
// Driver Code 
int main() 
{ 
    int arr[] = {100,101,102,103,104,105}; 
    int m = sizeof(arr)/sizeof(arr[0]); 
    int n;
    cin>>n;
    int k=count(arr, m, n); 
    if(k==0)
    cout<<"0";
    else
    cout<<"1";
    return 0; 
} 
  

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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif
}

#define debug(x)    cerr << #x << ": <" << (x) << ">\n"
#define dotc()      int tcs; if (cin >> tcs) for (int tc = 0; tc < tcs; tc++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second
#define mod         1000000007

using ll = long long;
using vi = vector<int>;

int main() {
  ioThings();

  int h, n; cin >> h >> n;
  while (n--) {
    int a; cin >> a;
    h -= a;
    if (h <= 0) {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";

  return 0;
}


Measured memory_bytes: 256
# ABC 054: B – Template Matching
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

isIncluding = False

for a_row in range(n):
    for a_column in range(n):

        if a[a_row][a_column] == b[0][0]:

            isExact = True
            for b_row in range(m):
                for b_column in range(1, m):
                    if a_row + b_row > n - 1 or a_column + b_column > n - 1:
                        isExact = False
                        break

                    if b[b_row][b_column] != a[a_row + b_row][a_column + b_column]:
                        isExact = False
                        break

                if not isExact:
                    isExact = True
                    break
            else:
                isIncluding = True
                break

        if isIncluding:
            break
            
    if isIncluding:
        break

print('Yes' if isIncluding else 'No')

Measured memory_bytes: 3064
use std::io;
use std::cmp;


/// 1 < n < 10^10
/// a * b = n
/// min(max(digits of a, digits of b))
fn main() {
    let n = read_one::<usize>();
    let ans = (1..).take_while(|&x| x * x <= n)
        .filter(|&x| n % x == 0)
        .map(|x| cmp::max(digits(x), digits(n / x)))
        .min()
        .unwrap();

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

fn digits(x: usize) -> usize {
    x.to_string().len()
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  if(1<=N && N<=9){
  switch ( N ) {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    System.out.println (N*N*N);
  }
 }
}
}

Measured memory_bytes: 23636
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int N, M, Q, A[60], B[60], C[60], D[60], seq[11], ans;

void recv(int idx)
{
	if (idx == N + 1)
	{
		int cur = 0;
		for (int i = 0; i < Q; ++i)
		{
			if (seq[B[i]] - seq[A[i]] == C[i])
				cur += D[i];
		}
		ans = max(ans, cur);
	}
	else
	{
		for (int i = seq[idx - 1]; i <= M; ++i)
		{
			seq[idx] = i;
			recv(idx + 1);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; ++i)
		cin >> A[i] >> B[i] >> C[i] >> D[i];
	seq[0] = 1;
	recv(1);
	cout << ans;
}

Measured memory_bytes: 3636
N = int(input())
mochi = []
count = 1
tmp = 0
for i in range(N):
    mochi.append(int(input()))

mochi.sort(reverse=True)

for i in range(N-1):
    if i == 0:
        tmp = mochi[0]

    if tmp != mochi[i+1]:
        count += 1
        tmp = mochi[i+1]

print(count)

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


int main(){
    int N;
    cin >> N;
    int MOD = 1e9+7;
    int64_t p = 1;
    for(int i=1;i<=N;i++){
        p = p*i%MOD;
    }
    cout << p;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.math.BigInteger;
 
public class Main implements Runnable {
	
	static int mod = 1000000007;
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        out.println(Math.min(a*n, b));
        
        out.flush();
    }
    
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextintArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public long[] nextlongArray(int n){
		long[] a = new long[n];
		for(int i=0;i<n;i++){
			a[i] = nextLong();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public int[][] nextintMatrix(int h, int w){
		int[][] mat = new int[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				mat[i][j] = nextInt();
			}
		}
		return mat;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

typedef long long ll ;
typedef long double ld ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arr[100005] ;

int main()
{
    ld a, b, c ;
    cin >> a >> b >> c ;
    if (sqrt(a) + sqrt(b) + EPS < sqrt(c))  cout << "Yes" ;
    else    cout << "No" ;

    return 0 ;
}


Measured memory_bytes: 256
<?php

$string = trim(fgets(STDIN));

$parts = explode(" ", $string);

$A	 = $parts[0];
$B	 = $parts[1];
$C	 = $parts[2];


for ($i = 0; $i < 10000; $i ++ )
{
	$test = ($i * $A) % $B;

	if ($test == $C)
	{
		echo "YES\n";
		die();
	}
}
	
echo "NO\n";
die();


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<long long> data(n+1);
  for(int i=1; i<=n; i++){
    cin >> data.at(i);
  }
  
  if(n == 1){
    cout << "Yes" << endl;
    return 0;
  }
  
  long long height = data.at(1)-1; 
  int flag=1;
  
  for(int i=2; i<=n; i++){
    long long tmp = data.at(i);
    if(height == tmp){
      continue;
    }else if(height == tmp - 1){
      continue;
    }else if(height < tmp-1){
      height = tmp-1;
    }else if(height > tmp){
      flag = 0;
      break;
    }
  }
  
  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int x = 0;
  int max_x = 0;
  for (auto c : s) {
    x += (c == 'I' ? 1 : -1);
    max_x = max(max_x, x);
  }
  cout << max_x << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <bitset>

using namespace std;
const int MAX = 1000010;
bitset<MAX> isPrime;

void sieve(){
    bitset<MAX> find;
    int i;
    for(i=2;i*i < MAX;i++){
        if(find[i]) continue;
        isPrime.set(i);
        for(int j=i;j<MAX;j++){
            if(j%i == 0){
                find.set(j);
            }
        }
    }
    for(;i<MAX;i++){
        if(!find[i]) {
            isPrime.set(i);
        }
    }
}

int main(){
    sieve();

    while(true){
        int n,x;
        cin >> n >> x;
        if(n==0 && x==0) return 0;
        vector<int> R(n);
        for(int i=0;i<n;i++){
            cin >> R[i];
        }

        bitset<MAX> S;
        S.set(0);
        for(int i=0;i<R.size();i++){
            for(int j=0;j<=x;j++){
                if(!S[j]) continue;
                int newe = j + R[i];
                if(newe > x) continue;
                S.set(newe);
            }
        }
        int maxn = -1;
        for(int i=0;i<=x;i++){
            if(isPrime[i] && S[i]) maxn = i;
        }
        if(maxn == -1) cout << "NA" << endl;
        else cout << maxn << endl;
    }
    return 0;
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    if (k > (n+1)/2) puts("NO");
    else puts("YES");
}



Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from collections import deque
import sys
def main(N, M, G, S, T):
    INF = 10**10
    q = deque([S])
    dist = [INF] * (3 * N)
    dist[S] = 0
    while q:
        v = q.popleft()
        for to in G[v]:
            if dist[to] < INF: continue
            dist[to] = dist[v] + 1
            q.append(to)
    print(dist[T] // 3 if dist[T] < INF else -1)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, M = map(int, input().split())
    G = [[] for _ in range(N * 3)]
    for _ in range(M):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        G[x].append(y + N)
        G[x + N].append(y + N + N)
        G[x + N + N].append(y)
    S, T = map(lambda x: int(x) - 1, input().split())
    main(N, M, G, S, T)


Measured memory_bytes: 109448
#include<iostream>
#include<string>
#include<vector>
#define X '#'

using namespace std;

vector<string> Init(int);
void DrawSpiral(vector<string>&, int);
int DrawTopLine(vector<string>&, int&, int&, int);
int DrawBottomLine(vector<string>&, int&, int&, int);
int DrawLeftLine(vector<string>&, int&, int&, int);
int DrawRightLine(vector<string>&, int&, int&, int);

int main(){
  int i, j, n, m;
  vector<string> data;

  cin >> n;

  for(i=0; i<n; ++i){
    cin >> m;
    data = Init(m);
    DrawSpiral(data, m);

    for(j=0; j<data.size(); ++j)
      cout << data[j] << endl;

    if(i != n-1) cout << endl;
  }
  return 0;
}

vector<string> Init(int n){
  const string str(n, ' ');
  vector<string> data;
  for(int i=0; i<n; ++i) data.push_back(str);
  return data;
}

void DrawSpiral(vector<string>& data, int n){
  if(n == 1){
    data[0][0] = X;
    return;
  }
  if(n == 2){
    data[0][0] = X;
    data[1][0] = X;
    data[0][1] = X;
    return;
  }

  int i, j;
  i = n-1;
  j = 0;
  while(1){
    if(DrawLeftLine(data, i, j, n) == 1) return;
    if(DrawTopLine(data, i, j, n) == 1) return;
    if(DrawRightLine(data, i, j, n) == 1) return;
    if(DrawBottomLine(data, i, j, n) == 1) return;
  }
}

int DrawTopLine(vector<string>& data, int& i, int& j, int n){
  if(j == n-1 || (j <= n-3 && data[i][j+2] == X)) return 1;
  if(n%2 == 0 && data[i][j+3] == X){
    data[i][j+1] = X;
    return 1;
  }
  while(j <= n-1 && data[i][j+2] != X){
    data[i][j] = X;
    if(j == n-1 || (j <= n-3 && data[i][j+2] == X)) return 0;
    ++j;
  }
  return 0;
}

int DrawBottomLine(vector<string>& data, int& i, int& j, int n){
  if(j == 0 || (j >= 2 && data[i][j-2] == X)) return 1;
  if(n%2 == 0 && data[i][j-3] == X){
    data[i][j-1] = X;
    return 1;
  }
  while(j >= 0 && data[i][j-2] != X){
    data[i][j] = X;
    if(j == 0 || (j >= 2 && data[i][j-2] == X)) return 0;
    --j;
  }
}

int DrawLeftLine(vector<string>& data, int& i, int& j, int n){
  if(i == 0 || (i >= 2 && data[i-2][j] == X)) return 1;
  if(n%2 == 0 && data[i-3][j] == X){
    data[i-1][j] = X;
    return 1;
  }
  while(1){
    data[i][j] = X;
    if(i == 0 || (i >= 2 && data[i-2][j] == X)) return 0;
    --i;
  }
}

int DrawRightLine(vector<string>& data, int& i, int& j, int n){
  if(i == n-1 || (i <= n-3 && data[i+2][j] == X)) return 1;
  if(n%2 == 0 && data[i+3][j] == X){
    data[i+1][j] = X;
    return 1;
  }
  while(1){
    data[i][j] = X;
    if(i == n-1 || (i <= n-3 && data[i+2][j] == X)) return 0;
    ++i;
  }
}

Measured memory_bytes: 1236
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// ２つの円の交点を求める
type point struct {
	x, y float64
}

const eps = 1e-9

func circleCrossPt(p0, p1 point, r1, r2 float64) ([]point, int) {
	dx := p1.x - p0.x
	dy := p1.y - p0.y
	l2 := dx*dx + dy*dy
	a := (l2 + r1*r1 - r2*r2) / 2.0
	D := l2*r1*r1 - a*a
	if D < 0 || l2 == 0 {
		return []point{}, 0
	}
	D = math.Sqrt(D)
	return []point{
		point{(a*dx+D*dy)/l2 + p0.x, (a*dy-D*dx)/l2 + p0.y},
		point{(a*dx-D*dy)/l2 + p0.x, (a*dy+D*dx)/l2 + p0.y}}, 2
}

func abs(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

func equal(a, b float64) bool {
	return abs(a-b) < eps
}

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

func circleCrossPt2(p0, p1 point, r1, r2 float64) ([]point, int) {
	vx := p1.x - p0.x
	vy := p1.y - p0.y
	l := math.Sqrt(vx*vx + vy*vy)
	if equal(l, 0) {
		return []point{}, 0
	}
	if equal(l+r1+r2, max(l, max(r1, r2))*2) {
		return []point{point{p0.x + vx*r1/l, p0.y + vy*r1/l}}, 1
	}
	if l+r1+r2 < max(l, max(r1, r2))*2 {
		return []point{}, 0
	}
	x := -(r2*r2 - l*l - r1*r1) / (2 * l)
	y := math.Sqrt(r1*r1 - x*x)
	mx := p0.x + vx*(x/l)
	my := p0.y + vy*(x/l)
	vx, vy = vy, -vx
	return []point{
		point{mx + vx*(y/l), my + vy*(y/l)},
		point{mx - vx*(y/l), my - vy*(y/l)}}, 2
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	//out(circleCrossPt(point{0, -10}, point{0, 10}, 10, 10))
	//panic(-1)
	N, K := getInt(), getInt()
	p := make([]point, N)
	c := make([]float64, N)
	for i := 0; i < N; i++ {
		x, y, z := getInt(), getInt(), getInt()
		p[i] = point{float64(x), float64(y)}
		c[i] = float64(z)
	}

	//	out(N, K, p, c)

	L := float64(0)
	R := float64(400000)

	for n := 0; n < 100; n++ {
		T := (L + R) / 2.0
		ap := make([]point, 0)
		// 中心を登録
		for i := 0; i < N; i++ {
			ap = append(ap, p[i])
		}
		// 交点を登録
		for i := 0; i < N; i++ {
			for j := i + 1; j < N; j++ {
				//out(i, j)
				pos, num := circleCrossPt2(p[i], p[j], T/c[i], T/c[j])
				//posx, numx := circleCrossPt2(p[i], p[j], T/c[i], T/c[j])
				//out("circle\t", pos, num, "\n\t", posx, numx)
				//out("pt", p[i], p[j], T/c[i], T/c[j], "pos", pos, num)
				switch num {
				case 1:
					ap = append(ap, pos[0])
				case 2:
					ap = append(ap, pos[0])
					ap = append(ap, pos[1])
				}
			}
		}
		ans := false
		for _, v := range ap {
			cnt := 0
			for i := 0; i < N; i++ {
				dx := p[i].x - v.x
				dy := p[i].y - v.y
				r := math.Sqrt(dx*dx+dy*dy) * c[i]
				if r <= T+eps {
					cnt++
				}
			}
			if cnt >= K {
				ans = true
				break
			}
		}
		if ans == true {
			R = T
		} else {
			L = T
		}
		//		out(ans, L, R)
	}
	out(L)
}


Measured memory_bytes: 6528
def price(target, item, recipe):
    ret = []
    
    if target in recipe:
        ret.append(sum(price(r,item, recipe) for r in recipe[target]))
    if target in item:
        ret.append(item[target])
    if len(ret) == 0:
        return 0

    return min(ret)

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    item = [f.readline().split() for _ in range(n)]
    item = {name:int(price) for name, price in item}
    recipe = [f.readline().strip().split() for _ in range(int(f.readline()))]
    recipe = {r[0]:r[2:] for r in recipe}
    print(price(f.readline().strip(), item, recipe))

Measured memory_bytes: 6724
//atcoder 176 B
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
    string s;
    cin >> s;
    ll sum = 0;
    for (int i = 0; i < s.length(); ++i) {
    	sum += s[i] - '0';
	}
	if (sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl; 
} 

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

int main() {
  int N , a , b , c , d;
  cin >> N;
  a = N/1000;
  b = (N-(a*1000))/100;
  c = (N-(a*1000)-(b*100))/10;
  d = N-(a*1000)-(b*100)-(c*10);
  if(a==b&&a==c){
  cout << "Yes" << endl;
  }
   else if(b==c&&b==d){
      cout << "Yes" << endl;
    }
  else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val list =
      for{
        in <- Source.stdin.getLines.toList
      } yield in

    list.map(_.split(" ").map(_.toInt).toList).init.foreach{ list =>
      val height = list.head
      val width = list.last

      (1 to height).foreach{ i =>
        print("#" * width)
        println
      }
      println
    }
  }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
int main()
{
	ll r = 0, k;
	cin >> k;
	REP(i,1,k+1)REP(j,1,k+1)REP(l,1,k+1)r += gcd(i, gcd(j, l));
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W; cin >> H >> W; 
	char C[55][55] = {}; 
	for(int i = 0; i < 53; i++){
		for(int j = 0; j < 53; j++){
			C[i][j] = '.'; 
		}
	}
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			cin >> C[i][j]; 
		}
	}
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			if(C[i][j] == '.') continue; 
			if(C[i-1][j] == '#') continue; 
			if(C[i+1][j] == '#') continue; 
			if(C[i][j-1] == '#') continue; 
			if(C[i][j+1] == '#') continue; 
			cout << "No" << endl; return 0; 
		}
	}
	cout << "Yes" << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
int dp[18][301];
int main(){
	dp[0][0]=1;
	for(int i=1;i<=17;i++){
		for(int j=0;j<=300;j++){
			dp[i][j]=dp[i-1][j];
			if(j>=i*i)dp[i][j]+=dp[i][j-i*i];
		}
	}
	int a;
	while(scanf("%d",&a),a)printf("%d\n",dp[17][a]);
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
using namespace std;
int main(){
short a,c,n,t,end;
vector <int> g;
cin>>a;
 c=a;
 for(int i=0;c!=0;i++){
 	n=c%10;
 	g.push_back(n);
 	c/=10;
 }

 if(g.front()==g.back()){
 	printf("Yes");
 }
 else
 printf("No");


}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define MP(a,b) make_pair(a,b)
#define PB push_back

typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
const int mod = 1e9 + 7;

int dp[2][5010];
int atwo,N;
char s[5010];

int Q_pow(int x,int y){
	int res = 1;
	while(y){
		if(y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return res;
}

int main(){
	atwo = Q_pow(2,mod - 2);
	scanf("%d%s",&N,s + 1);
	dp[0][0] = 1;
	int len = strlen(s + 1);
	for(int i = 1; i <= N; ++i){
		int id = i & 1,pre = id ^ 1;
		for(int j = 0; j <= N; ++j){
			dp[id][j] = dp[pre][j + 1];
			if(!j) dp[id][j] = (dp[id][j] + dp[pre][j]) % mod;
			if(j) dp[id][j] = (dp[id][j] + dp[pre][j - 1] * 2LL) % mod;
			//printf("dp[%d][%d] : %d\n",i,j,dp[id][j]);
		}
	}
	atwo = Q_pow(atwo,len);
	printf("%d\n",(int)(1ll * atwo * dp[N & 1][len] % mod));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
	
		n--;
		m--;
		System.out.println(n*m);
	}

}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS

//biginner052

#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long int lli;

int N, A, B;
int x[100000];

int main(){
	scanf("%d %d %d", &N, &A, &B);
	for (int i = 0; i < N; i++){
		scanf("%d", &(x[i]));
	}
	long long int ans = 0;
	for (int i = 0; i < N - 1; i++){
		ans += min((long long int)A * ((lli)x[i + 1] - (lli)x[i]), (long long int)B);
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
#define MN 300000
#define MOD 1000000007
char s[MN+5];
int p[MN+5],f[MN+5][3][3];
inline void rw(int&a,int b){if((a+=b)>=MOD)a-=MOD;}
int main()
{
	int n,i,j,k,ans=0;
    scanf("%s",s+1);n=strlen(s+1);
    for(p[n+1]=1,i=n;i;--i)p[i]=(p[i+1]<<(s[i]=='?'))%MOD;
    for(f[0][0][0]=i=1;i<=n;++i)for(j=0;j<3;++j)for(k=0;k<3;++k)
    {
    	if(s[i]=='1'||s[i]=='?')
    		if(k)rw(f[i][j][k-1],f[i-1][j][k]);
    		else if(j<2)rw(f[i][j+1][k],f[i-1][j][k]);
    		else rw(ans,1LL*f[i-1][j][k]*p[i+1]%MOD);
		if(s[i]=='0'||s[i]=='?')
			rw(f[i][j][k<2?k+1:1],f[i-1][j][k]);
	}
	rw(ans,f[n][1][0]);
	rw(ans,f[n][2][1]);
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 12288
#include <iostream>
using namespace std;
 
int main() {

  int n,orig;
  int x = 0;
  cin >> n;
  orig = n;

  while(n!=0){
    x += n%10;
    n /= 10;
  }

  if(orig%x==0) cout << "Yes";
  else cout << "No";

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, w;
    cin >> h >> w;
    using P = pair<int, int>;
    P a, b;
    vector<vector<int>> v(h+2, vector<int> (w+2, 0));
    queue<P> Q, QQ;
    vector<vector<int>> dist1(h+2, vector<int> (w+2, MOD));

    auto dist2 = dist1;

    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            v[i+1][j+1] = (s[j] != '#');
            if(s[j] == '@') {
                a = {i + 1, j + 1};
                dist1[i+1][j+1] = 0;
            }
            else if(s[j] == '%') b = {i+1, j+1};
            else if(s[j] == '$') {
                Q.emplace(i+1, j+1);
                dist2[i+1][j+1] = 0;
            }
        }
    }
    array<int, 4> di{0, 0, -1, 1}, dj{1, -1, 0, 0};

    QQ.emplace(a);
    while(!QQ.empty()){
        int i, j;
        tie(i, j) = QQ.front(); QQ.pop();
        for (int k = 0; k < 4; ++k) {
            if(v[i+di[k]][j+dj[k]] && dist1[i+di[k]][j+dj[k]] > dist1[i][j]+1){
                dist1[i+di[k]][j+dj[k]] = dist1[i][j]+1;
                QQ.emplace(i+di[k], j+dj[k]);
            }
        }
    }
    while(!Q.empty()){
        int i, j;
        tie(i, j) = Q.front(); Q.pop();
        for (int k = 0; k < 4; ++k) {
            if(v[i+di[k]][j+dj[k]] && dist2[i+di[k]][j+dj[k]] > dist2[i][j]+1){
                dist2[i+di[k]][j+dj[k]] = dist2[i][j]+1;
                Q.emplace(i+di[k], j+dj[k]);
            }
        }
    }
    puts((dist2[b.first][b.second] > dist1[b.first][b.second]) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    int ans[n] = {};
    REP(i,m){
        cin >> a >> b;
        ans[a - 1]++;
        ans[b - 1]++;
    }
    REP(i,n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

ll ans=0;
int R, S, P;

char win(char x){
  char y;
  if(x=='r'){
    y='p';
  }
  else if(x=='s'){
    y='r';
  }
  else{
    y='s';
  }
  return y;
}

ll point(char x){
  ll y;
  if(x=='r'){
    y=R;
  }
  else if(x=='s'){
    y=S;
  }
  else{
    y=P;
  }
  return y;
}

int main(){
  int N, K; cin>>N>>K>>R>>S>>P;
  string T, res; cin>>T;
  res=T;
  ll ans=0;
  for(int i=0; i<K; i++){
    res.at(i)=win(T.at(i));
    ans+=point(res.at(i));
  }
  for(int i=K; i<N; i++){
    if(res.at(i-K)!=win(T.at(i))){
      res.at(i)=win(T.at(i));
      ans+=point(res.at(i));
    }
    else{
      if(i<N-K){
        res.at(i)=T.at(i+K);
        if(T.at(i+K)==res.at(i-K)){
          res.at(i)=win(win(T.at(i+K)));
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRGBColoring solver = new BRGBColoring();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRGBColoring {
        static final int MOD = 998244353;
        int n;
        long[] ac;
        long[] bc;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            long a = in.nextInt(), b = in.nextInt();
            long k = in.nextLong();
            cache();
            long count = 0;
            int y = n;
            for (int x = 0; x <= n; x++) {
                long val;
                while ((val = (a * x) + (b * y)) > k) {
                    y--;
                }
                if (y < 0) {
                    break;
                }
                if (val != k) {
                    continue;
                }
                count += (nCk(x) * nCk(y) % MOD);
            }
            out.println(count % MOD);
        }

        long modPow(long x, long y) {
            if (y == 0) {
                return 1;
            } else if (y == 1) {
                return x;
            } else if (y % 2 == 0) {
                long z = modPow(x, y / 2);
                return z * z % MOD;
            } else {
                return (modPow(x, y - 1) * x) % MOD;
            }
        }

        long nCk(int k) {
            return (ac[k] * modPow(bc[k], MOD - 2) % MOD) % MOD;
        }

        void cache() {
            ac = new long[n + 1];
            ac[0] = 1;
            for (int i = 0; i < n; i++) {
                ac[i + 1] = ac[i] * (n - i);
                ac[i + 1] %= MOD;
            }
            bc = new long[n + 1];
            bc[0] = 1;
            bc[1] = 1;
            for (int i = 2; i <= n; i++) {
                bc[i] = bc[i - 1] * i;
                bc[i] %= MOD;
            }
        }

    }
}



Measured memory_bytes: 26836
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL = std::numeric_limits<long long>::max();

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

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    string s; cin >> s;
    if (s[s.size() - 1] == 's')
    {
        s = s + "es";
    }
    else {
        s = s + "s";
    }
    cout << s << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 3620
n=int(input())
red=[]
blue=[]
for i in range(n):
  a,b=map(int,input().split())
  red.append([a,b])
for j in range(n):
  a,b=map(int,input().split())
  blue.append([a,b])
blue.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1],reverse=True)

cnt=0
for x,y in blue:
  for i in range(n):
    if red[i][0]<x and red[i][1]<y:
      cnt+=1
      red[i][0]=float("INF")
      red[i][1]=float("INF")
      break
print(cnt)   
      
  


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

using namespace std;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N), Player(N);
  for (int i = 0; i < Q; i++) {
    int x;
    cin >> x;
    Player[x - 1] += 1;
  }

  int sumPoint = accumulate(Player.begin(), Player.end(), 0);

  for (int x : Player) {
    int tmp = K - sumPoint + x;
    cout << ((tmp > 0) ? "Yes" : "No") << endl;
  }
}

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

typedef uint32_t u32;
typedef uint64_t u64;

int dfs(int remain_n, int remain_sum, int remain_choice) {
  if( remain_choice < 0 ) return 0;
  if( remain_n <= 0 ) {
    if( remain_sum == 0 and remain_choice == 0 ) return 1;
    return 0;
  }
  int res = 0;
  res += dfs(remain_n - 1, remain_sum, remain_choice);
  res += dfs(remain_n - 1, remain_sum - remain_n, remain_choice - 1);
  return res;
}

int main() {

  int dp[16][160];
  int n, k, s;

  while( std::cin >> n >> k >> s ) {
    if( n == 0 and k == 0 and s == 0 ) break;
    std::cout << dfs(n, s, k) << std::endl;       
  }
   
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main() {
  int x,y; cin >> x >> y;
  int b = (4*x - y);
  if (b%2 == 0 && b >= 0 && x-(b/2) >= 0 ) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

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

int main()
{
    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }

    int last = -1;
    for (int i = 0; i < N - 1; i++)
    {
        if (a.at(i) + a.at(i + 1) >= L)
        {
            last = i;
        }
    }

    if (last < 0)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        cout << "Possible" << endl;
        for (int i = 0; i < last; i++)
        {
            cout << i + 1 << endl;
        }
        for (int i = N - 2; i >= last; i--)
        {
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 1152
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<stack>
const int maxn =1e5+5;
const double INF=0xfffff;
using namespace std;
typedef long long ll;
int pre[maxn];
ll val[maxn];
int num[maxn];
int minn[maxn];
int book[maxn];
int book2[maxn];
int anss[maxn];
struct node
{
    ll x, y;
    friend bool operator < (node a, node b)
    {
        return a.x > b.x;//结构体中，x小的优先级高
    }
};
priority_queue<node>q;
int find(int x)
{
	if(pre[x]!=x)
		pre[x]=find(pre[x]);
		return pre[x];
}
void join(int x,int y)
{
	int p,q;
	p=find(x);
	q=find(y);
	if(p!=q)
		{
			pre[p]=q;
			minn[q]=min(minn[p],minn[q]);
		}
	return ;
}
int main()
{
   int n,m;
   int x,y;
   int sum=0;
   int cnt=0;
   ll ans=0;
   int i;
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++)
  {
      cin>>val[i];
  }
   	for(i=0;i<n;i++)
   	{
   		pre[i]=i;
   		minn[i]=val[i];
   	}
   	while(m--)
   	{
   	   scanf("%d%d",&x,&y);
	   	join(x,y);
   	}
   	for(int i=0;i<n;i++)
    {
        int tmp=find(i);
        if(book[tmp]==0)
            {
                book[tmp]=1;
                anss[cnt++]=tmp;
            }
    }
   // cout<<cnt<<endl;
    if(cnt==1)
    {
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<cnt;i++)
    {
        ans+=minn[anss[i]];
        sum++;
    }
   	for(int i=0;i<n;i++)
    {
         int tmp=find(i);
         node pp;
        pp.x=val[i];
        pp.y=tmp;
        q.push(pp);
    }
    while(!q.empty())
    {
        ll a=q.top().x;
        int b=q.top().y;
        q.pop();
        if(book2[b]==0)
        {
            book2[b]=1;
            continue;
        }
        if(num[b]<cnt-1&&sum<(cnt-1)*2)
        {
            sum++;
            num[b]++;
            ans+=a;
        }
        if(sum==(cnt-1)*2)
            break;
    }
    if(sum<(cnt-1)*2)
        cout<<"Impossible"<<endl;
    else
        cout<<ans<<endl;
   return 0;
 }


Measured memory_bytes: 5104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define mod 998244353
#define maxx INT_MAX
#define minn INT_MIN

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,d;
        cin>>n>>d;
        ll p=0;
        while(n--)
        {
             ll x,y;
             cin>>x>>y;
             if((sqrt(x*x+y*y))<=d)
                p++;
        }
        cout<<p;
    }
    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

int ans;

int main(void) {
    int a, b, c, k;
     cin >> a >> b >> c >> k;

    if (k<=a) {
        printf("%d\n", k);
        return 0;
    } else if (k<=a+b) {
        printf("%d\n", a);
    } else {
        k -= (a+b);
        printf("%d\n", a-min(k, c));
        return 0;
    }


    

    //cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstdlib>
#include <climits>
using namespace std;

int main (){

    int n;
    cin >> n;

    long a[n];
    long sum = 0;

    int count = 0;
    int zerocount = 0;
    long long ans;
    long long min = 100000000;

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

        if (abs(a[i])< min) {
            min = abs(a[i]);
        }

        if (a[i] < 0){

            count ++;

        }else if (a[i] == 0 ){
  
            zerocount ++;
        }
    }

    if (count % 2 == 0 || zerocount > 0){

        ans = sum;

    } else{

        ans = sum - 2 * min;

    }
    
    cout << ans << endl;

    return 0;

    
}

Measured memory_bytes: 1024
get;lines.map({my ($a,$b)=.words.sort: +*;my$f=0+|sqrt $a*$b-1;$f-=$f**2>=$a*$b;say $a+0|1==$b??2*$a-2!!2*$f+($a*$b>$f*($f+1))-2})

Measured memory_bytes: 73052
N, M = map(int, input().split(' '))

A_list = list(map(int, input().split(' ')))
A_sum = sum(A_list)

lower_bound = 0
if A_sum % (4 * M) == 0:
    lower_bound = A_sum // (4 * M) - 1
else:
    lower_bound = A_sum // (4 * M)
s = 0
for vote in A_list:
    if vote > lower_bound:
        s += 1

if s >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#define exchange(a,b) {tmp=a;a=b;b=tmp;}

typedef struct Card{
  char suit;
  int num;
  int mmm;
}Card;

int Partition(Card *A,int p,int r){
  int j;
  Card tmp;
  int x = A[r].num;
  int i = p-1;
  for (j = p;j<r;j++){
    if (A[j].num <= x){
      i = i+1;
      exchange(A[i],A[j]);  
    }
  } 
  exchange(A[i+1],A[r]);
  
  return i+1;
}

void Quicksort(Card *A, int p,int r){
  int q;
  if( p < r){
    q = Partition(A, p, r);
    Quicksort(A, p, q-1);
    Quicksort(A, q+1, r);
  }
}

int main(){
  int n,i,k;
  Card A[100000];
  char dd;
  scanf("%d%c",&n,&dd);
  for(i=0;i<n;i++){
    scanf("%c%d%c",&A[i].suit,&A[i].num,&dd);
	A[i].mmm=i;
  }
  Quicksort(A,0,n-1);
  
  for(i=0;i<n-1;i++){
  if(A[i].num==A[i+1].num && A[i].mmm>A[i+1].mmm){
	printf("Not stable\n");i=-1;break;
  }
  }
  if(i!=-1){
  printf("Stable\n");
  }
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].suit,A[i].num);
  }  
  return 0;
  
}

Measured memory_bytes: 1776
#include <functional>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 2000000000
int p[100100],c[100100],e[100100];
int dp[2][100100];//dp[i+1][j]:=i番目までの箱を使ってj個の饅頭
int main()
{
    int n,m;
    cin >> n >> m;
    int sum=0;
    for(int i=0;i<n;i++)cin >> p[i];
    for(int i=0;i<m;i++)cin >> c[i] >> e[i];
    sort(p,p+n,greater<int>());
    for(int i=0;i<n;i++)p[i+1]+=p[i];
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[(i+1)%2][j]=min(dp[i%2][j],dp[i%2][max(j-c[i],0)]+e[i]);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,p[i-1]-dp[m%2][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;

void solve(){
    int n;
    cin >> n;
    vector <int> a(n);
    ll ans = 0;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int kol = 0;
    for (int i = 0; i < n; i++){
        ans += a[i] / 2;
        if (a[i] == 0) kol = 0;
        if (a[i] % 2){
            kol++;
            ans += kol / 2;
            if (kol > 1) kol = 0;
        }
    }
    cout << ans << endl;
}   
int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(10);
    //freopen("input.txt", "r", stdin);//freopen("output1.txt", "w", stdout);
    //freopen("icecream.in","r",stdin);// freopen("exam.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n;
  cin >> n;
  vi b(n - 1), a(n);
  for (int &i : b)
    cin >> i;
  int sum = 0;
  a[0] = b[0], a[n - 1] = b[n - 2];
  for (int i = 1; i < n - 1; i++)
    a[i] = min(b[i - 1], b[i]);
    // for(auto x:a) cout<<x<<" ";
  sum = accumulate(all(a), 0LL);
  cout << sum << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 3656
import scala.math._
  import scala.collection.mutable.ArrayBuffer

  object Main {
    def main(args: Array[String]): Unit = {
      val lines = io.Source.stdin.getLines().toSeq
      println(solve(lines))
    }

    def solve(lines: Seq[String]): String = {
      val Array(n, k) = lines.head.split(" ").map(_.toInt)
      debug(n, k)

      val timesBuf = ArrayBuffer.empty[Int]
      for (i <- 1 to n) {
        var num = i
        var times = 0
        while (num < k) {
          num = num * 2
          times += 1
        }
        timesBuf.append(times)
      }

      val ansBuf = ArrayBuffer.empty[Double]
      timesBuf.foreach { times =>
        val a = if (times > 0) (1.0 / n.toDouble) * pow(1.0 / 2.0, times.toDouble) else 1.0 / n.toDouble
        ansBuf.append(a)
      }
      ansBuf.sum.toString
    }

    private def debug(x: Any): Unit = {
      if (System.getenv("LOCAL_DEBUG") != null) println(x)
    }
  }

Measured memory_bytes: 36956
// I bet it's a SOS DP, but hell I cant see it

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1e16L;

int main () {
  int n;
  scanf("%d", &n);
  vector <vector <int>> a(n, vector <int> (n));
  vector <vector <ll>> dp(n + 1, vector <ll> (1 << n, -INF));
  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (int mask = 1; mask < (1 << n); mask++) {
    ll sum = 0;
    for (int b1 = 0; b1 < n; b1++) {
      if ((mask >> b1) & 1) {
        for (int b2 = n - 1; b2 > b1; b2--) {
          if ((mask >> b2) & 1) {
            sum += a[b1][b2];
          }
        }
      }
    }
    dp[1][mask] = sum;
  }
  ll ans = dp[1][(1 << n) - 1];
  for (int k = 2; k <= n; k++) {
    for (int mask = 1; mask < (1 << n); mask++) {
      for (int m = mask & (mask - 1); m > 0; m = (m - 1) & mask) {
        dp[k][mask] = max(dp[k][mask], dp[k - 1][m] + dp[1][mask & (~m)]);
      }
    }
    ans = max(ans, dp[k][(1 << n) - 1]);
  }
  printf("%lld\n", ans);
  return (0);
}


Measured memory_bytes: 11004