akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,ans,r,D,x;
bool a[100];

pair<LL, LL>d;
int main() {
	cin >> r>>D;
	if (r> 12) {
		cout << D << endl;
	}
	else {
		if(r>5)cout << D / 2 << endl;
		else cout << 0<<endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
	double a,b,s,t,d;
	scanf("%lf %lf %lf %lf",&a,&b,&s,&t);
	d=sqrt((a-s)*(a-s)+(b-t)*(b-t));
	printf("%f",d);
	return 0;
}

Measured memory_bytes: 652
# 累積和
import numpy as np
from numba import njit

@njit(cache=True)
def loop(n, k, A):
    for _ in [0] * k:
        B = np.zeros(n + 1, dtype=np.int64)
        for i in range(n):
            left = max(0, i - A[i])
            right = min(n, i + A[i] + 1)
            B[left] += 1
            B[right] -= 1
        A = np.cumsum(B)[:-1]
        #print(A)
        if np.all(A == n):
            return A
            break

    return A


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    A = np.array(a, dtype=np.int64)
    A = loop(n, k, A)
    print(*A)


if __name__ == "__main__":
    main()


Measured memory_bytes: 135128
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;


int main()
{
    int n;
    int res;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    res = p.back() / 2;
    p.pop_back();

    for (int i = 0; i < n - 1; i++) {
        res += p[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
int h[101010];
int main()
{
    int n, mi = 2e9 + 1, k;
    std::cin >> n >> k;
    for (int i = 1; i <= n; ++i) std::cin >> h[i];
    std::sort(h + 1, h + n + 1);
    for (int i = k; i <= n; ++i) mi = std::min(mi, h[i] - h[i - k + 1]);
    std::cout << mi;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using ULL=unsigned long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a , b;
    string op;
    cin >> a >> op >> b;
    cout << ( op == "+" ? a+b : a-b ) << endl;
    return 0;
}

Measured memory_bytes: 764
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = []
for i in range(N-K):
    a1 = A[i]
    a2 = A[i+K]
    if a1 < a2:
        ans.append('Yes')
    else:
        ans.append('No')

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

Measured memory_bytes: 31392
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b;
  string s;
  cin >> a >> b >> s;
  if(s[a] != '-'){
    cout << "No" << endl;
    return 0;
  }
  REP(i, a){
    if(s[i] < '0' || '9' < s[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  REP(i, b){
    if(s[a+1+i] < '0' || '9' < s[a+1+i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
P = list(map(float, input().split()))

dp = np.zeros(N + 2)
dp[1] = 1

for p in P:
    q = 1 - p
    dp[1:] = dp[:N + 1] * p + dp[1:] * q

# print (dp)
print (sum(dp[N // 2 + 2:]))

Measured memory_bytes: 14536
def judge(w1, w2):
    la = len(w1)
    lb = len(w2)
    for i in range(min(la,lb)):
        if w1[i] > w2[i]: return 1
        elif w1[i] < w2[i]: return 2
    if la > lb: return 1
    elif la < lb: return 2
    else: return 0

s = [0, 0, 0]
loop = int(raw_input())
for i in range(loop):
    w = raw_input().split()
    tmp = judge(*w)
    if tmp == 0:
        s[1] += 1
        s[2] += 1
    else:
        s[tmp] += 3
print s[1], s[2]

Measured memory_bytes: 4264
n, q = gets.split.map(&:to_i)
str = gets.chomp
l = []
r = []
q.times do |i|
  l[i], r[i] = gets.split.map(&:to_i)
end

# 累積和の配列
s = []
s[0] = 0
s[1] = 0
1.upto (str.size-1) do |i|
  if str[i-1] == 'A' && str[i] == 'C'
    s[i+1] = s[i] + 1
  else
    s[i+1] = s[i]
  end
end

# puts "#{s}"

q.times do |i|
  puts s[r[i]]-s[l[i]]
end

Measured memory_bytes: 5100
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;

	char a[2][1<<10];
	for(int i=0;i<n;i++){
		cin>> a[0][i]>> a[1][i];
	}

	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		char in;
		cin>> in;
		for(int j=0;j<n;j++){
			if(in==a[0][j]){
				in=a[1][j];
				break;
			}
		}
		cout<< in;
	}
	cout<<endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve()){};

	return 0;
}

 

Measured memory_bytes: 1152
//package abc166.E

import java.io.*
import java.math.*
import java.util.*
import kotlin.math.*

var reader: BufferedReader = System.`in`.bufferedReader()
var writer: PrintWriter = PrintWriter(System.`out`)

fun next() = reader.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextStrings() = next().split(" ")
fun nextInts() = nextStrings().map { it.toInt() }
fun nextLongs() = nextStrings().map { it.toLong() }
fun nextDoubles() = nextStrings().map { it.toDouble() }

fun put(v: Any?) = writer.print(v)
fun puts() = writer.println()
fun puts(v: Any?) = writer.println(v)

var debug = false
fun dp(v: Any?) {
    if (debug) println(v)
}
fun dp() {
    if (debug) println()
}

fun test(case: Int, input: String, expected: String) {
    reader = input.trimIndent().reader().buffered()

    val stringWriter = StringWriter()
    writer = PrintWriter(stringWriter)

    solve()
    writer.flush()

    val actual = stringWriter.toString()

    println("[test $case]")
    if ("${expected}" == actual) {
        println("OK")
    } else {
        println("NG")
        println()
        println("expected: \"${expected}\"")
        println("actual:   \"${actual}\"")
    }
    println()
}

@Suppress("UNUSED_PARAMETER")
fun xtest(case: Int, input: String, expected: String) {}

fun main(args: Array<String>) {
    if ((args.size == 1) && (args[0] == "test")) {
        testAll()
    } else {
        solve()
        writer.flush()
    }
}

///////////////////////////////////////////////////////////

fun testAll() {
    debug = true

    test(1,
    """
    6
    2 3 3 1 3 1
    """,
    "3")
    test(2,
    """
    6
    5 2 4 2 8 8
    """,
    "0")
    test(3,
    """
    32
    3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
    """,
    "22")
}

fun solve() {
    nextLong()

    val A = nextLongs()

    val map = mutableMapOf<Long, Long>()
    A.forEachIndexed { idx, a ->
        val k = a - idx
        map.merge(k, 1L) { v, _ ->
            v + 1
        }
    }

    var pairs = 0L
    A.forEachIndexed { idx, a ->
        val k = -(a + idx)
        pairs += map.getOrDefault(k, 0L)
    }

    put(pairs)
}


Measured memory_bytes: 77224
import java.util.Scanner;
 
public class Main{

public static void main(String[] args) {
 
int count = 0;
int H;
int A;
 
Scanner scanner = new Scanner(System.in);
H = scanner.nextInt();
A = scanner.nextInt();
 
while (H>0){
  H = H-A;
  count = count + 1;
}
  
System.out.println(count);
  
}
  
}

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

#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll>> //vvl data(10, vector<ll>(10);
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    int K;
    cin >> K;
    string S;
    cin >> S;    

    if(S.size() <= K) cout << S << endl;
    else{
        cout << S.substr(0,K) + "..." << endl;
    }
    
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3628
sortsecond = lambda val: val[1]
N, M = map(int, input().split())
l=[]
for i in range(M):
    t=input().split()
    l.append((int(t[0]),int(t[1])))
l.sort(key=sortsecond)
ans = int(0)
count = int(0)
br = int(0)


for i in range(M):
    if br<l[i][0]+1:
        count +=1
        br = l[i][1]

ans = count
print(ans)

Measured memory_bytes: 18196
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val N = nextInt()
    val XY = Array<IntArray>(N, { listOfInt().toIntArray() })
    val map = mutableMapOf<Pair<Int, Int>, Int>()
    for (n in 0 until N) {
        for (m in 0 until N) {
            if (n == m) continue
            val dx = XY[m][0] - XY[n][0]
            val dy = XY[m][1] - XY[n][1]
            val key = Pair(dx, dy)
            if (map.containsKey(key)) {
                map[key] = (map[key] ?: 0) + 1
            } else {
                map[key] = 1
            }
        }
    }
    var max = map.values.max() ?: 0
    var ans = N - max
    println("${ans}")
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }



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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code
	int n;
	cin >> n;
	cout <<	(n%2==0?n:n*2) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

long long int result[101][100001] = {};

int main()
{
	int n, W;
	cin >> n >> W;
	int w[100001], v[100001];
	for(int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
	}
	for(int i = w[0]; i <= W; i++){
		result[0][i] = v[0];
	}
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= W; j++){
			result[i][j] = result[i - 1][j];
			if(j >= w[i]) result[i][j] = max(result[i][j], result[i - 1][j - w[i]] + v[i]);
		}
	}
	long long int ans = 0;
	for(int i = 0; i <= W; i++){
		ans = max(ans, result[n - 1][i]);
	}
	cout << ans << endl;
}

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

int main(void){
    int N, M;
    long long K, Abuf, Bbuf;
    long long Asum = 0;
    int Anum = 0;
    int Bnum = 0;
    bool plusable = true;
    vector<int> A, B;
    cin >> N >> M >> K;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
        if(plusable && (Asum + Abuf <= K)){
            Asum += Abuf;
            Anum++;
        }else plusable = false;
    }
    plusable = true;
    for(int i=0; i<M; i++){
        cin >> Bbuf;
        B.push_back(Bbuf);
        if(plusable && (Asum + Bbuf <= K)){
            Asum += Bbuf;
            Bnum++;
        }else plusable = false;
    }
    int res = Anum + Bnum;
    for(int i=Anum-1; i>=0; i--){
        Asum -= A[i];
        if(Bnum < M){
            while(Asum + B[Bnum] <= K){
                Asum += B[Bnum];
                Bnum++;
                if(Bnum >= M)break;
            }
        }else break;
        res = max(res, i+Bnum);
    }
    cout << res << endl;

    return 0;
}

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

int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(b<c||d<a)
    cout<<0<<endl;
  else if(c<=a){
    if(d<b)
      cout<<d-a<<endl;
    else
      cout<<b-a<<endl;
  }
  else{
    if(b<d)
      cout<<b-c<<endl;
  else
      cout<<d-c<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int count;
  rep(i,n-2){
    string str=s.substr(i,3);
    if(str=="ABC"){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define dforr(i, a, b) for(int i = (int)(b-1); i >= (a); i--)
#define dforn(i, n) dforr(i, 0, n)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define fst first
#define snd second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = 100500;

int n, q, A[MAXN];
ll S[MAXN], T[MAXN];

int notyet(int x, int d){
    auto it1 = lower_bound(A, A+n, x-d);
    auto it2 = lower_bound(A, A+n, x+d);
    int forB = it2 - it1, forA = A+n - it2;
    return forB <= forA;
}

ll sum(int l, int r){ return S[r] - S[l]; }

ll calc(int x, int d, bool deb = 0){
    auto it1 = lower_bound(A, A+n, x-d);
    auto it2 = lower_bound(A, A+n, x+d);
    int forB = it2 - it1, forA = A+n - it2;
    assert(forA-forB <= 2);
    if(forA - forB == 2) forA--;
    if(deb){
        printf("Lo primero que toma es %lld\n", sum(n-forA, n));
        printf("Luego quedan los primeros %d\n", it1-A);
        printf("De aca sale %lld\n", T[it1-A]);
    }
    return sum(n-forA, n) + T[it1-A];
}

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d %d", &n, &q) >= 1){
        forn(i, n)scanf("%d", &A[i]);
        S[0] = 0; forr(i, 1, n+1)S[i] = S[i-1] + A[i-1];
        T[0] = 0; forr(i, 1, n+1)T[i] = T[i-1] + ((n%2 != i%2) ? 0 : A[i-1]);
//        printf("S:"); forn(i, n+1)printf(" %lld", S[i]); puts("");
//        printf("T:"); forn(i, n+1)printf(" %lld", T[i]); puts("");

        forn(cs, q){
            int x; scanf("%d", &x);
            int l = 0, r = 1e9;
            while(r-l > 1){
                int m = (l+r)/2;
                if(notyet(x, m))l = m;
                else r = m;
            }
//            printf("El limite correcto es %d\n", l);
            printf("%lld\n", calc(x, l, 0));
       }
	}
	return 0;
}


Measured memory_bytes: 3712
import copy
n,m=list(map(int,input().split()))
H=list(map(int,input().split()))
A=H.copy()

for _  in range(m):
  a,b=list(map(int,input().split()))
  if H[a-1]>H[b-1]:
    A[b-1]=0
  elif H[a-1]<H[b-1]:
    A[a-1]=0
  else:
    A[a-1]=0
    A[b-1]=0
#print(H,A)
print(n-A.count(0))

Measured memory_bytes: 20964
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007




n =  I()
final_slime = sorted(LI(), reverse=True)
now_slime = [final_slime[0]]
made_or_not = [0] * (2 ** n)
made_or_not[0] = 1
for i in range(n):
    k = 0
    for j in range(len(now_slime)):
        flag = 1
        while flag:
            if k == 2 ** n:
                print('No')
                exit(0)
            if made_or_not[k] == 0 and now_slime[j] - 1 >= final_slime[k]:
                now_slime += [final_slime[k]]
                made_or_not[k] = 1
                flag = 0
            k += 1
    now_slime.sort(reverse=True)
print('Yes')




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

using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  vector<int> a(n);
  vector<int> s,t;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]<0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }

  int sl = s.size();
  int tl = t.size();
  bool ok = false;
  if(sl > 0){
    if(n==k) ok = (tl%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }

  
  mint ans = 1;
  if(!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
	return abs(x) < abs(y);
      });
    for(int i=0;i<k;i++) ans *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(k%2==1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<long long> p;
    while (s.size()>=2){
      long long x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while(t.size()>=2) {
      long long x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    for(int i=0;i<k/2;i++) ans *= p[i];
  }

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


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

//ユークリッドの互除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main(){
    int N; cin >> N;
    vector<ll> A(N+1),L(N+1),R(N+2); rep(i,N) cin >> A[i+1];
    A[0]=0;
    R[N+1]=0;
    rep(i,N){
        L[i+1] = gcd(L[i],A[i]); //L[i]は左からi-1番目までのA[]の最大公約数
        R[N-i] = gcd(R[N-i+1],A[N-i]); //R[i]は右からA[i]番目までのの最大公約数
    }
    vector<ll> M(N+1);
    ll ans = 0;
    for(int i = 1; i < N+1; i++){
        M[i] = gcd(L[i],R[i+1]); //左からA[i-1]までの最大公約数と右からA[i+1]まで最大公約数
        if(ans < M[i]) ans = M[i];
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    constexpr int RARY = 60;
    for (int i = 0; i < 60000; i++) {
        const int t = (c + i * RARY);
        const int tim = t % (a + b);
        if (tim <= a) {
            cout << t << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

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

int decode(int p, string s) {
  // reverse(s.begin(), s.end());

  int ret = 0;
  for(int i=0; i<s.length(); i++) {
    ret *= p;

    int val = 0;
    if('0' <= s[i] && s[i] <= '9') {
      val += (s[i] - '0');
    }
    else if('A' <= s[i] && s[i] <= 'Z') {
      val += 10;
      val += (s[i] - 'A');
    }
    else {
      val += 10 + 26;
      val += (s[i] - 'a');
    }

    ret += val;
  }

  // printf("debug: p = %d, m = %s, result = %d\n", p, s.c_str(), ret);
  return ret;
}

void apply_num(int &res, int value) {
  int cons = 0;
  for(int i=0; i<20; i++, value >>= 1) {
    if(value & 1) cons++;
    else {
      res ^= cons;
      cons = 0;
    }
  }
}

int main() {
  int N; cin >> N;

  vector<int> P(N);
  vector<string> M(N);

  for(int i=0; i<N; i++) {
    cin >> P[i] >> M[i];
  }

  int res = 0;
  vector<int> V(N);
  for(int i=0; i<N; i++) {
    V[i] = decode(P[i], M[i]);
    apply_num(res, V[i]);
  }

  if(res != 0) cout << "win" << endl;
  else cout << "lose" << endl;
  return 0;
}



Measured memory_bytes: 9264
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
    int n;
    scanf("%d", &n);
    int d[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &d[i]);
    }
    qsort(d, n, sizeof(int), compare_int);
    int ans = d[n/2] - d[n/2-1];    
    
    printf("%d\n", ans);
    return 0; 
}

Measured memory_bytes: 892
import java.io.*;
  
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line;
while((line=br.readLine())!=null){
int ans=0;
char[] n=line.toCharArray();
int[] fig=new int[n.length];
for(int i=0;i<fig.length;i++){
fig[i]=toNum(n[i]);
}
for(int i=1;i<fig.length;i++){
if(fig[i-1]<fig[i]){
fig[i-1]*=-1;
}
}
for(int i=0;i<fig.length;i++){
ans+=fig[i];
}
System.out.println(ans);
}
}
static int toNum(char c){
int n=0;
switch(c){
case 'I': n=1;
          break;
case 'V': n=5;
          break;
case 'X': n=10;
          break;
case 'L': n=50;
          break;
case 'C': n=100;
          break;
case 'D': n=500;
          break;
case 'M': n=1000;
          break;
}
return n;
}
}

Measured memory_bytes: 15036
#include <iostream>
using namespace std;
int main()
{
string S;
long long int K,one=-1,i;
cin >> S;
cin >> K;
for(i=0;i<=S.length();i++)
{
  if(S[i]!='1')
  {
    break;
  }
  one=i;
}

if(one==-1)
{
  cout<<S[0];
}else if(one>=K-1){cout << 1;}else{cout << S[one+1];}
  return 0;
}

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

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z <<" " << x << " " << y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, count = 0;
  cin >> A >> B;
  
  for (int i = A; i <= B; i++){
    if ((i - i / 10000 - (i / 1000 + i / 10000 * 10) * 10) % 100 == 0) count++;
  }
  
  cout << count << endl;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s;
  cin >> s;
  rep(i,s.size()-8){
    cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	char s[16];
	int i;
	scanf("%s",s);
	for(i=0;i<=3;i++) printf("%c",s[i]);
	printf(" ");
	for(i=4;i<=11;i++) printf("%c",s[i]);
	printf("\n");
	return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vi b(n);
  int ans = 0;
  rep(i,1,n) cin>>b[i];
  for(int i = 1; i<=n; i++) {
    if(i == n) {
      ans += b[n-1];
    }
    else if(i == 1) {
      ans += b[1];
    }
    else ans += min(b[i], b[i-1]);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	LL a,b,c;
	cin>>a>>b>>c;
	LL ans=(LL)1e18;
	ans=min(ans,a*b*(c&1));
	ans=min(ans,a*(b&1)*c);
	ans=min(ans,(a&1)*b*c);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10**9+7
sum_x = 0
sum_y = 0
for i in range(n):
    sum_x += i*x[i]-(n-i-1)*x[i]
for i in range(m):
    sum_y += i*y[i]-(m-i-1)*y[i]
print(sum_x*sum_y%mod)

Measured memory_bytes: 24328
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i < X + K; ++i) {
        cout << i << (i != X + K - 1 ? ' ' : '\n');
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i,n) for (ll i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

int main()
{
	int n, r;
	cin >> n >> r;
	int ans;
	if (n >= 10)
	{
		ans = r;
	}
	else
	{
		ans = r + (100 * (10 - n));
	}

	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

void core() {
	long N;
	scanf("%ld", &N);
	int a = 100000;
	for (int i = ceil(sqrt(N)); i > 0; i--) {
		if (N % i == 0) {
			int l = floor(log10(N / i));
			if (a > l) {
				a = l;
			}
		}
	}
	printf("%d\n", a + 1);
}

int main() {
	core();
	return 0;
}


Measured memory_bytes: 128
package main

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

type pair struct {
	l, r int
}

const max = 100000

func main() {
	defer wr.Flush()

	q := getInt()
	ps := make([]pair, q)
	for i := range ps {
		ps[i].l = getInt() - 1
		ps[i].r = getInt()
	}

	primes := furui(max)
	like2017s := make([]int, max+1)
	for i, p := range primes {
		if p == 0 {
			continue
		}

		if f := (i + 1) / 2; primes[f] == 1 {
			like2017s[i] = 1
		}
	}

	s := make([]int, max+1)
	for i := 1; i <= max; i++ {
		s[i] = s[i-1] + like2017s[i]
	}

	for _, p := range ps {
		res := s[p.r] - s[p.l]
		fmt.Fprintln(wr, res)
	}
}

func furui(n int) []int {
	ns := make([]int, n+1)
	for i := range ns {
		ns[i] = 1
	}
	ns[0], ns[1] = 0, 0

	for i := 2; i*i <= n; i++ {
		if ns[i] == 1 {
			for j := i * 2; j <= n; j += i {
				ns[j] = 0
			}
		}
	}
	return ns
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

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


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int h,w,n;
int a[111111];
int res[111][111];

void proc(int& i,int& j){
  if(i%2==0){
    if(j==w-1)i++;
    else j++;
  }else{
    if(j==0)i++;
    else j--;
  }
}

int main(){
	cin.sync_with_stdio(false);
  cin>>h>>w>>n;
  rep(i,n)cin>>a[i];
  int ii=0,jj=0;
  rep(q,n){
    while(a[q]>0){
      res[ii][jj]=q+1;
      proc(ii,jj);
      a[q]--;
    }
  }
  rep(i,h)rep(j,w){
    printf("%d%c", res[i][j],j==w-1?'\n':' ');
  }
	return 0;
}


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


int main(){
    #define int long long
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n ,m; cin>>n>>m;
	
    if( n == 0 ){
    	cout << "0" << endl;
        return 0;
    }
    vector<vector<int > > dp(n,vector<int > (m));
    vector<string> grid( n );
    for(int i=0;i<n;i++)
        cin >> grid[i];
    for(int i=0;i<n;i++){
        if( grid[i][0] == '#' )
            break;
        dp[i][0] = 1;
    } 
    for(int i=0;i<m;i++){
        if( grid[0][i] == '#' )
            break;
        dp[0][i] = 1;    
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if( grid[i][j] != '#' )
                dp[i][j] = ( dp[i-1][j] + dp[i][j-1] )%1000000007;
        }
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
	
}

Measured memory_bytes: 9216
import java.util.*;
class Main{
    public static void main (String [] args){
	Scanner sc = new Scanner (System.in);
	int count = sc.nextInt();
	while (count > 0) {
	    Square square = new Square();
	    for(int i = 0; i < count - 1; i++){
		square.setSquare(sc.nextInt(),sc.nextInt());
	    }
	    System.out.println(square.width() + " " + square.height());
	    count = sc.nextInt();	
	} 
    }
}

class Square{
    int[][] square;
    int squareNumber;
    public static final int left = 0;
    public static final int down = 1;
    public static final int right = 2;
    public static final int up = 3;
    
    Square(){
        square = new int[400][400];
	for(int i = 0;i<square.length;i++){
	    for(int j = 0 ; j < square[i].length ; j ++){
		square[i][j] = -1;	 
	    }
	} 
	square[square.length/2][square[0].length/2] = 0; 
	squareNumber = 1;
    }
    void setSquare(int number, int direction){
	for(int i = 0; i < square.length ;i++){
	    for(int j = 0 ; j <square[i].length ; j++ ){
		if(square[i][j] == number){
		    switch (direction) {
		    case left:
			square[i-1][j] = squareNumber;
			break;
		    case down:
			square[i][j-1] = squareNumber;
			break;
		    case right:
			square[i+1][j] = squareNumber;
			break;
		    case up:
			square[i][j+1] = squareNumber;
			break;		    
		    }
		    squareNumber++;
		    return;
		}
	    }
	}
    }

int heightMin(){
for(int j = 0 ; j < square[0].length; j++) {
	for(int i = 0 ; i < square[0].length ; i++) {
		if(square[i][j] >= 0) {
			return j;
		}
	}
}
return 0;
}
int heightMax(){
for(int j = square[0].length-1 ; j >= 0 ; j--) {
	for(int i = square.length-1 ; i >= 0 ; i--) {
		if(square[i][j] >= 0){
			return j;
		}
	}
}
return 0;
}
    int height(){
	return heightMax() - heightMin() +1;
    }

    int widthMin(){
    	for(int i = 0; i < square.length ; i++){
    		for(int j = 0 ; j < square[i].length ; j++){
    			if(square[i][j] >= 0){
    				return i;
    			}
    		}
    	}
    	return 0;
    }

    int widthMax(){
    for(int i = square.length-1; i >=0 ; i--){
    		for(int j = square[i].length-1 ; j >= 0 ; j--){
    			if(square[i][j] >= 0){
    				return i;
    			}
    		}
    	}
    	return 0;	
    }
    int width(){
	return widthMax() - widthMin() + 1;
    }
}

Measured memory_bytes: 60724
#include<stdio.h>

int main(void){
	int w, h, x, y, r;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if ((r <= x && x<= w - r) && (r <= y && y<= h - r))
		printf("Yes\n");
	else
		printf("No\n");


	return 0;
}


Measured memory_bytes: 2120
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

const ll INF = (1e+12) + 1;

int main() {
	ll n, a, m_ma = INF, sum = 0, count = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a < 0) count++;
		m_ma = min(m_ma, abs(a));
		sum += abs(a);
	}
	if (count % 2) sum -= 2 * abs(m_ma);
	cout << sum << endl;
	return 0;
}

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

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector< int > P(N);
    std::vector< int > C(N);
    for(int i=0; i<N; i++){
        std::cin >> P[i];
        P[i]--;
    }
    for(int i=0; i<N; i++){
        std::cin >> C[i];
    }
    
    long long max = -1e18;
    
    for(int i=0; i<N; i++){
        int cnt = 1;
        int index = P[i];
        long long score = C[i];
        long long max_score = C[i];
        while(i != index && cnt < K){
            score += C[index];
            if(max_score < score){
                max_score = score;
            }
            index = P[index];
            cnt++;
        }
        if(i == index){
            if(score > 0){
                int loop_N = K / cnt - (K % cnt == 0) - 1;
                if(loop_N > 0){
                    score = score * loop_N;
                    cnt = cnt * loop_N;
                    if(max_score < score){
                        max_score = score;
                    }
                }
                while(cnt < K){
                    score += C[index];
                    if(max_score < score){
                        max_score = score;
                    }
                    index = P[index];
                    cnt++;
                }
            }
        }
        
        if(max < max_score){
            max = max_score;
        }
    }
    
    
    std::cout << max << std::endl;
    
    
    return 0;
    
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int kazu = 1;
  int ans = 0;
  while(kazu < b){
    kazu += a;
    kazu --;
    ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll A,B,C;cin>>A>>B>>C;
    cout<<max(0LL,C-(A-B))<<endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
	int a,s,d,i,f=0;
	scanf("%d %d %d",&a,&s,&d);
	for(i=a;i<=s;i++){
		if(d%i==0)
			f++;
	}
	printf("%d\n",f);
}

Measured memory_bytes: 2748
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long a,b,t=1000000001,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		ans+=a;
		if(a>b)
		t=min(t,b);
	}
	if(t==1000000001)
		printf("0");
	else printf("%lld",ans-t);
}

Measured memory_bytes: 128
import numpy as np
h,w,k = map(int,input().split())
c = []
for _ in range(h):
  row = [1 if a=='#' else 0 for a in input()]
  c.append(row)
c = np.array(c).reshape(h,w)
ans = 0
for bith in range(1<<h+w):
  d = np.copy(c)
  for i in range(h+w):
    if (bith>>i)&1:
      if i<h:
        d[i]=0
      else:
        d[:,i-h]=0
  if np.sum(d)==k:
    ans += 1
print(ans)

Measured memory_bytes: 27152
n = int(input())
cnt = 0

def rec(pref):
	global cnt
	if pref <= n:
		s = str(pref)
		if '3' in s and '5' in s and '7' in s:
			#print(pref)
			cnt += 1
		for d in {3, 5, 7}:
			rec(pref * 10 + d)


rec(0)
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll x, y, z;
	cin >> x >> y >> z;
	if( y >= z ){
		cout << "delicious" << endl;
	} else if( z - y <= x ){
		cout << "safe" << endl;
	} else {
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
S = defaultdict(int)
for i in range(N):
    s = input()
    S[s] += 1

print('AC', 'x', S["AC"])
print('WA', 'x', S["WA"])
print('TLE', 'x', S["TLE"])
print('RE', 'x', S["RE"])

Measured memory_bytes: 9488
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Array as A

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  xs <- map (read . pure) <$> getLine :: IO [Int]
  print . length . filter (p xs) . sequence . replicate 3 $ [0..9]

p :: [Int] -> [Int] -> Bool
p = \xs -> maybe False (const True) . p' xs
  where
    p' :: [Int] -> [Int] -> Maybe ()
    p' _ [] = Just ()
    p' [] _ = Nothing
    p' xs (i : is) = f i xs >>= flip p' is

f :: Int -> [Int] -> Maybe [Int]
f i xs = case dropWhile (/= i) xs of _ : xs' -> Just xs'; _ -> Nothing

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 2940
import heapq

X, Y, Z, K = map(int, input().split())
A = [-int(i) for i in input().split()]
B = [-int(i) for i in input().split()]
C = [-int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

queue = [(A[0]+B[0]+C[0], 0, 0, 0)]
flg = {}
for i in range(K):
    cake, a, b, c = heapq.heappop(queue)
    print(-cake)
    for j in range(3):
        aa = a + [1, 0, 0][j]
        bb = b + [0, 1, 0][j]
        cc = c + [0, 0, 1][j]
        if aa < X and bb < Y and cc < Z:
            if flg.get((aa, bb, cc)) is None:
                flg[aa, bb, cc] = 1
                heapq.heappush(queue, (A[aa]+B[bb]+C[cc], aa, bb, cc))


Measured memory_bytes: 4908
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

int main(){
    ll n; cin >> n;
    priority_queue<ll,v<>,greater<>> q;
    rep(i,n){
      ll t; cin >> t;
      q.push(t);  
    }
    ll c = 0;

    while(q.size()>1){
        ll i = q.top();q.pop();
        ll j = q.top();q.pop();
        if(i*2>=j) c++;
        else c=0;
        q.push(i+j);
    }
    cout << c+1 << endl;

}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

ll rez, n, x;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    FOR (i, 0, n, 1)
        cin >> x,
        rez += (x - 1);
    cout << rez << "\n";
}

Measured memory_bytes: 256
def main():
    N = int(input())
    lst = [input().split()for i in range(N)]
    Y = 0

    for i in range(0, N):
        if str(lst[i][1]) == "JPY":
            Y += float(lst[i][0])
        else:
            Y += float(lst[i][0])*380000.0
    print(Y)


if __name__ == "__main__":
    main()

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  map<string, int> m;
  rep(i, n) {
    cin >> s[i];
    if (m.count(s[i]) != 0) {
      m[s[i]]++;
    } else {
      m.insert(make_pair(s[i], 1));
    }
  }

  int mx = 0;

  for (auto it = m.begin(); it != m.end(); ++it) {
    mx = max(it->second, mx);
  }

  for (auto it = m.begin(); it != m.end(); ++it) {
    if (it->second == mx) {
      cout << it->first << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 26752
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a[110];

    int res = 0;

    bool u[110] = {false};

    int pro = 0;

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];

        if (a[i] >= 3200)
            pro++;
        else
        {
            if (!u[a[i] / 400])
            {
                u[a[i] / 400] = true;
                res++;
            }
        }
    }

    int resMax = res + pro;

    if (pro)
    {
        if (res == 0)
            res++;
    }

    cout << res << " " << resMax << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int res = 0;
    for(int i=1;i<=n;i++){
        int c = 0;
        for(int j=1;j<=n;j++){
            if(i%j == 0)c++;
        }
        if(c == 8 && i % 2 == 1)res++;
    }
    cout << res;
    return 0;
}

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

int main() {
  long long q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  long long ml500 = min(q * 2, h);
  long long l1 = min(ml500 * 2, s);
  long long l2 = min(l1 * 2, d);
  cout << (n / 2 * l2) + (n % 2 * l1) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
txy = [(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(N)]


for i in range(N):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    if N == 1:
        root = txy[1][1] + txy[1][2]
        time = txy[1][0]
        if time < root:
            print("No")
        else:
            if (time - root) % 2 == 0:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")


Measured memory_bytes: 18092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1<<13;


const ll inf=1e18;
const int maxm=1e3+7;
ll cost[maxm],k[maxm];
ll dp[maxm][maxn];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int j=0;j<=n;j++)for(int i=0;i<maxn;i++) dp[j][i]=inf;
	for(int i=1;i<=m;i++)
	{
		ll a,b;scanf("%lld%lld",&a,&b);
		int t=0;
		for(int j=1;j<=b;j++)
		{
			int x;scanf("%d",&x);
			t|=(1<<(x-1));
		}
		cost[i]=a;
		k[i]=t;
	}
	dp[0][0]=0;
	for(int j=1;j<=m;j++)
	{
		for(int i=0;i<(1<<n);i++) dp[j][i]=dp[j-1][i];
		for(int i=0;i<(1<<n);i++)dp[j][i|k[j]]=min(dp[j][i|k[j]],dp[j-1][i]+cost[j]);
	}
	if(dp[m][(1<<n)-1]!=inf)
	cout<<dp[m][(1<<n)-1]<<endl;
	else puts("-1");
 } 

Measured memory_bytes: 63488