akhauriyash/Code-Regression huggingface dataset:
import sys
from functools import lru_cache


@lru_cache(maxsize=None)
def alg_memoization_recursion(n):
    if n == 1:
        return 1
    else:
        return alg_memoization_recursion(n // 2) + alg_memoization_recursion(n // 2) + 1


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h = int(input().rstrip('\n'))
    print(alg_memoization_recursion(h))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int gcd(int a, int b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}

int main() {
  int n, k;
  cin >> n >> k;
  int all_gcd;
  int max_num = 0;
  REP(i, n) {
    int t;
    cin >> t;
    if (i == 0) {
      all_gcd = t;
    } else {
      all_gcd = gcd(all_gcd, t);
    }
    max_num = max(max_num, t);
  }
  if (k % all_gcd == 0 && k <= max_num) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
from itertools import accumulate


N = int(input())
A = list(map(int, input().split()))
MOD = 1_000_000_007
acc = list(accumulate(A, initial=0))

ans = 0
for i in range(N):
    ans += A[i] * (acc[N] - acc[i + 1])
    ans %= MOD
print(ans)


Measured memory_bytes: 31268
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = new long[](N);
    foreach (i; 0 .. N)
        A[i] = lread();
    auto dp = new long[](N + 1);
    dp[] = long.min;
    dp[0] = long.max;
    long ans = long.min;
    foreach (i; 0 .. N)
    {
        long j = () {
            long ok = 0;
            long ng = N + 2;
            while (1 < ng - ok)
            {
                long m = (ng + ok) / 2;
                if (A[i] <= dp[m])
                {
                    ok = m;
                }
                else
                {
                    ng = m;
                }
            }
            return ng;
        }();
        dp[j] = A[i];
        ans = ans.max(j);
    }
    writeln(ans);
}


Measured memory_bytes: 4732
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}L M(L i){return i?B[i]+M(i^i&-i):0;}L S(L a,L i){for(a=M(i++G i);i<1e5;i+=i&-i)B[i]+=a;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Measured memory_bytes: 33480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    int flag = 0;
    for(int i=0; i<=25; i++){
        for(int j=0; j<=15; j++){
            if(4 * i  + 7 * j == n) flag = 1;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main (void){
	int i, p = 0, n = 0;
	int s[1000], e[1000];
	
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d %d",&s[i],&e[i]);
		p += e[i]-s[i]+1;
	}
	printf("%d",p);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int A = 0, B = 0,a=0,b=0,c=0;
	cin >> A >> B;
	a = A * 2 - 1;
	b = B * 2 - 1;
	c = A + B;
	c = max(max(a, b),c);
	cout << c;
	return 0;
	
}

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

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int n, m; cin >> n >> m;
	vi a(m), b(m);
	map<int, vi> mp;
	for (int i = 0; i < m; i++) {
		cin >> a.at(i) >> b.at(i);
		mp[a.at(i)].push_back(b.at(i));
	}
	for (int i = 0; i < mp[1].size(); i++) {
		for (int j = 0; j < mp[mp[1].at(i)].size(); j++) {
			if (mp[mp[1].at(i)].at(j) == n) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 20984
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define range(a, i, b) for(int i = a; i <b; ++i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(x);
  readl(y);

  ll res;

  while(x <= y){
    x *= 2;
    res++;
  }
  cout << res;
  
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



void solve(){
    ll n,m;
    cin >> n >> m;
    vector<ll> nums(n);
    ll total=0;
    for(ll i=0; i<n; i++){
        cin >> nums[i];
        total+=nums[i];
    }
    ll ans=0;
    for(ll i=0; i<n; i++){
        if(nums[i]*4*m>=total){
            ans++;
        }
    }
    if(ans>=m){
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
using namespace std;
string z(int i){string s="";if(i>25){s+='a'+i/25;i%=25;}s+='a'+i;return s;}
int main(){
	string s;
	map<string,int>m;
	int i=0;
	cout<<"?shiritori"<<endl<<flush;
	for(;i<50;i++){
		cin>>s;
		if(s[0]!='i'||m[s]){cout<<"!OUT"<<endl;return 0;}
		m[s]=1;cout<<string("?")<<s[s.size()-1]<<z(i)<<'i'<<endl<<flush;
	}
}

Measured memory_bytes: 0
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            string[] LineReader = ReadLine().Split(' ');
            int H = int.Parse(LineReader[0]);
            int A = int.Parse(LineReader[1]);

            int count = 0;
            for (; H > 0;) 
            {
                H -= A;
                count++;
            }
            
                
            WriteLine(count);
        }
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int x,n,m,a,ts,us,sum,ans=0;
string str;
vector<int> t;
vector<int> u;
int main(){
  cin>>x;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str>>a;
    if(str=="D")t.push_back(a);
  }
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>str>>a;
    if(str=="DD")u.push_back(a);
  }
  sort(u.begin(),u.end());
  reverse(u.begin(),u.end());
  for(int i=0;(2*i<=x);i++){
    sum=0;
    for(int j=0;j<min(i,(int)u.size());j++)sum+=u[j];
    for(int j=0;j<min(x-2*i,(int)t.size());j++)sum+=t[j];
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

// #define DEBUG


main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, w, vi, wi, ans;
    cin >> n >> w;
    int dp_list[w+1];
    fill(dp_list, dp_list + w + 1, 0);
    for (int i = 0; i < n; i++){
        cin >> vi >> wi;
        for (int j = 0; j <= w; j++)
        {
            if (j + wi <= w)
                dp_list[j + wi] = max(dp_list[j + wi], dp_list[j] + vi);
            // cout << dp_list[j] << " ";
        }
        // cout << endl;
    }

    ans = 0;
    for (int x : dp_list)
        ans = max(x, ans); 
    cout << ans << endl;
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    if(s.at(0)!=s.at(1)&&s.at(1)!=s.at(2)&&s.at(2)!=s.at(0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import math

a, b, x = map(float, raw_input().split())

if 2 * x / (b * a) <= a:
    y = 2 * x / (b * a)
    print(math.degrees(math.atan(b / y)))

else:
    h = (x - a * a * b / 2) / (a * a / 2)
    print(math.degrees(math.atan((b - h) / a)))

Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int ans = 0;
    string s,t;
    cin >> s >> t;
    rep(i, 3){
        if(s[i]==t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import numpy as np
import fractions
N, K = [int(i) for i in input().split(' ')]

if N == 0:
	result = 0
elif K == 0:
	result = N
elif N % K == 0:
	result = 0
elif K % N == 0:
	result = K/N if N > K/N else N
elif N > K:
  result = N % K if N % K < K - N % K else K-N%K
elif N < K:
  result = K-N if N > K - N else N
  
print("{}".format(result))

#lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

#count = sum(sum(lis) / 4.0 / int(M) <= lis)



Measured memory_bytes: 22164
import math
A,B,H,M = map(int,input().split())


h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))
print(math.sqrt(C))


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

using namespace std;

int main(void) {
  long long A; cin >> A;

  int B = 0;
  for (int i = 0; i < 4; i++) {
    char a; cin >> a;
    if (a != '.') {
      B = B*10 + (a - '0');
    }
  }

  long long ans = A * B / 100;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3640
N = int(input())
A = list(map(int,input().split()))
A = [0] + A  #単純にリスト横につなげる
A.append(0)

cost = [0]*(N+1)
for i in range(0,N+1):
    cost[i] = abs(A[i+1] - A[i])
ini = sum(cost)

for i in range(1,N+1):  #iが取りやめた奴
    dam = ini
    dam -= cost[i-1]
    dam -= cost[i]
    dam += abs(A[i+1] - A[i-1])
    print(dam)


Measured memory_bytes: 86512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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 long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:

    int N, M;

    vector<int> P, Y;
    vector<vector<pair<int, int>>> vv; //year, id
    vector<string> ans;


    void input() {
        cin >> N >> M;

        vv.resize(N + 1);
        rep(i, 0, M) {
            int p, y;
            cin >> p >> y;

            P.push_back(p);
            Y.push_back(y);

            vv[p].emplace_back(y, i);
        }

    }

    string conv(int p, int n) {
        string s;
        string mae = to_string(p);
        string ato = to_string(n);
        while (mae.size() < 6) {
            mae.insert(mae.begin(), '0');
        }
        while (ato.size() < 6) {
            ato.insert(ato.begin(), '0');
        }

        return mae + ato;
    }

    void solve() {
        input();

        ans.resize(M);
        for (int p = 1; p < vv.size(); ++p) {
            auto vp = vv[p];
            sort(all(vp));
            for (int i = 0; i < vp.size(); ++i) {
                ans[vp[i].second] = conv(p, i + 1);
            }
        }

        for(int i = 0; i < ans.size(); ++i){
            cout << ans[i] << endl;
        }


    }
};


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

    Solve().solve();


    return 0;
}


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

using namespace std;

int main()
{
	int a, b, c, d, e;
	cin >> a;
	
	b = a/1000;
	c = a/100%10;
	d = a/10%10;
	e = a % 10;
	
	if (b + c + d + e == 7)
		cout << b << "+" << c << "+" << d << "+" << e << "=7";
	else if (b + c + d - e == 7)
		cout << b << "+" << c << "+" << d << "-" << e << "=7";
	else if (b + c - d + e == 7)
		cout << b << "+" << c << "-" << d << "+" << e << "=7";
	else if (b + c - d - e == 7)
		cout << b << "+" << c << "-" << d << "-" << e << "=7";
	else if (b - c + d + e == 7)
		cout << b << "-" << c << "+" << d << "+" << e << "=7";
	else if (b - c + d - e == 7)
		cout << b << "-" << c << "+" << d << "-" << e << "=7";
	else if (b - c - d - e == 7)
		cout << b << "-" << c << "-" << d << "-" << e << "=7";
	else
		cout << b << "-" << c << "-" << d << "+" << e << "=7";	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
  VE a(n),b(n);rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  int ans = 0;
  rep(i,n){
    int now = 0;
  	rep(j,i+1){
    	now += a[j];
    }
    for(int j = i; j < n; j++)now+=b[j];
    chmax(ans,now);
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>
int main() {
    int H, W;
    cin>>H>>W;
    pint C, D;
    cin >> C.first >> C.second;
    cin >> D.first >> D.second;
    C.first--; C.second--;
    D.first--; D.second--;
    vector<string> Map(H);
    REP(i, 0, H) cin >> Map[i];
    int ans;
    vvi visited(H, vi(W, __INT_MAX__));
    queue<pint> que, que_2;

    que.push({C.first, C.second});
    visited[C.first][C.second] = 0;

    while(!que.empty()){
        auto cur = que.front(); que.pop();
        int y = cur.first;
        int x = cur.second;
        int warp = visited[y][x];
        REP(i, 0, 4){
            int next_y = y, next_x = x;
            if(i == 0) next_y++;
            else if(i == 1) next_y--;
            else if(i == 2) next_x++;
            else if(i == 3) next_x--;
            if(next_y < 0 || next_y >= H || next_x < 0 || next_x >= W) continue;
            if(Map[next_y][next_x] == '.' && visited[next_y][next_x] > warp){
                que.push({next_y, next_x});
                visited[next_y][next_x] = warp;
            }else if(Map[next_y][next_x] == '#'){
                que_2.push({y, x});
            }
        }

        if(que.empty()){
            while(!que_2.empty()){
                auto cur = que_2.front(); que_2.pop();
                int y = cur.first;
                int x = cur.second;
                REP(i, 0, 25){
                    int next_y = y, next_x = x;
                    int d_y = i / 5 - 2;
                    int d_x = i % 5 - 2;
                    next_y += d_y;
                    next_x += d_x;
                    if(next_y < 0 || next_y >= H || next_x < 0 || next_x >= W) continue;
                    if(Map[next_y][next_x] == '.' && visited[next_y][next_x] > warp + 1){
                        que.push({next_y, next_x});
                        visited[next_y][next_x] = warp + 1;
                    }
                }
            }
        }

    }
    /*
    REP(i, 0, H){
        REP(j, 0, W) cout << visited[i][j] << " ";
        cout << endl;
    }*/
    if(visited[D.first][D.second] == __INT_MAX__) cout << -1 << endl;
    else cout << visited[D.first][D.second] << endl;
}

Measured memory_bytes: 9620
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut grid = vec![vec![]; n];
    for i in 0..n {
        grid[i] = read::<String>().chars().collect::<Vec<_>>();
    }
    if grid.iter().all(|ref x| x.iter().all(|&x| x == '#')) {
        println!("0");
        return;
    }
    if grid.iter().all(|ref x| x.iter().all(|&x| x == '.')) {
        println!("-1");
        return;
    }
    let mut already_completed_columns = 0;
    for x in 0..n {
        if (0..n).all(|y| grid[y][x] == '#') {
            already_completed_columns += 1;
        }
    }

    let mut existed_column = HashSet::new();
    for row in 0..n {
        for column in 0..n {
            if grid[row][column] == '#' {
                existed_column.insert(column);
            }
        }
    }

    let mut need_for_complete_one_row = n;
    for row in 0..n {
        let mut count = 0;
        for column in 0..n {
            if grid[row][column] == '#' {
                count += 1;
            }
        }
        if existed_column.contains(&row) {
            need_for_complete_one_row = min(need_for_complete_one_row, n - count);
        } else {
            need_for_complete_one_row = min(need_for_complete_one_row, n - count + 1);
        }
    }
    println!(
        "{}",
        need_for_complete_one_row + n - already_completed_columns
    );
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class union_find_t {
public:
  union_find_t(int T) : T_(T), parent_(new int[T]), rank_(new int[T]) {
    for (int i = 0; i < T_; i++) {
      parent_[i] = i;
      rank_  [i] = 0;
    }
  };

  ~union_find_t() {
    delete[] parent_;
    delete[] rank_;
  };

public:
  int find(int x) {
    if (parent_[x] == x) {
      return x;
    }
    else {
      return parent_[x] = find(parent_[x]);
    }
  };

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y)
      return;

    if (rank_[x] < rank_[y]) {
      parent_[x] = y;
    }
    else {
      parent_[y] = x;

      if (rank_[x] == rank_[y])
        rank_[x] ++;
    }
  };

  bool same(int x, int y) {
    return find(x) == find(y);
  };

private:
  int T_;

  int* parent_;
  int* rank_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, K, A, B, C, D;
  
  std::cin >> N >> M >> K;

  union_find_t uf(N);

  std::vector<std::vector<int>> G(N), H(N);

  for (int i = 0; i < M; i ++) {
    std::cin >> A >> B;

    A --;
    B --;

    G[A].push_back(B);
    G[B].push_back(A);

    uf.unite(A, B);
  }

  std::map<int, std::vector<int>> map;

  for (int i = 0; i < N; i ++)
    map[uf.find(i)].push_back(i);

  for (int i = 0; i < K; i ++) {
    std::cin >> C >> D;

    C --;
    D --;

    H[C].push_back(D);
    H[D].push_back(C);
  }

  for (auto& i : G)
    std::sort(ALL(i));

  for (auto& i : H)
    std::sort(ALL(i));

  for (int i = 0; i < N; i ++) {
    int p = uf.find(i);

    assert(map.count(p));

    int c = map[p].size() - G[i].size() - 1;

    for (const auto& j : H[i])
      if (uf.same(i, j))
        c --;

    std::cout << c << ' ';
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 19584
//#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<double> x(N), y(N);
  for( int i=0; i<N; i++ ) cin >> x[i] >> y[i];
  
  double m = 0;
  for( int i=0; i<N-1; i++ ){
    for( int j=i+1; j<N; j++ ){
      m += pow( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]), 0.5 );
    }
  }
  m /= (N*(N-1)/2);
  
  printf( "%.10lf", m*(N-1) );                                                     
  return 0;  
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,M;
  int sum=0;
  cin >> N >> M;
  vector<int>A(N);
  for (int i=0; i<N; i++)
  {
    cin >> A[i];
    sum += A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  if (A[M-1]*4*M >= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int L;
ll dp[5];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> L;
    register ll A;

    for(int i = 0; i < L; ++i){
        cin >> A;
        ll mn = dp[0];
        dp[0] += A;
        mn = min(mn, dp[1]), dp[1] = mn + (A == 0 ? 2 : A % 2);
        mn = min(mn, dp[2]), dp[2] = mn + (A + 1) % 2;
        mn = min(mn, dp[3]), dp[3] = mn + (A == 0 ? 2 : A % 2);
        mn = min(mn, dp[4]), dp[4] = mn + A;
    }
    cout << min({dp[0], dp[1], dp[2], dp[3], dp[4]}) << endl;
    return 0;
}

Measured memory_bytes: 256
#coding:utf-8

N = int(input())

A = [int(an) for an in input().split()]

def royale(An):

    tmp = An
    while True:
        n_tmp = []
        # 残り1体の時は終了
        if len(tmp) == 1:
            return tmp[0]

        # 一番体力が小さいモンスターを決定する
        min_hp = min(tmp)
        n_tmp.append(min_hp)
        min_num = tmp.index(min_hp)

        # 体力が1のモンスターがいるなら1で確定
        if min_hp == 1:
            return 1

        # 他を攻撃する
        for i in range(len(tmp)):
            # 自分以外
            if i != min_num:
                tmp[i] = tmp[i] % min_hp
                if tmp[i] != 0:
                    n_tmp.append(tmp[i])
        tmp = n_tmp

print(royale(A))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
  
int32_t main(){
    SPEED;
    int a, b;
    cin >> a >> b;
    string s = "";
    s += to_string(a);
    s += to_string(b);
    int res = stoi(s);
    if(isPerfectSquare(res)) cout << "Yes" ;
    else cout << "No" ;
}


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


int main() {

    string s;
    cin >> s;
    int x = s.length();
    
    for(int i = 0; i < x; i++){
        cout << s[i];
        i++;
    }
    cout << endl;
    

}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#define S(a,b,c,d) (s[c][d]-s[c][(b)-1]-s[(a)-1][d]+s[(a)-1][(b)-1])
using namespace std;
const int maxn=105;
int n,m,x,y,s[maxn][maxn],ans,F[maxn][maxn][maxn][maxn];
char mp[maxn][maxn];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++){
		s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(mp[i][j]=='o');
		if(mp[i][j]=='E') x=i,y=j;
	}
	for (int i=0;x+i<=n;i++)
	for (int j=0;x-j;j++)
	for (int k=0;y+k<=m;k++)
	for (int t=0;y-t;t++){
		if(F[i][j][k][t]>ans) ans=F[i][j][k][t];
		if(x+i+j<n) F[i+1][j][k][t]=max(F[i+1][j][k][t],F[i][j][k][t]+S(x+i+1,max(k+1,y-t),x+i+1,min(m-t,y+k)));
		if(x-i-j>1) F[i][j+1][k][t]=max(F[i][j+1][k][t],F[i][j][k][t]+S(x-j-1,max(k+1,y-t),x-j-1,min(m-t,y+k)));
		if(y+k+t<m) F[i][j][k+1][t]=max(F[i][j][k+1][t],F[i][j][k][t]+S(max(i+1,x-j),y+k+1,min(n-j,x+i),y+k+1));
		if(y-k-t>1) F[i][j][k][t+1]=max(F[i][j][k][t+1],F[i][j][k][t]+S(max(i+1,x-j),y-t-1,min(n-j,x+i),y-t-1));
	}
	printf("%d\n",ans);
	return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

bool check = 0;
bool boo = 0;
ll min = INF, maxx = 0;

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    int n, m, c;
    cin >> n >> m >> c;
    vi b(m);
    int a, sum = 0;

    rep(i, m) cin >> b[i];
    rep(i, n)
    {
        rep(j, m)
        {
            cin >> a;
            sum += (a * b[j]);
        }
        if (sum + c > 0)
            ans++;
        sum = 0;
    }

    pr(ans);
    return 0;
}


Measured memory_bytes: 3560
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
        A[i] -= B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        A[i] = 0
        if A[i + 1] >= B[i]:
            ans += B[i]
            A[i + 1] -= B[i]
        else:
            ans += A[i + 1]
            B[i] -= A[i + 1]
            A[i + 1] = 0
print(ans)


Measured memory_bytes: 19004
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

char c1[30],c2[30];

int main(){
  int a,i,j,k;
  string s,t;
  cin >> s >> t;
  for(i=0;i<s.size();i++){
    if(c1[t[i]-'a']=='\0'){//t->s 初登場
      c1[t[i]-'a']=s[i];
    }else{//二回目以降
      if(c1[t[i]-'a']!=s[i]){
        cout << "No" << endl;
        return 0;
      }
    }

    if(c2[s[i]-'a']=='\0'){//s->t 初登場
      c2[s[i]-'a']=t[i];
    }else{//二回目以降
      if(c2[s[i]-'a']!=t[i]){//違うのがはいってたらno
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int r[n];
    for(int i=0;i<n;i++){
        cin >> r[i];
    }
    int min_num=r[0];
    int res = -1000000000;
    for(int i=1;i<n;i++){
        if(r[i]-min_num>res){
            res = r[i] -min_num;
        }
        if(r[i]<min_num){
            min_num = r[i];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3884
#include <stdio.h>

int main()
{
	int N, K;
	int i;
	int way=1;

	scanf("%d%d", &N, &K);

	for(i=1; i<=(N-1); i++){
		way = way * (K-1);
	}

	way = way * K;

	printf("%d", way);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
    cin >> n;
    int a[n];
    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += abs(a[i]);
    }
    sort(a, a + n);
    int mn = a[0], mx = a[n - 1];
    if(a[0] * a[n - 1] <= 0){
        cout << sum << endl;
    }else if(mn > 0){
        cout << sum - 2 * mn << endl;
    }else{
        cout << sum + 2 * mx << endl;
    }
    for(int i = 1; i < n - 1; i++){
        if(a[i] >= 0){
            cout << mn << " " << a[i] << endl;
            mn -= a[i];
        }else{
            cout << mx << " " << a[i] << endl;
            mx -= a[i];
        }
    }
    cout << mx << " " << mn << endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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

int n;
ll k;
ll a[200000], f[200000];

bool isok(ll m) {
    ll sum = 0, t;
    for (int i = 0; i < n; ++i) {
        t = (a[i] * f[i] - m + f[i] - 1) / f[i];
        sum += max(0LL, t);
    }
    if (sum <= k)
        return true;
    return false;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> f[i];
    }
    sort(a, a + n);
    sort(f, f + n, greater<ll>());

    ll l = -1, r = 1e12, m;
    while (r - l > 1) {
        m = (l + r) / 2;
        if (isok(m)) {
            r = m;
        }
        else {
            l = m;
        }
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 6764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);

//入力変数
int H = sc.nextInt();
int W = sc.nextInt();
int D = sc.nextInt();
int num[][] = new int[H][W];
for(int i=0;i<H;i++){
   for(int j=0;j<W;j++){
      num[i][j] = sc.nextInt();
   }
}
int Q = sc.nextInt();
int L[] = new int[Q];
int R[] = new int[Q];
for(int q=0;q<Q;q++){
   L[q] = sc.nextInt();
   R[q] = sc.nextInt();
}

//変換:数値→座標
int pos[][] = new int[H*W][2];
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
           pos[num[i][j]-1][0] = i;
           pos[num[i][j]-1][1] = j;
       }
     }

//座標→距離
int len[] = new int[H*W];
for(int k = 0;k<H*W;k++){
if(k/D ==0){
len[k]=0;
}else{
len[k] = len[k-D] +Math.abs(pos[k][0]-pos[k-D][0])+Math.abs(pos[k][1]-pos[k-D][1]);
}
}

//出力変数
int ans[] = new int[Q];

//計算
for(int q=0;q<Q;q++){
   //ｑの関わる変数の初期化
   ans[q] = len[R[q]-1]-len[L[q]-1];
  }

//出力
for(int q=0;q<Q;q++){
   System.out.println(ans[q]);
}

}
}


Measured memory_bytes: 96144
n, k = map(int, input().split())
a = list(map(int, input().split()))
if len(set(a)) == k:
    print(0)
    exit()

d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

s = sorted(d.items(), key=lambda x:x[1])
ans = 0
for j in range(len(s) - k):
    ans += s[j][1]

print(ans)

Measured memory_bytes: 49020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int lsum = 0;
    REP(i,26) lsum += c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol;
    V<> loss(26,0);
    V<set<int>> pla(26);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] + loss[j] + c[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol.pb(r);
        pla[r].insert(i);
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    int Q = 10000;
    random_device rnd;
    while(Q--){
        int newi = rnd() % 365;
        int newsol = rnd() % 26;
        int ev = 0;
     /* cout << "newi="<<newi<<" newsol="<<newsol<<endl;
      cout << "ev+=" << *pla[newsol].lower_bound(newi) - newi <<"*"<<c[newsol] << '\n';
       cout << "ev-=" << (*pla[sol[newi]].upper_bound(newi) - newi)<<"*"<<c[sol[newi]] << endl;*/
        ev += (*pla[newsol].lower_bound(newi) - newi) * c[newsol];
        ev -= (*pla[sol[newi]].upper_bound(newi) - newi) * c[sol[newi]];
        if(ev > 0){
            pla[sol[newi]].erase(newi);
            pla[newsol].insert(newi);
            sol[newi] = newsol;
        }
    }
    REP(i,d) cout << sol[i] + 1 << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

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

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e3+5;
const ll mod = 1e9+7;

ll dp[L][L];

void solve()
{
    ll h = nxt(), w = nxt();

    vector <string> v(h);

    for(ll i=0; i<h; i++)
    {
        cin >> v[i];
    }

    dp[0][0] = 1;

    for(ll i=0; i<h; i++)
    {
        for(ll j=0; j<w; j++)
        {
            if(i+1 < h && v[i+1][j] == '.')
            {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= mod;
            }

            if(j+1 < w && v[i][j+1] == '.')
            {
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= mod;
            }
        }
    }

    cout << dp[h-1][w-1] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

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


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

	int N;
	int a[105], b[105];
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		cin >> b[i];
	}
	int sum = 0;
	fill(a, a + N, INT_MAX);
	while (true) {
		bool s = 0;
		a[0] = b[0];
		a[N - 1] = b[N - 2];
		for (int i = 1; i < N-1; i++) {
			if (b[i] < a[i]) {
				a[i] = b[i];
				s = 1;
			}
			if (b[i - 1] < a[i]) {
				a[i] = b[i - 1];
				s = 1;
			}
		}
		if (s == 0)break;
	}
	for (int i = 0; i < N; i++) {
		sum += a[i];
	}
	cout << sum << endl;

}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    b = [0] + a + [0]
    n = n+2
    total = 0
    for i in range(n-1):
        total += abs(b[i+1] - b[i])
    
    for i in range(1,n-1):
        print(total - abs(b[i] - b[i-1]) - abs(b[i+1] - b[i]) + abs(b[i-1] - b[i+1]))
    
    

solve()


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

ll solve(ll M, vector<ii>& ds)
{
    sort(ds.begin(), ds.end());

    ll ans = 0, left = M;

    for (size_t i = 0; i < ds.size(); ++i)
    {
        auto A = ds[i].first;
        auto B = ds[i].second;

        ll qtd = min(left, B);

        ans += A*qtd;
        left -= qtd;

        if (left == 0)
            break;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ii> ds(N);

    for (int i = 0; i < N; ++i)
        cin >> ds[i].first >> ds[i].second;

    auto ans = solve(M, ds);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792