akhauriyash/Code-Regression huggingface dataset:
s=[x for x in input()]
t=[x for x in input()]
s=sorted(s)
t=sorted(t,reverse=True)
s=''.join(s)
t=''.join(t)

ans=[]
ans.append(s)
ans.append(t)
ans.sort()

if s==t:
  print('No')
elif ans[0]==s:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9132
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == "__main__":
    k,n = list((map(int, input().split(' '))))
    a = list(map(int, input().split(' ')))
    # a = quick_sort
    result = 0
    for i in range(1,n):
        length = a[i]-a[i-1]
        result = max(length, result)
        
    length = a[0] + (k-a[n-1])
    result = max(result, length)
    print(k-result)
    





      
# for i in range(10):
#     print(i)
#     if i%5==4:
#         break

Measured memory_bytes: 26444
import copy

in_num = int(input())
in_prepared_list = list(map(int,input().split()))
in_criteria_list = list(map(int,input().split()))

# print(in_num)
# print(in_prepared_list)
# print(in_criteria_list)

# 準備合計より基準合計のほうが大きければ、試験には合格できない
prepared_sum = sum(in_prepared_list)
criteria_sum = sum(in_criteria_list)
diff = prepared_sum - criteria_sum
if diff < 0:
    print('-1')
    exit()

# 準備と基準の差分が大きいものから、不足分に配分していき、
# 合格できるポイントの最終的な配分数を出力する
# print(diff)
# print(in_prepared_list)
# print(in_criteria_list)

diff_list = []
for i in range(in_num):
    diff_list.append(in_prepared_list[i] - in_criteria_list[i])

# print(diff_list)
lower_diff_list = copy.copy(diff_list)
lower_diff_list.sort()
upper_diff_list = copy.copy(diff_list)
upper_diff_list.sort(reverse=True)

# print(lower_diff_list)
# print(upper_diff_list)

if lower_diff_list[0] >= 0:
    print('0')
    exit()

change_count = 0
low_index = 0
upp_index = 0
prev_diff = 0
for i in range(in_num):
    low = lower_diff_list[low_index]
    upp = upper_diff_list[upp_index]
    if low >= 0:
        change_count += 1
        print(change_count)
        exit()
    if prev_diff == 0:
        one_diff = low + upp
    elif prev_diff < 0:
        one_diff = upp + prev_diff
    else:
        one_diff = low + prev_diff

    # print(str(one_diff) + ':' + str(prev_diff))
    prev_diff = one_diff
    if one_diff == 0:
        low_index += 1
        upp_index += 1
        change_count += 2
    elif one_diff < 0:
        upp_index += 1
        change_count += 1
    else:
        low_index += 1
        change_count += 1

# print('error')

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }
  return x;

}

Node treeMaximum(Node x){

  while(x->right!=NIL){
    x=x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeSuccessor(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)
    y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }


}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

 
  return 0;
}



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

vector<vector<int> > mul_mat(const vector<vector<int> > &a, const vector<vector<int> > &b, int m)
{
	int n = a.size();
	vector<vector<int> > ret;

	ret.resize(n);
	for(int i = 0; i < n; ++i)
		ret[i].resize(n);

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			ret[i][j] = 0;
			for(int k = 0; k < n; ++k)
				ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % m;
		}
	}

	return ret;
}

vector<vector<int> > pow_mat(const vector<vector<int> > &mat, int k, int m)
{
	int n = mat.size();
	vector<vector<int> > ret, x = mat;

	ret.resize(n);
	for(int i = 0; i < n; ++i)
		ret[i].resize(n, 0);

	for(int i = 0; i < n; ++i)
		ret[i][i] = 1;

	for(int bit = 0; bit < 31; ++bit, x = mul_mat(x, x, m)) {

		if((k & (1 << bit)) == 0)
			continue;
		ret = mul_mat(ret, x, m);
	}

	return ret;
}

int main()
{
	while(true) {

		int n, m, a, b, c, t;
		vector<int> s;

		scanf("%d%d%d%d%d%d", &n, &m, &a, &b, &c, &t);

		if(n == 0)
			break;

		s.resize(n);
		for(int i = 0; i < n; ++i)
			scanf("%d", &s[i]);

		vector<vector<int> > mat;

		mat.resize(n);
		for(int i = 0; i < n; ++i)
			mat[i].resize(n);

		for(int i = 0; i < n; ++i) {
			if(i - 1 >= 0) mat[i][i - 1] = a;
			if(i + 1 < n) mat[i][i + 1] = c;
			mat[i][i] = b;
		}

		vector<vector<int> > x = pow_mat(mat, t, m);
		vector<int> ans(n);

		for(int i = 0; i < n; ++i) {
			ans[i] = 0;
			for(int j = 0; j < n; ++j)
				ans[i] = (ans[i] + x[i][j] * s[j]) % m;
		}

		for(int i = 0; i < n; ++i)
			printf("%d%c", ans[i], i < n - 1 ? ' ' : '\n');
	}

	return 0;
}

Measured memory_bytes: 1116
import fractions
N = int(input())
A = list(map(int, input().split()))
max_val = 0
#i番目を消すとするとR[i+1]とL[i-1]のgcdが答え
L = [0] * N
R = [0] * N
for i in range(N-1):
    L[i+1] = fractions.gcd(L[i], A[i])
for i in range(N-1, 0, -1):
    R[i-1] = fractions.gcd(R[i], A[i])
#R.reverse()
for i in range(N):
    max_val = max(max_val, fractions.gcd(L[i], R[i]))


print(max_val)

Measured memory_bytes: 16148
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


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-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;

int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };
char A[1010][1010];

void solve() {
	int H, W; cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
		}
	}
	REP(i, H) {
		REP(j, W) {
			if (A[i][j] == '#') {
				bool ok = false;
				REP(k, 4) {
					int x = i + dx[k], y = j + dy[k];
					if (x < 0 || x >= H || y < 0 || y >= W)continue;
					if (A[x][y] == '#')ok = true;
				}
				if (!ok) {
					print("No"); return;
				}
			}
		}
	}
	print("Yes");
}

signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



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

typedef long double db;
const int N = 1005;
db dis[N];

struct circle { int x, y, r; } p[N];
db distance(circle a, circle b) {
	int x = a.x - b.x, y = a.y - b.y;
	db dis = std::sqrt((db) x * x + (db) y * y);
	return std::max(dis - a.r - b.r, (db) 0);
}

bool vis[N];
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	int x, y, n; std::cin >> p[0].x >> p[0].y >> x >> y >> n;
	++n, p[n].x = x, p[n].y = y;
	for (int i = 1; i < n; ++i)
		std::cin >> p[i].x >> p[i].y >> p[i].r;
	for (int i = 1; i <= n; ++i) dis[i] = 1e10;
	for (int t = 0; t <= n; ++t) {
		int min = -1;
		for (int i = 0; i <= n; ++i)
			if (!vis[i] && (min == -1 || dis[i] < dis[min])) min = i;
		vis[min] = 1;
		for (int i = 0; i <= n; ++i)
			if (!vis[i]) dis[i] = std::min(dis[i], dis[min] + distance(p[min], p[i]));
	}
	std::cout << std::fixed << std::setprecision(18) << dis[n] << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        boolean b = true;
        for (int i=0;i<n;i++){
            b&=s.charAt(i)==s.charAt(n-1-i);
        }
        for (int i=0;i<(n-1)/2;i++){
            b&=s.charAt(i)==s.charAt((n-1)/2-1-i);
        }
        for (int i=(n+3)/2-1;i<n;i++){
            b&=s.charAt(i)==s.charAt(n-1-i+(n+3)/2-1);
        }
        if (b)System.out.println("Yes");
        else System.out.println("No");
    }
    static long factorial(long num){
        if (num<2)return 1;
        else return num*factorial(num-1);
    }
    static int arraySum(int[] array){
        int ans = 0;
        for (int value : array) ans += value;
        return ans;
    }
    static long combination(long a, long b){
        long data = 1;
        for (int i=0;i<b;i++){
            data*=a-i;
        }
        return data/factorial(b);
    }
    static double log(double base,double antilogarithm){
        return Math.log(antilogarithm)/Math.log(base);
    }

    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long lcm(long x,long y){
        return x/gcd(x,y)*y;
    }

}


Measured memory_bytes: 35528
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i) cin >> a[i];
	sort(a.begin(),a.end(),greater<int>());
	long long ans=a[0];
	for(int i=2; i<n; ++i){
		ans += a[i/2];
	}
	cout << ans << endl;
}


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

using namespace std;

#define K 501
#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define pb push_back

int n, m;

int oc = 0;
int a[K];

vector<int> sol;

void solveE() {
	if (oc > 2) {
		puts("Impossible");
		return;
	}
	
	if (oc == 0) {
		sol.pb(1);
	
		FOE(i, 1, m) printf("%d%c", a[i], (i == m ? '\n': ' '));
		FOE(i, 1, m) {
			if (i != m) sol.pb(a[i]);
			else if (a[i] >= 2) sol.pb(a[i] - 1);	
		}
		printf("%d\n", sol.size());
		
		for (int i = 1; i <= sol.size(); i++) {
			printf("%d%c", sol[i - 1], (i == sol.size() ? '\n': ' '));	
		}
	} else {
		int good1 = -1, good2 = -1;
		
		FOE(i, 1, m) {
			if (a[i] % 2 == 1) {
				if (good1 == -1) good1 = i;
				else good2 = i;
			}
		}
		
		int t = a[1]; a[1] = a[good1]; a[good1] = t;
		t = a[m]; a[m] = a[good2]; a[good2] = t;
	
		FOE(i, 1, m) printf("%d%c", a[i], (i == m ? '\n': ' '));
	
		FOE(i, 1, m) {
			if (i == 1) {
				if (a[1] > 1) sol.pb(a[1] - 1);
			} else if (i == m) {
				sol.pb(a[m] + 1);	
			} else {
				sol.pb(a[i]);	
			}
		}
		printf("%d\n", sol.size());
		
		for (int i = 1; i <= sol.size(); i++) {
			printf("%d%c", sol[i - 1], (i == sol.size() ? '\n': ' '));	
		}
	}
}

void solveO() {
	if (oc > 1) {
		puts("Impossible");
		return;
	}	
	
	if (n == 1) {
		puts("1\n1\n1\n");
		return;	
	}
	
	int good = 0;
	
	FOE(i, 1, m) if (a[i] % 2) good = i;
	
	int t = a[m]; a[m] = a[good]; a[good] = t;
	
	FOE(i, 1, m) printf("%d%c", a[i], (i == m ? '\n': ' '));
	
	int items = m + (a[m] != 1);
	
	printf("%d\n", items);
	
	int left = n;
	
	FOE(i, 1, items) {
		if (i == 1) {
			printf("%d", 1);
			left--;	
		} else if (i != items) {
			printf("%d", a[i - 1]);
			left -= (a[i - 1]);
		} else {
			printf("%d", left);	
		}
		
		if (i != items) printf(" ");
		else puts("");
	}
}

int main() {
	scanf("%d%d", &n, &m);
	
	FOE(i, 1, m) {
		scanf("%d", &a[i]);
		
		if (a[i] % 2) oc++;
	}
	
	if (n % 2 == 0) {
		solveE();
	} else {
		solveO();	
	}
}

Measured memory_bytes: 256
s = input()
ans = 0
n = len(s)
m = n-1
t= s
for mask in range(0 , (1<<(n))):
	res=0
	cur=0
	for j in range(0 , n):
		if mask&(1<<j):
			res = res+cur
			cur = (ord(t[j])-ord('0'))
		else:
			cur = cur*10+(ord(t[j])-ord('0'))
	#print(res+cur)
	ans = ans+res+cur
print(ans//2)

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

int main(){
  int n,m,x;
  cin >>n >>m >>x;
  int a[12][12];
  vector<int> c(n);
  rep(i,n){
    cin >>c[i];
    rep(j,m) cin >>a[i][j];
  }
  int ans = 100100100;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i&1){
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) {
      if(d[j]<x) ok = false;
    }
    if(ok) ans = min(ans, cost);
  }
  if(ans==100100100) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

int main()
{
    int n;
    long long m;
    cin >> n >> m;
    vector<long long> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    vector<long long> dp(2, -INF);
    dp[0] = 0;
    for(int i=40; i>=0; --i){
        vector<long long> nextDp(2, -INF);
        int cnt = 0;
        for(int j=0; j<n; ++j){
            if(a[j] & (1LL << i))
                ++ cnt;
        }
        for(int j=0; j<2; ++j){
            for(int x=0; x<2; ++x){
                if(j == 0 && x == 1 && !(m & (1LL << i)))
                    continue;
                int k = j;
                if(x == 0 && (m & (1LL << i)))
                    k = 1;
                nextDp[k] = max(nextDp[k], dp[j] + (1LL << i) * (x ? n - cnt : cnt));
            }
        }
        dp = move(nextDp);
    }
    long long ans = *max_element(dp.begin(), dp.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int, input().split()))
q=int(input())

for i in range(q):
    b,e,t=map(int, input().split())
    if t>b:
        a=a[:b]+a[t:t+e-b]+a[e:t]+a[b:e]+a[t+e-b:]
    else:
        a=a[:t]+a[b:e]+a[t+e-b:b]+a[t:t+e-b]+a[e:]
print(*a)


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

vector<int> smallest_prime_factors(int n){

    vector<int> spf(n+1);
    for (int i=0;i<=n;i++)spf[i]=i;
    for (int i=2;i*i<=n;i++){
        // 素数だったら
        if (spf[i]==i){
            for (int j=i*i;j<=n;j+=i){
                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j]==j) {
                    spf[j]=i;
                }
            }
        }
    }
    return spf;
}

vector<int> factolization(int x, vector<int> &spf) {
    vector<int> ret;
    while (x!=1) {
        ret.push_back(spf[x]);
        x/=spf[x];
    }
    sort(ret.begin(),ret.end());
    ret.erase(unique(ret.begin(),ret.end()),ret.end());
    return ret;
}

int N;
bool used[1000005];

bool pairwise_coprime=true;
bool setwise_coprime=true;

signed main(){
    cin>>N;
    auto spf=smallest_prime_factors(1000000);
    int g;
    for(int i=0;i<N;++i){
        int a;
        cin>>a;
        auto res=factolization(a,spf);
        for(auto z:res){
            if(used[z])pairwise_coprime=false;
            used[z]=true;
        }
        if(i==0)g=a;
        else g=__gcd(a,g);
    }
    if(pairwise_coprime)cout<<"pairwise coprime"<<endl;
    else if(g==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}

Measured memory_bytes: 12056
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>
#include <wchar.h>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

int main(){
    int N,M,K,count=0;
    cin>>N>>M;
    map<int,int> A;
    rep(i,N){
        cin>>K;
        rep(j,K){
            int num;
            cin>>num;
            A[num]++;
        }
    }
    for(auto x:A){
        if(x.second==N){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#二分ヒープ
class BinaryHeap
  def initialize(a, &b)
    @heap = a
    @size = a.size
    #ex) |parent, child| parent <= child
    @b = b
  end
  def change
    me = 0
    x = @heap[0] / 2
    while me < @size do
      child = (me << 1) + 1
      break if child >= @size
      if (child + 1) < @size && @b.call(@heap[child + 1], @heap[child]) then
        child += 1
      end
      break if @b.call(x, @heap[child])
      @heap[me] = @heap[child]
      me = child
    end
    @heap[me] = x
  end
  def inject
    @heap.inject(&:+)
  end
end

N, M = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

A.sort!.reverse!
bh = BinaryHeap.new(A){|parent, child| parent >= child}
M.times{ bh.change}

puts bh.inject


Measured memory_bytes: 10496
//============================================================================
// Name        : abc105-a.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

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

	cout << ((N%K==0) ? 0 : 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,s;
    cin>>n>>s;
    if(n==s){
        for(int i=0;i<s;i++){cout<<n;}
        cout<<endl;
    }else if(n>s){
        for(int i=0;i<n;i++){cout<<s;}
        cout<<endl;
    }else{
        for(int i=0;i<s;i++){cout<<n;}
        cout<<endl;
    }
}




Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc104_c(){
    //入力
    string s,t;
    cin >> s >> t;
    bool ans = false;
    
    //処理
    if(s==t) ans = true;
    REP(i,s.length()){
        string news(s);
        news[0] = s[s.length()-1];
        for(int j=1 ; j<s.length() ; ++j){
            news[j] = s[j-1];
        }
        s = news;
        if(s==t) ans = true;
    }
    
    //出力
    if(ans) cout << "Yes" << enter;
    else cout << "No" << enter;
    return 0;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{	int i=0;
	char s[2];
	char a[] = "abcdefghijklmnopqrstuvwxyz";
	scanf("%s",s);
	
	for(i=0; i<25; i++){
		if(s[0]==a[i]){
			printf("%c",a[i+1]);

			return 0;
		}
	}
	

	return 0;
}

Measured memory_bytes: 1660
s = input()
k = int(input())
lis = list()
for i in range(len(s)):
    for j in range(i+1, i+6):
        if s[i:j] not in lis:
            lis.append(s[i:j])
lis = list(set(lis))
lis.sort()
print(lis[k-1])

Measured memory_bytes: 4584
// AOJ 3045 Painting
// 2019.8.13 bal4u

#include <stdio.h>

typedef long long ll;

//// 入出力関係
#if 1
#define gc() getchar_unlocked()
#define pc(x) putchar_unlocked(x)
#else
#define gc() getchar()
#define pc(x) putchar(x)
#endif

int in() { // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(ll n) { // 非負整数の表示（出力）
	int i; char b[50];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

#define HASHSIZ 1000003 
typedef struct { ll k, id; } HASH;
HASH hash[HASHSIZ+5], *hashend = hash + HASHSIZ;

int insert(int d, int b, int id) {
	ll k = ((ll)d << 17) | b;
	HASH *p = hash + (int)(k % HASHSIZ);
	while (p->k) {
		if (p->k == k) return p->id;
		if (++p == hashend) p = hash;
	}
	p->k = k, p->id = id;
	return -1;
}

//// 本問題関連
typedef struct { int d, b, f; } T;
T tbl[100005]; int sz;
ll x[100005]; int w;
ll base;

int main()
{
	int i, j, a, b, N, M;

	N = in(), M = in();
	for (i = 0; i < M; i++) {
		a = in(), b = in();
		if (b == 1) continue;
		base += a, w++;
		if (b-a > N) continue;
		if ((j = insert(b-a, b, sz)) >= 0) tbl[j].f++;
		else tbl[sz].d = b-a, tbl[sz].b = b, tbl[sz++].f = 1;
	}
	for (i = 0; i < sz; i++) {
		for (j = tbl[i].d; j <= N; j += tbl[i].b) x[j] -= (ll)tbl[i].f * tbl[i].b;
	}
	for (i = 1; i <= N; i++) {
		x[i] += x[i-1] + w;
		out(x[i] + base);
	}
	return 0;
}



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

int main() {
    int N, Y;
    cin >> N >> Y;
    int x = -1, y = -1, z = -1;

    for (int i = 0; i <= N; ++i) {
        bool solve = false;
        for (int j = 0; i + j <= N; ++j) {
            int k = N - i - j;
            if (10000 * i + 5000 * j + 1000 * k == Y) {
                x = i;
                y = j;
                z = k;
                solve = true;
                break;
            }
        }
        if (solve) break;
    }

    cout << x << ' ' << y << ' ' << z << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n, t;
  cin >> n >> t;
  ll a[n];
  for (ll i = 0; i < n; i++) cin >> a[i];
  ll time = 0;
  for (ll i = 0; i < n - 1; i++) {
    if (a[i + 1] - a[i] >= t)
      time += t;
    else
      time += a[i + 1] - a[i];
  }
  time += t;
  cout << time << endl;
  return 0;
}

Measured memory_bytes: 1792
H, W, M, *hw = map(int, open(0).read().split())
H_cnt = [0] * (H + 1)
W_cnt = [0] * (W + 1)
bombs = [(h, w) for h, w in zip(*[iter(hw)] * 2)]
for h, w in bombs:
    H_cnt[h] += 1
    W_cnt[w] += 1

H_max_cnt = max(H_cnt)
W_max_cnt = max(W_cnt)

comb_cnt = H_cnt.count(H_max_cnt) * W_cnt.count(W_max_cnt)
for h, w in bombs:
    if H_cnt[h] == H_max_cnt and W_cnt[w] == W_max_cnt:
        comb_cnt -= 1

ans = H_max_cnt + W_max_cnt
print(ans if comb_cnt else ans - 1)


Measured memory_bytes: 77808
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const int N = 200000 + 500;

LL tree[4 * N];

void update(int node, int l, int r, int where, LL what)
{
	if (l > r) return ;
	if (l > where || r < where) return ;
	if (l == r){
		tree[node] = what;
		return ;
	}
	int mid = (l + r) / 2;
	update(node + node, l, mid, where, what);
	update(node + node + 1, mid + 1, r, where, what);
	tree[node] = max(tree[node + node], tree[node + node + 1]);
}

LL query(int node, int l, int r, int a, int b)
{
	if (l > r || a > b || l > b || r < a) return 0;
	if (a <= l && r <= b) return tree[node];
	int mid = (l + r) / 2;
	return max(query(node + node, l, mid, a, b), query(node + node + 1, mid + 1, r, a, b));
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin >> n;
    pair<LL,pair<LL,LL> > arr[n + 1];

    for (int i = 1; i <= n; i++){
    	cin >> arr[i].fi;
    
    	arr[i].se.se = i;
    }

    for (int i = 1; i <= n; i++) 	cin >> arr[i].se.fi;

    sort(arr + 1, arr + n + 1);
    LL ans = 0;
    for (int i = 1; i <= n; i++){
    	LL temp = query(1, 1, n, 1, arr[i].se.se);
    //	cout << i << " " << temp << endl;
    	temp += arr[i].se.fi;
    	ans = max(ans, temp);
    	update(1, 1, n, arr[i].se.se, temp);
    }

    cout << ans << endl;

	return 0;
}

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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (line[0] == line[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.Write("No");
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;
#define rep(i,s,n)for(ll i = s;i<n;i++)

char s[Z];
int main() {
	cin >> s;
	int i = 0;
	while (s[i++] != '\0');
	cout << s[0] << i - 3 << s[i - 2] << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a;
	if(a%2==1){
            b=a/2;
    cout<<b*(b+1)<<endl;
	}
	else {
            b=a/2;
            cout<<b*b<<endl;}
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define poly vector<ll>
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void wri(ll a){write(a); putchar(' ');}
inline void writeln(ll a){write(a); puts("");}
const int N=200005;
const ll inf=1e18;
vector<int> v[N];
poly me(poly a,poly b){
	int n=a.size(),m=b.size(),i=0,j=0;
	poly c(n+m-1);
	while(i<n&&j<m){
		c[i+j]=a[i]+b[j];
		if((i+1<n&&(j+1==m||a[i+1]+b[j]>a[i]+b[j+1])))i++; else j++;
	}
	return c;
}
poly operator +(poly a,poly b){
	poly A[2],B[2];
	for(int i=0;i<2;i++){
		for(unsigned j=i;j<a.size();j+=2)A[i].push_back(a[j]);
		for(unsigned j=i;j<b.size();j+=2)B[i].push_back(b[j]);
	}
	poly ans(a.size()+b.size()-1);
	for(auto &i:ans)i=-inf;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			poly c=me(A[i],B[j]);
			for(unsigned k=0;k<c.size();k++){ ans[k*2+i+j]=max(ans[k*2+i+j],c[k]); }
		}
	}
	return ans;
}
poly solve(int l,int r){
	if(l==r){
		sort(v[l].begin(),v[l].end()); 
		int m=v[l].size(); poly ans(m+1);
		for(int i=1;i<=m;i++)ans[i]=ans[i-1]+v[l][m-i];
		ans[1]=-inf; //cout<<l<<" fjzzq "<<ans.size()<<endl;
		return ans;
	}
	int mid=(l+r)>>1;
	return solve(l,mid)+solve(mid+1,r);
}
signed main(){
	int n=read(),k=read();
	for(int i=1;i<=n;i++){
		int c=read(),w=read();
		v[c].push_back(w);
	}
	poly ans(n+1);
	for(auto &i:ans)i=-inf;
	for(int i=1;i<=2;i++){
		for(int i=1;i<=k;i++)swap(v[i],v[((ll)rand()<<15^rand())%i+1]);
		poly zs=solve(1,k);
		for(int i=1;i<=n;i++)ans[i]=max(ans[i],zs[i]);
	}
	for(int i=1;i<=n;i++){
		if(ans[i]<0)puts("-1");
		else writeln(ans[i]);
	}
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



i64 n, k, d;
void solve(){
	cin >> n >> k >> d;
	
	if(k > abs(n/d)){
		k -= abs(n/d);
		n %= d;
		k %= 2;
		if(k) cout << abs(abs(n)-d) << endl;
		else cout << abs(n) << endl;
	}
	else if(n < 0){
		cout << abs(n+k*d) << endl;
	}
	else{
		cout << n-k*d << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define f(i,n)   for(int i=0;i<n;i++)
#define tsolve() int t; cin>>t; while(t--) solve();
#define all(s)  s.begin(),s.end()
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>  
int main(){
    int n;
    cin>>n;
    if(n==1)        cout<<"Hello World";
    else if(n==2){
        int a,b;
        cin>>a>>b;
        cout<<a+b;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		int value = ((S[i] - 'A') + N) % 26 + 'A';
		cout << static_cast<char>(value);
	}

	return 0;
}


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

typedef long long ll;
const ll MOD = 1e9+7;



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,h,w;

    cin>>n>>h>>w;

    cout<<(n-h+1)*(n-w+1);

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    string s, t; cin >> s >> t;
    int sl = s.size();
    int tl = t.size();
    int ans = 2000;
    rep(i, sl-tl+1) {
        int c = 0;
        rep(j, tl) {
            if (s[i+j] != t[j]) ++c;
        }
        ans = min(ans, c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<functional>
using namespace std;
int main(void)
{
	int a[4],b[2],min=101,min2=101,sum=0,sum2=0,i;
	for(i=0;i<4;i++) {
		scanf("%d",&a[i]);
		sum+=a[i];
		if(min>a[i]) min=a[i];
	}
	for(i=0;i<2;i++) {
		scanf("%d",&b[i]);
		sum2+=b[i];
		if(min2>b[i]) min2=b[i];
	}
	printf("%d\n",(sum-min)+(sum2-min2));
	return 0;
}
	
		

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define MAX_N (ll)23200
using namespace std;
typedef long long ll;
ll dp[1005][MAX_N+1],n;
 
struct node{
	ll w,s,v,indx;
};
node arr[100005];
bool cmp(node a,node b){
	return a.w+a.s>b.s+b.w;
}
 
ll rec(ll i,ll k){
 
	
	if(i==n+1){
		return 0;
	}
	if(dp[i][k]!=-1){
		return dp[i][k];
	}
	    ll ans=rec(i+1,k);
	    
    if(k-arr[i].w>=0){
    	ll x=min(k-arr[i].w,arr[i].s);
    	ans=max(ans,rec(i+1,x)+arr[i].v);
    }	
    
    return dp[i][k]=ans;
 
}
 
int main() {
	
	ll i,j;
	
	cin>>n;
 
	for(i=1;i<=n;i++){
			
		cin>>arr[i].w>>arr[i].s>>arr[i].v;
		arr[i].indx=i;
		
	}

	
   sort(arr+1,arr+n+1,cmp);
	
   for(i=0;i<=n;i++){
   	for(j=0;j<=MAX_N;j++){
   		dp[i][j]=-1;
   	}
   }
   
ll ans=rec(1,MAX_N);
 
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 182784
import bisect
n,x=map(int,input().split())
L=list(map(int,input().split()))
a=[0]*(n+1)
for i in range(1,n+1):
    a[i]=a[i-1]+L[i-1]
for i in range(n+1):
    if x==a[i]:
        print(bisect.bisect_right(a,x))
        exit()
print(bisect.bisect_left(a,x))


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T;
	if(S==T) cout<<"H"<<endl;
	else cout<<"D"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

using namespace std;

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

    vector<char> A(N);
    bool only = true;
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        if(i>0 && A.at(i)!=A.at(i-1))only = false;
    }
        
    if(only){
        cout << 0 << endl;
        return 0;
    }

    int posR = N-1;
    int posW = 0;
    int res = 0;
    while(true){
        while(posR > 0 && A.at(posR) != 'R')posR--;
        while(posW < N && A.at(posW) != 'W')posW++;

        if(posR > posW){
            A.at(posR) = 'W';
            A.at(posW) = 'R';
            res++;
        }else{
            break;
        }
    }

    cout << res << endl;
    
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  if (S == "Sunny") cout << "Cloudy" << '\n';
  if (S == "Cloudy") cout << "Rainy" << '\n';
  if (S == "Rainy") cout << "Sunny" << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (int i = 0; i < v.size(); ++i) {
        if(i) os << ",";
        os << v[i];
    }
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s += 'x';
    vector<pair<int, int>> v;
    int l = 0, r = 0;
    while(l < n && r < n){
        while(s[l] == s[r]) r++;
        v.emplace_back(l, r);
        l = r;
    };
    int ans = 0;
    int c = 0, p = 0; l = 0;
    for (int i = 0; i < v.size(); ++i) {
        if(s[v[i].first] == '0') c++;
        p += v[i].second-v[i].first;
        if(c > k) {
            if(s[v[l].first] == '1'){
                p -= v[l].second - v[l].first;
                l++;
            }
            p -= v[l].second - v[l].first;
            l++;
            c--;
        }
        ans = max(ans, p);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
long long sm[100005],sum=0,sm2=1e16,ans=0;
int a[100005],b[100005],d[100005],x[100005],y[100005];
int main()
{
	int z,s,c;
	cin>>z>>s>>c;
	for(int i=0;i<z;i++)
		cin>>a[i];
	for(int i=0;i<s;i++)
		cin>>b[i];
	for(int i=0;i<c;i++)
	{
		cin>>x[i]>>y[i]>>d[i];
		x[i]--;
		y[i]--;
	}	
	int smalla=1e8;
	int smallb=1e8;
	for(int i=0;i<z;i++)
	{
		smalla=min(smalla,a[i]);
	}
	for(int i=0;i<s;i++)
	{
		smallb=min(smallb,b[i]);
	}
	sum=smalla+smallb;
	for(int i=0;i<c;i++)
	{
		sm[i]=a[x[i]]+b[y[i]]-d[i];
	}
	for(int i=0;i<c;i++)
	{
		sm2=min(sm[i],sm2);
	}
	ans=min(sum,sm2);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2944
a, b = map(int, input().split())
#greatest commmon divisor(gdc)を定義する
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
#least common multiple (lcm)を定義する
def lcm(a,b):
    return (a*b)// gcd(a, b)

print(lcm(a,b))
    


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int a,b;
    cin >> a >>b;
    for(int i=1;i<=10000;i++){
        double che=i*0.08,chee=i*0.1;
        ll aa = che,bb=chee;
        if(aa==a&&bb==b){
            cout << i<<endl;
            return 0;
        }
    }
    cout << -1<<endl;
}
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s=0;
  	int a[3];
  	for(int i=0;i<3;i++) {
      cin>>a[i];
      s+=a[i];
    }
  	int k;
  	cin>>k;
  	sort(a,a+3);
  	cout<<s-a[2]+pow(2,k)*a[2];
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	string N;
	cin >> N;

	int S = 0;
	for (int i = 0; i < N.length(); i++) {
		S += stoi(N.substr(i, 1));
	}

	if (stoi(N) % S == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  for(int i = 7; i >= 0; --i)
  {
    if ((1 << i) <= n)
    {
      cout << (1 << i);
      return;
    }
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main() {
  int N; cin >> N;
  int a[100000]={}, b[100001][2]={};
  for(int i=0; i<N; i++) cin >> a[i];
  
  sort(a, a+N);
  
  int cnt=0;
  for(int i=0; i<N; i++){
    if(a[i]==b[cnt][0]){
      b[cnt][1]++;
    }else{
      cnt++;
      b[cnt][0]=a[i];
      b[cnt][1]=1;
    }
  }
  
  int res=0;
  for(int i=1; i<=cnt; i++){
    if(b[i][0]>b[i][1]){
      res+=b[i][1];
    }else{
      res+=(b[i][1]-b[i][0]);
    }
  }
  cout << res << endl;
  
}

Measured memory_bytes: 1408
from heapq import *
from itertools import *


def Dijkstra(G: list, source=0):
	INF = float("inf")
	V = len(G)
	D = [INF] * V
	D[source] = 0
	vis = [False] * V
	H = [(0, source)]
	while H:
		dist, cur = heappop(H)
		if vis[cur]:
			continue
		vis[cur] = True
		for nxt, cost in G[cur]:
			t = dist + cost
			if D[nxt] > t:
				D[nxt] = t
				heappush(H, (t, nxt))
	return D


n, m, s, t, *L = map(int, open(0).read().split())
yen = [[] for _ in range(n)]
snuuk = [[] for _ in range(n)]
for u, v, a, b in zip(*[iter(L)] * 4):
	u -= 1
	v -= 1
	yen[u].append((v, a))
	yen[v].append((u, a))
	snuuk[u].append((v, b))
	snuuk[v].append((u, b))
stoi = Dijkstra(yen, s - 1)
ttoi = Dijkstra(snuuk, t - 1)
rest = [10 ** 15 - x - y for x, y in zip(stoi, ttoi)]
ans = list(accumulate(rest[::-1], max))[::-1]
print(*ans)


Measured memory_bytes: 92192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count = 0;
  cin >> N;
  
  for(int i = 1; i <= N; i++){
    count += (int)(N/i);
    if(i*(int)(N/i) == N)count--;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_D 3
#define MAX_N 9
#define MAX_C 362880
int fact1[MAX_N][MAX_N][MAX_N][MAX_N][MAX_N][MAX_N][MAX_N][2];
vector<int> fact2[MAX_C]; int MAP[MAX_D][MAX_D]; int DP[MAX_C], K;
void FACT() {
	int a[MAX_N]; for (int i = 0; i < MAX_N; i++) { a[i] = i; }int cnt = 0;
	do {
		if (a[MAX_N - 2] < a[MAX_N - 1]) { fact1[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]][0] = cnt; }
		else { fact1[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]][1] = cnt; }
		vector<int>vec; for (int i = 0; i < MAX_N; i++) { vec.push_back(a[i]); }fact2[cnt] = vec; cnt++;
	} while (next_permutation(a, a + MAX_N));
}
int main() {
	for (int i = 0; i < MAX_D; i++) {
		for (int j = 0; j < MAX_D; j++) { cin >> MAP[i][j]; }
	}FACT(); for (int i = 0; i < MAX_C; i++) { DP[i] = MAX_C; }
	int T = fact1[1][2][3][4][5][6][7][1];
	if (MAP[2][1] < MAP[2][2]) { K = fact1[MAP[0][0]][MAP[0][1]][MAP[0][2]][MAP[1][0]][MAP[1][1]][MAP[1][2]][MAP[2][0]][0]; }
	else { K = fact1[MAP[0][0]][MAP[0][1]][MAP[0][2]][MAP[1][0]][MAP[1][1]][MAP[1][2]][MAP[2][0]][1]; }DP[K] = 0;
	while (DP[T] == MAX_C) {
		for (int i = 0; i < MAX_C; i++) {
			if (DP[i] >= MAX_C) { continue; }vector<int>X = fact2[i]; int y[MAX_D][MAX_D], z[MAX_D][MAX_D], cx, cy; int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
			for (int j = 0; j < X.size(); j++) { y[j / 3][j % 3] = X[j]; if (X[j] == 0) { cx = j / 3; cy = j % 3; } }
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < MAX_N; k++) { z[k / 3][k % 3] = y[k / 3][k % 3]; }int ex = cx + dx[j], ey = cy + dy[j];
				if (ex >= 3 || ex <= -1 || ey >= 3 || ey <= -1) { continue; } swap(z[cx][cy], z[ex][ey]);
				if (z[2][1] < z[2][2]) { K = fact1[z[0][0]][z[0][1]][z[0][2]][z[1][0]][z[1][1]][z[1][2]][z[2][0]][0]; }
				else { K = fact1[z[0][0]][z[0][1]][z[0][2]][z[1][0]][z[1][1]][z[1][2]][z[2][0]][1]; }DP[K] = min(DP[K], DP[i] + 1);
			}
		}
	}
	cout << DP[T] << endl;
	return 0;
}

Measured memory_bytes: 65324
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	vi A575 = { 5,5,7 };
	vi ABC(3);
	REP(i, 3)ABC[i] = IN();
	sort(ALL(ABC));
	YESNO(A575 == ABC);
	return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int count=0,i=0,half,hantei=0;

	while (s[i] != '\0')//文字列の終わりまで繰り返す
	{
		count++;
		i++;
	}

	count--;

	while (count > 1)
	{
		if (count % 2 == 0)
		{
			half = count / 2;
			hantei = 0;

			for (int j = 0;j < count/2 ;j++)
			{
				if (s[j] != s[half]) hantei = 1;

				half++;
			}

			if (hantei == 0)
			{
				cout << count << endl;
				hantei = -1;
			}

		}

		count--;
		if (hantei == -1) break;
	}

	return 0;
}

Measured memory_bytes: 256