akhauriyash/Code-Regression huggingface dataset:
in_1() = parse(Int, readline())
in_a() = [parse(Int,s) for s in split(readline())]
yesno(b) = b ? "Yes" : "No"
function main()
  A = reshape(vcat(in_a(),in_a(), in_a()), 3, 3) |> transpose
  N = in_1()
  c = fill(false, 3, 3)
  for _ in 1:N
    b = in_1()
    c[A .== b] = true
  end
  res = all(c[:,1]) || all(c[:,2]) || all(c[:,3]) ||
        all(c[1,:]) || all(c[2,:]) || all(c[3,:]) ||
        all(diag(c)) || (c[1,3] && c[2,2] && c[3,1])
  res |> yesno |> println
end

isempty(ARGS) && main()


Measured memory_bytes: 184912
def main():
    examE()

def examA():
    N = I()
    ans = 1^N
    print(ans)
    return

def examB():
    a, b, c, d = LI()
    ans = max(a*c,a*d,b*c,b*d)
    print(ans)
    return

def examC():
    N = I()
    if N==1:
        ans = 0
    else:
        ans = pow(10,N,mod) - pow(9,N,mod)*2 + pow(8,N,mod)
        ans += mod*2
        ans %= mod
    print(ans)
    return

def examD():
    class combination():
        # 素数のmod取るときのみ　速い
        def __init__(self, n, mod):
            self.n = n
            self.mod = mod
            self.fac = [1] * (n + 1)
            self.inv = [1] * (n + 1)
            for j in range(1, n + 1):
                self.fac[j] = self.fac[j - 1] * j % mod

            self.inv[n] = pow(self.fac[n], mod - 2, mod)
            for j in range(n - 1, -1, -1):
                self.inv[j] = self.inv[j + 1] * (j + 1) % mod

        def comb(self, n, r):
            if r > n or n < 0 or r < 0:
                return 0
            return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod
    S = I()
    C = combination(S,mod)
    cnt = 0
    for i in range(S//3):
        cur = S - (i+1)*3 + i
        cnt += C.comb(cur,i)
        cnt %= mod
    ans = cnt
    print(ans)
    return

def examE():
    N = I()
    CD = [[]for _ in range(2)]
    for i in range(N):
        x, y = LI()
        CD[0].append(x-y)
        CD[1].append(x+y)
    ans = max(max(CD[0]) - min(CD[0]),max(CD[1]) - min(CD[1]))
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 103252
#include <stdio.h>

int main(void) {
  int a, b;

  while(1) {
    scanf("%d %d",&a,&b);
    if(a==0 && b==0) break;
    if(a<b) {
      printf("%d %d\n",a,b);
    } else {
      printf("%d %d\n",b,a);
    }
  }
  return 0;
}


Measured memory_bytes: 1912
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;

	s[k - 1] = tolower(s[k - 1]);
	cout << s << endl;


	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int h,w;
    int i,j;
    int tmp;
    vector<string> s;
    vector<vector<int>> l,r,u,d;
    cin >> h >> w;
    s.assign(h,"");
    l.assign(h,vector<int>(w,0));
    r.assign(h,vector<int>(w,0));
    u.assign(h,vector<int>(w,0));
    d.assign(h,vector<int>(w,0));
    for(i=0;i<h;i++) cin >> s[i];
    for(i=0;i<h;i++){
        tmp = 0;
        for(j=0;j<w;j++){
            if(s[i][j]=='#') tmp = 0;
            else tmp++;
            l[i][j] = tmp;
        }
    }
    for(i=0;i<h;i++){
        tmp = 0;
        for(j=w-1;j>=0;j--){
            if(s[i][j]=='#') tmp = 0;
            else tmp++;
            r[i][j] = tmp;
        }
    }
    for(j=0;j<w;j++){
        tmp = 0;
        for(i=0;i<h;i++){
            if(s[i][j]=='#') tmp = 0;
            else tmp++;
            u[i][j] = tmp;
        }
    }
    for(j=0;j<w;j++){
        tmp = 0;
        for(i=h-1;i>=0;i--){
            if(s[i][j]=='#') tmp = 0;
            else tmp++;
            d[i][j] = tmp;
        }
    }
    tmp = 0;
    for(i=0;i<h;i++) for(j=0;j<w;j++){
        tmp = max(tmp,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
    }
    cout << tmp << endl;
}

Measured memory_bytes: 71168
#include <cstdio>

int a[120000], b[120000], c[120000];

int n;
unsigned long long ans;

void sort(int *a, int n) {
	for(int i = n - 1; i > 0; --i) {
		int k = 0, tmp = a[i];
		a[i] = a[0];
		a[0] = tmp;
		for(;;)
			if(k * 2 + 2 < i)
				if(tmp < a[k * 2 + 1])
					if(a[k * 2 + 1] > a[k * 2 + 2]) { SWAP_1: a[k] = a[k * 2 + 1]; a[k = k * 2 + 1] = tmp; }
					else { SWAP_2: a[k] = a[k * 2 + 2]; a[k = k * 2 + 2] = tmp; }
				else if(tmp < a[k * 2 + 2]) goto SWAP_2;
				else break;
			else if(k * 2 + 2 == i)
				if(tmp < a[k * 2 + 1]) goto SWAP_1;
				else break;
			else break;
	}
}

void bs(int l = 0, int r = n, int a_left = 0, int a_right = n, int c_left = 0, int c_right = n) {
	if(l < r) {
		int al = a_left, ar = a_right;
		while(al < ar)
			if(a[(al + ar - 1) / 2] < b[(l + r - 1) / 2]) al = (al + ar + 1) / 2;
			else ar = (al + ar - 1) / 2;
		int cl = c_left, cr = c_right;
		while(cl < cr)
			if(c[(cl + cr) / 2] > b[(l + r - 1) / 2]) cr = (cl + cr) / 2;
			else cl = (cl + cr + 2) / 2;
		ans += (unsigned long long)ar * (n - cr);
		bs(l, (l + r - 1) / 2, a_left, ar, c_left, cr);
		bs((l + r + 1) / 2, r, ar, a_right, cr, c_right);
	}
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		for(int j = i, ia = a[i]; ia > a[(j - 1) / 2]; a[j = (j - 1) / 2] = ia) a[j] = a[(j - 1) / 2];
	}
	for(int i = 0; i < n; ++i) {
		scanf("%d", b + i);
		for(int j = i, ib = b[i]; ib > b[(j - 1) / 2]; b[j = (j - 1) / 2] = ib) b[j] = b[(j - 1) / 2];
	}
	for(int i = 0; i < n; ++i) {
		scanf("%d", c + i);
		for(int j = i, ic = c[i]; ic > c[(j - 1) / 2]; c[j = (j - 1) / 2] = ic) c[j] = c[(j - 1) / 2];
	}
	sort(a, n);
	sort(b, n);
	sort(c, n);
	bs();
	printf("%llu\n", ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ld a, b, C;
    cin >> a >> b >> C;

    // 高さ
    ld radian = C * PI / 180.0;
    ld H = b * sin(radian);
    // 面積
    ld S = a * H / 2;
    // 周の長さ
    // ＝ａ＋ｂ＋√（ａの2乗＋ｂの2乗－2×ａ×ｂ×cosＣ）
    ld cPow2 = pow(a, 2) + pow(b, 2);
    ld c = sqrtl(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(radian));
    ld L = a + b + c;

    cout << setprecision(10) << S << endl;
    cout << setprecision(10) << L << endl;
    cout << setprecision(10) << H << endl;
}


Measured memory_bytes: 3592
#include<cctype>
#include<iostream>
#include<string>
int main(void) {
		std::string InputString;
		std::getline(std::cin , InputString);
		for (unsigned int i = 0; i < InputString.size(); ++i) {
			if (std::islower(InputString[i])) { InputString[i] = std::toupper(InputString[i]); }
			else { InputString[i] = std::tolower(InputString[i]); }
		}
		std::cout << InputString<<std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e6+5;
const int mod=1e9+7;
int n,dp[N];

inline int nxi(FILE *fd=stdin){
	int x=0;
	char c;
	while((c=fgetc(fd))>'9'||c<'0');
	while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
	return x;
}

int main(){
	n=nxi();
	const int endless=(lint)(n-1)*(n-1)%mod;
	int pre=dp[0]=1,ans=0;
	for(int i=1; i<=n; ++i){
		int cur=(pre-(i>=2?dp[i-2]:0)+mod)%mod;
		if(i<n-1){
			ans=(ans+(lint)cur*(endless+(i+1)))%mod;
		}
		if(i==n-1){
			ans=(ans+(lint)cur*(n-1))%mod;
		}
		if(i==n){
			ans=(ans+cur)%mod;
		}
		pre=(pre+(dp[i]=cur))%mod;
	}
	printf("%d\n",(ans+endless+(n>1))%mod);
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const long long mod = 1e9+7;
void addself(ll &a, ll b){
    a+=b;
    if(a>mod){
        a-=mod;
    }
}

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

    int n,m;
    cin>>n>>m;
    char arr[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }
    ll dp[n][m];
    memset(dp,0,sizeof dp);

    dp[0][0]=1;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(i==n-1 & j==m-1){
                continue;
            }
            else if(i==n-1){
                if(arr[i][j+1]=='.')addself(dp[i][j+1],dp[i][j]);

            }
            else if(j==m-1){
                if(arr[i+1][j]=='.')addself(dp[i+1][j],dp[i][j]);
            }
            else{
                if(arr[i+1][j]=='.')addself(dp[i+1][j],dp[i][j]);
                if(arr[i][j+1]=='.')addself(dp[i][j+1],dp[i][j]);
            }
        }
    }

    cout<<dp[n-1][m-1];
}


Measured memory_bytes: 9088
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>
#include<set>
 
#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000
 
typedef long long int ll;
typedef unsigned long long int ull;
 
using namespace std;
 
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; }
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N;
	cin >> N;
	vl A(N);
	rep(i, N) {
		cin >> A[i];
	}
	ll sum = 0;
	rep(i, N) {
		sum += A[i];
	}
	ll h = sum / 2;
	ll a = 0, b;

	rep(i, N) {
		a += A[i];
		if (a >= h){
			break;
		}
		b = a;
	}

	ll sum1 = sum - a;
	ll sum2 = sum - b;

	ll out = min(abs(sum1 - a), abs(sum2 - b));

	cout << out;





	return 0;

}

Measured memory_bytes: 1792
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	int a[n+1];
	int cnt=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==cnt){
			cnt++;
		}
	}
	if(cnt==1){
		cout<<-1<<endl;
		return;
	}
	cnt--;
	cout<<n-cnt<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 1024
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
using namespace std;

char al;
 
int main(){
  cin>>al;

  cout<<(char)(al+1);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define max(a,b) (a)>(b)?(a):(b)
int main(void)
{
  int a,b,c,max;
  scanf("%d%d%d",&a,&b,&c);
  max=max(a,max(b,c));
  printf("%d",max*9+a+b+c);
  return 0;
}


Measured memory_bytes: 128
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

auto solve(long N, long[] A, long[] B){
    long ans;
    foreach (i; iota(N.to!uint).retro) {
        const a = min(A[i + 1], B[i]);
        A[i + 1] -= a;
        B[i] -= a;
        ans += a;

        const b = min(A[i], B[i]);
        A[i] -= b;
        B[i] -= b;
        ans += b;
    }
    return ans;
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N+1));
    foreach (i; 0 .. cast(size_t) (N+1)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    long[] B = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        B[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A, B);
    else
        solve(N, A, B).writeln;
}


Measured memory_bytes: 12460
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Stack;
import java.util.PriorityQueue;

import static java.lang.System.out;

public class Main {
    private static final int INF = (int)1e9;

    static class Vertex {
        int v;
        Set<Integer> vs;

        public Vertex(int v) {
            this.v = v;
            this.vs = new HashSet<>();
        }
    }

    static class Pair {
        int first;
        int second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public boolean equals(Object other) {
            if (other != null && other instanceof Pair) {
                Pair p = (Pair)other;
                return p.first == first && p.second == second;
            }
            return false;
        }

        @Override
        public int hashCode() {
            int hash = 17;
            hash += hash*31 + first;
            hash += hash*31 + second;

            return hash;
        }
    }

	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            Vertex[] g = new Vertex[n];
            for (int i = 0; i < n; i++) 
                g[i] = new Vertex(i);

            int[][] ws = new int[n][n];
            for (int i = 0; i < n; i++) {
                int f = in.nextInt();
                int d = in.nextInt();

                for (int j = 0; j < d; j++) {
                    int t = in.nextInt();
                    int w = in.nextInt();

                    g[f].vs.add(t);
                    ws[f][t] = w;
                }
            }

            dijkstra(g, n, ws, 0);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}
	}

    private static void dijkstra(Vertex[] g, int n, int[][] ws, int s) {
        int[][] d = new int[n][2];
        for (int i = 0; i < n; i++) {
            d[i][0] = INF;
            d[i][1] = -1;
        }

        d[s][0] = 0;
        d[s][1] = s;
        PriorityQueue<Pair> pq = new PriorityQueue<>((x, y) -> Integer.compare(x.second, y.second));
        pq.add(new Pair(s, 0));

        while (!pq.isEmpty()) {
            Pair p = pq.poll();
            
            for (int vv : g[p.first].vs) {
                int nd = d[p.first][0] + ws[p.first][vv];
                if (nd < d[vv][0]) {
                    Pair pp = new Pair(vv, d[vv][0]);
                    d[vv][0] = nd;
                    d[vv][1] = p.first;
                    pq.remove(pp);
                    pq.add(new Pair(vv, d[vv][0]));
                }    
            }
        }

        for (int i = 0; i < n; i++)
            out.printf("%d %d\n", i, d[i][0]);
    }
}

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

typedef long long ll;

int main()
{
    ll D, T, S;
    cin >> D >> T >> S;
    if (D > S * T)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if (a>b){
        cout<<"a > b"<<endl;
    }
    else if (a<b){
        cout<<"a < b"<<endl;
    }
    else {
        cout<<"a == b"<<endl;
    }
}



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

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

    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end(), greater<int>());

    int total = 0;
    int top;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            top = d.at(i);
            total++;
        }
        if (d.at(i) < top) {
            top = d.at(i);
            total++;
        }
    }
    cout << total;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NX = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = NX[0];
            var X = NX[1];
            var mList = Enumerable.Range(0, N).Select(x => Console.ReadLine()).Select(int.Parse).ToArray();

            var mTotal = 0;
            var mMin = 100000;
            foreach (var m in mList)
            {
                mTotal += m;
                mMin = Math.Min(mMin, m);
            }

            var nokori = X - mTotal;
            var output = N + nokori / mMin;

            Console.WriteLine(output);
        }
    }
}


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

typedef long long LL;

int main(){
	LL n,m;
	cin >> n >> m;
	if(n == 1 || m == 1){
		if(max(n,m) < 2LL) cout << 1 << endl;
		else cout << max(n,m) - 2LL << endl;
	}
	else if(n == 2 || m == 2){
		cout << 0 << endl;
	}
	else{
		cout << (n - 2LL) * (m - 2LL) << endl;
	}
}

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

int main() {
    int n,sum=0;
    cin>>n;

    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }

    sort(p.begin(),p.end());

    for(int i=0;i<n-1;i++){
        sum+=p.at(i);
    }

    cout<<sum+(p.at(n-1)/2)<<endl;
}

Measured memory_bytes: 256
// ConsoleApplication2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//


#include <iostream>

using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c<=b && c>=a){
        cout<<"Yes";
    }
    else
    cout<<"No";
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

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

    sort(begin(l), end(l), [](const auto& l1, const auto& l2) {
        return l1 > l2;
    });

    int ans = 0;
    for (int i = 0; i < K; ++i) {
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int is_prime(int x) {
  int i;
  if(x <= 1) return -1;
  for(i = 2; i * i <= x; i++) {
    if(x%i==0) return -1;
  }
  return 0;
}

int main(void)
{
  int x, i;
  
  scanf("%d", &x);

  for(i = x; ; i++) {
    if(is_prime(i) == 0) break;
  }

  printf("%d\n", i);
  
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 1e9 + 7;

int64_t gcd(int64_t a, int64_t b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

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

int64_t inv(int64_t x) { return dpow(x, MOD - 2); }

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

  vector<int64_t> a(n);
  rep(i, n) { cin >> a[i]; }

  map<int, int> factors;
  rep(i, n) {
    int tmp = a[i];
    for (int i = 2; i * i <= tmp; i++) {
      bool isPrime = true;
      for (int j = 2; j * j <= i; j++) {
        isPrime = isPrime && (i % j != 0);
      }

      if (isPrime) {
        int cnt = 0;
        while (tmp % i == 0) {
          tmp /= i;
          cnt++;
        }
        factors[i] = max(factors[i], cnt);
      }
    }
    if (tmp != 1) {
      factors[tmp] = max(factors[tmp], 1);
    }
  }

  int64_t lcm = 1;
  for (auto p : factors) {
    int k, v;
    tie(k, v) = p;
    if (v != 0) {
      rep(i, v) { lcm = lcm * k % MOD; }
    }
  }

  int64_t result = 0;
  rep(i, n) { result = (result + lcm * inv(a[i]) % MOD) % MOD; }

  cout << result << endl;
  return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int maxx = 0;
    int x = 0;
    for (int i=0; i<n; ++i) {
        if (s[i] == 'I') {
            ++x;
            maxx = max(maxx, x);
        }
        else --x;
    }
    cout << maxx << endl;
}

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

#define ll long long
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define INF (ll)1e9
#define fora(i,a,b) for(ll i=a;i<b;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
#define mli map<ll,int>
#define mll map<ll,ll>

using namespace std;

int main()
{   ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll l,r,d,cnt=0;
    cin>>l>>r>>d;
    cnt+=r/d;
    cnt-=l/d;
    if(l%d==0)
    cnt++;
    cout<<cnt<<endl;
    return 0;
}




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

int main(){
	int n;
	cin >> n;
	int a[n],count;
	unsigned long sum = 0;
	int min = 1000000001;
	for(int i = 0; i < n;i++){
		cin >> a[i];
		if(abs(a[i]) < min){
			min = abs(a[i]);
		}
		if(a[i] < 0){
			count++;
			a[i] = -a[i];
		}
		sum += a[i];
	}
	if(count % 2 == 1){
		sum -= 2 * min;
	}
	cout << sum << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a) for ( int i=0; i<int(a); i++ )
using namespace std;

typedef long long ll;
int n;
vector<ll> a;

int main() {
    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];

    ll mx=-1e12,mxi,mi=1e12,mii;
    vector<pair<int,int>> ans;
    for ( int i=0; i<n; i++ ) {
        if ( mx<a[i] ) {
            mx=a[i];
            mxi=i;
        }
        if ( mi>a[i] ) {
            mi=a[i];
            mii=i;
        }
    }
    if ( abs(mx)>=abs(mi) ) {
        for ( int i=0; i<n; i++ ) {
            ans.emplace_back(mxi,i);
        }
        for ( int i=0; i<n-1; i++ ) {
            ans.emplace_back(i,i+1);
        }
    } else {
        for ( int i=0; i<n; i++ ) {
            ans.emplace_back(mii,i);
        }
        for ( int i=n-2; i>=0; i-- ) {
            ans.emplace_back(i+1,i);
        }        
    }
    cout << ans.size() << '\n';
    for ( int i=0; i<ans.size(); i++ ) {
        cout << ans[i].first+1 << ' ' << ans[i].second+1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){
  int n,m,i,u[999999],a[999999];std::cin>>n>>m;
  for(i=0;i<m;i++) scanf("%d",a+i);
  for(i=m-1;i>=0;i--) if(!u[a[i]-1])  printf("%d\n",a[i]),u[a[i]-1]=1;
  for(i=0;i<n;i++) if(!u[i]) printf("%d\n",i+1);
  return 0;
}

Measured memory_bytes: 4336
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    
    long a;
    long double b;
    cin>>a>>b;
    
    cout<<(ll)(a*b);    //cout<<s;
    
    

    return 0;
}


Measured memory_bytes: 3724
loop do
    n = gets.to_i
    break if n == 0
    queue = []
    n.times do
        w, t1, t2 = gets.split.map(&:to_i)
        queue << [t1, +w]
        queue << [t2, -w]
    end
    queue.sort_by!(&:first)
    total = 0
    answer = 'OK'
    until queue.empty?
        t = queue[0][0]
        until queue.empty? or queue[0][0] != t
            _, w = queue.shift
            total += w
        end
        if total > 150
            answer = 'NG'
            break
        end
    end
    puts answer
end



Measured memory_bytes: 6868
#include<stdio.h>

int binary(int n){
    if(n/2){
        return n%2+binary(n/2)*10;
    }else{
        return n;
    }
}

int main(){
    int i,t,flag;
    double a,b,c,s[16]={0.0,0.0625,0.125,0.1875,0.25,0.3125,0.375,0.4375,0.5,0.5625,0.625,0.6875,0.75,0.8125,0.875,0.9375};
    while(1){
        scanf("%lf",&a);
        if(a < 0)break;
        t = a;
        c = a - t;
        if(t > 255){
            puts("NA");
            continue;
        }
        for(i = 0,flag = 0;i < 16;i++){
            if(s[i]==c){
                flag=i+1;
                break;
            }
        }
        if(!flag)puts("NA");
        else printf("%08d.%04d\n",binary(t),binary(flag-1));
    }
    return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
  int n;
  cin>>n;
  int four=0,even=0,odd=0;
  rep(i,n){
    int t;
    cin>>t;
    if(t%4==0) four++;
    else if (t%2==0) even++;
    else odd++;
  }
  if (even==0) cout<<((four>=odd-1)?"Yes":"No")<<endl;
  else cout<<((four>=odd)?"Yes":"No")<<endl;
  return 0;
}


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

int N, K;

int main() {
    int a;
    cin >> N >> K;
    int sum = 0;
    for (int i=0; i<K; i++) {
        cin >> a;
        sum += a;
    }
    sum >= N ? cout << "Yes\n" : cout << "No\n";
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int id,k,temp2,t,j,n,a,b,c[300010],i,temp;
    scanf("%d%d%d",&n,&a,&b);
	if((b>(n-a+1)) || (b<((n+a-1)/a)))
		cout<<"-1\n";
	else
	{
		for(i=1;i<=n;i++)
			c[i]=n-i+1;
		for(i=1;i<=n;i++)
			if(i+(n-i*a)<b)
				break;
		i--;
		id=i;
		for(j=1;j<=id;j++)
		for(i=1+(j-1)*a,k=0;i<=(j*a+1+(j-1)*a)/2;i++,k++)
		{
			temp=c[j*a-k];
			c[j*a-k]=c[i];
			c[i]=temp;
		}
		b-=id;
		temp=n-id*a;
		temp-=(b-1);
		for(j=id*a+1,k=1;k<=temp/2;k++,j++)
		{
			temp2=c[id*a+temp-k+1];
			c[id*a+temp-k+1]=c[j];
			c[j]=temp2;
		}
		for(i=1;i<=n;i++)
		   printf("%d ",c[i]);
	   cout<<endl; 
	}
    return 0;
}


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

using namespace std;

int main()
{
    int h,r;
    cin >> h>> r;
    if(h<0){
        if(h+r==0)cout << 0 << endl;
        else if(h+r<0) cout<< -1<<endl;
    }
    else {
        cout << 1 << endl;
    }
        return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>

void sort(int *a, int n)
{
	int i, j;
	
	for (i = 0; i < n - 1; i++) {
		for (j = n - 1; j > i; j--) {
			if (a[j - 1] > a[j]) {
				int tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
			}
		}
	}
}

int main(void)
{
	int i;
	int x[3];
	
	scanf("%d %d %d", &x[0], &x[1], &x[2]);
	
	sort(x, 3);
	
	printf("%d %d %d\n", x[0], x[1], x[2]);
	
	return 0;
}

Measured memory_bytes: 596
a,b,c = map(int,input().split())
if a >= b >= c:
  s1 = a
  s2 = b
  s3 = c
elif a >= c >= b:
  s1 = a
  s2 = c
  s3 = b
elif b >= a >= c:
  s1 = b
  s2 = a
  s3 = c
elif b >= c >= a:
  s1 = b
  s2 = c
  s3 = a
elif c >= a >= b:
  s1 = c
  s2 = a
  s3 = b
elif c >= b >= a:
  s1 = c
  s2 = b
  s3 = a

print(abs(s1-s2) + abs(s2-s3))

Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi v(n);
    rep(i, n) rep(j, 5) {
      int x;
      cin >> x;
      v[i] += x;
    }
    auto p = minmax_element(all(v));
    cout << *p.second << ' ' << *p.first << endl;
  }
}

Measured memory_bytes: 2924
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> x_vec(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> x_vec.at(i);
  }
  long long ans = INF;
  for (int i = 1; i < 101; ++i)
  {
    long long temp = 0;
    for (int j = 0; j < N; ++j)
    {
      temp += pow(x_vec.at(j) - i, 2);
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	if(n>=65 && n<=90){
		printf("1\n");
	}
	else if(n>=97 && n<=122){
		printf("2\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 2112
import sys
p,t='+X=','X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or(p[:2]in e)*(p not in e):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5616
#include <stdio.h>

int main(){
    int a, b, i, j = 0, count;
    
    while(1){
    	scanf("%d %d", &a, &b);
    	if(a == 0 && b == 0) break;
    	count = 0;
    	if(j != 0) printf("\n");
        for (i = a; i <= b; i++){
        	if(i % 4 != 0) continue;
        	else if(i % 100 == 0 && i % 400 != 0) continue;
            else{
                printf("%d\n", i);
                count++;
            }
        }
        if(count == 0) printf("NA\n");
        j++;
    }
    return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

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

    vector<ll>a(n),b(n),c(n);

    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    rep(i,n){
        cin>>c[i];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    ll ans=0;

    rep(i,n){
        ll cnta=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll cntc=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans+=cnta*cntc;
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
tmp = N
for a in A:
    ans += B[a-1]
    if tmp+1 == a:
        ans += C[a-2]
    tmp = a

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

//????????¨??¢??°???
string MrJ(string s){
  string res="";
  int len=s.length();
  res += s[len-1];
  for(int i=0;i<len-1;i++) res += s[i];
  return res;
}
string MissC(string s){
  string res="";
  int len=s.length();
  for(int i=1;i<len;i++) res += s[i];
  res += s[0];
  return res;
}
string MrE(string s){
  string res="";
  int len=s.length();
  if(len%2==0){
    for(int i=len/2;i<=len-1;i++) res+=s[i];
    for(int i=0;i<=len/2-1;i++) res+= s[i];
  }
  else{
    for(int i=(len+1)/2;i<=len-1;i++) res += s[i];
    res += s[(len-1)/2];
    for(int i=0;i<=(len-3)/2;i++) res += s[i];
  }
  return res;
}
string MrA(string s){
  string res="";
  int len=s.length();
  for(int i=len-1;0<=i;i--) res += s[i];
  return res;
}
string DrP(string s){
  string res="";
  int len=s.length();
  for(int i=0;i<len;i++){
    if(48<s[i] && s[i]<=57){
      res += s[i]-1;
    }
    else if(s[i]==48) res+= "9";
    else res+= s[i];
  }
  return res;
}
string MrM(string s){
  string res="";
  int len=s.length();
  for(int i=0;i<len;i++){
    if(48<=s[i] && s[i]<57){
      res += s[i]+1;
    }
    else if(s[i]==57) res+= "0";
    else res+= s[i];
  }
  return res;
}

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

  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    string order;
    string s;
    cin >> order >> s;
    int len=order.length();
    for(int j=len-1;0<=j;j--){
      if(order[j]=='J') s=MrJ(s);
      else if(order[j]=='C') s=MissC(s);
      else if(order[j]=='E') s=MrE(s);
      else if(order[j]=='A') s= MrA(s);
      else if(order[j]=='P') s=DrP(s);
      else s=MrM(s);
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 3028
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n, k;
    cin >> n >> k;

    // when k is odd
    ll ans;
    if (k % 2 == 1) {
        ans = pow(n / k, 3);
    }
    // when k is even
    else {
        ans = pow(n / k, 3);
        ans += pow(((n+k/2) / k), 3);
    }
    P(ans);


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define MAX 100000
using namespace std;
struct Node{
    int parent,depth;
    vector<int> children;
    string name;
};
Node trees[MAX];
void depth_search(int,int);
int main(void){
    int n,key,num,child,root_id;
    cin >> n;
    for(int i=0;i<n;i++){
        trees[i].parent = -1;
    }
    for(int i=0;i<n;i++){
        cin >> key >> num;
        for(int j=0;j<num;j++){
            cin >> child;
            trees[key].children.push_back(child);
            trees[child].parent = key;
        }
    }
    for(int i=0;i<n;i++){
        if(trees[i].parent==-1){
            trees[i].name = "root";
            root_id = i;
        }else if(trees[i].children.empty()){
            trees[i].name = "leaf";
        }else{
            trees[i].name = "internal node";
        }
    }
    depth_search(root_id,0);
    for(int i=0;i<n;i++){
        cout << "node " << i << ": parent = "<< trees[i].parent << ", depth = " << trees[i].depth << ", ";
        cout << trees[i].name << ", " <<'[';
        for(int j=0;j<trees[i].children.size();j++){
            cout << trees[i].children[j];
            if(j<trees[i].children.size()-1){
                cout << ", ";
            }
        }
        cout << ']' << endl;
    }
    return 0;
}
void depth_search(int p,int d){
    trees[p].depth = d;
    for(int i=0;i<trees[p].children.size();i++){
        depth_search(trees[p].children[i],d+1);
    }
}


Measured memory_bytes: 12568
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	string a,b;
	cin>>a>>b;
	a+=b;
	int k=0,siz=a.size();
	for(int i=0;i<siz;i++){
		k*=10;
		k+=a[i]-'0';
	}
	for(int i=0;i*i<=k;i++){
		if(i*i==k){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
from math import log10 as log10

n = int(input())

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

_max = 10 ** (18)

ans = a[0]
min_a = min(a)

for _a in a[1:]:
    if min_a == 0:
        break
    if ans > _max:
        break


    ans *= _a

if (ans > _max):
    print(-1)
elif min_a == 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 22524
import bisect
import copy
import heapq
import sys
import itertools
import math
from functools import lru_cache
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    P = read_lists(N)
    # N = 15
    # P = [(i ** 2 + 1, i ** 2 + 1, i ** 2 + 1) for i in range(N)]
    
    C = [1 << 62] * (N + 1)
    # CX = [None for _ in range(2 ** N)]
    # CY = [None for _ in range(2 ** N)]
    CX = [1 << 62] * (N * 2 ** N)
    CY = [1 << 62] * (N * 2 ** N)

    LX = [0] * (2 ** N)
    LY = [0] * (2 ** N)
    for K in range(2 ** N):
        X = {0}
        Y = {0}
        for i in range(N):
            if (K >> i) & 1:
                X.add(P[i][0])
                Y.add(P[i][1])
         
        # CXX = [0] * N
        # CYY = [0] * N
        for j, (xp, yp, cp) in enumerate(P):
            for x in X:
                # CXX[j] = min(abs(xp - x) * cp, CXX[j])
                CX[K * N + j] = min(abs(xp - x) * cp, CX[K * N + j])
            for y in Y:
                CY[K * N + j] = min(abs(yp - y) * cp, CY[K * N + j])
                # CYY[j] = min(abs(yp - y) * cp, CYY[j])
            
        LX[K] = len(X)
        LY[K] = len(Y)
        # CX[K] = tuple(CXX)
        # CY[K] = tuple(CYY)

    for T in range(2 ** N):
        p = format(T, "160b").count("1")
        if C[p] == 0:
            continue

        r = 1 << 62
        tx = T
        while True:
            ty = T - tx
            c = 0
            for n in range(N):
                c += min(CX[tx * N + n], CY[ty * N + n])
            r = min(r, c)
            if tx == 0:
                break
            tx = (tx - 1) & T
        C[p] = min(C[p], r)
    print("\n".join(map(str, C)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 84028
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=103};

char s[N][N],t[N];
int a[N];

int main(){
	int n=ci();
	rep(i,1,n){
		scanf("%s",s[i]+1);
		a[i]=ci();
	}
	scanf("%s",t+1);
	rep(i,1,n){
		if( strcmp(s[i]+1,t+1)==0 ){
			int ans= 0;
			rep(j,i+1,n) ans+=a[j];
			printf("%d\n",ans);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, ans = 0; cin >> n >> a;
	for (int h = 0; h < n; h++) {
		cin >> b;
		if (b >= a) {
			ans++;
		}
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N, K = l_inpl()
    xy = []
    for _ in range(N):
        xi, yi = l_inpl()
        xy.append([xi, yi])

    ans = INF * INF
    xy.sort()

    for l, (xl, yl) in list(enumerate(xy))[:N-K+1]:
        for r, (xr, yr) in list(enumerate(xy))[l+K-1:]:
            ys = sorted([ y for _, y in xy[l:r+1]]) 
            for yd, yu in zip(ys, ys[K-1:]):
                # if yd <= yl and yd <= yr and yl <= yu and yr <= yu:
                if yd <= yl and yr <= yu:
                    ans = min(ans, (xr-xl) * (yu - yd))
    
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 3824
# https://atcoder.jp/contests/tenka1-2018-beginner/submissions/6799465
def tenka18beg_c():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()

    if N % 2 == 0:
        lower = A[:N//2]
        upper = A[N//2:]
        ans = (2 * sum(upper) - upper[0]) - (2 * sum(lower) - lower[-1])
    else:
        lower = A[:N//2]
        upper = A[N//2 + 1:]
        mid = A[N//2]
        x = 2 * sum(upper) - 2 * sum(lower) - mid + lower[-1]  # 中央が +2* -1* -1* のパターン
        y = 2 * sum(upper) - 2 * sum(lower) + mid - upper[0]  # 中央が +1* +1* -2* のパターン
        ans = max(x, y)
    print(ans)

tenka18beg_c()

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

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

  for (int i = 0; i < N; i++)
  {
    cin >> C;

  	if (C == "Y")
      break ;
  }
  if (C == "Y")
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  vector<ll> d(m, 0);
  for (int i = 0; i < m - 1; i++) {
    d[i] = v[i + 1] - v[i];
  }
  sort(d.rbegin(), d.rend());

  ll ans = v[m - 1] - v[0];

  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < n - 1; i++) {
    ans -= d[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
using namespace std;
 
using i64 = long long int;
template <typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template <typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
 
void err(__attribute__((unused)) istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl;
  err(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& os, const pair<T1, T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")";
}
template<typename T>
inline ostream &operator << (ostream & os,const vector<T>& v) {
  bool first = true;
  os << "[";
  for (const auto &e: v) {
    if(!first) os << ", ";
    os << e;
    first = false;
  }
  return os << "]";
}
template<typename T>
inline ostream &operator << (ostream & os, multiset<T>& v) {
  bool first = true;
  os << "{";
  for (auto ii = v.begin(); ii != v.end(); ++ii) {
    if(!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "}";
}
template<typename T>
inline ostream &operator << (ostream & os,const unordered_set<T>& v) {
  bool first = true;
  os << "{";
  for (const auto &x : v) {
    if(!first) os << ", ";
    os << x;
    first = false;
  }
  return os << "}";
}
template<typename T1, typename T2>
inline ostream &operator << (ostream & os,const map<T1, T2>& v) {
  bool first = true;
  os << "{";
  for (const auto &e : v) {
    if(!first) os << ", ";
    os << e;
    first = false;
  }
  return os << "}";
}
template<typename T>
ostream &operator << (ostream & os,const vector<vector<T>>& v) {
  for (auto &u: v) os << '\n' << u;
  return os;
}
template<typename T>
void finish(T ans) {cout << ans << '\n'; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/
signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  i64 n;
  cin >> n;
  if (n <= 2) finish(0);
  i64 ans = n - 1;
  for (i64 i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      i64 x = i - 1;
      if (n / x == n % x) ans += x;
      if (i * i == n) break;
      x = n / i - 1;
      if (n / x == n % x) ans += x;
    }
  }
  cout << ans << '\n';
  
  return 0;
}


Measured memory_bytes: 256