akhauriyash/Code-Regression huggingface dataset:
import heapq
N,M=list(map(int,input().strip().split(' ')))
A=list(map(int,input().strip().split(' ')))
A=[-x for x in A]
heapq.heapify(A)
while M>0:
    temp=heapq.heappop(A)
    temp=-temp
    temp=temp//2
    temp=-temp
    heapq.heappush(A,temp)
    M-=1

print(-sum(A))

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

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

    vector<long long> march(5, 0);
    for(long long i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s[0] == 'M') march[0]++;
        else if(s[0] == 'A') march[1]++;
        else if(s[0] == 'R') march[2]++;
        else if(s[0] == 'C') march[3]++;
        else if(s[0] == 'H') march[4]++;
    }

    long long cnt = 0;
    for(long long i = 0; i < 5; i++){
        for(long long j = i + 1; j < 5; j++){
            for(long long k = j + 1; k < 5; k++){
                cnt += march[i]*march[j]*march[k];
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3620
A, B = map(int, input().split())

def calc(x): #[0, x]
    if x == 0: return 0
    res = 0
    x += 1
    for i in range(64):
        length = 2**i
        cycle = 2**(i+1)
        num = (x // cycle) * length
        if (x % cycle) > length: num += x % cycle - length
        if num%2: res += 2**i
    return res
'''
def calc2(x):
    res = 0
    for i in range(x+1): res ^= i
    return res

for i in range(100):
    a, b = calc(i), calc2(i)
    assert a == b ,f'i={i}, a={a}, b={b}'
'''

ans = calc(B) ^ calc(A-1)
print(ans)


Measured memory_bytes: 3064
type Count = { A: int; B: int }
let rec check a b s count result =
    match s with
    | [] -> result
    | x :: xs ->
        if x = 'c' then check a b xs { A = count.A; B = count.B } ("No" :: result)
        elif x = 'a' then
            if count.A + count.B < a + b
            then check a b xs { A = count.A + 1; B = count.B } ("Yes" :: result)
            else check a b xs { A = count.A; B = count.B } ("No" :: result)
        else
            if (count.A + count.B < a + b) && count.B < b
            then check a b xs { A = count.A; B = count.B + 1 } ("Yes" :: result)
            else check a b xs { A = count.A; B = count.B } ("No" :: result)

let fc a b s = check a b (Seq.toList s) { A = 0; B = 0 } [] |> List.rev

//let input = [| (10, 2, 3, "abccabaabb"); (12, 5, 2, "cabbabaacaba"); (5, 2, 2, "ccccc") |]
//for (n, a, b, s) in input do (fc a b s |> List.map (printfn "%A"))

[<EntryPoint>]
let main argv =
    let inputFst = stdin.ReadLine().Split(' ') |> Array.map int
    let n = inputFst.[0]
    let a = inputFst.[1]
    let b = inputFst.[2]
    let s = stdin.ReadLine()
    fc a b s |> List.map (printfn "%s") |> ignore
    0

Measured memory_bytes: 30284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc103_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 0;
  rep(i, N) { ans += c[i] - 1; }

  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <queue>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int n; cin >> n;
    if (n == 1) { cout << "Yes\n2\n1 1\n1 1\n"; return 0; }
    int k = 2;
    while (k * (k+1) / 2 < n) k++;
    if (k * (k+1) / 2 > n) {cout << "No\n"; return 0;}
    cout << "Yes\n" << k+1 << endl;
    queue<int> q[k+1];
    int cnt = 1;
    for (int j = 0; j <= k; j++) {
        cout << k << ' ';
        for (int m = 0; m < j; m++) {
            cout << q[m].front() << ' ';
            q[m].pop();
        }
        for (int m = j; m < k; m++) {
            cout << cnt << ' ';
            q[j].push(cnt);
            cnt++;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int c = vs[2];
			int ans = 0;
			if (a > b && a > c) {
				ans = b * c / 2;
			} else if (b > a && b > c) {
				ans = a * c / 2;
			} else if (c > a && c > b) {
				ans = a * b / 2;
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
open Printf
open Scanf

let () =
  let x, a, b = scanf "%d %d %d\n" (fun x y z -> (x, y, z)) in
  let ax = abs (x - a) in
  let bx = abs (x - b) in
  (if ax < bx then "A" else "B") |> printf "%s\n"


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	string s;
	cin>>s;
	forn(i,s.len())cout<<'x';
	cout<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    string s;
    cin >> s;
    cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    cin>>n;
    int a[n];
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%4==0)x++;
        else if(a[i]%2==0)y++;
        else z++;
    }
    if(y==0){
        if(x+1>=z)cout<<"Yes";
        else cout<<"No";
    }else{
        if(x>=z)cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}

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

using ll = long long;

ll N, K;
map<ll, ll> mp;

int main() {
   cin >> N >> K;
   for (int i = 0; i < N; i++) {
      ll a, b;
      cin >> a >> b;
      mp[a] += b;
   }

   ll cnt = 0;
   for (auto x : mp) {
      cnt += x.second;
      if (cnt >= K) {
         cout << x.first << endl;
         return 0;
      }
   }

   return 0;
}

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

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

using ll = long long;

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

int main() {
  ll N;
  cin >> N;
  vector<ll> v(N);
  vector<ll> ans(N);
  for( ll i = 0LL; i < N; i++) {
    cin >> v[i];
  }
  ll d = 0LL;
  for(ll i = 0LL ;i <=N-3; i+=2LL) {
    d+=v[i]-v[i+1];
  }
  ans[0]=d+v[N-1];
  for(ll i = 1LL; i < N; i++) {
    ans[i]=2*v[i-1LL]-ans[i-1LL];
  }
  for(ll i = 0; i < N; i++) {
    cout<<ans[i]<<" ";
  }
  cout << endl;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

string S;

int count_swap(const char* str, int begin, int end, char c) {
	int pos = end - 1;
	int count = 0;
	
	while (pos >= begin) {
		if (str[pos] != c) {
			count += 1;
			c = str[pos];
		}
		--pos;
	}
	
	return count;
}

void solve() {
	cout << count_swap(S.c_str(), 0, S.length(), S[S.length() - 1]);
}

int main() {
	while (cin >> S) {
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

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


	int N;
	cin >> N;
	pair<ll, ll> AB[200200], BA[200200];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = 0;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		ll G = __gcd(a, b);
		a /= G;
		b /= G;
		if (a < 0) {
			a = -a;
			b = -b;
		}
		if (b > 0) AB[ka++] = { a,b };
		else BA[kb++] = { -b,a };
	}

	ll kotae = 1;
	sort(AB, AB + ka);
	sort(BA, BA + kb);
	BA[kb] = { 2e18, 2e18 };

	pair<ll, ll> mae = AB[0];
	int p = 0;
	int kA = 0;
	rep(i, ka) {
		ll a = AB[i].first;
		ll b = AB[i].second;
		if (mae != AB[i]) {
			int tmp = 0;

			pair<ll, ll> mae2 = BA[p];
			int kB = 0;
			while (p < kb && BA[p] <= mae) {
				if (mae2 != BA[p]) {
					kotae = kotae * modpow(2, kB) % mod;
					mae2 = BA[p];
					kB = 1;
				}
				else kB++;
				p++;
			}

			if (mae == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}

			if (tmp) {
				kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
			}
			else {
				kotae = kotae * modpow(2, kA) % mod;
			}

			mae = AB[i];
			kA = 1;
		}
		else kA++;
	}

	int tmp = 0;
	pair<ll, ll> mae2 = BA[p];
	int kB = 0;
	while (p < kb) {
		if (mae2 != BA[p]) {
			if (AB[ka - 1] == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}
			mae2 = BA[p];
			kB = 1;
		}
		else kB++;
		p++;
	}

	if (AB[ka - 1] == mae2) {
		tmp = kB;
	}
	else {
		kotae = kotae * modpow(2, kB) % mod;
	}

	if (tmp) {
		kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
	}
	else {
		kotae = kotae * modpow(2, kA) % mod;
	}

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 9916
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def dfs(v, p):
        for u, w in tree[v]:
            if u == p:
                continue
            else:
                dist[u] = dist[v] + w
                dfs(u, v)

    n = int(input())
    tree = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        tree[u - 1].append([v - 1, w])
        tree[v - 1].append([u - 1, w])

    dist = [0] * n
    dfs(0, -1)
    res = []
    for d in dist:
        res.append(0 if d % 2 == 0 else 1)
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 104444
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

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

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

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

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	k := nextInt()
	n := nextInt()
	a := make([]int, n)

	m := 0
	for i := range a {
		a[i] = nextInt()
		if i > 0 {
			m = max(m, a[i]-a[i-1])
		}
	}
	m = max(m, a[0]+k-a[n-1])

	_, _ = fmt.Fprintf(writer, "%d", k-m)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 3840
from collections import deque
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
INF=float("inf")

H,W=map(int,readline().split())
Ch,Cw=map(lambda x: int(x) - 1, readline().split())
Dh,Dw=map(lambda x: int(x) - 1, readline().split())
maze=list(map(str,read().rstrip().decode().split()))

path=[[INF]*W for _ in range(H)]
walk=[(1,0),(0,-1),(-1,0),(0,1)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if not (i, j) in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s)) 
    for dx, dy in warp: 
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1)) 
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

Measured memory_bytes: 102120
#include <cstdio>
#include <queue>
#include <iostream>
#include <cstring>
using namespace std;
int n;
int a[100100];
bool b[100100];
 
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; ++i) scanf("%d", a+i);
	b[0] = true;
	int t = 0;
	for(int i=0; i<n; ++i){
		t = a[t]-1;
		if(b[t]){
			printf("-1\n");
			break;
		}
		if(t == 1){
			printf("%d\n", i+1);
			break;
		}
		b[t] = true;
	}
}


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


int main() {
    int n, m;
    std::priority_queue< int, std::vector<int>, std::less<int> > q;

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        q.push(t);
    }

    for (int i = 0; i < m; i++) {
        int t = q.top();
        // printf("%d\n", t);
        q.pop();
        q.push(t / 2);
    }

    long long sum = 0;

    for (int i = 0; i < n; i++) {
        int t = q.top();
        // printf("%d\n", t);
        q.pop();
        sum += t;
    }

    cout << sum << endl;
}


Measured memory_bytes: 892
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = sum(b)
for i in range(n-1):
    if a[i] == a[i+1]-1:
        sum += c[a[i]-1]
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,ans=1;
  cin >> n >> m;
  long long x[m],y[m],num[n];
  bool bl[n];
  for(int i=0;i<n;i++){
    num[i]=1;
    if(i==0){
      bl[i]=true;
    }else{
      bl[i]=false;
    }
  }
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i];
    x[i]--;y[i]--;
    num[x[i]]--;
    num[y[i]]++;
    if(bl[x[i]]==true){
      if(bl[y[i]]==false){
        ans++;
      }
      bl[y[i]]=true;
    }
    if(num[x[i]]==0&&bl[x[i]]==true){
      bl[x[i]]=false;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int n, k;
	cin >> n >> k;
	cout << (n % k == 0 ? 0 : 1) << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);

ll fpow(ll a, ll b, ll mod){
	if(b == 0)
		return 1;
	if(b == 1)
		return a;
	ll prod = fpow(a,b/2,mod)%mod;
	ll ans = (prod*prod)%mod;
	if(b%2)
		return (ans*a)%mod;
	return ans;
}

using namespace std;

int main(){
	fastIO;
	ll n;
	string s = "ACL";

	string ans = "";
	cin >> n;
	while(n--)
		ans += s;
	cout << ans << "\n";

}

Measured memory_bytes: 3656
#include <stdio.h>

int main(){
    
    int kloadaNol = 0;
    int a;
    long long b, temp;
    long long ans = 1;
    scanf("%d", &a);

    long long arr[100000];
    for (int i=0; i<a; i++){
        scanf("%lld", &arr[i]);
        if (arr[i] == 0){
            kloadaNol = 1;
        }
    }
    
    if (kloadaNol == 0){
        for(int i = 0 ; i < a ; i++){
			if(arr[i]<=1000000000000000000/ans){
				ans*=arr[i];
			}
            else{
            	printf("-1\n");
            	return 0;
			}
        }
        printf("%lld\n", ans);
    }
    else{
    	printf("0\n");
	}
	
	return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

/*
0-index
functionの中を書いて使う
宣言の時に単位元を書く
*/
template<typename T>
class segtree{
	int n;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, int a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return a + b;
	}
	
	T get(int k){return dat[k+n-1];}
	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(R,dat[--B]);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};

int main(){
	
	int n;cin >> n;
	vector<pair<int,int>> v(n);
	REP(i,n){
		cin >> v[i].FI;
		v[i].SE = i;
	}
	sort(ALL(v),greater<pair<int,int>>());
	
	ll ans = 0;
	segtree<int> seg(n,0);
	
	int num = 0;
	while(num < n){
		vector<pair<int,int>> now;
		now.PB(v[num]);
		while(num < n && v[num].FI == v[num+1].FI){
			now.PB(v[num + 1]);
			num++;
		}
		REP(i,now.size()){
			ans += min(seg.que(0,now[i].SE), seg.que(now[i].SE, n));
		}
		REP(i,now.size()){
			seg.update(now[i].SE, 1);
		}
		num++;
	}
	
	cout << ans << endl;
		
	
	return 0;
}


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;


int main(){
    int N;
    cin >> N;
    vector<LL> p(N), ind(N+1);
    multiset<LL>    s;
    for(int i = 0;i < N;i++){
        scanf("%d", &p[i]);
        ind[p[i]] = i;
    }
    s.insert(N);
    s.insert(N);
    s.insert(-1);
    s.insert(-1);
    LL ans = 0;
    LL l, ll, r, rr, cur;
    for(LL i = N;i > 0;i--){
        cur = ind[i];
        s.insert(cur);
        auto it = s.lower_bound(cur);
        l = *(--it);
        ll = *(--it);
        it++;
        it++;
        r = *(++it);
        rr = *(++it);
        LL p1 = (rr - r) * (cur - l);
        LL p2 = (r - cur) * (l - ll);
        ans += (p1 + p2) * i;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 6528
import java.util.*;

public class Main {
    public static void main(String[] args){
        int data[][][] = new int[4][3][10];
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i<n; i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            data[b-1][f-1][r-1] += v;
        }
        for(int i = 0; i<4; i++){
            for(int j = 0; j<3; j++){
                for(int k = 0; k<10; k++){
                    if(k == 0) System.out.printf(" ");
                    System.out.printf("%d", data[i][j][k]);
                    if(k != 9) System.out.printf(" ");
                }
                System.out.printf("\n");
            }
            if(i!=3) System.out.printf("####################\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 30500
#include<stdio.h>
#include<math.h>
int main() {
  int A,B,X,Y,Z;
  scanf("%d %d",&A,&B);
  X=A+B;
  Y=A-B;
  Z=A*B;
  if(X>=Y&&X>=Z) {
     printf("%d",X);
  } else if (Y>=X&&Y>=Z) {
      printf("%d",Y);
  } else if(Z>=X&&Z>=Y) {
     printf("%d",Z);  
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	fastio
	int n;
	cin>>n;
	int x=ceil(n/1.08);
	if(floor(x*1.08)==n) cout<<x;
	else cout<<":(";
	return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
#include <atcoder/all>
using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline void dump(T& v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U>& v) {
    irep(i, v) { cout << i->first << " " << i->second << '\n'; }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */

int main() {
    int n, q;
    cin >> n >> q;
    dsu d(n);
    rep(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t) {
            cout << d.same(u, v) << endl;
        } else {
            d.merge(u, v);
        }
    }
}

Measured memory_bytes: 4000
N = input()
T, A = map(int, input().split())
Hs = list(map(int, input().split()))
result1 = []
for x in Hs:
    tmp = T - (x * 0.006)
    result1.append(tmp)
result2 = {}
for i, tmp in enumerate(result1):
    result2[i+1] = abs(A - tmp)
print(sorted(result2.items(), key=lambda x: x[1])[0][0])

Measured memory_bytes: 3188
using System;
using System.Linq;

namespace ABC133A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] nab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(nab[0] * nab[1] > nab[2] ? nab[2] : nab[0] * nab[1]);
        }
    }
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    ll res = 0;
    while (a != b || b != c || c != a) {
        ll a1 = a, b1 = b, c1 = c;
        if (a1 % 2 == 1 || b1 % 2 == 1 || c1 % 2 == 1) {
            break;
        }
        a = (b1 + c1) / 2;
        b = (a1 + c1) / 2;
        c = (a1 + b1) / 2;
        res++;
    }
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
        cout << res << endl;;
        return 0 ;
    }
    if (a == b && b == c && c == a)
        res = -1;
    cout << res << endl;
    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);
	  long N=sc.nextLong(),res=0,M=N;
      for(int i=2;N!=1&&i<(int)Math.sqrt(M);i++){
          if(N%i==0){
              int s=0,t=1;
              while(N%i==0){
                  N/=i;
                  s++;
                  if(s==t){
                      s-=t;
                      t++;
                  }
              }
              res+=t-1;
          }
      }
      if(N!=1) res++;
      System.out.println(res);
	  sc.close();
	}

}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ll n;
  cin >> n;

  int ans = 0;

  FOR(i, 1, 10) FOR(j, 1, 10 - i) FOR(k, 1, 10 - i - j) {
    vector<int> v;
    REP(l, i) v.push_back(3);
    REP(l, j) v.push_back(5);
    REP(l, k) v.push_back(7);

    do {
      ll h = 0;
      REP(l, v.size()) {
        ll m = v[l];
        REP(o, l) { m *= 10; }
        h += m;
      }
      if (h <= n) {
        ans++;
      }
    } while (next_permutation(v.begin(), v.end()));
  }

  cout << ans << endl;

  return 0;
}


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


int main(){
   long long int n,k,q;
   cin >> n >> k >> q;
   vector<long long int> v(n);
   for(int i=0;i<n;i++)v[i]=k;
   for(int i=0;i<q;i++){
   	  int inp;
   	  cin >> inp;
   	  v[inp-1]++;
   }
   for(int i=0;i<n;i++){
   	  if(v[i]-q<=0)cout<<"No";
   	  else cout<<"Yes";
   	  cout<<endl;
   }	
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>

using namespace std;

long long N;

vector<long long> A;

using Graph=vector<vector<int>>;

Graph E,O;

int dfs(int n,int m)
{


}
int main()
{
  cin >> N;
  long long i,j,k,m,count=0;

  A.assign(N,0);
  j=0;
  m=1000000000;
  for(i=0;i<N;i++)
  {
    cin >> k;
    if(k>0)
    {
      j+=k;
    }
    else
    {
      count++;
      j+=-k;
    }
    m=min(m,abs(k));
  }
  
  if(count%2==0)
  {
    cout << j;
  }
  else
  {
    cout << j-2*m;
  }


}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())
V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		if j - v[i] >= 0:
			dp[i + 1][j] = dp[i][j - v[i]] + w[i]
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j
print(ans)
# copy

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

int n, k;
int arr[109];
int dp[100009];


bool solve(int idx, int k) {
	if(k == 0)
		return false;
	
	if(dp[k] != -1) {
		return dp[k];
	}
	
	bool ans = false;
	bool curr;
	for(int i = 0 ; i < n; i++) {
		if(arr[i] > k) break;
		curr = !(solve(idx, k - arr[i]));
		ans |= curr;
	}
	
	return dp[k] = ans;
}

int main() {
	cin>>n>>k;
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < n; i++) 
		cin>>arr[i];
	sort(arr, arr + n);
	
	if(solve(0, k)) cout<<"First\n";
	else cout<<"Second\n";
	return 0;
}

Measured memory_bytes: 5376
import itertools
from collections import defaultdict

H, W, D = [int(n) for n in input().split()]

A = []
for _ in range(H):
    A.append([int(n) for n in input().split()])

Q = int(input())
LR = []
for _ in range(Q):
    LR.append(tuple([int(n) for n in input().split()]))

P = defaultdict(lambda: (0, 0))
for i, j in itertools.product(range(H), range(W)):
    P[A[i][j]] = (i + 1, j + 1)

DD = defaultdict(int)
for i in range(D + 1, H * W + 1):
    DD[i] = DD[i - D] + abs(P[i][0] - P[i - D][0]) + abs(P[i][1] - P[i - D][1])

for l, r in LR:
    print(DD[r] - DD[l])


Measured memory_bytes: 51104
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>> n;
    for (int i=0;i<26;++i){
        for (int j=0;j<=15;++j){
            if(4*i+7*j==n){
                cout << "Yes"<< endl;
                return 0;
            }
        }
    }
    cout << "No"<< endl;
    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.nextLine());
    int k = Integer.parseInt(sc.nextLine());
    int x = Integer.parseInt(sc.nextLine());
    int y = Integer.parseInt(sc.nextLine());
    int pay = 0;
    
    for(int i = 1; i <= n; i++){
      if(i <= k){
        pay += x;
      }else{
        pay += y;
      }
    }
    
    System.out.println(pay);
  }
}

Measured memory_bytes: 35656
from collections import defaultdict as mapp
vis=mapp(lambda:0)
x=int(input())
s=list(map(int,input().split()))
for n in s:
    vis[n]+=1

sm=sum(s)
y=int(input())
for n in range(y):
    a,b=map(int,input().split())
    p=vis[a]
    vis[a]=0
    vis[b]+=p
    sm-=p*a
    sm+=p*b
    print(sm)

Measured memory_bytes: 24016
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<P> v;
	ll a, b;
	rep(i,n){
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	sort(v.begin(), v.end());
	ll ans = 0, cnt = 0;
	rep(i,n){
		if(v[i].second + cnt < m){
			cnt += v[i].second;
			ans += v[i].first * v[i].second;
		}
		else{
			ans += v[i].first * (m - cnt);
			cnt = m;
		}
		if(cnt == m) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    ll k, n, m;
    cin>>k;
    cin>>n>>m;
    if(n%k==0 || m%k==0)
    {
        cout<<"OK"<<endl;
    }
    else
    {
        ll res=n/k;
        if(((res+1)*k)<=m)
            cout<<"OK"<<endl;
        else
            cout<<"NG"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
N, X, Y = map(int, input().split())

l = [0 for _ in range(N)]
line = []

for i in range(1, N+1):
    for j in range(1, N+1):
        if i < j:
            l[min(abs(i-j), abs(X-i)+1+abs(Y-j), abs(X-j)+1+abs(Y-i))] += 1

for k in range(1, N):
    print(l[k])


Measured memory_bytes: 47964
def chmin(a, b):
    if a > b:
        return b
    return a

N = int(input())
H = list(map(int, input().split()))

dp = [float('inf')]*N
dp[0] = 0
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]))
    dp[i] = chmin(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[-1])

Measured memory_bytes: 13980
import sys
import collections
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())
cnt = collections.Counter(a)
sm = sum(a)
res = []
for i in range(q):
    b, c = map(int, input().split())
    sm += cnt[b] * (c - b)
    res.append(sm)
    cnt[c] += cnt[b]
    cnt[b] = 0
for r in res:
    print(r)

Measured memory_bytes: 27080
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

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


int main(){

	while(1){

		int H;
		int sum = 0;
		cin >> H;

		if(H == 0){
			break;
		}

		vector< vector <int> > v(H, vector<int>(8));

		rep(i, H){
			rep(j, 5){
				cin >> v[i][j];
			}
		}

		while(1){

			int A = 0;

			rep(i, H){
				rep(j, 3){
					if(v[i][j] == v[i][j + 1] && v[i][j] == v[i][j + 2] ){
						sum += v[i][j] * 3;
						if(v[i][j] == v[i][j + 3]){
							sum += v[i][j];
							v[i][j + 3] = 0;
							if(v[i][j] == v[i][j + 4]){
								sum += v[i][j];
								v[i][j + 4] = 0;
							}
						}
						v[i][j] = 0;
						v[i][j + 1] = 0;
						v[i][j + 2] = 0;
					}
				}
			}


			while(1){
				int p = 0;
				rep(i,H - 1){
					rep(j, 5){
						if(v[i+1][j] == 0 && v[i][j] != 0){
							p++;
							A++;
							v[i+1][j] = v[i][j];
							v[i][j] = 0;
						}
					}
				}
				if(p == 0){
					break;
				}
			}
			
			if(A == 0){
				break;
			}
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
console.log((args=>{
  const [[N],...tmp] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const c = tmp[N-1].sort((a,b)=>a-b);
  const G = Array.from({length:N},_=>[]);
  for ( let i = 0; i < N-1; i++ ) {
    const [a,b] = tmp[i];
    G[a-1].push(b-1);
    G[b-1].push(a-1);
  }
  let stack = [0], _stack = [];
  const d = Array(N).fill(0);
  d[0] = c.pop();
  const M = c.reduce((a,b)=>a+b);
  while( stack.length ) {
    const v = stack.pop();
    for ( const n of G[v] ) {
      if ( d[n] ) continue;
      d[n] = c.pop();
      _stack.push( n );
    }
    if ( stack.length === 0 ) [stack,_stack] = [_stack,[]];
  }
  return M + '\n' + d.join` `;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 43032
#include<iostream>
#include<deque>

using namespace std;

int main() {
	
	int n;
	cin >> n;
	
	int choice;
	int temp1, temp2;	
	deque<int> deq;
	
	for(int i=0;i<n;i++) {
		
		cin >> choice;
		switch(choice) {
			case 0:
				cin >> temp1 >> temp2;
				if( temp1 == 0)
				deq.push_front(temp2);
				else
				deq.push_back(temp2);
				break;
			case 1:
				cin >> temp1;
				cout << deq[temp1] << "\n";
				break;
			case 2:
				cin >> temp1;
				if( temp1 == 0)
				deq.pop_front();
				else
				deq.pop_back();
				break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 4648
a,b = map(int,input().split())
s = list(input())
cnt = 0
num = list("0123456789")
for i in range(a):
    if s[i] in num:
        cnt += 1
        
if s[a] == "-":
    cnt += 1
    
for i in range(b):
    if s[i+a+1] in num:
        cnt += 1
        
if cnt == a+b+1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    K--;

    if(S[K] == 'A') S[K] = 'a';
    else if (S[K] == 'B') S[K] = 'b';
    else S[K] = 'c';
    
    cout << S << endl;

    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  ll mx = 1;
  for ( ll i = 1; i <= sqrt(n); i++ ) {
    if ( n % i != 0 ) { continue; }
    mx = i;
  }
  cout << (mx-1) + (n/mx - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
Drinks = sorted([list(map(int, input().split())) for i in range(N)], reverse=True)


ans = 0
while M > 0:
    a, b = Drinks.pop()
    if M > b:
        M -= b
        ans += a * b
    else:
        ans += a * M
        break

print(ans)


Measured memory_bytes: 29520
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body

$aa = inputs[0][0]
$bb = inputs[0][1]
$cc = inputs[0][2]

if $debugFlag
  p $aa
  p $bb
  p $cc  
end

if ($bb / $aa) > $cc
  res = $cc
else
  res = $bb / $aa
end
puts res



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/
 
typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
 
//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;
 
int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    int ans=0;
    if(n>=100000)
        n=99999;
    if(n>=9999)
        ans+=(n-9999);
    n=min(n, 999);
    if(n>99)
        ans+=(n-99);
    n=min(n, 9);
    ans+=n;
    cout<<ans<<endl;
}

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

template <typename T> inline void cmax(T& x, T y) {
    if (x < y) x = y;
}

template <typename T> inline void cmin(T& x, T y) {
    if (x > y) x = y;
}

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int n, x[N], y[N], d[N];

double get(double now) {
    double xmin, xmax, ymin, ymax;
    xmin = ymin = 1e9, xmax = ymax = -1e9;
    for (int i = 1; i <= n; ++i) {
        double tx = x[i] + dx[d[i]] * now, ty = y[i] + dy[d[i]] * now;
        cmin(xmin, tx), cmax(xmax, tx), cmin(ymin, ty), cmax(ymax, ty);
    }
    return (xmax - xmin) * (ymax - ymin);
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    char op[10];
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", x + i, y + i);
        scanf("%s", op);
        if (*op == 'R') d[i] = 0;
        if (*op == 'L') d[i] = 1;
        if (*op == 'U') d[i] = 2;
        if (*op == 'D') d[i] = 3;
    }
    double l = 0, r = 1e18;
    for (int i = 1; i <= 500; ++i) {
        double tmp = (r - l) / 3.0, midl = l + tmp, midr = r - tmp, resl, resr;
        resl = get(midl), resr = get(midr);
        if (resl < resr) r = midr;
        else l = midl;
    }
    printf("%.11f\n", get(l));
    return 0;
}


Measured memory_bytes: 1408
S = input()
L = ["A","C","G","T"]
ans = 0
for i in range(len(S)):
  for j in range(i+1,len(S)+1):
    s = S[i:j]
    ok = True
    for c in s:
      if not c in L:
        ok = False
    if ok:
      ans = max(ans,j-i)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm> //min, max, sort, unique, fill
#include <utility>  //pair, swap,
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>


#define REP(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;


vector<ll> vi;



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

  cout <<max(a+b,max(a*b,a-b))<<endl;
    
  



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  cin >> N;
  vector<vector<int>> F(N, vector<int>(10));
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < 10; j++ ) cin >> F[i][j];
  }

  vector<vector<int>> P(N, vector<int>(11));
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < 11; j++ ) cin >> P[i][j];
  }

  int ans = -1000000000000000;
  for (int bit = 0; bit < (1<<10); ++bit) {
    vector<int> kaburi(N, 0);
    int now = 0;
    bool fg = 0;
    for (int i = 0; i < 10; ++i) {
      if (bit & (1<<i)) { // i番目のbitが立っていれば
      fg = 1;
        for( int j = 0; j < N; j++ ){
          if( F[j][i] == 1 ) kaburi[j]++;
        }
      }
    }
    for( int j = 0; j < N; j++ ){
      now += P[j][kaburi[j]];
    }
    if( fg ) ans = max(ans, now);
  }
  cout << ans << endl;




}


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

int main(){
    string S;  cin >> S;
    int n = S.length();
    int cntr = 0, cntb = 0;
    for(int i=0; i<n; i++){
        if(S[i]=='0') cntr++;
        if(S[i]=='1') cntb++;
    }
    cout << min(cntr,cntb)*2 << endl;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;

class Main{
  public static StringBuilder bl = new StringBuilder();
  public static final int WHITE = 0;
  public static final int BLACK = 2;
  public static final int GRAY = 1;
  static int color[];
  static int time;
  static int M[][];
  static int nt[];
  static  int d[]; // 行きの時間 discover;
  static  int f[]; // 帰りの時間 finishing;
  static int n;
  // static Deque<Integer> stack = new ArrayDeque<Integer>();

  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    M = new int[n][n];
    color = new int[n];
    d = new int[n];
    f = new int[n];
    nt = new int[n];
    int u, k, v;

    for(int i = 0; i<n; i++){
      for(int j = 0; j<n; j++){
        M[i][j] = 0;
      }
    }

    for(int i = 0; i<n; i++){
      u = sc.nextInt();
      k = sc.nextInt();
      for(int j = 0; j<k; j++){
        v =sc.nextInt();
        M[u-1][v-1] = 1;
      }
    }
    dfs_init();
    System.out.print(bl);
  }

  static void dfs_init(){
    for(int i =0; i<n; i++){
      color[i] = WHITE;
      nt[i] = 0;
    }
    time = 0;
    //  //dfs(0);

    for(int u = 0; u<n; u++){
      if(color[u] == WHITE)dfs(u);
    }

    for(int i = 0; i<n; i++){
      bl.append(i+1).append(" ").append(d[i]).append(" ").append(f[i]).append("\n");
      // System.out.println((i+1)+" "+d[i]+" "+f[i]);
    }

  }

  static void dfs(int r){

    for(int i =0; i<n; i++){
      nt[i] = 0;
    }
    Deque<Integer> stack = new ArrayDeque<Integer>();
    stack.offerFirst(r);
    color[r] = GRAY;
    d[r] = ++time;

    while(stack.peek()!=null){
      int u = stack.getFirst();
      int v = next(u);
      if(v != -1){
        if(color[v] == WHITE){
          color[v] = GRAY;
          d[v] = ++time;
          stack.offerFirst(v);
        }
      }else{
        stack.removeFirst();
        color[u] = BLACK;
        f[u] = ++time;
      }
    }
    
  }

  //ノードuに隣接しているノードを返す 隣接行列で表現されているのでuの行を探索して1があればその列の添字を返す。
  static int next(int u){
    for(int v = nt[u]; v <n; v++){
      nt[u] = v+1;
      if(M[u][v] == 1) return v;
    }
    return -1;
  }

}


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

int main() {
  int N,count,end = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  while(end == 0){
    for(int i = 0; i < N; i++){
      if(A.at(i) % 2 == 0){
      A.at(i) /= 2;
      count ++;
      }
      else{
        end ++;
        break;
      }
    }
  }
  cout << count / N;
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    int a;
    cin >> a;
    string s;
    cin >> s;
    int n = s.length();
    for(int i=0;i<n;i++)
    {
        cout << (char)((s[i] - 'A'+a)%26 + 'A');
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256