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

using namespace std;

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

	int n, k, q;
	cin >> n >> k >> q;

	vector<int> a(n+1);
	
	for(int i = 0; i < q; i++) {
		int x;
		cin >> x;
		a[x]++;
	}

	int ans = 0;

	for(int i = 1; i <= n; i++) {
		if(q - a[i] >= k) cout << "No\n";
		else cout << "Yes\n";
	}

	return 0;
} 

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double X = sc.nextDouble();
		double max = 0;
		for(double b=1; Math.pow(b, 2)<=X; b++){
			for(double j=2; Math.pow(b, j) <= X; j++){
				max = Math.max(max, Math.pow(b, j));
				//System.out.print("\rb="+b+" j="+j);
				if(b==1)break;
			}
		}
		System.out.println((int)max);
	}	
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

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

    cout << S.substr(0, K-1) << (char) tolower(S[K-1]) << S.substr(K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7



int main(){
  VE v;
  int a, b;
  cin >> a >> b;
  REP(i, 1000){
    int h = i * (1 + i) / 2;
    v.push_back(h);
  }
  int c = b - a;
  print(v[c] - b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 5050;

int n,k;
int pr[N][N], su[N][N];
int a[N];

bool fnd(int pos, int val) {
	//printf("pos=%d, val=%d\n", pos, val);
	if (val <= 0) return 1;
	int cnt=0;
	for (int j = val; j < k; j++) cnt += su[pos+1][j];
	for (int i = 0; i < k; i++) {
		if (pr[pos-1][i]) {
			if (cnt) return 1;
		}
		cnt -= su[pos+1][k-i-1];
		if (i+1 <= val) cnt += su[pos+1][val-i-1];
		/*for (int j = max(val-i,0); j < k-i; j++) {
			if (su[pos+1][j])
				return 1;
		}*/
	}
	//printf("pos=%d, val=%d returning false\n", pos, val);
	return 0;
}

int main() {
	scanf("%d%d", &n, &k);
	FORI(i,n) scanf("%d", &a[i]);
	pr[0][0] = 1;
	FORI(i,n) {
		FOR(j,k) pr[i][j] = pr[i-1][j];
		for (int j=0; j+a[i] < k; j++) {
			if (pr[i-1][j]) pr[i][j+a[i]] = 1;
		}
	}
	su[n+1][0] = 1;
	for (int i=n; i>=1; i--) {
		FOR(j,k) su[i][j] = su[i+1][j];
		for (int j=0; j+a[i] < k; j++) {
			if (su[i+1][j]) su[i][j+a[i]] = 1;
		}
	}
	/*FOR(i,n+2) {
		FOR(j,k) printf("%d", pr[i][j]);
		printf("\n");
	}
	printf("\n");
	FOR(i,n+2) {
		FOR(j,k) printf("%d", su[i][j]);
		printf("\n");
	}*/
	int res = n;
	FORI(i,n) if (fnd(i, k-a[i])) res--;
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 198912
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	double pi = Math.PI;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			double n = sc.nextDouble();
			if(n == 0.0) break;
			
			for(int i = 1;; i++){
				double x = pi * i;
				int [] res = new int[]{(int) Math.floor(x), (int) Math.ceil(x)};
				boolean flg = false;
				for(int j = 0; j < 2; j++){
					double now = Math.abs(pi - ((double)res[j] / i));
					if(now <= n){
						System.out.println(res[j] + "/" + i);
						flg = true;
						break;
					}
				}
				if(flg) break;
			}
		}
	}
	

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

Measured memory_bytes: 12000
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        count += 1
    elif p[i-1] > p[i] and p[i] > p[i+1]:
        count += 1
    else:
        pass

print(count)

Measured memory_bytes: 3060
N, T = map(int, input().split())
t = list(map(int, input().split()))
s, e = 0, 0
ans = 0
for i in range(N):
  if t[i] <= e:
    e = t[i] + T
  else:
    ans += e - s
    s = t[i]
    e = t[i] + T
ans += e - s
print(ans)




Measured memory_bytes: 25196
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

string tostr(ll x){
    if(x  <= 0)return "";
    char c = '0'+x%10;
    return tostr(x/10) + c;
}
 
 
int main(){
    int h, w, k;
    cin >> h >> w >> k;

    char s[h][w];
    vector<pair<ll, ll>> sbr;
    rep(i, h)rep(j, w){
        cin >> s[i][j];
        if(s[i][j]=='#')sbr.push_back(make_pair(i, j));
    }

    ll ans[400][400] = {};
    rep(i, k){
        ll y = sbr[i].first;
        ll x = sbr[i].second;
        ll cut = i+1;
        ans[y][x] = cut;
        ll add = 1;
        while(s[y+add][x] == '.' && y+add<h)ans[y+add][x] = cut, add++;
        add = 1;
        while(s[y-add][x] == '.' && y-add>=0)ans[y-add][x] = cut, add++;
    }
    rep(i, w-1)if(ans[0][i]!=0){
        if(ans[0][i+1] == 0)rep(j, h)ans[j][i+1] = ans[j][i];
    }
    for(ll i = w-1; i>=0; i--)if(ans[0][i]!=0){
        if(ans[0][i-1] == 0)rep(j, h)ans[j][i-1] = ans[j][i];
    }

    rep(i, h){
        rep(j, w)cout << ans[i][j] << " ";
        cout << endl;
    }
}

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

int main() {
	int grid[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> grid[i][j];
		}
	}
	int diff1[3], diff2[3];
	for (int i = 0; i < 3; i++) {
		diff1[i] = abs(grid[i][0] - grid[i][1]);
		diff2[i] = abs(grid[i][1] - grid[i][2]);
	}
	bool flag = true;
	if (diff1[0] != diff1[1] || diff1[1] != diff1[2]) {
		flag = false;
	}
	if (diff2[0] != diff2[1] || diff2[1] != diff2[2]) {
		flag = false;
	}

	for (int i = 0; i < 3; i++) {
		diff2[i] = abs(grid[0][i] - grid[1][i]);
		diff2[i] = abs(grid[1][i] - grid[2][i]);
	}
	if (diff2[0] != diff2[1] || diff2[1] != diff2[2]) {
		flag = false;
	}
	if (diff2[0] != diff2[1] || diff2[1] != diff2[2]) {
		flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int min = 2147483647;
        int max = 0;
        for (int index=0; index<M; index++){
            
            int left = sc.nextInt();
            int right = sc.nextInt();
            if (left>max){
                max=left;
            }
            if (right<min){
                min=right;
            }
        }
        
        if (min<max){
            System.out.println("0");
        } else {
            System.out.println(min-max+1);
        }
        
        
    }
}

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

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

	int X;
	cin >> X;

	int m[N];
	for (int i=0; i<N; i++)
		cin >> m[i];

	sort(m, m+N);
	for (int i = 0; i < N; i++) {
		X -= m[i];
	}

	int donuts;
	donuts = X/m[0];
	
	cout << N + donuts << endl;
}


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

int main(){
	ll n;
	cin>>n;
	ll c[n],s[n],f[n];
	rep(i,n-1)cin>>c[i]>>s[i]>>f[i];

	ll ans=0,now=0,dif=0;
	bool flag=false;
	rep(i,n-1){
		ans = 0; now = 0; flag = false;
		for(ll j=i;j<n-1;j++){
			if(!flag){//１回目だけ
				now += c[j]+s[j];
				ans += c[j]+s[j];
				flag = true;
			}else{
				if(now>=s[j]){
					if((now-s[j])%f[j]==0){//ちょうど来ている
						now += c[j];
						ans += c[j];
					}else{
						ll tmp = now - s[j];
						tmp /= f[j];
						tmp+=1;
						//cout<<"tmp:"<<tmp<<endl;
						now = s[j] + tmp*f[j];
					//	cout<<now<<endl;
						now += c[j];
						ans = now;
						//cout<<"i,j:"<<i<<" "<<j<<" now:"<<now<<endl;
					}
				}else{//１発目の電車も来ていない
					now = c[j]+s[j];
					ans = c[j]+s[j];
				}
			}
		}
		cout<<ans<<endl;
	}
	cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

/////////////////////////////////////////////////////////

template< typename T >
vector< T > slide_min(const vector< T > &v, int k)
{
  deque< int > deq;
  vector< T > ret;
  for(int i = 0; i < v.size(); i++) {
    while(!deq.empty() && v[deq.back()] >= v[i]) {
      deq.pop_back();
    }
    deq.push_back(i);
    if(i - k + 1 >= 0) {
      ret.emplace_back(v[deq.front()]);
      if(deq.front() == i - k + 1) deq.pop_front();
    }
  }
  return ret;
}

void Main() {
  int N, K; cin >> N >> K;
  vector<int> P(N), Q(N);
  rep(i, 0, N){
    cin >> P[i];
    Q[i] = -P[i];
  }
  vector<int> miP = slide_min(P, K);
  vector<int> maP = slide_min(Q, K);

  ll res = 1;
  rep(i, 0, N - K){
    //before
    if(P[i] != miP[i]){
      res++;
      continue;
    }
    //after
    if(P[i + K] != -maP[i + 1]){
      res++;
      continue;
    }
  }

  bool you = false;
  int cnt = 1;
  rep(i, 1, N){
    if(P[i - 1] > P[i]) cnt = 1;
    else{
      cnt++;
      if(cnt == K){
        res--;
        you = true;
      }
    }
  }

  if(you) res++;
    
  cout << res << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 4212
#include<stdio.h>
int n,A[20];
int solve(int i,int m){
  int res;
  //  printf("%d\n",m);
  if(m==0)return 1;
  if(i>=n)return 0;
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}
  
int main(){
  int q,i,ans;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  int m[200];
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    ans=solve(0,m[i]);
    if(ans==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    
    vector<vector<int>> dp1(N+1, vector<int>(T)), dp2(N+1, vector<int>(T));
    rep(i, N) {
        rep(j, T) {
            chmax(dp1[i+1][j], dp1[i][j]);
            if (j + A[i] < T) chmax(dp1[i+1][j+A[i]], dp1[i][j] + B[i]);
        }
    }

    repr(i, N) {
        rep(j, T) {
            chmax(dp2[i][j], dp2[i+1][j]);
            if (j + A[i] < T) chmax(dp2[i][j+A[i]], dp2[i+1][j] + B[i]);
        }
    }

    int ans = 0;
    rep(i, N) {
        rep(j, T) {
            chmax(ans, dp1[i][j] + dp2[i+1][T-1-j] + B[i]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 72832
from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    """N以下で0でないものがちょうどK個。0を含める"""
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    # divmod : 商と余りを両方取れる
    m, r = divmod(N,10)
    ans = 0
    if K >= 1:
        # 1の位が nonzero
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    # 1の位が zero
    ans += solver(m, K)
    return ans


if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = solver(data[0][0], data[1][0])
    print(result)

Measured memory_bytes: 3940
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

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

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return abs(a); }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

int m, n, k, l, q;

vi zaminen(vi&tab){
	vi ret(n);
	vi dp(n + 2);

	for(int i = 0; i < n; i++){
		dp[max(i + 1 - tab[i], 0)]++;
		dp[min(i + 1 + tab[i] + 1, n + 1)]--;
	}

	int temp = 0;
	FOR(i, n + 2){
		temp += dp[i];
		if(i and i < n + 1){
			ret[i - 1] = temp;
		}
	}
	return ret;
}	

bool same_n(vi & tab){
	for(auto & u : tab)
		if(u != n)
			return false;
	return true;
}

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

	cin >> n >> k;

	vi tab(n);
	cin >> tab;

	while(k--){
		tab = zaminen(tab);
		if(same_n(tab))
			break;
	}
	cout << tab;
}

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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define test cout<<"#"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll x = 0; x < n; x++)
		cin>>v[x];
	ll ans[n] = {0};
	ans[0] = 0;
	for(ll x = 1; x < n; x++)
	{
		ans[x] = ans[x-1] + abs(v[x]-v[x-1]);
		if(x-2>=0)
			ans[x] = min(ans[x], ans[x-2]+abs(v[x]-v[x-2]));
	}
	cout<<ans[n-1]<<"\n";
}

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

int main() {
  string N;
  int T, n;
  cin >> N;
  
  int i = 0;
  while (N[i]) {
    T += N[i] - '0';
    i++;
  }
  
  n = stoi(N.c_str());

  if (n % T == 0) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    /*vl v[10005];
    ll cnt=0;
    ll a[51][51]={0};
    bool visited[10005]={0};
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            if(!visited[f])
            {
                dfs(f);
            }
        }
    }*/
    void solve()
    {
        inp(n);
        if(n>=30)cout<<"Yes";
        else cout<<"No";
    }
    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            //cout<<"           ";
            solve();cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3648
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;


	public class Main {
		
		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			TreeMap<Integer,Integer> m1 = new TreeMap<Integer,Integer>();
			TreeMap<Integer,Integer> m2 = new TreeMap<Integer,Integer>();
			int sum1 = 0;
			int max11 = 0;
			int key11 = 0;
			int max12 = 0;
			int key12 = 0;
			
			int sum2 = 0;
			int max21 = 0;
			int key21 = 0;
			int max22 = 0;
			int key22 = 0;
			
			for(int i=0;i<n/2;i++) {
				m1.merge(sc.nextInt(), 1, Integer::sum);
				m2.merge(sc.nextInt(), 1, Integer::sum);
			}
			
			for(Map.Entry<Integer, Integer> e : m1.entrySet()) {
				sum1 += e.getValue();
				if(max11<=e.getValue()) {
					max12 = max11;
					max11 = Math.max(max11, e.getValue());
					key12 = key11;
					key11 = e.getKey();
					continue;
				}
				
				if(max12<=e.getValue()) {
					max12 = Math.max(max12, e.getValue());
					key12 = e.getKey();
				}
				
				
			}
			
			for(Map.Entry<Integer, Integer> e : m2.entrySet()) {
				sum2 += e.getValue();
				if(max21<=e.getValue()) {
					max22 = max21;
					max21 = Math.max(max21, e.getValue());
					key22 = key21;
					key21 = e.getKey();
					continue;
				}
				if(max22<=e.getValue()) {
					max22 = Math.max(max22, e.getValue());
					key22 = e.getKey();
				}
			}
			
			/*
			System.out.println(m1);
			System.out.println(m2);
			System.out.println(key11);
			System.out.println(key12);
			System.out.println(key21);
			System.out.println(key22);
			*/
			if(m1.size()==1&&m1.equals(m2)) {
				System.out.println(n/2);
			}else {
				if(key11!=key21) {
					System.out.println(sum1+sum2-m1.get(key11)-m2.get(key21));
				}else {
					if(m1.get(key11)+m2.get(key22)>m1.get(key12)+m2.get(key21)) {
						System.out.println(sum1+sum2-m1.get(key11)-m2.get(key22));
					}else {
						System.out.println(sum1+sum2-m1.get(key12)-m2.get(key21));
					}
				}
			}
			
			
			
	    }
		
	}
	


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

int n, m;
unordered_map<string, int> mp;

int main(void){
	cin >> n;
	rep(i, n){
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	rep(i, m){
		string t;
		cin >> t;
		mp[t]--;
	}
	int ans = -INT_MAX;
	for(auto i : mp){
		ans = max(ans, i.second);
	}
	cout << max(ans, 0) << endl;
	return 0;
}


Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

ll const inf = 1<<28;
double const pi = acos(-1);

typedef complex<double> P;

double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

struct L : public vector<P> {
    L(const P &a, const P &b) {
        push_back(a); push_back(b);
    }
    L(){}
};

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}

bool intersectSS(const L &s, const L &t) {
    return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
        ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P ps[4];
L l;

bool solve(){
    int c=0;
    rep(i,3){
        L m(ps[i],ps[i+1]);
        if(intersectSS(l,m))c++;
    }
    return c==1;
}

int main(){
    int n;cin>>n;
    rep(_,n){
        rep(i,3){
            double x,y;cin>>x>>y;
            ps[i]=P(x,y);
        }
        ps[3]=ps[0];
        double a,b,c,d;
        cin>>a>>b>>c>>d;
        l={P(a,b),P(c,d)};
        cout << (solve()?"OK":"NG")<<endl;
    }
}

Measured memory_bytes: 1244
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 100010
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

void swap(ll& s1, ll &s2){
    ll temp=s1;
    s1=s2;
    s2=temp;
}

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

struct p_str{
    ll r, c;
};

ll _sgn(ll n){
    if(n>=0){
        return 1;
    }
    return -1;
}


void solve(){
    ll n, m, x;
    cin>>n>>m>>x;
    ll a[n][m];
    ll c[n];
    ll sum=0;
    for(ll i=0;i<n;i++){
        cin>>c[i];
        sum+=c[i];
        for(ll j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    bool init=1;
    ll ans=sum;
    for(ll i=0;i<(1LL<<n);i++){
        ll cur[m];
        ll cost=0;
        memset(cur, 0, sizeof(cur));
        for(ll j=0;j<n;j++){
            ll mask=(1LL<<j);
            if(i&mask){
                for(ll k=0;k<m;k++){
                    cur[k]+=a[j][k];
                }
                cost+=c[j];
            }
            
        }
        bool f=1;
        for(ll j=0;j<m;j++){
            if(cur[j]<x){
                f=0;
                break;
            }
        }
        if(f){
            init=0;
            ans=min(ans, cost);
        }
    }
    if(init){
        ans=-1;
    }
    cout<<ans<<endl;
}


int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    

    ll t=1;
    
    // cin>>t;

    while(t--){
        
        solve();
    }
    
    return 0;
}


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

using namespace std;

int main() {
	int N, K; cin >> N >> K;
	int res = 0;
	vector<int> probs(26);
	for(int i = 0; i < N; i++) {
		string tmp; cin >> tmp;
		probs[tmp[0] - 'A']++;
	}
	while(1) {
		int cnt = 0;
		sort(probs.begin(), probs.end());

		for(int i = probs.size()-1; i>=0; i--) {
			if(!probs[i]) break;
			probs[i]--;
			cnt++;
			if(cnt==K) break;
		}

		if(cnt < K) break;

		res++;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
using namespace std;
long long gcd(long long a,long long b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main(){
	long n;
	cin>>n;
	long long a[100000];
	long long g;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i==0){
			g=a[0];
		}else{
			g=gcd(g,a[i]);
		}
		
	}
	cout<<g<<endl;


	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

const int INF = 3e18;

int n, m;
char flag[55][55];
int ans = INF;

int cnt(int start, int end, char character){
  int ret = 0;
  for(int i = start; i < end; i++){
    for(int j = 0; j < m; j++){
      if(flag[i][j] != character){
	ret++;
      }
    }
  }
  return ret;
}

signed main()
{
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> flag[i][j];
    }
  }
  
  for(int i = 1; i < n; i++){
    for(int j = i + 1; j < n; j++){
      ans = min(ans, cnt(0, i, 'W') + cnt(i, j, 'B') + cnt(j, n, 'R'));
    }
  }

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

Measured memory_bytes: 3016
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
    ll n,k; cin >> n >> k;
    vl a(n); rep(i,n) cin >> a[i];
    vvl table(202020);
    rep(i,n){
        table[a[i]].push_back(i);
    }
    ll now = 0;
    vl cnt;
    while(now != n){
        now %= n;
        ll c = a[now];
        auto itr = upper_bound(all(table[c]),now);
        if(itr == table[c].end()){
            cnt.push_back(now);
            now = table[c][0];
        }
        else now = *itr;
        now++;
    }
    ll r = k % (cnt.size()+1);
    r--;
    if(r<0){
        cout << endl;
        return 0;
    }
    for(ll i=cnt[r]; i<n; i++){
        auto itr = upper_bound(all(table[a[i]]),i);
        if(itr == table[a[i]].end()) cout << a[i] << " ";
        else i = *itr;
    }
    cout << endl;
}

Measured memory_bytes: 15732
#include <stdio.h>
int main(){
  char txt;
 
  while(1){
    scanf("%c",&txt);
 
    if(txt>96 && txt<123)txt-=32;
    else  if(txt>64 && txt<91)txt+=32;
 
    printf("%c",txt);
   if(txt=='\n')break;
  }
  return 0;
}
 

 

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> P(M),Y(M);
    map<pair<int,int>,int> rank;
    vector<vector<int>> city(N+1);
    rep(i,M){
        int p,y;
        cin>>p>>y;
        P.at(i)=p;
        Y.at(i)=y;
        city.at(p).push_back(y);
    }
    rep(i,N+1){
        sort(city.at(i).begin(),city.at(i).end());
    }
    rep(i,N+1){
        int r=1;
        for(int j:city.at(i)){
            rank[mp(i,j)]=r;
            r++;
        }
    }
    rep(i,M){
        printf("%06d%06d\n",P.at(i),rank[mp(P.at(i),Y.at(i))]);
    }
}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+20;
int X,K,Q,solve();
int hehe=solve(),r[maxn],mx[maxn],mn[maxn],c[maxn];
int solve(){
	scanf("%d",&X);
	scanf("%d",&K);
	for(int i=1;i<=K;++i){
		scanf("%d",&r[i]); 
	}
	mx[0]=X;
	for(int i=1;i<=K;++i){
		mx[i]=mx[i-1];mn[i]=mn[i-1];
		if(i&1){
			mn[i]=max(mn[i],min(r[i]-r[i-1]-c[i-1],mx[i]));
			c[i]=max(c[i-1]+mn[i-1]-r[i]+r[i-1],0)-mn[i]; 
		}
		else{
			mx[i]=min(mx[i],max(X-r[i]+r[i-1]-c[i-1],mn[i]));
			c[i]=min(c[i-1]+mx[i-1]+r[i]-r[i-1],X)-mx[i];
		}
	}
	scanf("%d",&Q);
	for(int a,t,pl,ans;Q--;){
		scanf("%d%d",&t,&a);
		ans=c[pl=(upper_bound(r+1,r+K+1,t)-r-1)];
		if(a<=mn[pl])ans+=mn[pl];
		else if(a>=mx[pl])ans+=mx[pl];
		else ans+=a;
		if(pl&1)ans=min(X,ans+t-r[pl]);
		else ans=max(0,ans-t+r[pl]);
		printf("%d\n",ans);     
	}
	return 0;
}
main(){};

Measured memory_bytes: 2816
package main

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

func main() {
	scan_init()
	box:= make([]int,4)
	for i:= 0; i<4; i++ {
		box[i] = scanInt()
	}
	minusMax := -int(math.Pow(10,18))+1
	plusMax := -int(math.Pow(10,18))+1
	//if plusMax < box[1] && 0 < box[3]{
	//	plusMax = box[1]
	//}
	//if plusMax < box[3] && 0 < box[1] {
	//	plusMax = box[3]
	//}
	if plusMax < box[1]*box[3] {
		plusMax = box[3]*box[1]
	}
	if plusMax < box[3]*box[0] {
		plusMax = box[3]*box[0]
	}
	//if minusMax < -box[0] && 0 < -box[2] {
	//	minusMax = -box[0]
	//}
	//if minusMax < -box[2] && 0 < -box[0] {
	//	minusMax = box[2]
	//}
	if minusMax < box[0]*box[2] {
		minusMax = box[0]*box[2]
	}
	if minusMax < box[1]*box[2] {
		minusMax = box[1]*box[2]
	}
	if minusMax < plusMax {
		fmt.Println(plusMax)
	} else {
		fmt.Println(minusMax)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll x;
    cin >> x;
    cout << !x << endl;
    return 0;
}


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


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 50


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yield i
            if i != n // i:
                yield n // i


def crt(R, M):
    def exEuclid(a, mod):
        b = mod
        s, u = 1, 0
        while b:
            q = a // b
            a, b = b, a % b
            s, u = u, s - q * u
        return a, s % mod
    assert len(R) == len(M)
    r0, m0 = 0, 1
    for r, m in zip(R, M):
        assert m >= 1
        r %= m
        if m0 < m:
            r0, r = r, r0
            m0, m = m, m0
        if m0 % m == 0:
            if r0 % m != r:
                return (0, 0)
            continue
        g, im = exEuclid(m0, m)
        u = m // g
        if (r - r0) % g:
            return (0, 0)
        x = (r - r0) // g % u * im % u
        r0 += x * m0
        m0 *= u
        if r0 < 0:
            r0 += m0
    return (r0, m0)


@mt
def slv(N):
    ans = INF
    for x in divisor(2*N):
        kc, _ = crt([0, -1], (x, 2*N//x))
        if kc != 0:
            ans = min(ans, kc)
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 69152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
#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++)
#define _GLIBCXX_DEBUG
int main()
{
    int n,d;
    cin>>n>>d;
    vvin x(n,vin(d));
    rep(i,n){
        rep(j,d)cin>>x[i][j];
    }
    int sum=0;
    rep(i,n-1){
        rep2(j,i+1,n){
            int dis=0;
            rep(k,d){
                dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            for(int l=1;l*l<=10*40*40;l++){
                if(dis==l*l){
                    sum++;
                    break;
                }
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int c[3][3];
    int ans = 0;
    int res = 0;
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
            ans += c[i][j];
        }
    }   
    rep(i, 3){
        rep(j, 3){
            if(i==j)
                res += c[i][j];
        }
    }
    

    if(ans == 3 * res){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    
    return 0;
}

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

int hs[200000];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    string s1, s2;
    cin >> s1 >> s2;
    int l = s1.size();
    for(int i = 0; i < l; i++){
        if(s1[i] - s2[i] != 0){
            hs[i] = 2;
        }
    }
    cout << count(hs, hs + l, 2);
    return 0;
}

Measured memory_bytes: 4568
def solve():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))

    b = [0] * 50

    for x in a:
        for j in range(50):
            if (x >> j) & 1:
                b[j] += 1

    dp = [-1] * 2
    dp[False] = 0
    # dp[k>=x確定]:=最大値

    for j in reversed(range(50)):
        if (k >> j) & 1:
            # bitを立てられる
            if dp[True] == -1:
                dp[True] = dp[False] + (b[j] << j)
            else:
                dp[True] = max(
                    dp[True] + (max(b[j], n - b[j]) << j),
                    dp[False] + (b[j] << j)
                )
            dp[False] += (n - b[j]) << j
        else:
            # bitを立てられない
            if dp[True] == -1:
                pass
            else:
                dp[True] += max(b[j], n - b[j]) << j
            dp[False] += (b[j] << j)
    return max(dp)


print(solve())


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(void)
{
        int n;
        int cnt[100010] = {0};

        cin >> n;
        int a;
        for(int i = 0; i < n; i++){
                cin >> a;
                cnt[a]++;
                cnt[a+1]++;
                cnt[a+2]++;
        }

        int max = -1;
        for(int i = 0; i <= 100000; i++)
                if(max < cnt[i]) max = cnt[i];

        cout << max << endl;

        return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = new int[N];
        int max = 0;
        int sum =0;
        for (int i =0; i<N; i++) {
            int temp = sc.nextInt();
            sum += temp;
            if (max<temp) {
                max = temp;
            }
        }

        System.out.println(sum - (max/2));
    }

}

Measured memory_bytes: 22996
#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+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<ll,int> P;

int cnt[200010];

int main(){
    int k,n;
    cin >> n >> k;
    rep(i,n){
        int a;
        cin >> a;
        ++cnt[a-1];
    }
    sort(cnt,cnt+n); // A[i] < Nなので、0~nまでに全ての値がある。
    int ans=0;
    rep(i,n-k)ans+=cnt[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

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


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair
#define fast_in_out ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move





int main()
{
    fast_in_out;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    double r;
    cin>>r;
    double ans=2*PI*r;
    cout<<ans<<endl;

}



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

int main(){
  int i, n, u=1, f=2, r=3, s, sum=1;
  string com;

  while(1){
    cin >> n;
    if (n == 0) break;

    for (i=0; i<n; i++){
      cin >> com;
      if (com == "North"){
	s=u; u=f; f=7-s;
      } else if (com == "East"){
	s=r; r=u; u=7-s;
      } else if (com == "West"){
	s=u; u=r; r=7-s;
      } else if (com == "South"){
	s=f; f=u; u=7-s;
      } else if (com == "Right"){
	s=f; f=r; r=7-s;
      } else {
	s=r; r=f; f=7-s;
      }

      sum += u;
    }

    cout << sum << endl;
    u=1; f=2; r=3; sum=1;
  }

  return 0;
}

	

Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,M,A[100],sum=0,res=0;
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>A[i];
		sum+=A[i];
	}
	for(int i=0;i<N;i++){
		if(A[i]*M*4>=sum)res++;
	}
	if(res>=M)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc130/tasks/abc130_b
# 愚直にシミュレーションしてみれば良い
N, X = read_ints()
L = read_ints()
D = [0]
for l in L:
    D.append(D[-1] + l)
print(bisect_right(D, X))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
   char a;
   cin>>a;
   if(a<=90)
   {
    cout<<"A"<<endl;
   } 
   else
    cout<<"a"<<endl;
}
return 0;
}

Measured memory_bytes: 3604
print' :: [String] -> [String] -> IO ()
print' list xs = do
  putStrLn $ head list
  solve (tail list) xs

solve :: [String] -> [String] -> IO ()
solve _ [] = do return ()
solve list (x:xs)
  | x == "0" = do print' list xs
  | otherwise = solve (x:list) xs

main = getContents >>= solve [] . lines

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

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

int main() {
	int N;
	cin >> N;
	int count = 0;
	vector<int> data(N);

	rep(i, N) {
		int a, b;
		cin >> a>>b;
		if (a == b) {
			count++;
			data.at(i) = count;
		}
		else {
			count = 0;
		}
	}

	int max = *std::max_element(data.begin(), data.end());

	if (max >= 3) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3628
#include <iostream>
#include <queue>

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

using namespace std;

int main(){
	int n,m; cin>>n>>m;
	priority_queue<int> Q;
	rep(i,n){
		int a; cin>>a;
		Q.push(a);
	}

	rep(i,m){
		int a=Q.top(); Q.pop();
		Q.push(a/2);
	}

	long long ans=0;
	rep(i,n) ans+=Q.top(), Q.pop();
	cout<<ans<<endl;

	return 0;
}


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

int main() {
    string w;
    string str = "Yes";
    cin >> w;
    int l,i,j;
    int count[24] = {0};
    (int)( l = w.length());
    for(i=0;i<l;i++){
        count[ w[i]-'a' ]++;
    }
    for(j=0;j<24;j++){
        if( count[j]%2 ){
            str = "No";
            break;
        }
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    return 0;
}

Measured memory_bytes: 256