akhauriyash/Code-Regression huggingface dataset:
import bisect

a,b,q=map(int,input().split())
tem=[-10**18]+[int(input()) for _ in range(a)]+[10**18]
shr=[-10**18]+[int(input()) for _ in range(b)]+[10**18]
ans=[]

for _ in range(q):
    x=int(input())
    t=bisect.bisect_right(tem, x)
    s=bisect.bisect_right(shr, x)
    dt=[tem[t-1], tem[t]]
    ds=[shr[s-1], shr[s]]

    res=10**18
    for i in dt:
        for j in ds:
            d1=abs(x-i)+abs(i-j)
            d2=abs(x-j)+abs(i-j)
            res=min(res, d1, d2)
    ans.append(res)

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



Measured memory_bytes: 18536
#include <stdio.h>

int answer(int S);
void time(int S);

int main(void){
	int num=0;
    int S;
    
    scanf("%d",&S);
	num=answer(S);
	
	switch(num){
	case 1:
	time(S);
	break;
	case 2:
	printf("0<=S<=86400の数字を入力して下さい\n");
	break;
	}
    
    return 0;
}

int answer(int S){
	
	if(0<=S<86400){
	return 1;
	}else{
	return 2;
	}
}
    
void time(int S){

	int h=0;
	int m=0;
	int s=0;

	h=S/3600;
	m=(S%3600)/60;	
	s=(S%3600)%60;
	
	printf("%d:%d:%d\n",h,m,s);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < int(B); ++I)

int main(){
    ll N,M;
    cin >> N >> M;
    priority_queue< vector<ll> > CB;
    vector<ll> cb(2),A(N);
    FOR(i,0,N) cin >> A[i];
    sort(A.begin(),A.end());
    FOR(i,0,M){
        cin >> cb[1] >> cb[0];
        CB.push(cb);
    }
    FOR(i,0,N){
        if(CB.empty()) break;
        if(CB.top()[0] <= A[i]) break;
        auto x = CB.top();
        CB.pop();
        A[i] = x[0];
        x[1]--;
        if(x[1]){
            CB.push(x);
        }
    }
    ll ans = 0;
    FOR(i,0,N) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 7348
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 x;
  cin >> x;
  string ans[7] = {"thu", "fri", "sat", "sun", "mon", "tue", "wed"};
  cout << ans[x % 7] << endl;
  return 0;
}



Measured memory_bytes: 3208
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	x := make([]int, n)
	y := make([]int, n)
	h := make([]int, n)
	for i := range x {
		x[i] = readInt()
		y[i] = readInt()
		h[i] = readInt()
	}

	for cx := 0; cx <= 100; cx++ {
		for cy := 0; cy <= 100; cy++ {
			m := make(map[int]bool)
			for i := 0; i < n; i++ {
				ch := estimateHeight(cx, cy, x[i], y[i], h[i])
				if m[ch] {
					continue
				}
				m[ch] = true
				flag := true
				for i := 0; i < n; i++ {
					nh := calcHeight(cx, cy, ch, x[i], y[i])
					if nh != h[i] {
						flag = false
						break
					}
				}
				if flag {
					println(cx, cy, ch)
					return
				}
			}
		}
	}
}

func estimateHeight(cx, cy, x, y, h int) int {
	return absInt(cx-x) + absInt(cy-y) + h
}

func calcHeight(cx, cy, ch, x, y int) int {
	return maxInt(ch-absInt(x-cx)-absInt(y-cy), 0)
}

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

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, k;
vector<pii> e;
int main() {
	scanf("%d %d", &n, &k);
	int cnt = (n - 1) * (n - 2) / 2;
	if (k > cnt) {
		printf("-1\n");
		return 0;
	}
	//1以外の任意の2点間に辺を追加すると1辺減る
	//cnt-x=k <=> x=cnt-k
	printf("%d\n", (cnt-k) + (n-1));
	for (int i = 2; i <= n; i++)
		printf("%d %d\n", 1, i);
	int rem = cnt - k;
	for (int i = 2; i <= n && 0 < rem; i++)
		for (int j = i + 1; j <= n && 0 < rem; j++, rem--)
			printf("%d %d\n", i, j);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long

string s;

signed main() {
	cin >> s;
	int cnt = 0;
	int w = 0;
	int start = 0;

	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == 'B') {
			start = i;
			break;
		}
	}
	for (size_t i = start; i < s.size(); i++)
	{
		if (s[i] == 'W') {
			cnt += (i - start - w);
			w++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	auto left = 0;
	auto right = 0;
	for (auto i = 0; i < M; ++i)
	{
		int A;
		cin >> A;
		if (X > A)
		{
			++left;
		}
		else
		{
			++right;
		}
	}

	cout << min(left, right) << endl;

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(' ').map { it.toInt() }
    val l = readLine()!!.split(' ').map { it.toInt() }
    var p = 0
    for (i in (0 until n)) {
        p += l[i]
        if (p > x) {
            println(i + 1)
            return
        }
    }
    println(n + 1)
}

Measured memory_bytes: 38248
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
set<int> a;
a.insert(n);
for(int i=2;;i++){
	if(n%2==0)
		n/=2;
	else
		n=n*3+1;
	a.insert(n);
	if(i!=a.size())
	{
		cout<<i;
		return 0;
	}
}
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    xyh=[]
    for _ in range(n):
        x,y,h=inpm()
        xyh.append([x,y,h])
    xyh.sort(key=lambda x: x[2], reverse=True)
    for xc in range(101):
        for yc in range(101):
            x=xyh[0][0]
            y=xyh[0][1]
            h=xyh[0][2]
            d=abs(xc-x)+abs(yc-y)
            H=h+d
            for i in range(1,n):
                x=xyh[i][0]
                y=xyh[i][1]
                h=xyh[i][2]
                d = abs(xc-x) + abs(yc-y)
                if h!=max(0,H-d):
                    break
                if i == n-1:
                    print(xc,yc,H)
                    return
if __name__ == "__main__":
    main()

Measured memory_bytes: 43116
package main

import (
        "fmt"
)

func main() {
        var s []byte
        fmt.Scan(&s)
        exists := make([]byte, 'z'-'a'+1)
        for _, v := range s {
                exists[v-'a']++
        }
        for k, v := range exists {
                if v == 0 {
                        fmt.Printf("%c\n", k+'a')
                        return
                }
        }
        fmt.Println("None")
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


int main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    sort(rall(a));

    int l = a[0];
    int r = 0;
    rep(i,n)if(l > i){
        if(abs(l/2 - r) > abs(l/2 - a[i]))r = a[i];
    }
    cout << l << " " << r << endl;
}

// D - Binomial Coefficients

Measured memory_bytes: 640
N = int(input())

def num10to26(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num10to26(num//26-1)+chr(90)
    else:
        return num10to26(num//26)+chr(64+num%26)

print(str.lower(num10to26(N)))

Measured memory_bytes: 9164
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static boolean[] isPrime;
	static int[] primes=new int[78500];
	static int N,P;
	static void a(){
		isPrime=new boolean[1000000];
		Arrays.fill(isPrime, true);
		isPrime[0]=isPrime[1]=false;
		for(int i=2;i*i<=isPrime.length;i++){
			if(isPrime[i]){
				for(int j=i+i;j<isPrime.length;j+=i){
					isPrime[j]=false;
				}
			}
		}
		int cnt=0;
		for(int i=0;i<isPrime.length;i++){
			if(isPrime[i]){
				primes[cnt++]=i;
			}
		}
	}
	public static void main(String[] args) {
		a();
		Scanner cin=new Scanner(System.in);
		while(true){
			N=cin.nextInt();
			P=cin.nextInt();
			if(N+P==-2)break;
			int idx=0;
			for(int i=0;i<primes.length;i++){
				if(primes[i]>N){
					idx=i;
					break;
				}
			}
			List<Integer> list = new LinkedList<Integer>();
			for(int i=idx;i<40+idx;i++){
				for(int j=i;j<idx+40;j++){
					list.add(primes[i]+primes[j]);
//					System.out.println(primes[i]+" "+primes[j]+" "+(primes[i]+primes[j]));
				}
			}
//			System.out.println(idx);
			Collections.sort(list);
			int cnt=0;
			for(int s:list){
//				System.out.println(s);
				cnt++;
				if(cnt==P){
					System.out.println(s);
					break;
				}
			}
		}
	}

}

Measured memory_bytes: 68012
n = gets.chomp.to_i
h = Hash.new(0)
n.times do
  h[gets.chomp] += 1
end

ans = []
max = 0
h.each do |k, v|
  if v > max
    max = v
    ans = [k]
  elsif v == max
    ans << k
  end
end

ans.sort.each do |si|
  puts si
end

Measured memory_bytes: 35932
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  ll ans = N % 1000;
  if (ans != 0) {
    ans = 1000 - ans;
  }

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


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

int main(){
    int N, T;
    cin >> N >> T;
    int ans = 10000;
    for(int i = 0; i < N; i++)
    {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == 10000) {
        cout << "TLE" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>

struct str{
	int first;
	int second;
	int prev;
};

std::vector<int> V[200010];
std::queue< str > Q;
int check[200010],prev[200010];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=b;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		V[c].push_back(d);
		V[d].push_back(c);
	}
	
	Q.push({1,1,0});
	while(!Q.empty())
	{
		int x0 = Q.front().first;
		int y0 = Q.front().second;
		int p = Q.front().prev;
		Q.pop();
		
		if(check[x0]) continue;
		check[x0] = y0;
		prev[x0] = p;
		for(int i=0;i<V[x0].size();i++) Q.push({V[x0][i],y0+1,x0});
	}
	
	for(int i=1;i<=a;i++)
	{
		if(check[i]==0)
		{
			printf("No");
			return 0;
		}
	}
	
	printf("Yes\n");
	for(int i=2;i<=a;i++) printf("%d\n",prev[i]);
}

Measured memory_bytes: 15548
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

ll a,b,n;
ll solve(){
   ll ans=0;
   
   if(n<b)ans=(a*n)/b;
   else ans=(a*(b-1))/b;
   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>a>>b>>n;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            scanner.nextInt();
            while (scanner.hasNextInt()) {
                List<Integer> integers = new ArrayList<>();
                integers.add(scanner.nextInt());
                integers.add(scanner.nextInt());
                integers.add(scanner.nextInt());
                integers.sort(Integer::compareTo);
                int a = integers.get(0) * integers.get(0);
                int b = integers.get(1) * integers.get(1);
                int c = integers.get(2) * integers.get(2);
                if (c == a + b) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 35924
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll a;
    cin>>a;
    cout<<(a+a*a+a*a*a);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
n , m = map(int, input().split())

lis = []
for i in range(m):
    a = list(map(int, input().split()))
    a.append(i)
    lis.append(a)

t = 1
tmp = sorted(lis)[0][0]

nlis =[]

for i in sorted(lis):
    if tmp == i[0]:
        left = str(i[0]).zfill(6)
        right = str(t).zfill(6)
        t += 1
    else:
        t = 1
        tmp = i[0]
        left = str(i[0]).zfill(6)
        right = str(t).zfill(6)
        t += 1
    
    nlis.append([i[2],left+right])

for j in sorted(nlis):
    print(j[1])


Measured memory_bytes: 46784
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;int dist[144][144],hearts[6],dp[1<<6][144];int di[]={-1,1,0,0},dj[]={0,0,-1,1};int main(){for(int h,w;scanf("%d%d",&h,&w),h|w;){int n=h*w;rep(i,n) rep(j,n) dist[i][j]=1<<29;int hsize=0;rep(i,h) rep(j,w){int x; scanf("%d",&x);if(x==1)hearts[hsize++]=i*w+j;int p=i*w+j;dist[p][p]=0;rep(k,4){int ii=i+di[k],jj=j+dj[k],pp=ii*w+jj;if(0<=ii && ii<h && 0<=jj && jj<w)dist[p][pp]=dist[pp][p]=1;}}rep(k,n) rep(i,n) rep(j,n)dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);rep(i,1<<hsize) rep(j,n)dp[i][j]=1<<29;rep(i,hsize) rep(j,n)dp[1<<i][j]=dist[hearts[i]][j];rep(i,1<<hsize){for(int j=i;j;j=(j-1)&i) rep(k,n)dp[i][k]=min(dp[i][k],dp[j][k]+dp[i^j][k]);rep(j,n) rep(k,n)dp[i][j]=min(dp[i][j],dp[i][k]+dist[k][j]);}int* dpb=dp[(1<<hsize)-1];printf("%d\n",n-(*min_element(dpb,dpb+n)+1));}return 0;}

Measured memory_bytes: 0
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;
 
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <set>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
typedef long long LL;
 
LL N, A[100001];
 
int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
	}
	LL max = 0;
	LL sum = 0;
	REP(i, 0, N) {
		if (A[i] > max) {
			if (A[i] == max + 1) {
				++max;
			} else {
				sum += (A[i] - 1) / (max + 1);
				if (max == 0) max = 1;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1152
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	if len(s) != n{
		return
	}

	ans := "No"
	if n == 1 || n % 2 == 0{
		if s[:n/2] == s[n/2:]{
			ans = "Yes"
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int S, W;
    cin >> S >> W;

    cout << (S <= W ? "unsafe" : "safe") << endl;
    return 0;
}

Measured memory_bytes: 3616
s = input()
t1 = 0
t2 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != '0':
            t1 = t1 + 1
    if i % 2 == 1 and s[i] != '1':
        t1 = t1 + 1

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != '1':
            t2 = t2 + 1
    if i % 2 == 1 and s[i] != '0':
        t2 = t2 + 1

print(min(t1,t2))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
bool cmp(long long a, long long b)
{
	return a > b;
} 
int main()
{
	int a, b;
	cin >> a >> b;
	long long arr[a + 50][3];
	for(int i=1; i<=a; i++)
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	long long anss = -999999999999999999;
	for(int i=0; i<8; i++)
	{
		long long ans[99999], m = 0;
		for(int j=1; j<=a; j++)
		{
			long long temp = 0;
			for (int k = 0; k < 3; k++)
            {
                if ((i / (1 << k)) % 2 == 0)
                    temp += arr[j][k];
                else
                    temp -= arr[j][k];
            }
            ans[m++] = temp;
		}
		long long ansss = 0;
		sort(ans, ans + m, cmp);
		for(int i=0; i<b; i++)
			ansss += ans[i];
		anss = max(anss, ansss);
	}
	printf("%lld\n",anss);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] w = new int[n];

        for (int i = 0; i < n; i++) {
            w[i] = Integer.parseInt(sc.next());
        }

        int[] s = new int[n + 1];
        s[0] = 0;
        int sum = 0;
        for (int i = 1; i < s.length; i++) {
            s[i] = s[i - 1] + w[i - 1];
        }

        int result = 1000000;
        for (int t = 1; t < n; t++) {
            result = Math.min(result, Math.abs(s[t] - (s[n] - s[t])));
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
using namespace std;
//Xか＋のみ考えればよい
int main(){
	int A[3],memo = 0;cin >>A[0] >> A[1] >> A[2];
	for (int i = 0;i<=2;i++){
		for (int j = 0;j <= 2;j++){
			if (j >= i && A[i] <= A[j]){
				memo = A[i];
				A[i] = A[j];
				A[j] = memo;
			}
		}
	}
	cout << A[0]*10+A[1]+A[2] <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N (2000)
char s[N], ans[N], s2[N];
int main(){
    int len = 0;
    s[0] = '1';
    for (int i = 1; i < 12; i++){
        s[i] = '0';
        s[i + 1] = 0;
        printf("? %s\n", s);
        fflush(stdout);
        scanf("%s", ans);
        if (ans[0] == 'N'){
            len = i;
            break;
        }
    }
    if (len == 0){
        for (int i = 0; i < 12; i++){
            s2[i] = '9';
            s2[i + 1] = 0;
            printf("? %s\n", s2);
            fflush(stdout);
            scanf("%s", ans);
            if (ans[0] == 'Y'){
                len = i + 1;
                break;
            }
        }
        if (len == 1){
            printf("! 1\n");
            fflush(stdout);
            return 0;
        }
    }
    for (int i = 0; i < len - 1; i++){
        char l = '0', r = '9' + 1;
        s[i + 1] = 0;
        while (l + 1 < r){
            char mid = l + r >> 1;
            s[i] = mid;
            printf("? %s\n", s);
            fflush(stdout);
            scanf("%s", ans);
            if (ans[0] == 'Y'){
                l = mid;
            }
            else {
                r = mid;
            }
        }
        s[i] = l;
    }
    s[len] = '0';
    s[len + 1] = 0;
    char l = '0' - 1, r = '9';
    while (l + 1 < r){
        char ed = l + r >> 1;
        s[len - 1] = ed;
        printf("? %s\n", s);
        fflush(stdout);
        scanf("%s", ans);
        if (ans[0] == 'Y'){
            r = ed;
        }
        else {
            l = ed;
        }
    }
    s[len - 1] = r;
    s[len] = 0;
    printf("! %s\n", s);
    fflush(stdout);
}

Measured memory_bytes: 504
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static int[] _graph;
        static bool[] _seen;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            _graph = new int[n];
            _seen = new bool[n];
            for (var i = 0; i < n; i++)
            {
                _graph[i] = int.Parse(Console.ReadLine()) - 1;
            }

            Console.WriteLine(dfs(0, 0));
        }

        static int dfs(int n, int count)
        {
            if (n == 1) return count;
            _seen[n] = true;

            var next = _graph[n];
            if (_seen[next]) return -1;
            return dfs(next, ++count);
        }
    }
}


Measured memory_bytes: 34028
#include<iostream>
#include<vector>
#include<numeric>
#include<cstdlib>
#include<algorithm>

using namespace std;

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

long long INF = 10e17;

long long labs(long long a, long long b){
    if(a-b>=0){
        return a-b;
    } else {
        return b-a;
    }
}

int main(){
    long long n;
    cin >> n;

    vector<long long> l;
    REP(i, n){
        long long li;
        cin >> li;
        l.push_back(li);
    }

    long long sum = 0;
    REP(i, n){
        sum += l[i];
    }

    long long output = INF;
    long long a = 0;
    long long b = sum;
    for(long long i=0; i<n-1; i++){
        a += l[i];
        b -= l[i];
        output = min(output, labs(a, b));
    }
    cout << output << endl;
}


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

int main() {
  int a; //s1s2s3を入力するところ
  int b; //100で割ったときの値を代入する
  int c; //10で割ったときの値を代入する
  int d; // 1で割ったときの値を代入する

  cin >> a;
  b = a / 100;
  c = a / 10 - b * 10;
  d = a - b * 100 - c * 10;
  
  cout << b + c + d << endl;
}


Measured memory_bytes: 3604
n, m, q = map(int,input().split())
req = [list(map(int, input().split())) for _ in range(q)]

def dfs(array, length, next_min):
    ans = 0
    if length == n:
        score = 0
        for a,b,c,d in req:
            if array[b-1] - array[a-1] == c:
                score += d
        
        return score
    
    else:
        for num in range(next_min, m+1):
            next_array = array + [num]
            ans = max(dfs(next_array, length+1, num), ans)
    
    return ans

print(dfs([], 0, 1))    


Measured memory_bytes: 9128
#include <iostream>
using namespace std;
int main() {
  int D;
  cin >> D;
  if (D==25)
    cout << "Christmas" <<"\n";
  else if (D==24)
    cout << "Christmas Eve" <<"\n";
  else if (D==23)
    cout << "Christmas Eve Eve" <<"\n";
  else if (D==22)
    cout << "Christmas Eve Eve Eve" <<"\n";
}

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

int main() {
  int N;
  int a[2];
  cin >> N;
  
 a[0] = N / 100 ;
a[1] = ( N % 100 ) /10  ;
  a[2] =  ( N % 10 );
  
  if(a[0] == 7 || a[1] == 7 || a[2] == 7){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
	int n,m,x,a[101]={},b,l=0,r=0,i;

	scanf("%d%d%d",&n,&m,&x);
	for(i=0;i<m;i++){
		scanf("%d",&b);
		a[b]++;
	}

	for(i=1;i<x;i++)
		l+=a[i];
	for(i=x+1;i<n;i++)
		r+=a[i];
	if(l>r)
		l=r;
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 128
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,maxn,minn=0x7fffffff;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if (a>maxn) maxn=a;
		if (a<minn) minn=a;
	}
	printf("%d",maxn-minn);
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cout.precision(16);

  string S;
  deque<char> Sq;

  li Q;

  cin >>S;
  cin >>Q;

  for(auto s: S){
  	Sq.eb(s);
  }

  bool fw =1;
  int t,f;
  char c;
  Rep(i,Q){
  	cin >>t;
  	if(t==1){
  		fw = !fw;
  	}
  	else{
  		cin >>f;
  		cin >>c;
  		if(f==1){
  			if(fw){Sq.ef(c);}
  			else{Sq.eb(c);}
  		}
  		else{
  			if(fw){Sq.eb(c);}
  			else{Sq.ef(c);}
  		}
  	}
  }


  if(fw){
  	for(auto s: Sq){
  		cout <<s;
  	}
  }
  else{
  	for(li i =Size(Sq)-1;i >= 0;--i){
  		cout <<Sq[i];
  	}
  }
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
//    int64 N, D;
//    cin >> N >> D;
//    cout << (N+2*D)/(2*D+1) << endl;
    int64 r;
    cin >> r;
    cout << 3*r*r << endl;
}


Measured memory_bytes: 256
# A - 9x9
# 九九の計算
# 九九以外は -1 を返す

# 整数 a b を入力
a, b = map(int, input().split())

# print(a, b)

# a b が9以下の数字か判定し結果を代入
if a <= 9:
    if b <= 9:
        answer = a * b
    else:
        answer = -1
else:
    answer = -1

# 結果の表示
print(answer)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int n,k,q; cin >> n >> k >> q;
    vector<int> a(q + 1,0);
    for(int i = 1; i < q + 1; i++) cin >> a[i];

    //compute
    vector<int> p(n + 1, k - q);
    for(int i = 1; i < q + 1; i++) {
        p[a[i]] = p[a[i]] + 1;
    }

    //output
    for(int i = 1;i < n + 1 ; i++) {
        if(p[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    } 
}

Measured memory_bytes: 4024
import sys
input=sys.stdin.readline
n,w=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]

dp=[float("inf")]*(10**5+1)
dp[0]=0
for i in range(n):
  for j in range(10**5,A[i][1]-1,-1):
    dp[j]=min(dp[j],dp[j-A[i][1]]+A[i][0])
ans=0
for v,e in enumerate(dp):
  if e<=w:
    ans=v
print(ans)

Measured memory_bytes: 93132
def shortcut_path(src, dst, x, y):
    path = abs(src - x)
    path += 1 # shortcut
    path += abs(dst - y)
    return path

def normally_path(src, dst):
    return dst - src

N, X, Y = map(int, input().split())
shortcutnum = Y - X  - 1
shortest_paths = dict()

for i in range(1, N):
    for j in range(i+1, N+1):
        np = normally_path(i, j)
        sp = shortcut_path(i, j, X, Y)
        path = min(np, sp)
        if path in shortest_paths:
            shortest_paths[path] += 1
        else:
            shortest_paths[path] = 1

for i in range(1, N):
    if i in shortest_paths:
        print(shortest_paths[i])
    else:
        print(0)

Measured memory_bytes: 49756
#include <iostream>
#include <set>

using namespace std;

int main()
{
    set<char> map;
    for (int i = 0; i < 4; i++) {
        char ch; cin >> ch;
        map.insert(ch);
    }

    if (map.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main () {
	int n,k;
	cin>>n;
	double a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	{
			cin>>a[i];
			b[i]=1-a[i];
	}
	double dp[n+1][n+1];
	double pre[n+1],suf[n+1];
	pre[0]=suf[0]=1;
	
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]*a[i];
	
	for(int i=1;i<=n;i++)
		suf[i]=suf[i-1]*(1-a[i]);
	
	for(int i=1;i<=n;i++)
		dp[i][i]=pre[i];

	for(int i=2;i<=n;i++)
	{
		dp[i][1]=dp[i-1][1]*b[i] + a[i]*suf[i-1];	
	}
	
	for(int i=2;i<=n;i++)
	{
		for(int j=2;j<i;j++)
		{
			dp[i][j]=dp[i-1][j-1]*a[i]+dp[i-1][j]*b[i];
		}
	}
	double sum=0;
	int x=n/2+1;
	for(int i=x;i<=n;i++)
		sum+=dp[n][i];
	cout<<setprecision(12) <<sum<<"\n";
}

Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 10;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
inline int add(int a, int b) { a += b; if (a >= mod) return a - mod; return a; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}



void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  vector<int> dp(m + 1); // 0, 負け
  rep3(i, 1, m + 1) {
    rep(j, n) {
      if (i - a[j] < 0) break;
      if (dp[i - a[j]] == 0) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[m] ? "First" : "Second") << endl;
  // rep(i, m + 1) cout << dp[i] << " "; cout << endl;
}


Measured memory_bytes: 640
def main():
    H, W = [int(i) for i in input().split()]
    A = [[int(i) for i in input().split()] for _ in range(H)]
    B = [[int(i) for i in input().split()] for _ in range(H)]
    M = (H + W) * 80 + 1

    u = [[False] * M for _ in range(W)]
    v = [[False] * M for _ in range(W)]
    F = [False] * M
    v[0][0] = True
    for h in range(H):
        v, u = u, v
        vl = F
        for w in range(W):
            a, b = A[h][w], B[h][w]
            d = a - b if a > b else b - a
            uu = u[w]
            vv = v[w]
            for i in range(M):
                di = i - d if i > d else d - i
                vv[i] = ((i + d < M and (uu[i + d] or vl[i + d])) or
                           (uu[di] or vl[di]))
            vl = vv
    va = v[-1]
    for i in range(M):
        if va[i]:
            print(i)
            return
    raise

main()


Measured memory_bytes: 60144
io = STDIN
n=io.gets.chomp.to_i
$a=[]
n.times do
  $a<<io.gets.chomp.to_i
end
cnt = 0
cr=0
$a.each do |x|
  if cr==1
    if x>0
      cnt+=1
      x-=1
      cnt+=x/2
      cr=x%2
    else
      cr=0
    end
  else
    cnt+=x/2
    cr=x%2
  end
end
puts cnt

Measured memory_bytes: 2996
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
bool praime_numbers[100001];


static const int MOD = 1000000007;

const int int_inf = 2147483647;
const ll long_inf = 9223372036854775807ll;

#define rep(i,n) for(int i = 0;i<n;i++)
//#define rep(j,n) for(int j = 0;j<n;j++)
#define defvi(a,c) vector<int>(a,c)
#define defvvi(a,b,c) vector<vector<int>>(a, vector<int>(b, c))

int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };



void check_1D(vector<int>& ls);
void check_2D(vector<vector<int>>& ls);

int main(void)
{
	long l, r,ans = 2019;
	cin >> l >> r;
	for (long i = l; i < r + 1; ++i) {
		if (i % 2019 == 0) {
			ans = 0;
			break;
		}
		for (long j = i + 1; j < r + 1; j++) {
			if (j % 2019 == 0) {
				ans = 0;
				break;
			}
			ans = min(ans, (i * j) % 2019);
		}
	}
	cout << ans << endl;
}

//int main() {
//	ios::sync_with_stdio(false);
	//ここからコードを書く


	//ここまで
//}

//デバック用関数
//一次元の配列を出力する関数
void check_1D(vector<int>& ls) {
	int length = ls.size();
	for (int i = 0; i < length; i++) {
		cout << ls[i] << ' ';
	}
	cout << endl;
}
//二次元配列を出力する関数
void check_2D(vector<vector<int>>& ls) {
	for (int i = 0; i < ls.size(); i++) {
		for (int j = 0; j < ls[0].size(); j++) {
			cout << ls[i][j] << ' ';
		}
		cout << endl;
	}
}

//Union Find
class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  int a[n + 1], b[n + 1], c[m + 1], d[m + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> c[i] >> d[i];
  }

  for (int i = 1; i <= n; i++) {
    int min_D = abs(a[i] - c[1]) + abs(b[i] - d[1]);
    int checkpoint = 1;
    for (int j = 2; j <= m; j++) {
      int man_D = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (man_D < min_D) {
        min_D = man_D;
        checkpoint = j;
      }
    }
    cout << checkpoint << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using static Algo;
using System;

class Program
{
    static void Main(string[] args)
    {
        int amount = int.Parse(Console.ReadLine().Split(' ')[1]);
        int count = 0;
        int[] num = InputIntArray();
        BubbleSort(num);

        for(int i = 0; i < amount; i++)
        {
            count += num[i];
        }
        Console.WriteLine(count);
    }



}


static class Algo
{
    public static void BubbleSort<T>(T[] a)
        where T : IComparable<T>
    {
        int n = a.Length;
        for (int i = 0; i < n - 1; i++)
            for (int j = n - 1; j > i; j--)
                if (a[j].CompareTo(a[j - 1]) < 0)
                    Swap(ref a[j], ref a[j - 1]);
    }

    public static void Swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    }

    public static int[] InputIntArray()
    {
        string[] strs = Console.ReadLine().Split(' ');
        int[] num = new int[strs.Length];
        for (int i = 0; i < num.Length; i++)
        {
            num[i] = int.Parse(strs[i]);
        }
       
        return num;
        
    }

    public static float[] InputFloatArray()
    {
        string[] strs = Console.ReadLine().Split(' ');
        float[] num = new float[strs.Length];
        for (int i = 0; i < num.Length; i++)
        {
            num[i] = float.Parse(strs[i]);
        }
        return num;
    }
}




Measured memory_bytes: 27476
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if((A+B)>=C)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1001010;
int a[MAXN], f[MAXN];
int find(int x){
    return f[x] == 0 ? x : (f[x] = find(f[x]));
}
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++){
        scanf("%d", &a[i]);
    }
    int x, y;
    for(int i = 1; i <= m; i ++){
        scanf("%d%d", &x, &y);
        int xx, yy;
        if((xx = find(x)) == (yy = find(y)))
            continue;
        f[xx] = yy;
    }  
    int ans = 0;
    for(int i = 1; i <= n; i ++){
        if(find(i) == find(a[i]))
            ans ++;
    }
    printf("%d", ans);
    
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> hi(N);
    for(int i = 0; i < N; i++) cin >> hi[i];
    vector<int> G[N];
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> flag(N, 0);
    for(int i = 0; i < N; i++){
        if(flag[i] == 1) continue;
        int flag2 = 0;
        for(int j:G[i]){
            if(hi[j] < hi[i]){
                flag[j] = 1;
            } 
            else flag2 = 1;
        }
        if(flag2 == 1) flag[i] = 1;
    }
    int count = 0;
    for(int i = 0; i < N; i++){
        if(flag[i] == 0) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 9592
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n;
    cin >> n;
    double sum = 0;
    rep(i,n)
    {
        double a;
        cin >> a;
        sum += 1.0/a;
    }
    cout << 1.0/sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<cmath>
#include<vector>

int main() {
	const int64_t mod = 1e9+7;
	int n;
	std::cin >> n;
	int A = 0, C = 1, G = 2, T = 3;
	int64_t dp[102][4][4][4] = {};
	int64_t ans = 0;

	for (int a = 0; a < 4; a++) for (int b = 0; b < 4; b++) for (int c = 0; c < 4; c++) dp[3][a][b][c] = 1;
	dp[3][A][G][C] = 0;
	dp[3][A][C][G] = 0;
	dp[3][G][A][C] = 0;

	for (int i = 3; i < n; i++) {
		for (int b = 0; b < 4; b++) {
			for (int c = 0; c < 4; c++) {
				for (int d = 0; d < 4; d++) {
					for (int a = 0; a < 4; a++) {
						if (d == G && b == A && c == C)
							continue;
						if (d == C && ((b == A && c == G) || (b == G && c == A) || (a == A && c == G) || (a == A && b == G)))
							continue;

						dp[i + 1][b][c][d] += dp[i][a][b][c];
						dp[i + 1][b][c][d] %= mod;
					}
				}
			}
		}
	}

	for (int a = 0; a < 4; a++) for (int b = 0; b < 4; b++) for (int c = 0; c < 4; c++) { ans += dp[n][a][b][c]; ans %= mod; }
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    double l[10],v1,v2,t,S;
    int i;
    while((scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)!=EOF)){
	i=0;
	t=(l[0]+l[1]+l[2]+l[3]+l[4]+l[5]+l[6]+l[7]+l[8]+l[9])/(v1+v2);
	S=t*v1;
	while(S>=l[i]){
		S=S-l[i];
		if(S!=0)i++;
	}	
	printf("%d\n",i+1);
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll x[MAX];
int main(void) {
  ll a, b, k;
  cin >> n >> k;
  FOR(i, 0, n) {
	cin >> a >> b;
	x[a] += b;
  }

  FOR(i, 0, MAX) {
	k -= x[i];
	if (k <= 0) {
	  ans = i;
	  break;
	}
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>

int main(){
	int a, b;
	std::cin>>a>>b;

	if(a>=13)
		std::cout<<b<<std::endl;
	else if(a>=6)
		std::cout<<b/2<<std::endl;
	else
		std::cout<<0<<std::endl;


	return 0;
}

Measured memory_bytes: 256