akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    void solve(){
        Scanner sc = new Scanner(System.in);
        boolean[] timeTable = new boolean[24*60];
        int h, m;
        boolean isFirst;

        for (int i = 0; i < 2; ++i) {
            int j;
            j = sc.nextInt();
            for (; j > 0; --j) {
                h = sc.nextInt();
                m = sc.nextInt();
                timeTable[h*60 + m] = true;
            }
        }

        isFirst = true;
        for (h = 0; h < 24; ++h){
            for (m = 0; m < 60; ++m)      {
                if ( timeTable[h*60 + m] ){
                    if ( !isFirst ) System.out.print(" ");
                    else isFirst = false;
                    System.out.format("%d:%02d", h, m);
                }
            }
        }
        System.out.println();
    }

    public static void main(String[] args){ new Main().solve(); }
}





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

n = int(input())
ab = []
for i in range(n):
    a = list(map(int, input().split()))
    ab.append([a[0]+a[1], a[0], a[1]])

ab = sorted(ab, reverse=True)

a = sum(list(map(lambda x: x[1], ab[::2])))
b = sum((list(map(lambda x: x[2], ab[1::2]))))

print(a-b)

Measured memory_bytes: 24496
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
    int64_t A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(abs(A-B) <= (V-W) * T) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(m):
    data = list(map(int,input().split()))
    l.append(data)
l.sort(key=lambda x:x[1])
l.reverse()

a.sort()

b_idx=0
nokori=l[b_idx][0]
for i in range(n):
    if a[i] > l[b_idx][1]:
        break
    else:
        a[i] = l[b_idx][1]
        nokori-=1
        if nokori == 0:
            b_idx+=1
            if b_idx >= m:
                break
            nokori=l[b_idx][0]

print(sum(a))

Measured memory_bytes: 81516
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.insert(0, -1)

    i = 1
    ans = 1
    R = [False] * (N + 1)
    while True:
        R[i] = True

        if A[i] == 2:
            print(ans)
            return

        if R[A[i]]:
            print(-1)
            return

        i = A[i]
        ans += 1


main()


Measured memory_bytes: 9440
while True:
    ts={}
    c=input()
    if c==0: break
    for i in range(c):
        f=raw_input().split()
        ts[f[0]]=int(f[1])
    for i in range(input()):
        f=raw_input().split()
        m=0
        for j in range(int(f[1])):
            h=ts[f[j+2]] if f[j+2] in ts else 0
            m+=h
        q=ts[f[0]]
        ts[f[0]]=q if m > q else m
    print ts[raw_input()]

Measured memory_bytes: 4252
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int D,G;
vector<int> p,c;

int main(){
	cin>>D>>G;
	p.resize(D);
	c.resize(D);
	
	int ans=10e8;

	for(int i=0;i<D;i++){
		cin>>p[i]>>c[i];
	}
	for(int mask=0;mask<(1<<D);++mask){
		int s=0, num=0,rest_max=-1;
		for(int i=0;i<D;++i){
			if(mask>>i&1){
				s+=100*(i+1)*p[i]+c[i];
				num+=p[i];
			}else{
				rest_max=i;
			}
		}
		if(s<G){
			int s1=100*(rest_max+1);
			int need=(G-s+s1-1)/s1;
			if(need>=p[rest_max]){
				continue;
			}
			num+=need;
		}
		ans=min(ans,num);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
t, a = gets.split.map(&:to_i)
height_set = gets.split.map(&:to_i)
mean_temp_set = []

n.times do |i|
  mean_temp_set << t - height_set[i] * 0.006
end

minimum = 100000
best = 0
(0...mean_temp_set.length).each do |i|
  if (mean_temp_set[i] - a).abs < minimum
    minimum = (mean_temp_set[i] - a).abs
    best = i + 1
  end
end

puts best

Measured memory_bytes: 2044
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (s,) = input!(String);

    let mut lt = Vec::with_capacity(s.len() - 1);
    let mut gt = Vec::with_capacity(s.len() - 1);

    lt.push(0);
    gt.push(0);

    let mut count = 0;
    for c in s.chars() {
        match c {
            '<' => count += 1,
            '>' => count = 0,
            _ => {},
        }
        
        lt.push(count);
    }

    let mut count = 0;
    for c in s.chars().rev() {
        match c {
            '>' => count += 1,
            '<' => count = 0,
            _ => {},
        }
        gt.push(count);
    }

    let minimum_vec = lt.iter().zip(gt.iter().rev()).map(|(a, b)| std::cmp::max(a, b));
    let total: u64 = minimum_vec.sum();
    
    println!("{}", total);
}

fn main() {
    solve();
}


Measured memory_bytes: 14588
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    for (int i = 0; i < M; ++i)
    {
        int Ai;
        cin >> Ai;
        N -= Ai;
        if (N < 0)
            break;
    }
    cout << (N<0 ? -1 : N) << endl;
    return 0;
}

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

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
 
using namespace std; 



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    cout<<(a*3+b)/2;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int bitLength(int x) {
	if (x == 0) return 0;
	return 1 + bitLength(x >> 1);
}

int main() {
	int L; scanf("%d", &L);
	int bitCount = bitLength(L);
	// we will have bitCount vertices
	vector<pair<int, int>> edges;
	vector<int> eWeight;
	for (int dst = 1; dst < bitCount; ++dst) {
		edges.emplace_back(dst - 1, dst);
		eWeight.emplace_back((1<<(dst-1)));
		edges.emplace_back(dst - 1, dst);
		eWeight.emplace_back(0);
	}
	int cMax = (1 << (bitCount - 1)) - 1;
	for (int src = bitCount - 2; src >= 0; --src) {
		if (L & (1 << src)) {
			// add an edge
			edges.emplace_back(src, bitCount - 1);
			eWeight.emplace_back(cMax + 1);
			cMax = cMax + (1 << src);
		}
	}
	// printf("BC %d\n", bitCount);
	printf("%d %lu\n", bitCount, edges.size());
	for (int i = 0; i < edges.size(); ++i) {
		printf("%d %d %d\n", edges[i].first + 1, edges[i].second + 1, eWeight[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long gcd(long long a,long long  b)
{
	return b?gcd(b,a%b):a;
}
long long lcm(long long a,long long b)
{
	return a/gcd(a,b)*b;
}
main()
{
	int n,i;
	long long s,a[101];
	while(~scanf("%d",&n))
	{
		s=1; 
		for(i=0;i<n;i++)
		{
		scanf("%lld",&a[i]);
		}
		for(i=0;i<n;i++)
		{
			s=lcm(s,a[i]);
		}
		printf("%lld\n",s);
	}
}

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


int main() {
  int A,B;
  cin>>A>>B;
  
  int socket=1;
  int cnt=0;
  while(socket<B){
    socket+=A-1;
    cnt++;
  }
  
  cout<<cnt<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[200010];
int main(){
    int i,n,x = 0; cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        x ^= a[i];
    }
    for(i=0;i<n;i++){
        cout << (x^a[i]) << " ";
    }
    cout << endl;
}

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

vector<vector<int>> sub_problem(int k) {
    vector<vector<int>> ret;
    for (int j = 0; j < k; j++) {
        for (int i = 0; i < k; i++) {
            ret.emplace_back(vector<int>());
            int curr = i;
            for (int c = 0; c < k; c++) {
                ret.back().emplace_back(c*k+curr+1);
                curr = (curr + j) % k;
            }
        }
    }
    return ret;
}

bool valid(vector<vector<int>> &c) {
    int n = c.size(); int sz = c[0].size();
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            set<int> s;
            for (int k = 0; k < sz; k++) {
                s.insert(c[i][k]);
                s.insert(c[j][k]);
            }
            if (s.size() != sz * 2 - 1) return false;
        }
    }
    return true;
}

void output(vector<vector<int>> &c) {
    cout << c.size() << " " << c[0].size() << "\n";
    for (int i = 0; i < c.size(); i++) {
        for (int j = 0; j < c[i].size(); j++) {
            if (j) cout << " ";
            cout << c[i][j];
        }
        cout << "\n";
    }
}

int main() {
    int k = 38;
    int n = k * k - k + 1;
    auto res = sub_problem(k-1);
    vector<vector<int>> ans;
    vector<int> u;
    for (int i = 0; i < k; i++) {
        int f = (k-1) * (k-1) + 1 + i;
        u.emplace_back(f);
        if (i == 0) {
            for (int j = 0; j < k-1; j++) {
                ans.emplace_back(vector<int>());
                ans.back().emplace_back(f);
                for (int c = 0; c < k-1; c++) {
                    ans.back().emplace_back(j*(k-1)+c+1);
                }
            }
        } else {
            for (int j = 0; j < k-1; j++) {
                ans.emplace_back(res[(i-1)*(k-1)+j]);
                ans.back().emplace_back(f);
            }
        }
    }
    ans.emplace_back(u);
    // if (valid(ans)) cout << "ok" << "\n";
    output(ans);  
}

Measured memory_bytes: 1280
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

int32_t main(){
    int n;
    cin >>n;
    cout <<((n/ 100) >= (n % 100 + 4)/ 5) <<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x,i,a;
	scanf("%d",&x);
	printf("%d:",x);
	a=2;
	n=x;
	while(n>1)	{
		if(n%a==0)	{
			printf(" %d",a);
			n/=a;
		}
		else {
			a++;
			if(a*a>n){
				printf(" %d",n);
				break;
			}
		}
	}
	printf("\n");
	return 0;
}
	


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

const int MAX_N = 1 << 17;
typedef long long LL;

// Segment Tree
// (数列のサイズ N に対してSegment Treeの頂点は 2*N-1 となる)
struct Segment_tree{
	int n;
	vector<LL> dat;
	// コンストラクタで初期化
	Segment_tree(int n_){
		// 簡単のために要素数を2のべき乗にする 
		n = 1;
		while( n < n_ ) n *= 2;
		// すべての頂点の値を 0 にする
		for(int i=0 ; i < 2*n-1 ; i++ ){
			dat.push_back( 0 );
		}
	}
	// k 番目の値 (0-indexed) を a に更新
	void update(int k, LL a){
		k += n-1;
		dat[k] = a;
		// 登りながら更新
		while( k > 0 ){
			k = (k - 1) / 2;
			dat[k] = max( dat[k*2+1] , dat[k*2+2] );
		}
	}
	// [a,b)の最小値を求める
	LL query(int a, int b, int k=0, int l=0, int r=0){
		// 初回呼び出し時
		if( k == 0 && l == 0 && r == 0 ) r = n;
		
		// [a,b) と [l,r) が交差しないとき
		if( r <= a || b <= l ) return 0;
		
		// [a,b) が [l,r) を完全に含んでいるとき
		if( a <= l && r <= b ){
			return dat[k];
		}else{ // それ以外
			LL vl = query( a , b , k*2+1 , l , (l+r)/2 );
			LL vr = query( a , b , k*2+2 , (l+r)/2 , r );
			return max( vl , vr );
		}
	}
};

int main(){
	LL n;
	cin >> n;
	vector<LL> x(n);
	Segment_tree t(n+1);
	for(int i=0 ; i < n ; i++ ){
		cin >> x[i];
	}
	// segment tree について
	// t.query(0, b);
	// とすると (1..nの総和) - (荷物の重さ b 以下で整列させる最大のコスト)が返ってくる
	for(int i=0 ; i < n ; i++ ){
		// [0,x[i]) の中で最小値が返ってくる.
		LL cost = t.query(0, x[i]);
		// 位置 x[i] を cost - x[i] に更新
		t.update(x[i], cost+x[i] );
	}
	// 解 (1..nの総和は n*(n+1)/2 で計算できる)
	LL ans = n * (n+1) / 2 - t.query(0, n+1);
	cout << ans << endl;
}

Measured memory_bytes: 4148
N, T = map(int, input().split())
c = [0] * N
t = [0] * N

for i in range(N):
    c[i], t[i] = map(int, input().split())

dicts = {key:value for key, value in zip(c, t)}
dicts = sorted(dicts.items())
for key, value in dicts:
    if value <= T:
        print(key)
        exit()

print('TLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S, T;
    cin >> S >> T;
    bool ok = true;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) != T.at(i)) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 400+5;
int n, h, in[N], out[N], fa[N], valid[N];
int find(int x) { return fa[x] == x?x:fa[x] = find(fa[x]); }
int main()
{
    n = read(), h = read();
    for(int i = 1; i <= h<<1; ++i) fa[i] = i; 
    for(int i = 1; i <= n; ++i)
    {
        int a = read(), b = read(), c = read(), d = read();
        int x = c?c+h:a, y = d?d:b+h;
        ++out[x], ++in[y], x = find(x), y = find(y), fa[x] = y;
    }
    for(int i = 1; i <= h; ++i) if(in[i] > out[i]) return puts("NO"), 0;
    for(int i = h+1; i <= h<<1; ++i) if(in[i] < out[i]) return puts("NO"), 0;
    for(int i = 1; i <= h<<1; ++i) if(in[i] != out[i]||!in[i]) valid[find(i)] = 1;
    for(int i = 1; i <= h<<1; ++i) if(find(i) == i&&!valid[i]) return puts("NO"), 0;
    puts("YES");
    return 0;
}

Measured memory_bytes: 128
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[k]<L[i]+L[j] and L[i]<L[j]<L[k]:
                ans+=1
print(ans)

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

int main(){
    int size;
    cin >> size;
    int array1[size],array2[size];
    for(int i=0;i<size;i++){
        cin >> array1[i];
        array2[i]=array1[i];
    }
    sort(array1,array1+size);
    int count=0;
    for(int i=0;i<size;i++){
        if(array1[i]!=array2[i]){
            count++;
        }
    }
    if(count==0||count==2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
  string s;
  cin >> s;
  int count = 0;
  if (s[0] == 'o') ++count;
  if (s[1] == 'o') ++count;
  if (s[2] == 'o') ++count;
  int answer = 100 * count + 700;
  cout << answer << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int x,y;
	cin>>x>>y;
	int t=y-2*x;
	if((t>=0) && (t%2==0) && (t/2>=0) && (t/2<=x))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}



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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  = 3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  string ans = "";
  int sx, sy, tx, ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i, sx, tx)
    ans += "R";
  rep(i, sy, ty)
    ans += "U";
  rep(i, sx, tx)
    ans += "L";
  rep(i, sy, ty)
    ans += "D";
  ans += "L";
  repn(i, sy, ty)
    ans += "U";
  repn(i, sx, tx)
    ans += "R";
  ans += "DR";
  repn(i, sy, ty)
    ans += "D";
  repn(i, sx, tx)
    ans += "L";
  ans += "U";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef unsigned long long int ulli;
typedef long long int lli;

#define MAX(x, y) ((x) < (y) ? (y) : (x))

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

    int A, B;
    cin >> A >> B;

    if (A > B)
    {
        cout << 2 * A - 1 << "\n";
    }
    else if (B > A)
    {
        cout << 2 * B -1 << "\n";
    }
    else
    {
        cout << 2 * A << "\n";
    }

    return 0;
}



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

int h, w, n;
bool contain(int y, int x){
   return (0 <= y && y < h - 2 && 0 <= x && x < w - 2);
}

signed main(){
    cin >> h >> w >> n;
    map<P, int> mp;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        for(int y = a - 2; y <= a; y++){
            for(int x = b - 2; x <= b; x++){
                if(!contain(y, x)) continue;
                mp[{y, x}]++;
            }
        }
    }
    int ans[10] = {};
    int sum = 0;
    for(auto it = mp.begin(); it != mp.end(); it++){
        ans[it -> second]++;
        sum++;
    }
    ans[0] = (h - 2) * (w - 2) - sum;
    for(int i = 0; i <= 9; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 56448
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string str;
	cin >> str;
	
	
	for(int i = 0;i < str.size() - 1;i++)
	{
		if(str[i] == 'A' && str[i+1] == 'C')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
		
	
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	var n int
	fmt.Scanln(&n)

	S_numbers := make([]int, 0)
	H_numbers := make([]int, 0)
	C_numbers := make([]int, 0)
	D_numbers := make([]int, 0)

	for i := 0; i < n; i++ {

		scanner.Scan()
		string := scanner.Text()
		words := strings.Split(string, " ")

		number, _ := strconv.Atoi(words[1]) // number

		if words[0] == "S" {
			S_numbers = append(S_numbers, number)
		} else if words[0] == "H" {
			H_numbers = append(H_numbers, number)
		} else if words[0] == "C" {
			C_numbers = append(C_numbers, number)
		} else {
			D_numbers = append(D_numbers, number)
		}
	}

	for i := 1; i <= 13; i++ {
		if !(contain(S_numbers, i)) {
			fmt.Printf("S %d\n", i)
		}
	}
	for i := 1; i <= 13; i++ {
		if !(contain(H_numbers, i)) {
			fmt.Printf("H %d\n", i)
		}
	}
	for i := 1; i <= 13; i++ {
		if !(contain(C_numbers, i)) {
			fmt.Printf("C %d\n", i)
		}
	}
	for i := 1; i <= 13; i++ {
		if !(contain(D_numbers, i)) {
			fmt.Printf("D %d\n", i)
		}
	}

}

func contain(numbers []int, number int) bool {

	for _, n := range numbers {
		if n == number {
			return true
		}
	}

	return false
}



Measured memory_bytes: 1148
import itertools
import numpy as np


N = int(input())
n=[]
s=range(N)
for i in range(N):
    n.append([int(x) for x in input().split()])
Q = list(itertools.permutations(s))
L=0
for i in range(int(len(Q))):
    for j in range(N-1):
        L+= np.sqrt((n[Q[i][j+1]][0] - n[Q[i][j]][0])**2 + (n[Q[i][j+1]][1] - n[Q[i][j]][1])**2)
print(L/(len(Q)))



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

if n == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

li = factorization(n)
ans = 0

for a,b in li:
    tmp = 0
    while tmp * (tmp+1) // 2 <= b:
        tmp += 1
    ans += tmp - 1

print(ans)


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  int r, g;
  cin >> r >> g;
  puts(g*2-r)
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, t, u, ss, tt, uu;
  cin >> s >> t >> u;
  transform(s.begin(), s.end(), s.begin(), ::toupper);
  transform(t.begin(), t.end(), t.begin(), ::toupper);
  transform(u.begin(), u.end(), u.begin(), ::toupper);

  cout << s[0] << t[0] << u[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n, sum = 0;
  cin >> n;
  vector<int> s(n);
  REP(i, n){
    cin >> s[i];
    sum += s[i];
  }
  if(sum % 10 != 0){
    cout << sum << endl;
    return 0;
  }
  VSORT(s);
  REP(i, n){
    if(s[i] % 10 != 0){
      cout << sum - s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
char s[N];
int n;

int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	int flag=0;
	if(s[n]=='1'||s[1]=='0') flag=1;
	for(int i=1;i<=n/2;i++) {
		if(s[i]=='0'&&s[n-i]=='1') flag=1;
		if(s[i]=='1'&&s[n-i]=='0') flag=1;
	}
	if(flag) {puts("-1");return 0;}
	int cnt=1,pre=1,last=1;
	for(int i=2;i<=n;i++)
		if(s[i]=='1') {
			int now=++cnt;
			printf("%d %d\n",now,last);
			pre++;
			while(pre<i) {
				cnt++,pre++;
				printf("%d %d\n",now,cnt);
			}
			last=now;
		}
	int now=last;
	while(cnt<n) printf("%d %d\n",now,++cnt);
	return 0;
}

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

void solve(std::string S){
    bool isGood = true;
    ll n = S.length();
    if(S.at(0)!='A') isGood = false;
    
    //* find C
    bool haveC=false;
    ll iC;
    for(ll i=2; i< n-1; i++){
        if(S.at(i)=='C') {
            haveC=true;
            iC = i;
            break;
        }
    }
    for(ll i=1; i< n; i++){
        if(i == iC) continue;
        else{
            if(S.at(i)>'z' || S.at(i)<'a') {
                isGood = false;
                break;
            }
        }
    }

    if(isGood && haveC) cout << "AC" << endl;
    else cout << "WA" << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string s;
  cin >> s;
  s.pop_back();
  for (; ; s.pop_back()) {
    if (s.size() % 2) continue;
    auto a = s.substr(0, s.size() / 2);
    auto b = s.substr(s.size() / 2);
    if (a == b) {
      cout << s.size() << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[n+1];
  int b[n+1];
  
  for(int i=1; i<=n-1; i++) cin >> b[i];
  
  a[1] = b[1];
  a[2] = b[1];
  
  for(int i=2; i<=n-1; i++)
  {
      a[i] = min(a[i],b[i]);
      a[i+1] = b[i];
  }

  int res = 0;

  for(int i=1; i<=n; i++){
      res += a[i];
  }

  cout << res << endl;

}  
  
  
  

Measured memory_bytes: 256
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const A = input[1].trim().split(' ').map(Number).sort((a, b) => b-a);

  let ret = 0;
  for(let i=0; i<N*2; i++){
    if((i-1)%2 === 0){
      ret += A[i];
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37588
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  int r,d,x;
  cin >> r >> d >> x;
  for(int i = 0; i < 10;i++){
    x = x * r - d;
    cout << x << endl;
  }
 
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

		int S, h, m, s;

		scanf("%d", &S);

		if (S >= 3600) {
			h = S / 3600;
			S -= 3600 * h;
		}

		if (S >= 60) {
			m = S / 60;
			S -= 60 * m;
		}

		s = S;

		printf("%d:%d:%d", h, m, s);

		printf("\n");

		return 0;
	}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vi> path(n);
  vector<bool> seen(n,false);
  vi mark(n,-1);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    path[a].push_back(b);
    path[b].push_back(a);
  }
  queue<int> q;
  q.push(0);
  mark[0] = 0;
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    seen[v] = true;
    for(auto nv : path[v]) {
      if(mark[nv]==-1) {
        q.push(nv);
        mark[nv] = v;
      }
    }
  }
  rep(i,n) if(mark[i]==-1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  rep(i,n-1) cout << mark[i+1]+1 << endl;
  return 0;
}

Measured memory_bytes: 10248
def main():
    H, W = list(map(int, input().split()))
    c = [input() for j in range(H)]
    from collections import deque
    que = deque()
    dist = [[-1]*W for i in range(H)]
    for h in range(H):
        for w in range(W):
            if c[h][w] == "#":
                que.append((h, w))
                dist[h][w] = 0
 
    def bfs():
        d = ((1, 0), (0, 1), (-1, 0), (0, -1))
        while que:
            # popleftにすれば、手の短い方が優先されているので、それで訪れられる所は全て確定でいい。
            # 探索するところが無くなるまで続ける。
            cy, cx = que.popleft()
            for dy, dx in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                ny, nx = cy+dy, cx+dx
                if 0 <= ny < H and 0 <= nx < W and dist[ny][nx] == -1 and c[ny][nx] == '.':
                    dist[ny][nx] = dist[cy][cx] + 1
                    que.append((ny, nx))
 
    bfs()
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, dist[h][w])
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 87132
import sys
b=list(input())
a=list(map(int,(list(b))))

def dfs(m,sum,op):
    if m ==3:
        if sum == 7:
            print(op+"=7")
            sys.exit()
        return()

    dfs(m+1,sum+a[m+1],op+"+"+str(a[m+1]))
    dfs(m+1,sum-a[m+1],op+"-"+str(a[m+1]))

dfs(0,a[0],str(a[0])) 
print("ng")

Measured memory_bytes: 3064
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
   IOS

  int n, k;
  cin >> n >> k;
  int a[n+1];
  for(int i = 1;i<=n;i++){
    cin >> a[i];
  }
  int l = 1, r= 1e9;
  while(l<r){
    int mid = (l+r)>>1;
    int sum = 0;
    for(int i = 1;i<=n;i++){
      sum += ((a[i]+mid - 1)/mid) - 1 ;
    }
    
    if(sum<=k) r = mid;
    else l = mid + 1;
  }
  cout << l<< endl;
    


  
  

 
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
#define fi first
#define se second
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const int N = 1e5 + 5;

int n, m;
ll a[N];

priority_queue <int> q;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    ll ans = 0;
    for(int i = 1; i <= n; i++) q.push(a[i]);
    for(int i = 1; i <= m; i++) {
        int now = q.top(); q.pop();
        q.push(now >> 1);
    }
    while(!q.empty()) {
        ans += q.top(); q.pop();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define ll long long
#define PI acos(-1)
#define INF 0x7f3f3f3f
#define L first
#define R second
#define pii  pair<int ,int>
#define pll  pair<long,long>
#define pb push_back
#define lowbit(x)  (x&-x)
#define fr(i,m,n) for( int i=m;i<n;++i)
#define fo(i,m,n) for(int i=m;i<=n;++i)
#define MM(a,b) memset(a,b,sizeof(a));
#define fin freopen("C:\\Users\\w\\Desktop\\ACM\\in.txt","r",stdin)
#define fot freopen("C:\\Users\\w\\Desktop\\ACM\\out.txt","w",stdout)
#define fcs fclose(stdin);fclose(stdout);


using namespace std;

inline void read(int&a){char ch;while(!(((ch=getchar())>='0')&&(ch<='9')));a=ch-'0';while(((ch=getchar())>='0')&&(ch<='9'))(a*=10)+=ch-'0';}

int main()
{
   int a,b,w;
   scanf("%d%d%d",&w,&a,&b);
   if(abs(b-a)-w>0) cout<<abs(a-b)-w<<endl;
   else cout<<0<<endl;
}













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

using namespace std;

int main(int argc, char const *argv[])
{
    unordered_set<string> words;
    vector<string> order;
    int n;
    cin >> n;
    bool flag = true;
    string word;
    cin >> word;
    order.push_back(word);
    words.insert(word);
    for (int i = 1; i < n; i++)
    {
        cin >> word;
        if(words.find(word) != words.end())
            flag = false;
        else if(word.at(0) != order[i-1].at(order[i-1].length()-1))
            flag = false;
        else
        {
            words.insert(word);
            order.push_back(word);
        }
        if(!flag)
            break;
    }
    if(flag)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  int D, T, S;
  cin >> D >> T >> S;
  cout << (T * S >= D ? "Yes" : "No") << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rep3(i, m, n) for(ll i=m;i<=(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1000000000000000000

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

// nCr
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// usage:
//   combination comb(n+5);
//   ans = comb(n,r);
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

void solve_abc_d() {
	ll n, m;
	ll l_ans = 0;

	cin >> n;

	combination comb(n + 5);

	mint ans = 0;
	ll red = 0;
	rep(i, n) {
		red = n - 2 * (i + 1);
		ans += comb(red - 1, i);
	}

	cout << ans.x << "\n";

	return;
}

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

	solve_abc_d();

	return 0;
}


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

signed main(){
	int X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
	vector<pair<int,int>> app(A+B+C);
	for(int i=0;i<A;i++){
		cin>>app[i].first;
		app[i].second=1;
	}
	for(int i=0;i<B;i++){
		cin>>app[i+A].first;
		app[i+A].second=2;
	}
	for(int i=0;i<C;i++){
		cin>>app[i+A+B].first;
		app[i+A+B].second=3;
	}
	sort(app.begin(),app.end());
	reverse(app.begin(),app.end());
	int tmp=X+Y,n=0,ans=0;
	while(tmp>0){
		if(app[n].second==1){
			if(X==0){n++; continue;}
			else{
				ans+=app[n].first;
				tmp--; X--;
			}
		}
		else if(app[n].second==2){
			if(Y==0){n++; continue;}
			else{
				ans+=app[n].first;
				tmp--; Y--;
			}
		}
		else if(app[n].second==3){
			ans+=app[n].first;
			tmp--;
		}
		n++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int a[10000],b[10000];
int main()
{
	int n,m;	//???????????° ??????????????????
	while(1){
		int NF[501] = {0};	//		?????????
		NF[1] = 1;	//???????????????	
		int tomo = 0;	//????????????????????°
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		for(int i=0;i<m;i++){
			cin >> a[i] >> b[i];
			if(a[i] == 1){
				tomo++;
				NF[b[i]] = 1;	//??????
			}
		}
		//cout << "-----------" << endl;
		for(int i=0;i<m;i++){
			//cout << a[i] << " " << b[i];
			if(NF[a[i]] == 1 && NF[b[i]] == 0){
				tomo++;
				NF[b[i]] = 2;	//???????????????
				//cout << "???";
			}
			if(NF[b[i]] == 1 && NF[a[i]] == 0){
				tomo++;
				NF[a[i]] = 2;
				//cout << "???";
			}
			//cout << endl;
		}
		cout << tomo << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
L=list(map(int,input().split()))
N=L[0]
K=L[1]
x=int((N-K+2)*((1+N)*(K+N+1)+2)/2-(N+1)*(N+2)*(2*N+3)/6+K*(K-1)*(2*K-1)/6)
print(x%(10**9+7))

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

long N;
vector<long> A;
unordered_map<int,int> mp;
void solve(){
    rep(i, N) {
        int a = A[i];
        int k = 2;
        while((k * k) < a) {
            if (a % k == 0) {
                mp[k]++;
                a /= k;
            }
            else {
                k++;
            }
        }
        if (a > 1) mp[a]++;

    }
    long ans = 0;
    for(auto itr = mp.begin(); itr != mp.end();itr++) {
        long sum = 0;
        int key = itr->first;
        rep(i, N) {
            if (A[i] % key == 0) {
                sum += (long) A[i];
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

    cin >> N;
    A = vector<long>(N);
    rep(i, N) {
        cin >> A[i];
    }
    
    solve();

    
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    rep(i, 105) {
        if (i>=a && i<b && i>=c && i<d) ans++;
    }
    

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


Measured memory_bytes: 3548
#include <stdio.h>

inline void pll(int a, int b){
    char c[14];
    c[13]=' ';
    int i=12;
    do{ c[i]=b%10+48; b/=10; i--; }while(b>0);
    c[i]=' '; i--;
    do{ c[i]=a%10+48; a/=10; i--; }while(a>0);
    if(__builtin_expect(stdout->_IO_write_ptr+14 >= stdout->_IO_write_end,0)){
        fflush_unlocked(stdout);
    }
    for(i++;i<14;i++){
        *stdout->_IO_write_ptr++ = c[i];
    }
}

static void solve(const int n, const int a, const int b, int mask, const int common){
    if(n==1){
        pll(common|a, common|b);
    }else{
        const int t = a^b;
        const int d = t&(-t);
        mask ^= d;
        const int aa = a & mask, ab = aa ^ (mask&(-mask));
        solve(n-1, aa, ab, mask, common|(a&d));
        solve(n-1, ab, b&mask, mask, common|(b&d));
    }
}

int main(void){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if(__builtin_parity(a)==__builtin_parity(b)){
        puts("NO");
    }else{
        puts("YES");
        solve(n, a, b, -1, 0);
    }
    return 0;
}


Measured memory_bytes: 896
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    a.sort()
    maa = max(a)

    pn = [0]*(2*maa+1)
    pn[0] = n
    pa = 0
    for i in a:
        for j in range(pa+1,i+1):
            pn[j] = pn[pa]
        pn[i+1] = pn[pa]-1
        pa = i+1

    l = 0
    r = 2*maa
    while l < r:
        mid = l+(r-l+1)//2
        nm = 0
        for i in a:
            if mid <= i:
                nm += n
            else:
                nm += pn[mid-i]
        if nm >= m:
            l = mid
        else:
            r = mid-1

    pt = [0]*(2*maa+1)
    pp = maa+1
    for i in a[::-1]:
        for j in range(pp-1,i,-1):
            pt[j] = pt[pp]
        pt[i] = pt[pp]+i
        pp = i
    for j in range(pp-1,-1,-1):
        pt[j] = pt[pp]

    ans = 0
    sm = 0
    for i in a:
        sm += pn[max(0,l-i)]
        ans += pt[max(0,l-i)]+pn[max(0,l-i)]*i
    print(ans-l*(sm-m))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 59808
#include <bits/stdc++.h>
#define endl    '\n'
using namespace std;

typedef long long ll;

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

    int a, b, c;

    cin >> a >> b >> c;

    if (a == 0 && b == 1 || b == 0 && c == 0) {
        cout << "Close";
    } else {
        cout << "Open";
    }
    cout << endl;

    return 0;
}




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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<int>B(N);
  for (int i = 0; i < N-1; i++) {
     B.at(i) = A.at(i+1)-A.at(i);
  }
  B.at(N-1)=A.at(0)+K-A.at(N-1);
  sort(B.begin(), B.end());
  cout << K-B.at(N-1) << endl;
  
}


Measured memory_bytes: 1792
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <queue>

using std::vector;
using std::priority_queue;
const int N = 100010;
int _w;

int n, deg[N], rt, pa[N], dep[N], vis[N];

struct Cmp {
	bool operator()( int a, int b ) const {
		return dep[b] > dep[a];
	}
};

priority_queue<int, vector<int>, Cmp> leaf;

namespace G {
	int head[N], nxt[N*2], to[N*2], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v ) {
		to[eid] = v, nxt[eid] = head[u], head[u] = eid++;
		to[eid] = u, nxt[eid] = head[v], head[v] = eid++;
	}
}

void dfs( int u, int fa, int d ) {
	using namespace G;
	pa[u] = fa, dep[u] = d;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( v == fa ) continue;
		dfs(v, u, d+1);
	}
}

bool check( int u ) {
	using namespace G;
	vis[u] = 1;
	int cnt = 0;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( vis[v] ) continue;
		--deg[v];
		if( deg[v] == 0 ) ++cnt;
		else if( deg[v] == 1 ) leaf.push(v);
	}
	return cnt >= 2;
}

int main() {
	_w = scanf( "%d", &n );
	G::init();
	for( int i = 0; i < n-1; ++i ) {
		int u, v;
		_w = scanf( "%d%d", &u, &v );
		G::link(u, v);
		++deg[u], ++deg[v];
	}
	if( n == 2 ) return puts("Second"), 0;
	for( int i = 1; i <= n; ++i )
		if( deg[i] != 1 ) {
			rt = i;
			break;
		}
	dfs(rt, 0, 1);
	for( int i = 1; i <= n; ++i )
		if( deg[i] == 1 )
			leaf.push(i);
	while( !leaf.empty() ) {
		int u = leaf.top();
		leaf.pop();
		if( check( pa[u] ) ) return puts("First"), 0;
	}
	return puts("Second"), 0;
}



Measured memory_bytes: 3964