akhauriyash/Code-Regression huggingface dataset:
program main
  implicit none
  integer i,D,j,last(26),day, score(26)
  integer,allocatable :: c(:),s(:,:)
  read(*, *)D
  allocate(c(26))
  allocate(s(D,26))
  read(*, *) (c(i), i = 1,26)
  do i = 1,D
    read(*, *) (s(i,j), j = 1,26)
  end do
  last = 0
  do i = 1,D-3
    last = last + 1
    score = 0
    do j = 1,26
      score(j) = s(i,j) - 0.9*s(i+1,j) - 0.6*s(i+2,j) - 0.3*s(i+3,j) + last(j)*c(j)
    end do
    day = 1
    do j = 1,26
      if (score(j) > score(day)) then
        day = j
      end if
    end do
    write(*, *) day
    last(day) = 0
  end do
  do i = D-2,D
    last = last + 1
    score = 0
    do j = 1,26
      score(j) = s(i,j) + last(j)*c(j)
    end do
    day = 1
    do j = 1,26
      if (score(j) > score(day)) then
        day = j
      end if
    end do
    write(*, *) day
    last(day) = 0
  end do
end program main

Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a,b,c;

  a = N / 100;
  b = (N - a * 100) / 10;
  c = (N - a * 100 - b * 10);

  if(a == 7 || b == 7 || c == 7){
  cout << "Yes" << endl;    
  }else{
    cout << "No" << endl;
  } 
  
}

Measured memory_bytes: 3620
a = int(input())
b = int(input())
c = int(input())
d = int(input())

res = 0

for i in range(a+1):
    for x in range(b+1):
        for y in range(c+1):
            total = 500*i + 100*x + 50*y
            if total == d:
                res+= 1

print (res)

Measured memory_bytes: 3060
from operator import itemgetter

n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    x, y, z = info[i]
    info[i].append(-x-y-z)
    info[i].append(-x-y+z)
    info[i].append(-x+y-z)
    info[i].append(-x+y+z)
    info[i].append(+x-y+z)
    info[i].append(+x+y-z)
    info[i].append(+x-y-z)
    info[i].append(+x+y+z)

ans = 0
for i in range(8):
    info = sorted(info, key=itemgetter(i + 3), reverse=True)
    x, y, z = 0, 0, 0
    for j in range(m):
        x += info[j][0]
        y += info[j][1]
        z += info[j][2]
    res = abs(x) + abs(y) + abs(z)
    ans = max(res, ans)
print(ans)


Measured memory_bytes: 40304
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,M=LI()
LE = 1 << N
DP = [10**15]*(LE)
DP[0] = 0

for _ in range(M):
    a,b=LI()
    key = 0
    for i in LI():
        key |= 1<<(i-1)
    for j in range(LE):
        DP[j | key] = min(DP[j | key], DP[j] + a)

res = DP[(1 << N) - 1]
print(res if res != 10**15 else -1)


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll NMAX = 1e2;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, NMAX + 1) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod_pow(ll base, ll index, ll mod) {
    if(index == 0) return 1LL;
    ll res = mod_pow((base * base) % mod, index / 2, mod);
    if(index & 1) (res *= base) %= mod;
    return res;
}

ll N, A, B;

int main() {
    cin >> N >> A >> B;
    if(A >= B) {
        if(A == B)
            cout << 1 << "\n";
        else
            cout << 0 << "\n";
        return 0;
    }
    ll M, m;
    m = A * (N - 1) + B;
    M = B * (N - 1) + A;
    if(N >= 3) {
        cout << M - m + 1 << "\n";
    } else {
        if(N == 2) {
            cout << 1 << "\n";
        } else {
            cout << 0 << "\n";
        }
    }
}


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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> p(n);
    for(int i = 0; i < n; i++){
        std::cin >> p[i];
    }

    int increase = -1;
    int minValID;
    for(int i = 0; i < n - 1; i++){
        if(p[i] > p[i + 1] && increase == -1){
            increase = i;
            minValID = i;
        }
        if(increase != -1){
            if(p[minValID] > p[i]){
                minValID = i;
            }
        }
    }
    // 操作必要なし
    if(increase == -1){
        std::cout << "YES" << std::endl;
        return 0;
    }
    if(p[minValID] > p[n - 1]) minValID = n - 1; // 最後

    std::swap(p[increase], p[minValID]);

    // check
    for(int i = 0; i < n - 1; i++){
        if(p[i] > p[i + 1]){
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    std::cout << "YES" << std::endl;

    return 0;
}


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

int main()
{
  int64_t N, ans = 0;
  cin >> N;
  vector<int64_t> A(N);
  vector<bool> valid(1000100, 1);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for (int i = 1; i < N; i++)
  {
    if (A.at(i - 1) == A.at(i))
      valid.at(A.at(i)) = false;
  }
  if (A.at(0) == 1 && !valid.at(1))
  {
    cout << 0 << endl;
    return 0;
  }
  if (A.at(0) == 1 && valid.at(1))
  {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++)
  {
    if (valid.at(A.at(i)))
    {
      ans++;
    }
    for (int64_t j = A.at(i); j <= 1000000; j += A.at(i))
    {
      valid.at(j) = false;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    char *S = new char[N];
    char *T = new char[N];
    cin >> S >> T;
    for(int i=0;i<N;i++){
        cout << S[i] << T[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
A = 3.times.map{gets.split.map(&:to_i)}
N = gets.to_i
B = N.times.map{gets.split.map(&:to_i)}.flatten
check = Array.new(3){Array.new(3, false)}
B.each do |b|
  3.times do |i|
    3.times do |j|
      if b == A[i][j]
        check[i][j] = true
      end
    end
  end
end

ok = false
3.times do |i|
  if check[i][0] && check[i][1] && check[i][2]
    ok = true
  end
  if check[0][i] && check[1][i] && check[2][i]
    ok = true
  end
end

if check[0][0] && check[1][1] && check[2][2]
  ok = true
end

if check[0][2] && check[1][1] && check[2][0]
  ok = true
end

if ok
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun bsCondOpCl(A: LongArray, L: Int, R: Int, C: Int, K: Int): Int {
    val N = A.size
    fun isCondition(A: LongArray, m: Int): Boolean {
        var cnt = 1
        var i = 0
        var sum = 0
        var nt = A[0] + K
        while (i < N) {
            if (sum >= C || A[i] > nt) {
                cnt++
                sum = 0
                nt = A[i] + K
            }

            if (cnt > m) return false

            if (sum < C && A[i] <= nt) {
                sum++
                i++
            }
        }
        return true
    }
    var l = L; var r = R
    while (l+1 < r) {
        val m = (l + r) / 2
        if (isCondition(A, m)) {
            r = m
        } else {
            l = m
        }
    }
    return r
}


fun solve() {
    val (N, C, K) = rd.readIntArray()
    val T = rd.readListLongCol(N).sorted()

    val ans = bsCondOpCl(T.toLongArray(), 0, N, C, K)
    println(ans)
}


//val rd = debug.Reader("agc", "011", "a", "sample-2")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 60148
n = int(input())

al = list(map(int,input().split()))

even = 0
odd = 0

for a in al:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

if even == 0 or odd == 0:
    print("YES")
elif (odd%2) == 0:
    print("YES")
else:
    print("NO")



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

main()
{
    // int n,m;
    // cin>>n>>m;

    double a,b,h,m; cin>>a>>b>>h>>m;
    double pi=acos(-1);
    double ang=2*pi*(h/12+m/720-m/60);
    cout << fixed << setprecision(10);
    // cout<<cos(ang)<<endl;
    cout << sqrt(a*a+b*b-2*a*b*cos(ang)) << "\n";
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < N; i++){
        int start = a.at(i);
        int count = 1;
        int j = i + 1;
        while(true){
            if (j != N && a.at(j) == start){
                count++;
                j++;
            }
            else{
                if (start > count) ans += count;
                else ans += count - start;
                i += count - 1;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
ll a,b,c,k;
bool can = false;
void solve(ll x,ll y,ll z,ll i){
  if(k==i){
    if(y>x&&z>y){
      can = true;
    }
    return;
  }
  i++;
  solve(x*2,y,z,i);
  solve(x,y*2,z,i);
  solve(x,y,z*2,i);
}
signed main(){
  init_io();
  cin >> a >> b >> c >> k;
  solve(a,b,c,0);
  if(can) cout <<"Yes\n";
  else cout <<"No\n";
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int n,m;
	string s1,s2,s3;
	cin>>s1>>s2>>n>>m>>s3;
	if(s1==s3)
	{
		cout<<n-1<<" "<<m<<endl;
	}
	else
	{
		cout<<n<<" "<<m-1<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 256
package main

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

func main() {
	defer stdout.Flush()
	N := readInt()
	if N < 1000 {
		println("ABC")
	} else {
		println("ABD")
	}
}

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

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

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

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

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

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

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

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

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


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

int GetDelta(int a) {
  int delta = 0;
  while(a % 10 != 0) {
    a += 1;
    delta += 1;
  }
  return delta;
}

int main() {
  vector<int> v(5, 0);
  int sum = 0;
  int sumDelta = 0;
  int maxDelta = -1;
  for(int i = 0; i < 5; ++i) {
    cin >> v[i];
    sum += v[i];
    sumDelta += GetDelta(v[i]);
    maxDelta = max(maxDelta, GetDelta(v[i]));
  }
  cout << (sum + sumDelta - maxDelta) << endl;
  return 0;
}

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

int main(){
    const int room = 10;
    const int floor = 3;
    const int building = 4;
    array<array<array<int, room>, floor>, building> n_person = {0};

    int n;
    cin >> n;

    for (int i=0; i!=n; ++i){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        n_person[b-1][f-1][r-1] += v;
    }

    int b = 0;
    for (auto bs: n_person){
        b += 1;
        for (auto fs: bs){
            for (auto r: fs){
                cout << ' ' << r;
            }
            cout << endl;
        }
        if (b!=building){
            cout << "####################" << endl;
        }
    }

    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector <int> a(N);
    int amax=0;
    int amax2=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        if(amax<=a[i]){
            amax2=amax;
            amax=a[i];
        }
        else if(amax2<=a[i]){
            amax2=a[i];
        }
    }
    for(int i=0;i<N;i++){
        if(a[i]==amax){
            cout<<amax2<<endl;
        }
        else{
            cout<<amax<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    X.sort()
    idx = bisect_left(X, 0)
    #print("idx={}".format(idx))
    ans = 10**10
    if idx == N:
        print(-X[-K])
        return
    elif 0 == X[idx]:
        for i in range(idx + 1):
            num = idx - i + 1
            if num > K: continue
            elif num == K: ans = min(ans, -X[i])
            elif 0 <= idx + (K - num) and idx + (K - num) < N:
                ans = min(ans, -2 * X[i] + X[idx + (K - num)])
        for i in range(idx + 1, N):
            num = i - idx + 1
            if num > K: continue
            elif num == K: ans = min(ans, X[i])
            elif 0 <= idx - (K - num) and idx - (K - num) < N:
                ans = min(ans, 2 * X[i] - X[idx - (K - num)])
    else:
        for i in range(idx):
            num = idx - i
            if num > K: continue
            elif num == K: ans = min(ans, -X[i])
            elif 0 <= idx + (K - num) - 1 and idx + (K - num) - 1 < N:
                ans = min(ans, -2 * X[i] + X[idx + (K - num) - 1])
            #print("i={}, num={}, cand={}, ans={}".format(i, idx - (K - num) - 1, -2 * X[i] + X[idx + (K - num) - 1], ans))
        for i in range(idx, N):
            num = i - idx + 1
            if num > K: continue
            elif num == K: ans = min(ans, X[i])
            elif 0 <= idx - (K - num) and idx - (K - num) < N:
                ans = min(ans, 2 * X[i] - X[idx - (K - num)])
            #print("i={}, ans={}".format(i, ans))
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 62576
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <math.h>

using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;


#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define tasu(x, y) (x+y)%MOD
#define kake(x, y) x*y%MOD

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	return ((m / gcd(m, n)) * n);
}


int main(){
	int n;
	cin >> n;
	long count = 0;
	for (int i = 0; i < n; ++i){
		long long a;
		cin >> a;
		while(a%2==0){
			a/=2;
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var set = new HashSet<int>();
        for(var i = 0; i < num; i++)
        {
            var fig = ToInt32(ReadLine());
            if (set.Contains(fig)) set.Remove(fig);
            else set.Add(fig);
        }
        WriteLine(set.Count);
    }
}

Measured memory_bytes: 19424
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, l;
    cin >> n >> l;
    
    int tot = 0;
    forn(i, 0, n) {
        tot += l+i;
    }
    int mn = 1e9, ans;
    forn(i, 0, n) {
        int aux = 0;
        forn(j, 0, n) {
            if (j == i) continue;
            aux += l+j;
        }
        int d = abs(tot-aux);
        if (d < mn) {
            mn = d;
            ans = aux;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <complex>
#include <queue>
#include <cstdio>

using namespace std;

const double EPS = 1e-9;
const double INF = 1e12;
typedef complex<double> P;

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

bool ssIntersect(const P& ap, const P& aq, const P& bp, const P& bq){
	return cross(aq-ap, bp-ap)*cross(aq-ap, bq-ap) < 0 &&
    	   cross(bq-bp, ap-bp)*cross(bq-bp, aq-bp) < 0;
}

double solve(const vector<P>& pa, const vector<P>& pb){
	int n = pb.size();
	vector<int> visit(n, 0);
	vector<double> dist(n, INF); dist[0] = 0;
	typedef pair<double, int> Node;
	priority_queue< Node, vector<Node>, greater<Node> > qu; qu.push(make_pair(0, 0));
	while(!qu.empty()){
		Node nd = qu.top(); qu.pop();
		int pos = nd.second;
		double cost = nd.first;
		if(visit[pos]) continue;
		visit[pos] = 1;
		for(int i=0;i<n;i++){
			if(visit[i]) continue;
			if(ssIntersect(pb[pos], pb[i], pa[0], pa[1])) continue;
			double ncost = cost + abs(pb[pos]-pb[i]);
			if(ncost < dist[i]){
				dist[i] = ncost;
				qu.push(make_pair(ncost, i));
			}
		}
	}
	return dist[1] + abs(pa[0]-pa[1]);
}

int main(){
	int NA, NB;
	while(cin >> NA >> NB){
		vector<P> pA(NA), pB(NB);
		for(int i=0;i<NA;i++) cin >> pA[i].real() >> pA[i].imag();
		for(int i=0;i<NB;i++) cin >> pB[i].real() >> pB[i].imag();
		double res = min(solve(pA, pB), solve(pB, pA));
		if(res > 1e10) cout << -1 << endl;
		else printf("%.10lf\n", res);
	}
}

Measured memory_bytes: 1404
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int result = 0;
            for (int i = 1; i <= N; ++i)
            {
                result += i;
            }
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ll N, Q;
    cin >> N >> Q;
    VLL a(N);
    rep(i,N){
        cin >> a[i];
    }
    rep(i,Q){
        ll x; cin >> x;
        ll sum=0;
        ll res=0;
        ll right=0;
        for(int left=0; left<N; left++){
            while(right<N && sum+a[right]<=x){
                sum+=a[right];
                right++;
            }
            res+=(right-left);
            if(right==left) right++;
            else sum-=a[left];
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define itn int

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

    int a, b;
    cin >> a >> b;
    if (a <= 5) {
        cout << 0;
    } else if (a <= 12) {
        cout << b / 2;
    } else {
        cout << b;
    }
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())
a_deg = h * 30 + m * 0.5
b_deg = m * 6
deg = abs(a_deg - b_deg) if abs(a_deg - b_deg) <= 180 else 360 - abs(a_deg - b_deg)
# print(f'{deg=}')
dis_sqrt = a**2 + b**2 - 2 * a * b * math.cos(math.radians(deg))
ans = math.sqrt(dis_sqrt)
# print(ans)

# 極座標を計算して２点のeuclid距離を求める
a_th = math.radians(a_deg)
b_th = math.radians(b_deg)
a_x, a_y = a * math.cos(a_th), a * math.sin(a_th)
b_x, b_y = b * math.cos(b_th), b * math.sin(b_th)
dis = math.sqrt((b_x - a_x) ** 2 + (b_y - a_y) ** 2)
print(dis)

Measured memory_bytes: 9564
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ct=sum(b)
for i in range(n-1):
  if a[i]+1==a[i+1]:
    ct+=c[a[i]-1]
print(ct)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
  int d;
  scanf("%d",&d);

  if(22>d && d>25){
    return 1;
  }

  if(d==25){
    printf("Christmas\n");
  }else if(d==24){
    printf("Christmas Eve\n");
  }else if(d==23){
    printf("Christmas Eve Eve\n");
  }else if(d==22){
    printf("Christmas Eve Eve Eve\n");
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(Math.abs(x - a) < Math.abs(x - b)) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}
}


Measured memory_bytes: 20948
H,W=map(int,input().split())
a=[]
for i in range(H):
    ai=input()
    if ai=="."*W:
        continue
    a.append(ai)
h=len(a)
def tenti(a):
    b=[]
    h=len(a)
    w=len(a[0])
    for i in range(w):
        bi=[]
        for j in range(h):
            bi.append(a[j][i])
        b.append(bi)
    return b
b=tenti(a)
h=len(b)
w=len(b[0])
c=[]
for i in range(h):
    if b[i]==["."]*w:
        continue
    c.append(b[i])
d=tenti(c)
for i in range(len(d)):
    for j in range(len(d[0])):
        if j==len(d[0])-1:
            print(d[i][j])
            break
        print(d[i][j],end="")


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

struct P{
  double x, y;
};

void kohho(struct P, struct P, int);

int main(){
  
  struct P p1, p2;
  int n;

  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x, p1.y);
  kohho(p1,p2,n);
  printf("%.8f %.8f\n",p2.x, p2.y);

  return 0;
}

void kohho(struct P p1, struct P p2, int n){
  
  if(n==0) return;

  struct P a, b, c;
  double rad=M_PI/3;

  a.x=(2*p1.x+p2.x)/3;
  a.y=(2*p1.y+p2.y)/3;
  b.x=(p1.x+2*p2.x)/3;
  b.y=(p1.y+2*p2.y)/3;
  c.x=(b.x-a.x)*cos(rad)-(b.y-a.y)*sin(rad)+a.x;
  c.y=(b.x-a.x)*sin(rad)+(b.y-a.y)*cos(rad)+a.y;

  kohho(p1,a,n-1);
  printf("%.8f %.8f\n", a.x, a.y);
  kohho(a,c,n-1);
  printf("%.8f %.8f\n", c.x, c.y);
  kohho(c,b,n-1);
  printf("%.8f %.8f\n", b.x, b.y);
  kohho(b,p2,n-1);  
}



Measured memory_bytes: 2064
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c;
    cin >> a >> b >> c;
    int count = 0;
     for (int i = a; i <= b; i ++)
            {
                if (c%i == 0 ) {
                count++;
                }
            }
            cout << count <<endl;

}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int k;
	vector<int> a;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> k;
		a.push_back(k);
	}
	sort(a.begin(),a.end());
	k = a[0];
	int num = 0;
	int sum = 0;
	for(int i=0;i<n;i++){
		if(k == a[i]){
			num++;
		}else{
			if(k > num){
				sum += num;
			}else{
				sum += (num-k);
			}
			num = 1;
			k = a[i];
		}
	}
	if(k > num){
		sum += num;
	}else{
		sum += (num-k);
	}
	cout << sum << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  char s[25];
  for (int i = 0;i<19;i++){
    cin >> s[i];
  }
  s[5] = ' ';
  s[13]= ' ';
  for (int i = 0;i<19;i++){
    cout << s[i];
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n,a,b;
        cin>>n>>a>>b;
        int ans=min(b,n*min(a,b));
        cout<<ans;
         
     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#include<stdio.h> 
int main()
{
	int i,k,j,m,n,b,a,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(abs(a-c)<=d)
	{
		printf("Yes");
	}
	else if(abs(a-c)>d)
	{
		if(abs(a-b)<=d)
		{
			if(abs(b-c)<=d)
			{
				printf("Yes");
			}
			else
			{
				printf("No");
			}
		}
		else
		{
			printf("No");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  st S;
  ci(S);
  bool f = 1;
  if(S.at(0) != 'A'){
    f = 0;
  }
  int c = 0, a = 0;
  repi(i, 2, sz(S) - 1){
    if(S.at(i) == 'C'){
      c++;
      a = i;
    }
  }
  if(c != 1){
    f = 0;
  }
  repi(i, 1, sz(S)){
    if(i != a){
      if('a' <= S.at(i) && S.at(i) <= 'z'){
      }
      else{
        f = 0;
      }
    }
  }
  if(f){
    co("AC");
  }
  else{
    co("WA");
  }
}

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

using namespace std;

using ull = unsigned long long;

int main() {
    long N, A[100001], B[100000];
    ull sum = 0;
    cin >> N;
    for(int i = 0; i < N + 1; ++i) {
        cin >> A[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    for(int i = 0; i < N; ++i) {
        if(A[i] < B[i]) {
            sum += A[i] + min(B[i] - A[i], A[i + 1]);
            A[i + 1] -= min(B[i] - A[i], A[i + 1]);
        } else {
            sum += B[i];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
package main

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

var mod = int64(1e9 + 7)

func main() {
	N := nextInt()
	K := nextInt()
	A := make(ints, N)
	nn := 0
	np := 0

	for i := 0; i < N; i++ {
		A[i] = nextInt64()

		if A[i] <= 0 {
			nn++
		}
		if A[i] > 0 {
			np++
		}
	}

	sort.Sort(A)

	k := 0
	ans := int64(1)

	// 答えが負になる？
	if K%2 == 1 && np == 0 {
		for i := 0; i < K; i++ {
			ans = mul(ans, A[nn-1-i])
		}
		fmt.Println(ans)
		return
	}
	// 正の数なのでできるだけ絶対値を大きくする
	p := len(A) - 1
	n := 0
	for k < K {
		// 負の数を選べる場合
		if k <= K-2 && A[n]*A[n+1] > A[p]*A[p-1] {
			ans = mul(ans, A[n])
			ans = mul(ans, A[n+1])
			k += 2
			n += 2
		} else {
			ans = mul(ans, A[p])
			p--
			k++
		}
	}

	fmt.Println(ans)
}

func mul(a, b int64) int64 {
	n := ((a % mod) * (b % mod)) % mod
	if n < 0 {
		n += mod
	}
	return n
}

func even(n int) int {
	return n - n%2
}

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

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}

type ints []int64

func (a ints) Len() int           { return len(a) }
func (a ints) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ints) Less(i, j int) bool { return a[i] < a[j] }

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
char a[5],b[5];
int main(){
 	cin>>a>>b;
  	int ans=0;
  	if(a[0]==b[0])ans++;
  	if(a[1]==b[1])ans++;
  	if(a[2]==b[2])ans++;
  	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
 
struct UnionFind{
  vector< int > data;
  UnionFind(int sz){
    data.resize(sz, -1);
  }
  int Find(int a){
    return(data[a] < 0 ? a : data[a] = Find(data[a]));
  }
  void Union(int a, int b){
    a = Find(a), b = Find(b);
    if(a == b) return;
    data[a] += data[b];
    data[b] = a;
  }
};
 
struct edge {
  int to, cost;
};
struct edge2 {
  int u, v, cost;
  bool operator<(const edge2& e) const {
    return cost < e.cost;
  }
};
typedef vector< vector< edge > > Graph;
typedef pair< int, int > Pi;
const int INF = 1 << 30;
int N, M, K, Q, F[100000];
Graph graph;
vector< edge2 > weighted;
set< int > buffer[100000];
int ret[100000];
 
void Dijkstra(Graph& g, vector< int >& min_cost){
  min_cost.assign( g.size(), INF);
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  for(int i = 0; i < K; i++){
    que.push( make_pair( 0, F[i]));
    min_cost[F[i]] = 0;
  }
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.first > min_cost[p.second]) continue;
    for(int i = 0; i < g[p.second].size(); i++){
      edge& e = g[p.second][i];
      if(p.first + e.cost >= min_cost[e.to]) continue;
      que.push( make_pair( p.first + e.cost, e.to));
      min_cost[e.to] = p.first + e.cost;
    }
  }
}
 
 
int main(){
  scanf("%d %d %d %d", &N, &M, &K, &Q);
  graph.resize(N);
  UnionFind uftree(N);
 
  for(int i = 0; i < M; i++){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --a, --b;
    graph[a].push_back((edge){b, c});
    graph[b].push_back((edge){a, c});
    weighted.push_back((edge2){a, b});
  }
 
  for(int i = 0; i < K; i++){
    scanf("%d", &F[i]);
    --F[i];
  }
  for(int i = 0; i < Q; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    buffer[a].insert(i);
    buffer[b].insert(i);
  }
 
  vector< int > min_cost;
  Dijkstra( graph, min_cost);
   
  for(int i = 0; i < M; i++){
    weighted[i].cost = min( min_cost[weighted[i].u], min_cost[weighted[i].v]);
  }
  sort( weighted.rbegin(), weighted.rend());
 
  for(int i = 0; i < M; i++){
    int u = uftree.Find(weighted[i].u), v = uftree.Find(weighted[i].v);
    if(u == v) continue;
    if(buffer[u].size() < buffer[v].size()) swap( u, v);
    uftree.Union( u, v);
    set< int > *oo = &buffer[u], *pp = &buffer[v];
    for(set< int >::iterator it = pp -> begin(); it != pp -> end(); it++){
      if(oo -> find(*it) != oo -> end()) ret[*it] = weighted[i].cost;
    }
    oo -> insert( pp -> begin(), pp -> end());
    pp -> clear();
  }
   
  for(int i = 0; i < Q; i++){
    printf("%d\n", ret[i]);
  }
}

Measured memory_bytes: 28692
input_num = gets.chomp.split.map!(&:to_i)
route = [1001 ,1001]
num = 0
(1..input_num[0]).each{ |i|
  times = [0 ,0]
  times = gets.chomp.split.map!(&:to_i)
  if times[1] <= input_num[1] then
    if times[0] < route[0] then
      route = times
      num = i
    end
  end
}
if route[1] == 1001 then
  puts "TLE"
else
  puts route[0]
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = 0;
		while(true) {
			c-=b;
			if(c<=0) {
				e = 1;
				break;
			}
			a-=d;
			if(a<=0) {
				e = 2;
				break;
			}
		}
		if(e == 1) {
			System.out.println("Yes");
		}else if(e == 2) {
			System.out.println("No");
		}
		
	}
	
}


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

using namespace std;

int main(){
    string s,t,u;
    int a,b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(u==s){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
         }

    return 0;
}


Measured memory_bytes: 256
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let a: Vec<u32> = read_vec();
    let mut sum: u32 = 0;

    for element in a
    {
        sum += element;
    }

    if sum >= 22 { println!("bust"); } else { println!("win"); }
}


Measured memory_bytes: 4352
from sys import stdin, setrecursionlimit


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    n, k = map(int, input().split())

    mins = [0]
    maxs = [n]
    tmp_min = 0
    tmp_max = n
    for i in range(1, n + 1):
        tmp_min += i
        mins.append(tmp_min)
        tmp_max += n - i
        maxs.append(tmp_max)
    ans = 0
    for i in range(k - 1, n + 1):
        ans += maxs[i] - mins[i] + 1
        ans %= mod
    print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 94864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC155A()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c)
	{
		cout << "No" << endl;
	}
	else if (a != b && b != c && c != a)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
}
int main()
{
	ABC155A();
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    S = [input().strip() for _ in range(N)]
    d = Counter(S)
    # print(d)
    for s in ["AC", "WA", "TLE", "RE"]:
        print("{} x {}".format(s, d[s]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 16612
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main()
{
	ll n,m,x;cin>>n>>m>>x;
	
	ll mini=1e17;ll a[20][20],c[20];
	
	for(ll i=0;i<n;i++)
	{
		cin>>c[i];
		for(ll j=0;j<m;j++) cin>>a[i][j];
	}
		
	for(ll i=0;i<(1<<n);i++)
	{
		ll cost=0;vector <ll> alg(m+2,0);
		for(ll j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				cost+=c[j];
				for(ll k=0;k<m;k++) alg[k]+=a[j][k];
			}
		}
		bool is=true;
		for(ll j=0;j<m;j++)
		if(alg[j]<x)is=false;
		
		if(is==true) mini=min(mini,cost);
	}
	if(mini==1e17) cout<<-1;
	else
	cout<<mini;
	
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	//cout<<"222\n";	
 	string s;
 	cin>>s;
 	s[0]='2';
 	s[1]='0';
 	s[2]='1';
 	s[3]='8';
 	cout<<s<<" \n";
}

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

using namespace std;
using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int N) : data(N, -1) {}

  int find(int k) { return data[k] < 0 ? k : data[k] = find(data[k]); }

  int unite(int x, int y) {
    if ((x = find(x)) == (y = find(y))) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int size(int k) { return -data[find(k)]; }

  int same(int x, int y) { return find(x) == find(y); }
};
using namespace std;

namespace fastio {
static constexpr int SZ = 1 << 17;
char ibuf[SZ], obuf[SZ];
int pil = 0, pir = 0, por = 0;

struct Pre {
  char num[40000];
  constexpr Pre() : num() {
    for (int i = 0; i < 10000; i++) {
      int n = i;
      for (int j = 3; j >= 0; j--) {
        num[i * 4 + j] = n % 10 + '0';
        n /= 10;
      }
    }
  }
} constexpr pre;

inline void load() {
  memcpy(ibuf, ibuf + pil, pir - pil);
  pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
  pil = 0;
}
inline void flush() {
  fwrite(obuf, 1, por, stdout);
  por = 0;
}

inline void rd(char& c) { c = ibuf[pil++]; }
template <typename T>
inline void rd(T& x) {
  if (pil + 32 > pir) load();
  char c;
  do
    c = ibuf[pil++];
  while (c < '-');
  bool minus = 0;
  if (c == '-') {
    minus = 1;
    c = ibuf[pil++];
  }
  x = 0;
  while (c >= '0') {
    x = x * 10 + (c & 15);
    c = ibuf[pil++];
  }
  if (minus) x = -x;
}
inline void rd() {}
template <typename Head, typename... Tail>
inline void rd(Head& head, Tail&... tail) {
  rd(head);
  rd(tail...);
}

inline void wt(char c) { obuf[por++] = c; }
template <typename T>
inline void wt(T x) {
  if (por > SZ - 32) flush();
  if (!x) {
    obuf[por++] = '0';
    return;
  }
  if (x < 0) {
    obuf[por++] = '-';
    x = -x;
  }
  int i = 12;
  char buf[16];
  while (x >= 10000) {
    memcpy(buf + i, pre.num + (x % 10000) * 4, 4);
    x /= 10000;
    i -= 4;
  }
  int d = x < 100 ? (x < 10 ? 1 : 2) : (x < 1000 ? 3 : 4);
  memcpy(obuf + por, pre.num + x * 4 + 4 - d, d);
  por += d;
  memcpy(obuf + por, buf + i + 4, 12 - i);
  por += 12 - i;
}

inline void wt() {}
template <typename Head, typename... Tail>
inline void wt(Head head, Tail... tail) {
  wt(head);
  wt(tail...);
}
template<typename T>
inline void wtn(T x){
  wt(x, '\n');
}

struct Dummy {
  Dummy() { atexit(flush); }
} dummy;

}  // namespace fastio
using fastio::rd;
using fastio::wt;
using fastio::wtn;

int main() {
  int N, Q;
  rd(N, Q);
  UnionFind uf(N);
  while (Q--) {
    int t, u, v;
    rd(t, u, v);
    if (t)
      wtn(uf.same(u, v));
    else
      uf.unite(u, v);
  }
}

Measured memory_bytes: 4208
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int X, N;
set<int> st;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> X >> N;
    for(int i = 0; i < N; i++){
        int p;
        cin >> p;
        st.insert(p);
    }
    int dif = 10000;
    int ans = 0;
    for(int i = -1; i <= 101; i++){
        if(st.count(i) == 0){
            int tmp = abs(X-i);
            if(tmp < dif){
                ans = i;
                dif = tmp;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
def get_h_list(S):
    H = len(S)
    n_offset_rows = 0
    while '#' not in S[n_offset_rows]:
        n_offset_rows += 1
    assert n_offset_rows < H
    h_list = list()
    for h in range(n_offset_rows, H):
        if '#' in S[h]:
            h_list.append(h)
    h_list[0] = 0
    h_list.append(H)
    return h_list


def get_w_list(S, h_from, h_to):
    W = len(S[0])
    n_offset_columns = 0
    while '#' not in [S[h][n_offset_columns] for h in range(h_from, h_to + 1)]:
        n_offset_columns += 1
    assert n_offset_columns < W
    w_list = list()
    for w in range(n_offset_columns, W):
        if '#' in [S[h][w] for h in range(h_from, h_to + 1)]:
            w_list.append(w)
    w_list[0] = 0
    w_list.append(W)
    return w_list


def main():
    H, W, K = map(int, input().split())
    ans = [[0 for _ in range(W)] for _ in range(H)]
    color = 1
    S = [input() for _ in range(H)]
    h_list = get_h_list(S)
    for i in range(len(h_list) - 1):
        h_from, h_to = h_list[i], h_list[i + 1] - 1
        w_list = get_w_list(S, h_from, h_to)
        for j in range(len(w_list) - 1):
            w_from, w_to = w_list[j], w_list[j + 1] - 1
            # 塗る
            for h in range(h_from, h_to + 1):
                for w in range(w_from, w_to + 1):
                    ans[h][w] = color
            color += 1
    for a in ans:
        print(' '.join(map(str, a)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 12844