akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

struct vw_pair {
    int v, w;
    vw_pair(int v,int w) : v(v), w(w) {};
};

typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<int> vi;
typedef vector <string> vs;
typedef vector <vi> vvi;
typedef vector <vector<vw_pair>> adj_list;
typedef vector <bool> vb;
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<int> max_heap_int;
typedef priority_queue<int, vi, greater<>> min_heap_int;

#define isOn(S, j) (S & (1<<j))
#define setBit(S, j) (S |= (1<<j))
#define clearBit(S, j) (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1<<n)-1)

#define modulo(S, N) ((S) & (N-1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S-1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
#define turnOffLastConsecutiveBits(S) ((S) & (S+1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S-1))
#define in_range(lo, hi, x) ((x >= lo && x <= hi))

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

    string s;
    cin >> s;
    int n = s.size();
    vi a(n,0);
    
    for (int i=0;i<n-1;++i) if (s[i] == 'R' && s[i+1] == 'L') {
        a[i] = a[i+1] = 1;
        int oddR = 0, evenR = 0;
        int j = i-1;
        bool is_odd = true;
        while (j>=0 && s[j] == 'R') {
            if (is_odd) ++oddR; else ++evenR;
            is_odd = !is_odd;
            --j;
        }
        a[i+1] += oddR;a[i] += evenR;

        int oddL = 0, evenL = 0;
        j = i+2;
        is_odd = true;
        while (j<n && s[j] == 'L') {
            if (is_odd) ++ oddL; else ++ evenL;
            is_odd = !is_odd;
            ++j;
        }
        a[i] += oddL;a[i+1] += evenL;
        i = j-1;
    }
    for (int i=0;i<n;++i) cout << a[i] << " ";

    return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <string>
//#include <math.h>
using namespace std;

int main(){
  string a;
  cin >> a;
  if(a == "SUN"){
    cout << "7\n";
  }else if(a == "MON"){
    cout << "6\n";
  }else if(a == "TUE"){
    cout << "5\n";
  }else if(a == "WED"){
    cout << "4\n";
  }else if(a == "THU"){
    cout << "3\n";
  }else if(a == "FRI"){
    cout << "2\n";
  }else{
    cout << "1\n";
  }
  return 0;
}


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

 #define REP(i, a, n) for(int i=a; i<n; i++)

int main() {
	int a, b;
	cin >> a >> b;
  	if((a*b)%2==1){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int near(int c, int a, int b) {
    if (abs(c-a) < abs(c-b)) return a;
    else                     return b;
}

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());

    int n = a.back();
    auto it = lower_bound(a.begin(), a.end(), (n+1)/2);
    int r = near((n+1)/2, *it, *(it-1));

    cout << n << " " << r << endl;

    return 0;
}


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

const int MAX=100005;
const int NIL=-1;

struct www {int p,l,r;};
struct www T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout<<"node "<<u;
    cout<<": parent = "<<T[u].p;
    cout<<", depth = "<<D[u];
    if(T[u].p==NIL) cout<<", root, [";
    else if(T[u].l==NIL) cout<<", leaf, [";
    else cout<<", internal node, [";
    
    for(i=0,c=T[u].l ; c!=NIL ; i++,c=T[c].r){
        if(i) cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}

void rec(int u , int p) {
    D[u] = p;
    if(T[u].l!=NIL) rec(T[u].l,p+1);
    if(T[u].r!=NIL) rec(T[u].r,p);
}

int main(){

    int i,j,d,v,c,l,r;
    cin>>n;
    for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
    
    for(i=0;i<n;i++){
        cin>>v>>d;
        for(j=0;j<d;j++){
            cin>>c;
            if(j==0) T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p==NIL) r=i;
    }
    
    rec(r,0);
    
    for(i=0;i<n;i++) print(i);
        
        }



Measured memory_bytes: 4640
<?php
while (true) {
  list($m, $f, $r) = explode(' ', trim(fgets(STDIN)));
  if ($m < 0 && $f < 0 && $r < 0) {
    break;
  }
  $score = $m + $f;
  if ($m < 0 || $f < 0 || $score < 30) {
    echo "F\n";
  } elseif ($score < 50) {
    if ($r >= 50) {
      echo "C\n";
    } else {
      echo "D\n";
    }
  } elseif ($score < 65) {
    echo "C\n";
  } elseif ($score < 80) {
    echo "B\n";
  } else {
    echo "A\n";
  }
}

Measured memory_bytes: 15272
from collections import Counter
n = int(input())
#l = list()
ch = ['M', 'A', 'R', 'C', 'H']
c = Counter([])
c['M'] = 0
c['A'] = 0
c['R'] = 0
c['C'] = 0
c['H'] = 0
for i in range(n):
    s = str(input())
    if s[0] in ch:
        c[s[0]] += 1
        # l.append(s[0])
cnt = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            # print(i,j,k)
            cnt += c.most_common()[i][1] * \
                c.most_common()[j][1]*c.most_common()[k][1]
print(cnt)


Measured memory_bytes: 9396
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int searcha(int ok, int ng, int border, vector<int> &vec){
	if (ng - ok == 1) return ok;
	if (vec[(ok+ng)/2] < border) return searcha((ok+ng)/2, ng, border, vec);
	return searcha(ok, (ok+ng)/2, border, vec);
}

int searchc(int ok, int ng, int border, vector<int> &vec){
	if (ng - ok == 1) return ok;
	if (vec[(ok+ng)/2] > border) return searchc((ok+ng)/2, ng, border, vec);
	return searchc(ok, (ok+ng)/2, border, vec);
}



int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	vector<ll> ab(n);
	vector<ll> bc(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		cin >> b[i];
	}
	for (int i = 0; i < n; i++){
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(c.begin(), c.end(), greater<int>());

	for (int i = 0; i < n; i++){
		if (b[i] <= a[0]) ab[i] = 0;
		else if (b[i] > a[n-1]) ab[i] = n;
		else ab[i] = searcha(0, n-1, b[i], a) + 1;
		if (b[i] >= c[0]) bc[i] = 0;
		else if (b[i] < c[n-1]) bc[i] = n;
		else bc[i] = searchc(0, n-1, b[i], c) + 1; 
	}
	ll ans = 0;
	for (int i = 0; i < n; i++){
		ans += ab[i]*bc[i];
	}
	cout << ans << endl;
	return 0;
 }



Measured memory_bytes: 2944
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int s = 0;
	s += min(a, b);
	s += min(c, d);
	cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

struct Info_max{
	Info_max(int arg_point,int arg_id){
		point = arg_point;
		id = arg_id;
	}
	bool operator<(const struct Info_max &arg) const{
			return point < arg.point;
	};
	int point,id;
};

struct Info_min{
	Info_min(int arg_point,int arg_id){
		point = arg_point;
		id = arg_id;
	}
	bool operator<(const struct Info_min &arg) const{
			return point > arg.point;
	};
	int point,id;
};

 int main(){

	 int N,M,max_points[10001],point,num,tmp,forced_points[10001],maximum,minimum;
	 priority_queue<Info_max> MAX;
	 priority_queue<Info_min> MIN;
	 while(true){
		 scanf("%d %d",&N,&M);
		 if(N == 0 && M == 0)break;

		 for(int i = 1; i <= N; i++){
			 max_points[i] = 0;
			 forced_points[i] = 0;
		 }

		 for(int loop = 0; loop < M; loop++){
			 scanf("%d %d",&point,&num);
			 if(num == 1){
				 scanf("%d",&tmp);
				 forced_points[tmp] += point;
				 max_points[tmp] += point;
			 }else{ //num > 1
				 for(int i = 0; i < num; i++){
					 scanf("%d",&tmp);
					 max_points[tmp] += point;
				 }
			 }
		 }

		 while(!MAX.empty())MAX.pop();
		 while(!MIN.empty())MIN.pop();

		 for(int i = 1; i <= N; i++){
			 MAX.push(Info_max(max_points[i],i));
			 MIN.push(Info_min(forced_points[i],i));
		 }

		 if(MAX.top().id != MIN.top().id){
			 printf("%d\n",MAX.top().point-MIN.top().point+1);
		 }else{
			 maximum = MAX.top().point;
			 MAX.pop();
			 minimum = MIN.top().point;
			 MIN.pop();
			 printf("%d\n",max(maximum-MIN.top().point,MAX.top().point-minimum)+1);
		 }
	 }

	 return 0;
}

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

int main() {
	int A, B, C, D, E, F;
    cin >> A >> B >> C >> D;
	E = A + B;
	F = C + D;
	if ( E > F ) {
		cout << "Left" << endl;
	}
	else if ( E < F ) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#create date: 2020-05-03 21:20

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))



def main():
    x = ni()
    for a in range(-1000,1000):
        for b in range(-1000, 1000):
            if a**5 - b**5 == x:
                print("{} {}".format(a, b))
                quit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 64728
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

ll x[10];

int main() {
	ll n, ans = 0;
	cin >> n;
	string s;
	while (n--) {
		cin >> s;
		if (s[0] == 'A') ++x[1];
		if (s[0] == 'M') ++x[2];
		if (s[0] == 'R') ++x[3];
		if (s[0] == 'C') ++x[4];
		if (s[0] == 'H') ++x[5];
	}
	ans = x[1] * x[2] * x[3];
	ans += x[1] * x[2] * x[4];
	ans += x[1] * x[2] * x[5];
	ans += x[1] * x[3] * x[4];
	ans += x[1] * x[3] * x[5];
	ans += x[1] * x[4] * x[5];
	ans += x[2] * x[3] * x[4];
	ans += x[2] * x[3] * x[5];
	ans += x[2] * x[4] * x[5];
	ans += x[5] * x[3] * x[4];
	cout << ans << "\n";
	return 0;
} 


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[107],b[107];
int cha[107];
int sum1[107]={},sum2[107]={};
int main()
{
    int n,sum=0;scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    sum1[0]=a[0];sum2[0]=sum-a[0];
    cha[0]=sum1[0]-sum2[0];
    if(cha[0]<0) cha[0]=-cha[0];
    for(int i=1;i<n;i++)
    {
        sum1[i]=sum1[i-1]+a[i];
        sum2[i]=sum2[i-1]-a[i];
        cha[i]=sum1[i]-sum2[i];
        if(cha[i]<0) cha[i]=-cha[i];

    }
    sort(cha,cha+n);
    printf("%d ",cha[0]);
    return 0;
}

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

using namespace std;

void solve(){
	int n; cin>>n;
	cout << ((n>29)?"Yes\n":"No\n");
}

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	int cs = 1;
	while(t--){
		//cout << "Case #" << cs << ":\n";
		solve();
		cs++;
	}
	return 0;
}


Measured memory_bytes: 3648
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  string s;
  cin >> s;
  map<char,int> mp;
  for(int i=0; i<s.length();i++)
  {
    mp[s[i]]++;
  }
  for(auto &k: mp)
    if(k.second%2!=0)
    {
      cout<<"No";
      return 0;
    }
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
number=list(map(int,input().split()))
N,M,K=number[0],number[1],number[2]
A=list(map(int,input().split()))
B=list(map(int,input().split()))
answer=0
j=M
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    answer=max(answer,i+j)

print(answer)

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

int main() {

    int n;

    cin >> n;

    vector<int> v(n + 1);

    vector<int> ans(n + 1, 0);

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

    bool isTrue = true;

    for(int i = n; i >= 1; --i) {

        int sum = 0;
        for(int j = i + i; j <= n; j += i)
            sum ^= ans[j];

        ans[i] = sum ^ v[i];

   }

    vector<int> x;

    for(int i = 1; i <= n; ++i)
        if(ans[i])
            x.push_back(i);

    cout << x.size() << endl;

    for(int i = 0; i < x.size(); ++i)
        cout << x[i] << " ";


    return 0;

}

Measured memory_bytes: 5468
#include<stdio.h>
    int main(void){
    int a,b,c,d,answer=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
if(a<c){
if(b<d){
answer = b-c;
}else{
answer = d-c;
}
}
if(a>=c){
if(b<d){
answer = b-a;
}else{
answer = d-a;
}
}
if(b<=c || d<=a) answer = 0;
printf("%d",answer);
    return 0;
    }

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

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

Measured memory_bytes: 256
#include <iostream>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	long long int N, ans = 0;
	cin >> N;
	while (N)
	{
		if (N % 10 == 9)
		{
			ans++;
		}
		N /= 10;
	}
	cout << (ans == 0 ? "No" : "Yes") << endl;
}



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

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    
    const long long sz = (long long)1e5;
    const long long mx = (long long)2e5+5;
    const long long inf = (long long)1e18;
    const long long mod = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    long long pw(long long x,unsigned long long y) { 
        if (y==0) return 1; 
        else if (y%2==0)  return pw(x,y/2)*pw(x,y/2); 
        else return x*pw(x,y/2)*pw(x,y/2);
    }
    ll comp(pair<string, ll> &a, pair<string, ll> &b) {
        if(a.ff == b.ff) {
            if(a.ss < b.ss) return 1;
            else return 0;
        }
        if(a.ff < b.ff)return 1;
        else return 0;
    }
    int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll n, a, b;
        cin >> n >> a >> b;
        ll k = n / (a + b) * a;
        ll x = n - ((n / (a + b)) * (a + b));
        if(x >= a) k += a;
        else k += x;
        cout << k;
        return 0;
    }

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = min(A, B, C, D, E)
ans = 5
if N % a != 0:
    ans += (N // a) 
else:
    ans += (N // a) - 1
if a >= N:
    ans = 5
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(m, 0);
    for (int i = 0; i < m; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int res = v.back() - v[0];
    vector<int> gap;
    for (int i = 0; i < m - 1; i++) {
        gap.push_back(v[i + 1] - v[i]);
    }
    sort(gap.begin(), gap.end(), greater<int>());
    for (int i = 0; i < min(n - 1, (int)gap.size()); i++) {
        res -= gap[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 4252
#include <iostream>
using namespace std;
 
int linearSearch(int S[], int n, int key){
  int i = 0;
  S[n] = key;
  while(S[i] != key){
    i++;
  }
  return i != n;
}

int main(){
  int n, q, i, ans = 0;
  int S[10001], key;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> S[i];
  }
  cin >> q;
  for(i = 0; i < q; i++){
    cin >> key;
    if(linearSearch(S, n, key)) ans++;
  }

  cout << ans << endl;

  return 0;
}





Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> typename Bst::const_iterator gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    while(cin >> d and d) {
        int n, m;
        cin >> n >> m;
        set<int> s = {0, d};
        for(int i = 1; i < n; i++) {
            int di;
            cin >> di;
            s.insert(di);
        }
        int ans = 0;
        while(m--) {
            int k;
            cin >> k;
            auto suc = ge(s, k), pre = le(s, k);
            ans += min(abs(k - *suc), abs(k - *pre));
        }
        cout << ans << endl;
    }
    return 0;
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    string S, T;
    cin >> S >> T;

    vector<int> s(50);
    vector<int> t(50);

    for (char c: S) {
        s[c - 'a']++;
    }

    for (char c: T) {
        t[c - 'a']++;
    }

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    rep(i, s.size()) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N, K, i;
  cin >> N >> K;
  vector<ll> H(N);
  ll result = 0;
  REP(i, N) {
    cin >> H[i];
  }
  sort(ALL(H), greater<ll>());
  FOR(i, K, N) {
    result += H[i];
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int n;cin >> n;
  LL ans = 0;
  int st = 1;
  while(n--){
    if(st%3 && st%5){
      ans += st;
    }
    st++;
  }
  cout << ans << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int sum = 0;
	rep(i, k) sum += a[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>


#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint t1,t2,a1,a2,b1,b2;
  cin>>t1>>t2>>a1>>a2>>b1>>b2;
  if((a1>b1)){
    swap(a1,b1);
    swap(a2,b2);
  }

  Bint top_diff=(b2-a2)*t2+(b1-a1)*t1;
  Bint first_pos=(b1-a1)*t1;

  if(top_diff==0){
    cout<<"infinity"<<endl;
    return 0;
  }
  if(top_diff<0){
    Bint min=0,max=INT64_MAX;
    Bint mid=(min+max)/2;
    while(max-min>1){
      Bint top=first_pos+top_diff*mid;
      if(top==0){
        cout<<mid*2<<endl;
        return 0;
      }else if(top>0){
        min=mid;
      }else{
        max=mid;
      }
      mid=(min+max)/2;
    }
    cout<<min*2+1<<endl;
    return 0;

  }else{
    cout<<0<<endl;
  }


  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int p[200005];
int ans;
int m=1000000000;
int main(void){
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
        if(p[i]<m) ans++;
        m=min(m,p[i]);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
set<int> gr[114514];
bool sumi[114514];
queue<int> le;
int main()
{
	memset(sumi,false,sizeof(sumi));
	int n,a,b;
	cin>>n;
	rep(i,n-1){
		cin>>a>>b;
		gr[a].insert(b);gr[b].insert(a);
	}
	rep(i,n+1){
		if(gr[i].size()==1) le.push(i);
	}
	while(le.size()){
		int x=le.front();le.pop();
		if(sumi[x]) continue;
		//cout<<x<<endl;
		if(gr[x].size()==0){
			cout<<"First"<<endl;return 0;
		}
		int y=(*gr[x].begin());
		sumi[x]=sumi[y]=true;
		vector<int> v=vector<int>(All(gr[y]));
		rep(i,v.size()){
			gr[v[i]].erase(y);
			if(!sumi[v[i]] && gr[v[i]].size()<2) le.push(v[i]);
		}
	}
	cout<<"Second"<<endl;
}


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

int main(){
    long long n,k;
    cin>>n>>k;
    vector<int> p(n);
    vector<long long> c(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }

    vector<bool> seen(n,false);
    long long ans = LONG_LONG_MIN;

    for(int i=0;i<n;i++){
        int now = i;
        vector<int> loop;
        long long loop_sum=0;
        //一周するまでにどこを通るか見る
        while(1){
            now = p[now];
            loop.push_back(now);
            loop_sum += c[now];
            if(now==i) break;
        }
        //i個の部分和で最大のもの
        int l = loop.size();
        long long t = 0;
        for(int m=0;m<l;m++){
            t += c[loop[m]];
            if(m+1 > k) break;
            long long sum = t;
            if(loop_sum>0){
                long long e = (k-m-1)/l;
                sum += loop_sum*e;
            }
            ans = max(ans,sum);
        }
    }

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



Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int counter = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            if(num  < min){
                counter++;
                min = num;
            }
        }
        System.out.println(counter);
    }
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;

    n %= 1000;
    cout << ((!n) ? 0 : 1000 - n) << endl;
}   

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3648
N = int(input())
X = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
  tme = X[i + 1][0] - X[i][0]
  cor = abs(X[i + 1][1] - X[i][1]) + abs(X[i + 1][2] - X[i][2])
  ans.append(tme >= cor and tme % 2 == cor % 2)
print('Yes' if all(ans) else 'No')

Measured memory_bytes: 28148
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

class UnionFind {
  public:
    // 親の番号を格納する。親の場合 -1 になる
    vector<int> Parent;

    // 宣言されたとき Parent の値はすべて -1 にする
    UnionFind(int N) { Parent = vector<int>(N, -1); }

    // 与えられた値 x がどの親であるか調べる
    int root(int x) {
        if (Parent[x] < 0)
            return x;
        return Parent[x] = root(Parent[x]);
    }

    // 木の全体の数を返す
    int size(int x) { return -Parent[root(x)]; }

    // 2つの引数を同じ親にする
    bool update(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (size(x) < size(y))
            swap(x, y);
        Parent[x] += Parent[y];
        Parent[y] = x;
        return true;
    }

    // 引数の親が同じか判定する
    bool is_same(int x, int y) { return root(x) == root(y); }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    for (auto &&i : p) {
        cin >> i;
        i--;
    }
    auto uni = UnionFind(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        uni.update(a - 1, b - 1);
    }
    int ans = 0;
    REP(i, N) {
        if (uni.is_same(i, p[i]) || i == p[i])
            ans++;
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 1024
import math

A,B,H,M = map(int,input().split())

t=60*H+M

s1=2*math.pi*(t/60)/12
s2=2*math.pi*(t%60)/60

x1=A*math.cos(s1)
y1=A*math.sin(s1)

x2=B*math.cos(s2)
y2=B*math.sin(s2)

ans=math.sqrt((x2-x1)**2+(y2-y1)**2)

print(ans)

Measured memory_bytes: 9576
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

struct SegmentTree {
private:
	ll n;
	vector<ll> node;
public:
	SegmentTree(vector<ll> v) {
		ll sz = v.size();
		n = 1; while (sz > n) n *= 2;
		node.resize(2 * n - 1, 0);

		for (ll i = 0; i < sz; i++) {
			node[i + n - 1] = v[i];
		}
		for (ll i = n - 2; i >= 0; i--) {
			node[i] = node[i * 2 + 1] | node[i * 2 + 2];
		}
	}

	void update(ll x, ll val) {
		x += n - 1;
		node[x] = val;

		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = node[x * 2 + 1] | node[x * 2 + 2];
		}
	}

	ll getbitsum(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return node[k];


		ll vl = getbitsum(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = getbitsum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl | vr;
	}
};


int main(void)

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

	ll n;
	string s;
	cin >> n >> s;

	vector<ll> sl(n);

	rep(i, n)
	{
		sl[i] = 1LL << (ll)(s[i] - 'a');
	}

	ll q;
	cin >> q;

	SegmentTree bisu(sl);

	rep(i, q)
	{
		ll ty;
		cin >> ty;
		if (ty == 1)
		{
			ll point; char ch;
			cin >> point >> ch;

			bisu.update(point - 1, 1 << (ll)(ch - 'a'));
		}
		else
		{
			ll l, r;
			cin >> l >> r;
			cout << __builtin_popcount(bisu.getbitsum(l - 1, r)) << endl;

		}
	}
	return 0;
}

Measured memory_bytes: 16924
s = input()
k = int(input())
n = len(s)
temp_set = set()
for i in range(n):
    for j in range(i + 1, min(i + k + 1, n + 1)):
        temp_set.add(s[i:j])
temp_list = sorted(list(temp_set))
print(temp_list[k - 1])

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

int is_prime(int n) {
  int i;

  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  int n, m, c = 0;

  cin >> n;
  while (n--) {
    cin >> m;
    if (is_prime(m)) {
      c++;
    }
  }

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 1160
//mangesh2102000

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long int 
#define ld long double
#define pb push_back
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define F first
#define S second
#define mod 1000000000

int n,W;
int w[105];
int v[105];
int dp[1005*105][105];

void solve(int t)
{
	cin >> n >> W;
	int V=0;
	for(int i=0;i<n;i++)
	{
		cin >> w[i] >> v[i];
		V += v[i];
	}

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=V;j++)
		{
			dp[j][i] = 1e18;
			if(j==0)
				dp[j][i] = 0;
			if(i==0)
				continue;

			if(j-v[i-1]>=0)
				dp[j][i] = min(dp[j][i-1],dp[j-v[i-1]][i-1]+w[i-1]);
			else
				dp[j][i] = dp[j][i-1];

			//cout << j << "-" <<  i << "--" << dp[j][i] << " ";
		}
		//cout << endl;
	}

	int ans=-1;
	for(int i=V;i>=0;i--)
	{
		if(dp[i][n] <= W)
		{
			ans = i;
			break;
		}
	}	

	cout << ans;
    //cout << "Case #" << t << ": " << ;
}   


int32_t main()
{
    IOS;
    int t;
    t=1;
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }

    return 0;
}

Measured memory_bytes: 84224
#include<bits/stdc++.h>
using namespace std;
string func(string a,string b)
{
  int m=a.length();
  int n = b.length();
  int i,j;
  int dp[m+1][n+1];
  string lcs="";
  for(i=0;i<=m;i++)
  {
    for(j=0;j<=n;j++)
    {
      if(i==0||j==0)
        dp[i][j]=0;
      else if(a[i-1]==b[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  i=m;j=n;

  while(i>0&&j>0)
  {
    
    if(a[i-1]==b[j-1])
    {
      lcs+=a[i-1];
      i--;
      j--;
    }
    else
    {
      if(dp[i-1][j]>dp[i][j-1])
        i--;
      else
        j--;
    }
    
  }
  
  
  reverse(lcs.begin(),lcs.end());
  cout<<lcs<<"\n";
 
  
}
int main()
{
  string a,b;
  cin>>a>>b;
  func(a,b);
}
      
    
      

Measured memory_bytes: 35456
#include <vector>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int num = 0, res = 0;
    vector<int> data;
    cin >> num;
    for (int i = 0; i < num; ++i) {
        int tmp;
        cin >> tmp;
        data.push_back(tmp);
    }
    int index = 0;
    while (index < num) {
        ++res;
        int val = data[index++];
        while (index < num && data[index] == val) ++index;
        if (index == num) break;
        if (data[index++] > val) {
            while (index < num && data[index] >= data[index-1]) ++index;
        } else {
            while (index < num && data[index] <= data[index-1]) ++index;
        }
    }
    cout << res << endl;
    return 0;
}

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

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

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

int main () {
    string s,t;
    cin >> s >> t;
    int answer = 0;
    for (int i = 0; i < 3; i++) {
        if (s.at(i) == t.at(i)) {
            answer++;
        }
    }
    cout << answer << endl;
}

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

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

    int R;
    cin>>R;

    double pi=3.1415926535897932384626433;
    double ans = R*2*pi;
    printf("%lf\n",ans);

    return 0;
}


Measured memory_bytes: 3744
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

using namespace std;

// typename alias
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T> >;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using vvll = vvec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;

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

int main() {
    int A, B, N;
    cin >> N >> A >> B;
    int train_sum = A * N;
    int tax_sum = B;
    if (train_sum > tax_sum) cout << tax_sum << endl;
    if (train_sum <= tax_sum) cout << train_sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  int n;cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  long long ans=0;
  for(int i=n-1;i>1;i--){  
    for(int left=0;left<i-1;left++){ 
      int right=left+1;
      while(l[left]+l[right]<=l.at(i)){
        right++;
      }
      if(l[left]+l[right]>l[i]){
        ans+=i-right;
      }
    }
  }
  cout << ans;
}

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

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int WCON[2002][2002] = {0};
int HCON[2002][2002] = {0};

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL H, W; cin >> H >> W;
	vector<string> S;
	for(int i=0; i<H; i++){
		string s;
		for(int j=0; j<W; j++){
			char c; cin >> c;
			s.push_back(c);
		}
		S.push_back(s);
	}
	for(int i=0; i<H; i++){
		int sum = 0;
		for(int j=0; j<W; j++){
			if(S[i][j] == '#'){
				WCON[i][j] = 0;
				sum = 0;
			}
			else{
				sum++;
				WCON[i][j] = sum;
			}

		}
		for(int j=W-2; j>=0; j--){
			if(WCON[i][j] > 0 && WCON[i][j+1] > 0){
				WCON[i][j] = WCON[i][j+1];
			}
		}
	}
	for(int j=0; j<W; j++){
		int sum = 0;
		for(int i=0; i<H; i++){
			if(S[i][j] == '#'){
				HCON[i][j] = 0;
				sum = 0;
			}
			else{
				sum++;
				HCON[i][j] = sum;
			}

		}
		for(int i=H-2; i>=0; i--){
			if(HCON[i][j] > 0 && HCON[i+1][j] > 0){
				HCON[i][j] = HCON[i+1][j];
			}
		}
	}
	int ans = 0;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			int u = HCON[i][j] + WCON[i][j] - 1;
			if(ans < u){
				ans = u;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 38540
/*
Author : N_o_o_B
Created : December 03 2019 15:16:12 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;
bitset<10> a;
bool chk(int n){
    bool ok=1;
    while(n){
        int r=n%10;
        ok &= (a[r]==0);
        n/=10;
    }
    return ok;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n,k;
    cin >> n >> k;
    fori(i,k){
        int x;
        cin >> x;
        a[x] = 1;
    }
    for(int i=n;;i++){
        if(chk(i)){
            cout << i << endl;
            return 0;
        }
    }


    time_taken();
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	for i := n; i > 0; i-- {
		r := math.Sqrt(float64(i))
		if math.Ceil(r) == r {
			fmt.Println(int(i))
			return
		}
	}
}


Measured memory_bytes: 512
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def input():
    return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    A = list(map(int, input().split()))

    S = [0]
    for a in A:
        S.append(S[-1] + a)

    cnt = {}
    for s in S:
        if s not in cnt:
            cnt[s] = 1
        else:
            cnt[s] += 1

    ans = 0
    for v in cnt.values():
        if v >= 2:
            ans += cmb(v, 2)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 109120
#include <cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;++i)

const int N=2005;
const int P=924844033;
int n,k,a[N],fac[N];
long long f[N][N][2][2];
bool vis[N];

int main() {
    scanf("%d%d",&n,&k);
    fac[0]=1;
    FOR(i,1,n) fac[i]=1LL*fac[i-1]*i%P;
    int tot=0;
    FOR(i,1,n) if(!vis[i]) for(int j=i;j<=n;j+=k) vis[j]=1,a[++tot]=j;
    f[0][0][0][0]=1;
    a[0]=-(1<<30);
    FOR(i,1,n) {
        f[i][0][0][0]=1;
        FOR(j,1,i) {
            f[i][j][0][0]=(f[i-1][j][1][0]+f[i-1][j][0][0]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%P;
            f[i][j][0][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%P;
            f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%P;
            f[i][j][1][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%P;
        }
    }
    int ans=0;
    FOR(i,0,n) {
        int sum=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%P;
        if(i&1) (ans+=P-1LL*sum*fac[n-i]%P)%=P;
        else (ans+=1LL*sum*fac[n-i]%P)%=P;
    }
    printf("%d\n",ans);
    return 0;
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<t.size();i++)
    {
    	if(s[i]!=t[i])
    		cnt++;
    }

    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 3808
import heapq
# v:頂点数, s:始点, path[i]:[[cost,to]...] i=fromの隣接リスト
def dijkstra(v,s,path):
    inf = float('inf')

    # 距離をinfで初期化
    d = [inf for i in range(v)]
    d[s] = 0

    # sへの距離は0
    q = [[0,s]]
    heapq.heapify(q)

    # 距離が最小の頂点から更新していけば
    # p[1]から行ける
    while q:
        p = heapq.heappop(q)

        # 頂点p[1]までの距離がheapないのp[1]までの距離より小さい場合、continue
        if d[p[1]]<p[0]:
            continue

        # 頂点p[1]から伸びる、全ての辺の距離を確認
        for i in range(len(path[p[1]])):
            # 頂点p[1]から行ける頂点の距離がp[1]までの距離とp[1]からの距離の和より小さい場合 -> 距離を更新し、heapに追加
            if d[path[p[1]][i][1]] > d[p[1]] + path[p[1]][i][0]:
                d[path[p[1]][i][1]] = d[p[1]]+path[p[1]][i][0]
                heapq.heappush(q,[d[path[p[1]][i][1]], path[p[1]][i][1]])
    return d

n = int(input())

l = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    # dijkstraのlibraryに合わせるため、距離1を追加
    l[a-1].append([1,b-1])
    l[b-1].append([1,a-1])

d1 = dijkstra(n,0,l)
d2 = dijkstra(n,n-1,l)

a = 0
for i in range(n):
    if d1[i]<=d2[i]:
        a+=1
    else:
        a-=1
print('Fennec' if a>0 else 'Snuke')


Measured memory_bytes: 107680
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a, b;
    cin>>a>>b;
    rep(i, 1 , 3)
    {
        int to = a * i * b;
        if(to & 1)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256