akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

const int MOD=1e9+7;

int dp[100010];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    map<int,bool> m;
    rep(i,M){
        int a; cin >> a;
        m[a]=true;
    }
    dp[0]=1; if(!m[1]) dp[1]=1;
    rep(i,N-1){
        if(!m[i+2]){
            if(!m[i+1] && !m[i])
                dp[i+2] = dp[i+1] + dp[i];
            else if(!m[i+1])
                dp[i+2] = dp[i+1];
            else if(!m[i])
                dp[i+2] = dp[i];
            else {
                cout << 0 << endl;
                return 0;
            }
            dp[i+2]%=MOD;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 7296
def a(v1,v2):
	if v1[0] != v2[0]:
		return (v2[1]-v1[1])/(v2[0]-v1[0])
	else:
		return (v2[1]-v1[1])*(10**10)
		
def convex(v,n):
	k = 0
	d = []
	u = []
	for i in range(n):
		d.append(i)
		u.append(i)
		while len(d) > 2:
			if a(v[d[-3]],v[d[-2]]) < a(v[d[-2]],v[d[-1]]):
				del d[-2]
			else:
				break
		while len(u) > 2:
			if a(v[u[-3]],v[u[-2]]) > a(v[u[-2]],v[u[-1]]):
				del u[-2]
			else:
				break
	return n - len(set(d+u))
	
while 1:
	n = input()
	if n == 0: break
	v = [map(float,raw_input().split(",")) for i in range(n)]
	v = sorted(sorted(v, key = lambda x:x[1]))
	print convex(v,n)

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

int main(){
  int a,b;
  cin >> a >> b;
  for(int n=1; n<=100*(100/8); n++){
    if(floor(n*(8.0/100))==a && floor(n*(10.0/100))==b){
      cout << n << endl;
      break;
    }else if(floor(n*(8.0/100))>a || floor(n*(10.0/100))>b){
      cout << -1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
#define inf ll(1e9)
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}
int main()
{
	ios;
	ll t=1;
	while(t--){
		ll n,k,c;
	cin>>n>>k>>c;
	string s;cin>>s;vtr<ll> a,b;ll i;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='o')
		{
			a.pb(i+1);
			i+=c;
			if(a.size()>=k)break;
		}
	}
	for(i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='o')
		{
			b.pb(i+1);
			i-=c;
			if(b.size()>=k)break;
		}
	}reverse(b.begin(),b.end());vtr<ll> ans;
	for(i=0;i<k;i++)
	{
		if(a[i]==b[i])ans.pb(a[i]);
	}
	for(i=0;i<ans.size();i++)cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 6664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    int dp[100005];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    dp[n-1]=0;
    dp[n-2]=abs(arr[n-1]-arr[n-2]);
    for(int i=n-3; i>=0; i--)
    {
        dp[i]=min(dp[i+1]+abs(arr[i+1]-arr[i]), dp[i+2]+abs(arr[i+2]-arr[i]));
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  ll A, B, C, D, a = 0;
  ci(A, B, C, D);
  a = B - B / C - B / D + B / lcm(C, D) - ((A - 1) - (A - 1) / C - (A - 1) / D + (A - 1) / lcm(C, D));
  co(a);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int yen, happiness = 0, temp;

    scanf("%d", &yen);

    if(yen >= 500)
    {
        temp = yen / 500;
        happiness = temp * 1000;
        yen -= temp * 500;
        temp = yen / 5;
        happiness += temp * 5;
    }
    else
    {
        temp = yen / 5;
        happiness = temp * 5;
    }

    printf("%d", happiness);

    return 0;
}

Measured memory_bytes: 128
# coding: utf-8
import math


def main():
    input_list = [input() for i in range(3)]
    H = int(input_list[0])
    W = int(input_list[1])
    N = int(input_list[2])

    if H >= W:
        ans = math.ceil(N / H)
    else:
        ans = math.ceil(N / W)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rp(x)	return cout<<x<<endl,0;
using namespace std;

int main(){
	int x,n;
	cin>>x>>n;
	set<int>se;
	for(int i=0;i<n;i++){
		int k;cin>>k;
		se.insert(k);
	}
	int start=x,end=x;
	while (1){
		if(!se.count(start))break;
		start--;
	}
	while (1){
		if(!se.count(end))break;
		end++;
	}
	if(abs(x-start<=abs(x-end)))
		rp(start);
	cout<<end<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

int main() {
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    int D, G; cin >> D >> G;
    vector<int> vp(D), vc(D);
    REP(i, D) cin >> vp[i] >> vc[i];
    int res = INF;
    for (int bit = 0; bit < (1 << D); ++bit) {
        int pnum = 0; int score = 0;
        for (int i = 0; i < D; ++i) {
            if (bit >> i & 1) {
                score += 100 * (i+1) * vp[i] + vc[i];
                pnum += vp[i];
            }
        }
        for (int i = D-1; i >= 0; i--) {
            if (score >= G) { chmin(res, pnum); break; }
            if ((bit >> i & 1) == 0 && 100 * (i+1) * vp[i] >= G - score) {
                pnum += ((G - score) + 100 * (i+1) - 1) / (100 * (i + 1));
                chmin(res, pnum);
                break;
            }
        }
    }

    cout << res << endl;
}


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

const int N = 1e5 + 5;

int n, a[N], ans;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (a[i] < i && a[a[i]] == i) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
#include <stdbool.h>
#include<limits.h>
typedef  unsigned long long ll;
#define MOD 10e9+7  //10億　= 10^9
#define length 100000+3000 //10万
#define kw_len 10+2
#define INF 16446000000009000
#define pi 3.1415926535897932384

inline bool repmax(ll a,ll b,ll *array){
    if(a > b){
        *array = a;
        return true;
    }
    else{
        *array = b;
        return false;
        }
}

inline bool repmin(ll a,ll b,ll *array){
    if(a < b){
        *array = a;
        return true;
    }
    else{
        *array = b;
        return false;
        }
}
ll DP[100050];
ll height[100050];
int main(){
    ll N;
    scanf("%llu",&N);
    memset(height, INF, N+50);
    for(int i=0;i<N;i++){
        scanf("%llu",(height+i));
    }
    DP[1] = llabs(height[0]-height[1]);
    DP[0] = 0;
    
    for(int i=2;i<N;i++){
        repmin(llabs(height[i]-height[i-1])+DP[i-1],llabs(height[i-2]-height[i])+DP[i-2],DP+i);
    }
    
    printf("%llu",DP[N-1]);
    return 0;
}

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

using ll = long long;
ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

int main()
{
    int N, X;
    cin >> N >> X;
    vector<ll> x(N, 0);
    for (int i = 0; i < N; i++)
        cin >> x[i];
    vector<ll> diff(N, 0);
    for (int i = 0; i < N; i++)
    {
        diff[i] = abs(X - x[i]);
    }
    ll ans = diff[0];
    for (int i = 0; i < N; i++)
    {
        ans = gcd(ans, diff[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

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

  int max = H[N-1];
  for(int i=N-1; i>=0; --i) {
    if (H[i] >= (max+2)) {
      cout << "No" << endl;
      return 0;
    }
    if (H[i] < max) {
      max = H[i];
    }
  }
  cout << "Yes" << endl;
 
  return 0;
}


Measured memory_bytes: 640
/* ex4-2
   kas056*/

#include <stdio.h>
#include <stdlib.h>


#define SIZE 1000001

typedef struct node{
    char num;
    struct node *next;//次のノードのポインタ
}stack;



void push(stack **first,  char number){
    stack *new = calloc(1,sizeof(stack));//メモリ確保
    if(new == NULL){//できなかったら終了
        exit(1);
    }
    new->num = number;//newの指すアドレスのnumの要素にnumber代入
    new->next = *first;//新しく作ったノードの次のノードをfirstが指すノードにする。
    *first = new;//一番手前のノードをfirstとして更新
    
}

void pop(stack **first){
    stack *tmp = *first;//保存場所用意。
    
    if(tmp == NULL){//メモリ確保
        exit(1);
    }

    *first = tmp->next;//firstの値を、今指すノード(先頭だったもの)の次のノードに変える。
    free(tmp);//メモリ開放
}


int main(void){
    char sentence[SIZE];
    int i;
    int collected = 0;//収集した色
    stack *stk;

    stk = NULL;//初めはNULLを指すようにする。

    scanf("%s", sentence);//入力読込
    for(i=0; sentence[i] != '\0'; i++){
        push(&stk, sentence[i]);//stkの表すアドレスの位置にsentenceの要素を入れる。

        //次のノードがNULLでないかつそのノード内の値が異なる⇒2回popし、collectedを2増やす。
        if(stk->next != NULL && stk->num != stk->next->num){
            pop(&stk);
            pop(&stk);
            collected += 2;
        }
    
    }      
    
    //回収した合計値出力
    printf("%d\n", collected);

    return 0;
}

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

int main()
{
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double centx = (double)w/2.0;
    double centy = (double)h/2.0;
    int ans = 0;
    double area = (double)(w*h/2.0);
    if(x == centx && y == centy){
        ans = 1;
    }
    cout  << fixed << setprecision(10) << (double)w*(double)h/2 << " " << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<numeric>
using namespace std;
int main() {
	long long  a = 0, b = 0, x = 0, max = 0;
	long long  n = 0, ans = 0, k = 0;
	long long left = 0, right = 0, count = 0;
	string s, t, u;
	vector<double> z(3,0), zz;
	vector<long long int>::iterator position;
	bool q = false;
	cin >> z[0]>>z[1]>>z[2];
	sort(z.begin(), z.end());
	if (z.at(0) == z.at(1) && z.at(1) != z.at(2))cout << "Yes" << endl;
	else if (z.at(1) == z.at(2) && z.at(0) != z.at(1))cout << "Yes" << endl;
	else  cout << "No" << endl;
	
}

Measured memory_bytes: 256
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
long long solve()
{
	long long n,k;cin>>n>>k;
	std::vector<long long> inp(n);
	REP(i,0,n-1){cin>>inp[i];}
	std::vector<long long> fin(42,0);
	for(auto it:inp)
	{
		REP(i,0,40)
		{
			if(it&(1ll<<i)){++fin[i];}
		}
	}
	ll ans=0;
	for(long long i=40;i>=0;--i)
	{
		if((fin[i]<(n-fin[i]))&&((ans+(1ll<<i))<=k))
		{
			ans+=(1ll<<i);
		}
	}
	ll fin1=0;
	REP(i,0,n-1)
	{
		fin1+=(ans^inp[i]);
	}
	cout<<fin1<<"\n";
}
signed main(){
	//speed
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
s=input()

if s=="SUN":
    ans=7
elif s=="MON":
    ans=6
elif s=="TUE":
    ans=5
elif s=="WED":
    ans=4
elif s=="THU":
    ans=3
elif s=="FRI":
    ans=2
elif s=="SAT":
    ans=1
print(ans)


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

int main() {
  int N ;
  cin >> N ;
  int l ,r ;
  int p = 0;
  for (int i = 0; i < N; i++ ){
    cin >> l >> r;
    p = p + r - l + 1 ;
  }
  cout << p << endl;
}


Measured memory_bytes: 3552
n, k = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
# print(n, k, a)
if n == k:
    print(1)
elif (n-k)%(k-1) == 0:
    print((n-k)//(k-1)+1)
else:
    print((n-k)//(k-1)+2)


Measured memory_bytes: 14008
#include <stdio.h>

int main(void) 
{
  int a, b, tmp, GCM;

  scanf("%d %d", &a, &b);

  /* ユークリッドの互除法 */

  if (b > a) {
    tmp = a;
    a   = b;
    b   = tmp;
  }

  while (b != 0) {
    tmp = b;
    b   = a % b;
    a   = tmp;
  }

  GCM = a;

  printf("%d\n", GCM);

  return 0;
}

Measured memory_bytes: 592
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


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


def main():
    N = int(input())
    if N <= 999:
        print("ABC")
    else:
        print("ABD")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M,s[6],c[6];
	int flag=1;
	bool alre[5]={};
	int now[5]={};
	scan(N>>M);
	rep(i,M){
		scan(s[i]>>c[i]);
		if(N!=1&&s[i]==1&&c[i]==0) flag=0;
		if(alre[s[i]]==1&&now[s[i]]!=c[i]) flag=0;
		else{
			alre[s[i]]=1;
			now[s[i]]=c[i];
		}
	}
	if(flag){
		if(N==1) prin(now[1]);
		else if(N==2){
			if(now[1]==0) prin(10+now[2]);
			else prin(10*now[1]+now[2]);
		}
		else{
			if(now[1]==0) prin(100+10*now[2]+now[3]);
			else prin(100*now[1]+10*now[2]+now[3]);
		}
	}
	else prin(-1);
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	p := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		m, _ := strconv.Atoi(sc.Text())
		p[i] = m
	}

	sort.Ints(p)
	p[n-1] /= 2

	ans := 0
	for _, v := range p {
		ans += v
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N;
cin >> N;
long long numbers[200010];
long long count[200010];

long long zen = 0;

for(int i = 0; i < N; i++){
    long long A;
    cin >> A;
    A--;
numbers[i] = A;
count[i] = 0;
}

for(int i = 0; i < N; i++){
count[numbers[i]]++;
}
for(int i = 0; i < N; i++){
zen += (count[i]*(count[i]-1)) / 2;
}

for(int i = 0; i < N; i++){
long long val = count[numbers[i]];


long long before = 0;
long long after = 0;
before = (val * (val-1)) / 2;
after = ((val -2)*(val-1)) / 2;
cout << zen + after - before << endl;
}



} 


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using s32 = int32_t;
using u32 = uint32_t;
using s64 = int64_t;
using u64 = uint64_t;

int main() {
	long double L;
	cin >> L;
	
	cout << fixed << setprecision(7) << L * L * L / 27;
	return 0;
}

Measured memory_bytes: 256
import heapq


class MinCostFlow:
    class Edge:
        def __init__(self, to, cap, rev, cost):
            self.to, self.cap, self.rev, self.cost = to, cap, rev, cost

    def __init__(self, V):
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, fr, to, cap, cost):
        self.E[fr].append(self.Edge(to, cap, len(self.E[to]), cost))
        self.E[to].append(self.Edge(fr, 0, len(self.E[fr])-1, -cost))

    def run(self, source, sink, f, INF=10**5):
        res = 0
        h, prevv, preve = [0] * self.V, [0] * self.V, [0] * self.V
        while (f > 0):
            pque = []
            dist = [INF] * self.V
            dist[source] = 0
            heapq.heappush(pque, (0, source))
            while pque:
                cost, v = heapq.heappop(pque)
                cost = -cost
                if dist[v] < cost:
                    continue
                for i, e in enumerate(self.E[v]):
                    if e.cap > 0 and dist[v] - h[e.to] < dist[e.to] - e.cost - h[v]:
                        dist[e.to] = dist[v] + e.cost + h[v] - h[e.to]
                        prevv[e.to], preve[e.to] = v, i
                        heapq.heappush(pque, (-dist[e.to], e.to))
            if dist[sink] == INF:
                return -1
            for v in range(self.V):
                h[v] += dist[v]

            d, v = f, sink
            while v != source:
                d = min(d, self.E[prevv[v]][preve[v]].cap)
                v = prevv[v]
            f -= d
            res += d * h[sink]
            v = sink
            while v != source:
                self.E[prevv[v]][preve[v]].cap -= d
                self.E[v][self.E[prevv[v]][preve[v]].rev].cap += d
                v = prevv[v]
        return res


while True:
    N = int(input())
    if not N:
        break
    V = 366
    mcf = MinCostFlow(V)
    for i in range(V - 1):
        mcf.add_edge(i, i + 1, 2, 0)
    for _ in range(N):
        s, t, c = map(int, input().split())
        mcf.add_edge(s - 1, t, 1, -c)
    print(-mcf.run(0, V - 1, 2, 10 ** 9))

Measured memory_bytes: 8616
#include<bits/stdc++.h>
#include<string.h>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,j,k=0,sum=0;
    cin>>n;
  char a[n];
   for(i=0;i<n;i++)
   {
       cin>>a[i];
   }




for(i=0;i<n;i++)
   {
       if(a[i]!=a[i+1])
       {
           sum++;
       }

   }

cout<<sum<<endl;
    return 0;

}



Measured memory_bytes: 384
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, m, l[MAXN], r[MAXN], d[MAXN];
vector < pair < int, int > > g[MAXN];
vector < int > ts;
int used[MAXN];

void dfs(int v) {
	used[v] = 1;
	for(auto &it : g[v]) {
		int to = it.first;
		if(used[to] == 1) {
			cout << "No\n";
			exit(0);
		}
		if(!used[to]) dfs(to);
	}
	used[v] = 2;
	ts.pb(v);
}
int pos[MAXN];

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n >> m;
	rep(i, 1, m) {
		cin >> l[i] >> r[i] >> d[i];
		g[l[i]].pb(mp(r[i], d[i]));
	}
	rep(i, 1, n) if(!used[i]) dfs(i);
	reverse(all(ts));
	memset(pos, 255, sizeof pos);
	rep(i, 0, sz(ts) - 1) {
		int v = ts[i];
		if(pos[v] == -1) pos[v] = 0;
		for(auto &it : g[v]) {
			int to = it.first, w = it.second;
			if(pos[to] != -1 && pos[to] != pos[v] + w) {
				cout << "No\n"; return 0;
			}
			pos[to] = pos[v] + w;
		}
	}
	cout << "Yes\n";
	
	return 0;
}

Measured memory_bytes: 28920
#include<iostream>
using namespace std;
long n,x;
long f(long p,long q){
	if(q==0)return 0;
	if(p==0)return 1;
	long m=1LL<<p;
	if(q<2*m-1)return f(p-1,q-1);
	return m+f(p-1,q-2*m+1);
}
int main(){
	cin>>n>>x;
	cout<<f(n,x);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
sort_a = sorted(a, reverse=True)
amax = sort_a[0]
asecond = sort_a[1]
for i in range(n):
    tmp = a[i]
    if tmp == amax:
        print(asecond)
    else:
        print(amax)

Measured memory_bytes: 18780
#include <stdio.h>
#include <math.h>
int main() {
    int L,A,B,C,D;
    scanf("%d %d %d %d %d",&L,&A,&B,&C,&D);
    if (A % C == 0) {
        A = (A / C);
    }else{
        A = (A / C) + 1;
    }
    if (B % D == 0) {
        B = (B / D);
    }else{
        B = (B / D) + 1;
    }
    if (A > B) {
        L -= A;
    }else if(A <= B){
        L -= B;
    }
    printf("%d\n",L);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define le 210

using namespace std;
int n[le];

int main()
{
  int len, c = 0;
  scanf("%d", &len);
  for(int i = 0; i < len; i++) scanf("%d", &n[i]);
  bool f = 1;
  bool s = 1;
  while(f == 1){
    for(int i = 0; i < len; i++){
      if(n[i] % 2 != 0){
        s = 0;
        f = 0;
      }
    }
    if(s) c++;
    for(int i = 0; s == 1 && i < len; i++){
      n[i] = n[i] / 2;
    }
  }
  printf("%d\n", c);
  
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = b;
    int i = 1;
    while(b <= a){
      i++;
      b *= c;
    }
    System.out.println(i);
  }
}

Measured memory_bytes: 22484
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var N, K int
	fmt.Scan(&N, &K)
	p := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	sum := 0
	for i := 0; i < K; i++ {
		sum += p[i]
	}

	fmt.Fprintln(wtr, sum)
	_ = wtr.Flush()
}


Measured memory_bytes: 1896
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

long long mmax(long long a,long long b,long long c,long long d){
    vector<long long>temp(4);
    temp[0]=a*c;
    temp[1]=a*d;
    temp[2]=b*c;
    temp[3]=b*d;
    sort(temp.begin(),temp.end());
    //rep(i,4) cout<<temp[i]<<endl;
    return temp[3];
}

int main(void){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans=mmax(a,b,c,d);
    //cout<<ans<<endl;
    if(a*b<=0 || c*d<=0) if(ans<0) ans=0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong(); // S
        long m = sc.nextLong(); // c
        if (m >= 2 * n) {
            System.out.println(n + (m - 2 * n) / 4);
        } else {
            System.out.println(m / 2);
        }
    }
}

Measured memory_bytes: 19028
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        if all((A[i+y][j:j+M] == B[y] for y in range(M))):
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>

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

using namespace std;

int main(){
	long long int x, y, ans;
	cin >> x >> y;
	ans = 0;
	while (x<=y){
		x = x*2;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    string s; cin >> s;
    for (auto& c : s) {
        if (c == ',') {
            c = ' ';
        }
    }
    cout << s << endl;
}


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

int main() {
  vector<int> a(5);
  string s[7] = {"null", "one pair", "two pair", "three card", "straight", "full house", "four card"};

  while (~scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < 4; ++i) {
      if (a[i] == a[i + 1]) {
        ans = 1;
        for (int j = i + 2; j < 5; ++j) {
          if (a[j] == a[j + 1]) ans = 2;
        }
        break;
      }
    }

    for (int i = 0; i < 3; ++i) {
      if (a[i] == a[i + 2]) ans = 3;
    }

    bool f = true;
    for (int i = 1; i < 5; ++i) {
      if (a[i] - 1 == a[i - 1]) continue;
      if (a[i - 1] == 1 && a[i] == 10) continue;
      f = false;
    }
    if (f) ans = 4;

    if (a[0] == a[1] && a[3] == a[4] && (a[1] == a[2] || a[2] == a[3])) ans = 5;

    if (a[0] == a[3] || a[1] == a[4]) ans = 6;

    cout << s[ans] << endl;
  }
}

Measured memory_bytes: 3108
import numpy as np
N, M = list(map(lambda x: int(x), input().split()))
cleared = np.array([False for i in range(N+1)])
wa_count = np.array([0 for i in range(N+1)])
for _ in range(M):
  p, s = input().split()
  p = int(p)
  
  if cleared[p]:
    continue
  if s == "AC":
    cleared[p] = True
  elif s == "WA":
    wa_count[p] = wa_count[p] + 1

print("{} {}".format(sum(np.array(cleared) *1), sum(wa_count[cleared])))

Measured memory_bytes: 14852
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int c[m][2];
  for(int i=0;i<m;i++)
    cin>>c[i][0]>>c[i][1];
  int start=pow(10,n-1);
  int end=start*10;
  if(n==1)
    start=0;
  for(int i=start;i<end;i++){
    string s="";
    int j=i;
    do{
      char d='0'+j%10;
      s=d+s;
      j=j/10;
    }while(j!=0);
    int check=1;
    for(int k=0;k<m;k++){
      if(s[c[k][0]-1]!=c[k][1]+'0')
        check=0;
    }
    if(check==1){
      cout<<i;
      return 0;
    }
  }
  cout<<"-1\n";
}

Measured memory_bytes: 256
def main():
    n = int(input())
    w = [int(s) for s in input().split()]
    print(solve(n, w))

def solve(n, w):
    s = [w[0]]

    for i in range(1, n):
        s.append(s[-1] + w[i])
    
    ans = min(abs(s[i] * 2 - s[-1]) for i in range(n))
    return ans


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	string s;
	cin>>s;
	if((stoi(s.substr(0,2))>=13||stoi(s.substr(0,2))==0)&&((stoi(s.substr(2,2))>=13)||stoi(s.substr(2,2))==0))puts("NA");
	else if((stoi(s.substr(2,2))>=13)||stoi(s.substr(2,2))==0)puts("MMYY");
	else if(stoi(s.substr(0,2))>=13||stoi(s.substr(0,2))==0)puts("YYMM");
	else puts("AMBIGUOUS");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int A, B, C, X;
    int counter = 0;
    scanf("%i %i %i %i", &A, &B, &C, &X);
    for (int i = 0; i <= A; i++){
        for (int j = 0; j <= B; j++){
            for (int k = 0; k <= C; k++){
                if (500 * i + 100 * j + 50 * k == X){
                    counter++;
                }
            }
        }
    }
    printf("%i\n", counter);
}

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

const int N=110, M=5e3+300;
int h,w,F[M][M],idh[N][N],idw[N][N];
char mp[N][N]; int stx,sty,s[N][N];
inline int& f(int l,int r,int u,int d) {return F[idh[l][r]][idw[u][d]];}
inline int getarea(int xc1,int xc2,int yc1,int yc2) {
    return s[xc2][yc2]-s[xc1-1][yc2]-s[xc2][yc1-1]+s[xc1-1][yc1-1];
}
inline int calcl(int p,int up,int dn,int l,int r,int u,int d) {
    if(p<=r || p+l>w) return 0;
    up=max(up,d+1); dn=min(dn,h-u);
    if(up>dn) return 0;
    return getarea(up,dn,p,p);
}
inline int calcr(int p,int li,int ri,int l,int r,int u,int d) {
    if(p<=d || p+u>h) return 0;
    li=max(li,r+1); ri=min(ri,w-l);
    if(li>ri) return 0;
    return getarea(p,p,li,ri);
}
int main() {
    cin>>h>>w; 
    for(int i=1;i<=h;i++) cin>>(mp[i]+1);
    for(int i=1;i<=h;i++) 
        for(int j=1;j<=w;j++) {
            if(mp[i][j]=='o') s[i][j]=1;
            if(mp[i][j]=='E') stx=i, sty=j;
            s[i][j]=s[i][j-1]+s[i-1][j]-s[i-1][j-1]+s[i][j];
        }
    for(int l=0,cnt=0;l<=sty;++l)
        for(int r=0;sty+r<=w;++r)
            idh[l][r]=cnt++;
    for(int u=0,cnt=0;u<=stx;++u)
        for(int d=0;d+stx<=h;++d)
            idw[u][d]=cnt++;

    int ans=0;
    for(int l=0;l<=sty;++l)
        for(int r=0;sty+r<=w;++r)
            for(int u=0;u<=stx;++u)
                for(int d=0;d+stx<=h;++d) {
                    int &s=f(l,r,u,d);
                    if(l) s=max(s,f(l-1,r,u,d)+calcl(sty-l,stx-u,stx+d,l-1,r,u,d));
                    if(r) s=max(s,f(l,r-1,u,d)+calcl(sty+r,stx-u,stx+d,l,r-1,u,d));
                    if(u) s=max(s,f(l,r,u-1,d)+calcr(stx-u,sty-l,sty+r,l,r,u-1,d));
                    if(d) s=max(s,f(l,r,u,d-1)+calcr(stx+d,sty-l,sty+r,l,r,u,d-1));
                    ans=max(ans,s);
                }
    cout<<ans<<'\n';
}

Measured memory_bytes: 54912
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
	int l, r, d;
  	int ans = 0;
  	cin>>l>>r>>d;
  	for(int i = l; i<=r; i++){
      if(i%d==0) ans++;
    }
  	cout<<ans;
}

Measured memory_bytes: 3560
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++){
			int temp = sc.nextInt();
			//~ System.out.println(temp);
			if (temp % 2 == 0){
				if (temp % 3 != 0 && temp % 5 != 0){
					count++;
					//~ System.out.println(temp + " " + temp % 3 + " " + temp % 5);
				}
			}
		}
		if (count == 0)
			System.out.println("APPROVED");
		else
			System.out.println("DENIED");
	}
}


Measured memory_bytes: 23380
s = input()[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
flag = 0
for _ in range(25000):
    if flag==4 or len(s)==0:
        break
    else:
        flag=0
    for word in words:
        l = len(word)
        if s[0:l] == word:
            s = s[l:]
        else:
            flag+=1
if flag==4:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    ll h, w, n; cin >> h >> w >> n;
    ll x, y;
    vector< pair<ll, ll> > a;

    rep(i,0,n) {
        cin >> x >> y;
        x--; y--;
        if(x-1>=0 && x<h-1) {
            if(y-1>=0 && y<w-1) a.pb(pii(x-1,y-1));
            if(y-2>=0) a.pb(pii(x-1,y-2));
            if(y<w-2) a.pb(pii(x-1,y));
        }
        if(x-2>=0) {
            if(y-1>=0 && y<w-1) a.pb(pii(x-2,y-1));
            if(y-2>=0) a.pb(pii(x-2,y-2));
            if(y<w-2)a.pb(pii(x-2,y));
        }
        if(y-1>=0 && x<h-2 && y<w-1) a.pb(pii(x,y-1));
        if(y-2>=0 && x<h-2) a.pb(pii(x,y-2));
        if(x<h-2 && y<w-2) a.pb(pii(x,y));
    }
    sort(a.begin(), a.end());

    pair< ll, ll > prev;
    int cnt = 1;
    ll ans[10] = {};
    rep(i,0,a.size()) {
        if(i == 0) prev = a[i];
        else if(prev != a[i]) {
            ans[cnt]++;
            cnt = 1;
            prev = a[i];
        }
        else cnt++;
    }
    if(n!=0) ans[cnt]++;

    ll sum = 0;
    rep(i,1,10) sum += ans[i];
    ans[0] = (h-2) * (w-2) - sum;

    rep(i,0,10) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 16744
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;

map<pi, bool> bomb_map;
unordered_map<int,int> freq_bombs_row, freq_bombs_column;
void solve() {
  int r, c, m;
  cin >> r >> c >> m;
  int max_freq_row = 0, max_freq_column = 0;
  for(int i=0,x,y;i<m;i++) {
    cin >> x >> y;
    x--, y--;
    bomb_map[{x,y}] = true;
    freq_bombs_row[x]++, freq_bombs_column[y]++;
    max_freq_row = max(max_freq_row, freq_bombs_row[x]);
    max_freq_column = max(max_freq_column, freq_bombs_column[y]);
  }

  vector<int> rows_with_max_freq, columns_with_max_freq;
  for(auto it : freq_bombs_row) {
    if(it.second == max_freq_row) {
      rows_with_max_freq.push_back(it.first);
    }
  }
  for(auto it: freq_bombs_column) {
    if(it.second == max_freq_column) {
      columns_with_max_freq.push_back(it.first);
    }
  }

  int ans = max_freq_row + max_freq_column - 1;
  if((ll)rows_with_max_freq.size() * columns_with_max_freq.size() > m) {
    ans++;
  }
  else {
    for(auto row : rows_with_max_freq) {
      for(auto col : columns_with_max_freq) {
        if(!bomb_map.count({row,col})) {
          ans++;
          cout << ans;
          return;
        }
      }
    }
  }
  cout << ans;
}

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

  int T=1;
  //cin>>T;
  for(int TC=1;TC<=T;TC++) {
      //cout<<"Case #"<<TC<<": ";
      solve();
      cout<<"\n";
  }
}


Measured memory_bytes: 53264
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i[] = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;

int main(){
    ll n;cin >> n;
    vec high(n, 0);
    rep(i, n){
        cin >> high[i];
    }
    vec cost(n);
    cost[0] = 0;
    cost[1] = abs(high[1] - high[0]);
    for(int i = 2;i < n;i++){
        cost[i] = min(cost[i-1] + abs(high[i] - high[i-1]),cost[i-2] + abs(high[i]-high[i-2]));
    }
    cout << cost[n-1] << endl;
}

Measured memory_bytes: 4828
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>

int main() {
    vector<bool> prime(100001,true);prime[1]=false;
    for(int i=2;i<=1000000;i++)if(prime[i]==true)for(int j=i+i;j<=100000;j+=i)prime[j]=false;

    vl ruiseki(100001,0);ll sum=0;
    rep(i,100000){
        if(i%2==0)if(prime[i+1]&&prime[(i+2)/2])sum++;
        ruiseki[i+1]+=sum;
    }
    ll q; cin>>q;
    rep(i,q){
        ll l,r;cin>>l>>r;
        cout<<ruiseki[r]-ruiseki[l-1]<<endl;
    }
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

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

	    int N=gi();
	    long[] A=new long[N+2];

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

	    long sum=0;
	    long bx=0;
	    for(int i=0; i<N+2; i++) {
	        sum+=Math.abs(A[i]-bx);

	        bx=A[i];
	    }

	    for (int i=1; i<N+1; i++) {
		    long y=sum;
		    y-=Math.abs(A[i-1] - A[i]);
		    y-=Math.abs(A[i+1] - A[i]);
		    y+=Math.abs(A[i+1] - A[i-1]);
		    System.out.println(y);
	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 61220
# -*- coding: utf-8 -*-

while True:
    line = map(str, raw_input().split())
    H = int(line[0])
    W = int(line[1])
    if H+W:
        for i in range(H):
            if i%2:
                if W%2:
                    print ".#"*(W/2) + "."
                else:
                    print ".#"*(W/2)
            else:
                if W%2:
                    print "#."*(W/2) + "#"
                else:
                    print "#."*(W/2)
        print ""
    else:
        break

Measured memory_bytes: 6448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
 
int N, K;
int a[200100];
int cnt[200100];
 
int main(void) {
	cin >> N >> K;
	rep(i, N) cin >> a[i];
	rep(i, N) cnt[a[i]]++;
 
	vector<pair<int, int>> v;
	rep(i, N + 1) if(cnt[i] > 0) v.pb(mp(cnt[i], i));
	sort(all(v));
	reverse(all(v));	
	ll ans = 0;
	reps(i, K, v.size()) ans += v[i].fi;
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

int main (){
    int n;
    vector<int> v;
    vector<int> c;
    cin >> n;
    int out = 0;
    int in;

    for(int i = 0; i<n; i++){
        cin >> in;
        v.push_back(in);
    }
    for(int i = 0; i<n; i++){
        cin >> in;
        c.push_back(in);
    }
    for(int i = 0; i<n; i++){
        if(v[i] - c[i] > 0){
            out += v[i] - c[i];
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
  ll n,a,b,ans=-1;
  cin>>a>>b;
  rep(i,0,300000){
    int x=0.08*i;
    int y=0.10*i;
    if(x==a&&y==b){ans=i;break;}
  }
  cout<<ans;
}

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

using namespace std;

struct Node {
  int id;
  Node* parent = nullptr;
  Node* left = nullptr;
  Node* right = nullptr;
  int depth;
  int height;

  int calcHeight() {
    int leftHeight = left ? left->calcHeight() : -1;
    int rightHeight = right ? right->calcHeight() : -1;
    height = max(leftHeight, rightHeight) + 1;
    return height;
  }

  void calcDepth() {
    depth = parent ? parent->depth + 1 : 0;
    if (left) left->calcDepth();
    if (right) right->calcDepth();
  }

  int degree() {
    int d = 0;
    if (left) ++d;
    if (right) ++d;
    return d;
  }

  Node* sibling() {
    if (!parent) {
      return nullptr;
    }
    if (parent->left == this) {
      return parent->right;
    } else {
      return parent->left;
    }
  }

  void walkPostorder() {
    static bool isFirst = true;
    if (left) left->walkPostorder();
    if (right) right->walkPostorder();
    if (isFirst) {
      cout << (id + 1);
      isFirst = false;
    } else {
      cout << " " << (id + 1);
    }
  }

  static Node* reconstruct(
    vector<Node>& nodes,
    vector<int>::const_iterator preorderBegin, vector<int>::const_iterator preorderEnd,
    vector<int>::const_iterator inorderBegin, vector<int>::const_iterator inorderEnd
  ) {
    if (inorderBegin == inorderEnd) {
      return nullptr;
    }
    auto root = &nodes[*preorderBegin];
    auto inorderMid = std::find_if(inorderBegin, inorderEnd, [&](int id){ return id == *preorderBegin; });
    auto leftCount = inorderMid - inorderBegin;
    auto left = reconstruct(nodes, preorderBegin + 1, preorderBegin + 1 + leftCount, inorderBegin, inorderMid);
    auto right = reconstruct(nodes, preorderBegin + 1 + leftCount, preorderEnd, inorderMid + 1, inorderEnd);
    root->left = left;
    root->right = right;
    return root;
  }
};

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

  int nodeCount;
  cin >> nodeCount;
  vector<Node> nodes(nodeCount);
  for (int i = 0; i < nodeCount; ++i) {
    nodes[i].id = i;
  }

  std::vector<int> preorderIDs, inorderIDs;

  for (int i = 0; i < nodeCount; ++i) {
    int id;
    cin >> id;
    preorderIDs.push_back(id - 1);
  }

  for (int i = 0; i < nodeCount; ++i) {
    int id;
    cin >> id;
    inorderIDs.push_back(id - 1);
  }

  auto root = Node::reconstruct(nodes, preorderIDs.begin(), preorderIDs.end(), inorderIDs.begin(), inorderIDs.end());

  root->walkPostorder();
  cout << endl;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5010;
int n,m,k,p[maxn];
bool vis[maxn];
ll c[maxn],a[maxn];
ll sol(int s)
{
    memset(vis,0,sizeof(vis));
    m=0;
    while(!vis[s])
    {
        a[++m]=c[s];
        vis[s]=true;
        s=p[s];
    }
    for(int i=2;i<=m;i++)
        a[i]+=a[i-1];
    ll ans=-1e18;
    for(int i=1;i<=min(m,k);i++)
    {
        ans=max(ans,a[i]);
        ans=max(ans,a[i]+(k-i)/m*a[m]);
    }
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&p[i]);
    for(int i=1;i<=n;i++)
        scanf("%lld",&c[i]);
    ll ans=-1e18;
    for(int i=1;i<=n;i++)
        ans=max(ans,sol(i));
    printf("%lld\n",ans);
}


Measured memory_bytes: 3908