akhauriyash/Code-Regression huggingface dataset:
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int cnt[1000010] = {};
  rep(i, n) cnt[a[i]]++;
  int ans = n;
  rep(i, n)
  {
    for (int d = 1; d * d <= a[i]; d++)
    {
      if (a[i] % d != 0)
        continue;
      if (d != a[i] and cnt[d] >= 1)
      {
        ans--;
        break;
      }
      else if (d == a[i] and cnt[d] >= 2)
      {
        ans--;
        break;
      }
      int d2 = a[i] / d;
      if (d2 != a[i] and cnt[d2] >= 1)
      {
        ans--;
        break;
      }
      else if (d2 == a[i] and cnt[d2] >= 2)
      {
        ans--;
        break;
      }
    }
  }
  cout << ans << "\n";
}

int main()
{
  init_main();

  solve();

  return 0;
}


Measured memory_bytes: 7948
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define mod 1000000007
 
 
void solve(){
	string s1, s2;
	cin >> s1 >> s2;
	int n1 = s1.length(), n2 = s2.length();
	int dp[n1 + 1][n2 + 1], i, j;
	for(i = 0; i <= n1; i++) dp[i][0] = 0;
	for(j = 0; j <= n2; j++) dp[0][j] = 0;

	for(i = 1; i <= n1; i++){
		for(j = 1; j <= n2; j++){
			if(s1[i - 1] == s2[j - 1]){
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}else{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	i = n1, j = n2;
	string ans = "";
	while(dp[i][j] != 0){
		if(s1[i - 1] == s2[j - 1]){
			ans += s1[i - 1];
			i--;
			j--;
		}else{
			if(dp[i - 1][j] == dp[i][j]){
				i--;
			}else{
				j--;
			}
		}
	}

	reverse(ans.begin(), ans.end());
	cout << ans;
}
 
int main(){
	solve();
}


Measured memory_bytes: 35456
#include<stdio.h>
#include<stdlib.h>
int matrixChainOrder(int*,int);
int main(void)
{
  int i;//counter
  int n;//the number of matrix
  int *p;//array of each row(column)
  scanf("%d",&n);
  p=(int*)malloc(sizeof(int)*(n+1));
  for(i=0;i<n;i++) scanf("%d%d",&p[i],&p[i+1]);
  printf("%d\n",matrixChainOrder(p,n));
  free(p);
  return 0;
}
int matrixChainOrder(int *p,int n)
{
  int i,j;//counter
  int begin,mid,end;//counter
  int **m;//m[i][j]: the number of multiplication from matrix i to matrix j
  int tempMin;//temporary minimum value
  int cur;//current value
  m=(int**)malloc(sizeof(int*)*n);
  for(i=0;i<n;i++) m[i]=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++) m[i][i]=0;
  for(i=1;i<n;i++)
    {
      for(begin=0,end=i;end<n;begin++,end++)
	{
	  //printf("--\n");
	  for(mid=begin;mid<end;mid++)
	    {
	      //printf("[%d,%d,%d]->",begin,mid,end);
	      cur=m[begin][mid]+m[mid+1][end]+p[begin]*p[mid+1]*p[end+1];
	      //printf("%d+%d+%d*%d*%d=%d\n",m[begin][mid],m[mid+1][end],p[begin],p[mid+1],p[end+1],cur);
	      if(mid==begin) tempMin=cur;
	      else if(cur<tempMin) tempMin=cur;
	    }
	  m[begin][end]=tempMin;
	  //printf("m[%d][%d]=%d\n",begin,end,m[begin][end]);
	}
    }
  return m[0][n-1];
}



Measured memory_bytes: 2032
#include "bits/stdc++.h"

typedef long long ll;
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; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
int main() {
	int N, M, num = 0;
	ll res = 0;
	cin >> N >> M;
	vector<pair<ll,ll>> AB(N);

	rep(i,N){
		cin >> AB.at(i).first >> AB.at(i).second;
	}
	sort(AB.begin(), AB.end());

	rep(i, N) {
		int cunt = 0;
		while (cunt < AB.at(i).second) {
			if (num < M) {
				res += AB.at(i).first;
				num++;
				cunt++;
			}
			else if (num == M) break;
		}
		if (num == M) break;
	}
	cout << res << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
   uli z;
   while(scanf("%lld",&z),z!=0){
      uli maxi=0;
      for(uli i=1;i<=z;i++){
         for(uli j=1;j<=z;j++){
            if(i*i*i+j*j*j>z*z*z)break;
            maxi=max(maxi,i*i*i+j*j*j);
         }
      }
      uli ans=z*z*z-maxi;
      printf("%lld\n",ans);
   }
   return 0;
}

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

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   int a, b;
   int res = 0;
   cin >> n >> a >> b;
   for(int i = 1;i <= n;i++) {
      string s = to_string(i);
      int sum = 0;
      for(int j = 0;j < s.length();j++) {
         int n = s[j] -'0';
         sum+=n;
      }
      if(a<=sum&&sum<=b) {
         res+=stoi(s);
      }
   }
   cout << res << endl;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n){
        int t; cin >> t;
        a[i] = abs(t);
    }
    sort(ALL(a));
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans=b/x-a/x;
    if(a%x==0){
        cout << ans+1 << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,m,x;
    cin >>n>>m>>x;
    int ans1=0,ans2=0;
    for(int i=0;i<m;i++){
        int a;
        cin >>a;
        if(a<x){
            ans1++;
        }else{
            ans2++;
        }
    }
    ans1=min(ans1,ans2);
    cout <<ans1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
bool G[10][10];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = G[b][a] = true;
    }
    vector<int> ord(n);
    rep(i,n) ord[i] = i;
    int res = 0;
    do {
        if(ord[0] != 0)break;
        bool ok = true;
        for(int i = 0;i + 1 < n;i++){
            int from = ord[i];
            int to = ord[i+1];
            if(!G[from][to]) ok = false;
        }
        if(ok) res++;
    }
    while (next_permutation(ord.begin(),ord.end()));
    cout << res << endl;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  vector<ll> sum(n+1);
  for (ll i = 1; i <= n; ++i) {
    sum[i] = a[i-1] + sum[i-1];
  }
  
  ll ans = 1;
  for (ll i = n-1; i >= 0; --i) {
    if (sum[i]*2 >= a[i]) ++ans;
    else break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int k ;
    string s ;
    cin >> k >> s ;
    if (s.size() > k) 
    {
        for (size_t i = 0; i < k; i++)
        {
            cout << s.at(i) ;
        }
        cout << "..." << endl ;
    }else
    {
        cout << s << endl ;
    }
    
        
}


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

int main() {
	int n ;
	cin >> n; 
	int h[n] = {0} , c[n] = {0} ;
	for(int i = 0 ; i < n ; i++)
		cin >> h[i] ;
	c[0] = 0;
	c[1] = abs(h[1]-h[0]);
	for(int i = 2; i < n ; i++)
		c[i] = min(c[i-1]+abs(h[i]-h[i-1]) , c[i-2]+abs(h[i]-h[i-2]));
	cout << c[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{  int n;
 cin>>n;
 long int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
long long int ans=0;
 for(int i=0;i<n;i++)
 {  int t=arr[i];
    while(t>0)
    {  if(t%2!=0)
         break;
    t=t/2;
       ans++;
    }
 }
 cout<<ans;
  
  
}

Measured memory_bytes: 3680
n=int(input())
x=list(map(int,input().split()))
a,b,c=0,0,0
ans='No'
for i in x:
  if i%4==0:
    a+=1
  elif i%2==0:
    b+=1
  else:
    c+=1
if n%2==1:
  if c-a==1:
    if b==0:
      ans='Yes'
  elif a>=c:
    ans='Yes'
else:
  if a>=c:
    ans='Yes'
print(ans)


Measured memory_bytes: 20136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String s = in.next();
			long a = 0;
			long b = 0;
			long c = 0;
			for (int i = 0; i < s.length(); i++) {
				char ch = s.charAt(i);
				if (ch == 'a') {
					a++;
				} else if (ch == 'b') {
					b++;
				} else if (ch == 'c') {
					c++;
				}
			}
			String ans = "NO";
			if ((a <= b + c) && (b <= a + c) && (c <= a + b) && (Math.abs(a - b) <= 1) && (Math.abs(b - c) <= 1)
					&& (Math.abs(c - a) <= 1)) {
				ans = "YES";
			}
			if (s.length() < 2) {
				ans = "YES";
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ll N, M;
    cin >> N >> M;
    multiset<ll> st;
    for(int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        st.insert(a);
    }
    for(int i = 0; i < M; i++)
    {
        auto itr = st.end();
        itr--;
        ll key = *itr / 2LL;
        st.erase(itr);
        st.insert(key);
    }
    ll sum = 0;
    for(auto itr: st) sum += itr;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4992
/*
 * g.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_D = 20;

typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

struct Stat {
  ll c;
  int d, i;
  Stat() {}
  Stat(ll _c, int _d, int _i): c(_c), d(_d), i(_i) {}
  bool operator<(const Stat &s) const {
    return c > s.c || (c == s.c && d > s.d);
  }
};

/* global variables */

int ts[MAX_N];
vpii nbrs[MAX_N];
ll costs[MAX_N];
int dists[MAX_N], prts[MAX_N][MAX_D];

/* subroutines */

/* main */

int main() {
  int n, m;
  int tmp = scanf("%d%d", &n, &m);

  for (int i = 0; i < n; i++) tmp = scanf("%d", &ts[i]);

  for (int i = 0; i < m; i++) {
    int ai, bi, ci;
    tmp = scanf("%d%d%d", &ai, &bi, &ci);
    ai--, bi--;
    nbrs[ai].push_back(pii(bi, ci));
    nbrs[bi].push_back(pii(ai, ci));
  }

  for (int i = 0; i < n; i++) costs[i] = LINF;
  costs[0] = 0;
  dists[0] = 0;
  prts[0][0] = -1;

  priority_queue<Stat> q;
  q.push(Stat(0, 0, 0));

  while (! q.empty()) {
    Stat u = q.top(); q.pop();
    if (costs[u.i] != u.c || dists[u.i] != u.d) continue;

    int vd = u.d + 1;
    vpii &nbru = nbrs[u.i];

    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &vi = vit->first;
      ll vc = u.c + vit->second;

      if (costs[vi] > vc) {
	costs[vi] = vc;
	dists[vi] = vd;
	prts[vi][0] = u.i;
	q.push(Stat(vc, vd, vi));
      }
      else if (costs[vi] == vc) {
	if (dists[vi] > vd) {
	  dists[vi] = vd;
	  prts[vi][0] = u.i;
	  q.push(Stat(vc, vd, vi));
	}
	else if (dists[vi] == vd && ts[prts[vi][0]] > ts[u.i]) {
	  prts[vi][0] = u.i;
	}
      }
    }
  }

  for (int d = 1; d < MAX_D; d++)
    for (int i = 0; i < n; i++) {
      int j = prts[i][d - 1];
      prts[i][d] = (j < 0) ? -1 : prts[j][d - 1];
    }

  int k;
  tmp = scanf("%d", &k);

  while (k--) {
    int xi, di, pi;
    tmp = scanf("%d%d%d", &xi, &di, &pi);
    xi--;

    int r = dists[xi] - di;
    int yi = xi;
    //printf("xi=%d,di=%d,pi=%d: costs=%lld,dists=%d,r=%d\n",
    //xi, di, pi, costs[xi], dists[xi], r);

    if (r > 0)
      for (int d = MAX_D - 1; d >= 0; d--)
	if (r & (1 << d)) yi = prts[yi][d];
    //printf("  yi=%d\n", yi);
    
    ll cost = costs[xi] - costs[yi];
    if (cost < costs[xi] - pi) cost = costs[xi] - pi;

    printf("%lld\n", cost);
  }
}


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

 

 int main(){
  int N, K;
   int ans = 0;

 cin >> N >> K;
 int arr[N];
 for(int i = 0; i < N; i++) 
 cin >> arr[i];
 sort(arr, arr + N);
 for(int i = 0; i < K; i++) 
 ans += arr[i];
 cout << ans << endl;
 
   return 0;
}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
#define lli long long int
int main(){
  lli i,j,u;
  string s;
  cin>>s;
  lli n=s.size();
  if(n%2==1){
    u=0;
    for(i=0,j=n-1;i<n/2,j>=(n/2)+1;i++,j--){
      if(s[i]!=s[j])
        u++;
    }
  }
  else{
    u=0;
    for(i=0,j=n-1;i<n/2,j>=(n/2);i++,j--){
      if(s[i]!=s[j])
        u++;
    }
  }
  cout<<u;
  return 0;
}

Measured memory_bytes: 256
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
INF = float("inf")


def main():
    A, B, C = map(int, input().split())
    if A == B:
        print(C)
    elif A == C:
        print(B)
    elif B == C:
        print(A)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
x = input()

p = [-1 for _ in range(2*(10**7)+1)]
cnt = x.count('1')

def calc(a):
  #print('a=',a)
  if 0 <= a <= 2*(10**7) and  p[a] != -1:
    return p[a]
  else:
    if a == 0:
      ret = 0
    else:
      b = bin(a).count('1')
      ret = 1+calc(a%b)
    if 0 <= a <= 2*(10**7):
      p[a] = ret
    return ret

if cnt > 1:
  x0 = int(x,2)%(cnt-1)
  xx0 = [1]
  for i in range(n+1):
    xx0.append((xx0[-1]*2)%(cnt-1))
x1 = int(x,2)%(cnt+1)
xx1 = [1]
for i in range(n+1):
  xx1.append((xx1[-1]*2)%(cnt+1))

y = list(x)  
for i in range(n):
  if y[i] == '0':
    xx = xx1[n-i-1]
    print(calc((x1+xx)%(cnt+1))+1)
  else:
    if cnt == 1:
      print(0)
    else:
      xx = xx0[n-i-1]
      print(calc((x0-xx)%(cnt-1))+1)

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

using namespace std;

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

	int K;
	cin >> K;

	int L = K >> 1;

	cout << L * (K - L) << endl;

	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int n,x,m;
    cin >> n >> x;
    vector<int> M(n);
    int cnt = 0;
    rep(i,n) {
        cin >> M[i];
    }
    sort(all(M));
    rep(i,n) {
        x -= M[i];
        cnt++;
    }
    cnt += x/M[0];
    cout << cnt <<"\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
int N;
int kisuu_num;
double answer;


int main(void){
    std::cin >> N;

    kisuu_num = N / 2;

    if (N % 2 != 0)
        kisuu_num++;

    answer = kisuu_num / (double)N;
    

    std::cout << answer << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char S[5];
  scanf("%s",S);
  for(int i=0;i<3;i++){
    if(S[i]==S[i+1]){
      printf("Bad\n");
      return 0;
    }
  }
  printf("Good\n");
  return 0;
}

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

const int INF = 100100100;

vector<int>G[2050];

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  vector<int> ans(n);
  
  rep(i, n) {
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  G[x].push_back(y);
  G[y].push_back(x);

  rep(sv,n) {
    vector<int> dist(n, INF);
    queue<int> que;
    que.push(sv);
    dist[sv] = 0;

    int u;
    while(!que.empty()) {
      u = que.front(); que.pop();
      for(int v: G[u]){
        if(dist[v] == INF) {
          dist[v] = dist[u] + 1;
          que.push(v);
        }
      }
    }
    rep(i,n) ++ans[dist[i]];  
  }

  rep(i,n) ans[i] /= 2;
  for(int i = 1; i <= n-1; ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

using namespace std;

#define pb push_back
#define eps 1e-9
#define PI acos(-1.0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
const int INF = 1e9 + 5;

bool prime(ll x)
{
    if(x == 2)
        return true;
    for(int i = 2 ; i * i <= x ; i++)
        if(x % i == 0)
            return false;
    return true;
}

bool cmp(int a, int b)
{
    return a > b;
}
int a[int(1e5 + 5)];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio (0);
    cin.tie(0);

    int n;
    cin >> n;
    std::vector<int> dp(3);
    for (int d = 0; d < n; ++d)
    {
        std::vector<int> dp2(3);
        std::vector<int> c(3);
        for (int i = 0; i < 3; ++i)
        {
            cin >> c[i];
        }
        for (int i = 0; i < 3; ++i)
        {
            for(int j = 0; j < 3; j++)
            {
                if(j != i)
                    dp2[j] = max(dp2[j], dp[i] + c[j]);
            }
        }
        dp = dp2;
    }
    cout << max({dp[0],dp[1],dp[2]});
}


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

int main(){
    int n;
    cin >> n;
    int D[n];
    for(int i = 0; i < n; i++){
        cin >> D[i];
    }
    sort(D, D+n);
    cout << max(D[n/2] - D[n/2-1], 0) << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
struct Pox
{
  long double L,a,b;
  Pox(long double L,long double a,long double b):L(L),a(a),b(b){}
};

long double calc(vector<Pox>& vec)
{
  long double res = 0;
  for(int i=0;i<vec.size();i++)
    for(int j=i+1;j<vec.size();j++)
      res += pow(vec[i].L-vec[j].L,2)+pow(vec[i].a-vec[j].a,2)+pow(vec[i].b-vec[j].b,2);

  return res;
}

int main()
{
  int N,M;
  cin >> N >> M;
  long double ans = 0;
  vector<Pox> G;
  for(int i=0;i<N;i++)
    {
      long double L,a,b;
      cin >> L >> a >> b;
      G.push_back(Pox(L,a,b));
    }

  for(int i=0;i<=(1<<N)-1;i++)
    {
      if(__builtin_popcount(i) != M)
	continue;

      vector<Pox> vec;
      for(int j=0;j<N;j++)
	{
	  if((i>>j) & 1)
	    vec.push_back(G[j]);
	}
      ans = max(ans,calc(vec));
    }
  cout << setiosflags(ios::fixed) << setprecision(20) << ans << endl;

  return 0;
}

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

int n, m;

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

    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char n;
int a,b;
int main()
{
    cin>>a>>b;//输入
    for(int s=0;s<a;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')//判断前a个
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cin>>n;
    if(n!='-')//判断第a+1
    {
        cout<<"No"<<endl;
        return 0;

    }
    for(int s=0;s<b;s++)
    {
        cin>>n;
        if(n<'0'||n>'9')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
t1, t2=map(int, input().split())
a1, a2=map(int, input().split())
b1, b2=map(int, input().split())

if (a1-b1)*(a2-b2)>0:
  print(0)
elif a1*t1+a2*t2==b1*t1+b2*t2:
  print('infinity')
else:
  if a1>b1:
    da=(a1-b1)*t1
    db=(b2-a2)*t2
    
    if da>db:
      print(0)
    else:
      temp=da//(db-da)
      if da%(db-da)>0:
        temp=2*temp
      else:
        temp=2*temp-1
      print(temp+1)
  else:
    db=(b1-a1)*t1
    da=(a2-b2)*t2
    
    if db>da:
      print(0)
    else:
      temp=db//(da-db)
      if db%(da-db)>0:
        temp=2*temp
      else:
        temp=2*temp-1
      print(temp+1)

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

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

Measured memory_bytes: 3904
import math

d, g = map(int, input().split())
g = g // 100
p = [0]*d
c = [0]*d
for i in range(d):
    p[i], c[i] = map(int, input().split())
    c[i] = c[i] // 100

ans = sum(p)

for bit in range(1<<d):
    tmp_ans = 0
    tmp_score = 0
    for i in range(d):
        if (bit >> i) & 1 == 1:
            tmp_ans += p[i]
            tmp_score += (i+1) * p[i] + c[i]

    for i in reversed(range(d)):
        if (bit >> i) & 1 == 0 and tmp_score < g:
            if g - tmp_score > (i+1) * p[i]:
                tmp_ans += p[i]
                tmp_score += (i+1) * p[i] + c[i]
            else:
                n = math.ceil( (g - tmp_score) / (i+1) )
                tmp_ans += n
                tmp_score += (i+1) * n

    ans = min(ans, tmp_ans)

print(ans)


Measured memory_bytes: 41072
n = int(input())
ans = [0 for _ in range(10001)]
for i in range(1,101):
	for j in range(1,101):
		for k in range(1,101):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10001:
				ans[v]+=1

for i in range(n):
	print(ans[i+1])


Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s;
    vector<int>a(1);
    a[0]=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            a.push_back(a[i]+1);
        }
        else a.push_back(0);
    }
    int max=0;
    for(int i=0;i<s.size()+1;i++){
        if(max<a[i]) max=a[i];
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			double x1, y1, x2, y2, x3, y3, xp, yp;
			try
			{
				x1 = sc.nextDouble();
				y1 = sc.nextDouble();
				x2 = sc.nextDouble();
				y2 = sc.nextDouble();
				x3 = sc.nextDouble();
				y3 = sc.nextDouble();
				xp = sc.nextDouble();
				yp = sc.nextDouble();
			}
			catch (Exception e)
			{
				break;
			}
			
			if (!((f(x1, y1, x2, y2, x3) < y3 && f(x1, y1, x2, y2, xp) < yp)
				|| (f(x1, y1, x2, y2, x3) > y3 && f(x1, y1, x2, y2, xp) > yp)
			)) {
				System.out.println("NO");
				continue;
			}
			if (!((f(x2, y2, x3, y3, x1) < y1 && f(x2, y2, x3, y3, xp) < yp)
				|| (f(x2, y2, x3, y3, x1) > y1 && f(x2, y2, x3, y3, xp) > yp)
			)) {
				System.out.println("NO");
				continue;
			}
			if (!((f(x3, y3, x1, y1, x2) < y2 && f(x3, y3, x1, y1, xp) < yp)
				|| (f(x3, y3, x1, y1, x2) > y2 && f(x3, y3, x1, y1, xp) > yp)
			)) {
				System.out.println("NO");
				continue;
			}
			System.out.println("YES");
		}
	}
	private static double f(double x1, double y1, double x2, double y2, double x)
	{
		return (y1 - y2) / (x1 - x2) * (x - x1) + y1;
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define ll long long
#define MAX 100005
using namespace std;

ll arr[MAX],dp[MAX];



int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>arr[i];
    dp[1] = 0;
    dp[2] = abs(arr[2] - arr[1]);
    for(int i = 3;i<=n;i++)
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]),dp[i-2] + abs(arr[i] - arr[i-2]));
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
ll space;
const int Maxn=105;
const int Maxv=1e5+5;
int v[Maxn];
ll w[Maxn],dp[Maxv];

int main(){
	cin>>n>>space;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	rep(i,Maxv)dp[i]=1e18;
	dp[0]=0LL;
	for(int i=1;i<=n;i++){
		for(int j=Maxv-v[i]-1;j>=0;j--){
			chkmin(dp[j+v[i]],dp[j]+w[i]);
		}
	}
	int ans=0;
	rep(i,Maxv){
		if(dp[i]<=space){
			chkmax(ans,i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4376
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);

   int x1 = sc.nextInt();
   int y1 = sc.nextInt();
   int x2 = sc.nextInt();
   int y2 = sc.nextInt();

   int x3 = x2+(y1-y2);
   int y3 = y2-(x1-x2);
   int x4 = x3+(y2-y3);
   int y4 = y3-(x2-x3);
   
   System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
 }
}

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

int main(void) {
  int i, n, m = 100000;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    m *= 1.05;
    m += m % 1000 ? 1000 - m % 1000 : 0;
  }

  printf("%d\n", m % 1000 ? m - m % 1000 + 10000 : m);

  return EXIT_SUCCESS;
}

Measured memory_bytes: 588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    // Rust version 1.15.1, which is used by AtCoder,
    // does not support std::str::FromStr for char
    ($iter:expr, char) => {
        $iter.next().unwrap().chars().next().expect("Parse error")
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        n: usize,
        m: usize,
    }

    let time = 1900*m + 100*(n-m);

    println!("{}", time<<m);
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    int k=in.nextInt();
    int[]cnt=new int[k];
    for(int i=1;i<=n;i++){
      cnt[i%k]++;
    }
    long ans=1L*cnt[0]*cnt[0]*cnt[0];
    if(k%2==0){
      ans+=1L*cnt[k/2]*cnt[k/2]*cnt[k/2];
    }
    System.out.println(ans);
 }
}

Measured memory_bytes: 23124
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const A = Number(input[0][0]);
  const B = Number(input[1][0]);
  const C = Number(input[2][0]);
  const D = Number(input[3][0]);

  return Math.min(A, B) + Math.min(C, D);
};

console.log(main(read()));


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = N;
    
    for(int i = 1; i < N; i++){
        if(S[i-1] == S[i]) ans--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
l = list(map(int,input().split()))
r, g, b = l[0], l[1], l[2]
k = int(input())
 
for _ in range(k):
  if r >= g:
    g *= 2
  elif g >= b:
    b *= 2
 
if b > g and g > r:
  print('Yes')
else:
  print('No')

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

priority_queue<int>q; 

int main()
{
	long long n,m,total=0;
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		q.push(x);
	}
    while (m--)
    {
    	int t=q.top()/2;
    	q.pop();
    	q.push(t);
	}
	while (!q.empty())
	{
		total+=q.top();
		q.pop();
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 892
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int x = int.Parse(Console.ReadLine());

            int count = 0;

            for (int a_Number = 0; a_Number <= a; a_Number++)
            {
                for (int b_Number = 0; b_Number <= b; b_Number++)
                {
                    for (int c_Number = 0; c_Number <= c; c_Number++)
                    {
                        if (500 * a_Number + 100 * b_Number + 50 * c_Number == x)
                        {
                            count++;
                        }
                    }
                }
            }

            Console.WriteLine(count);
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<ll> node;
 
public:
    SegmentTree() {
        int sz = 600050;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }
    // hannkaikukann 
    ll getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return -INF;
        if(a <= l && r <= b) return node[k];
 
        ll vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    SegmentTree seg;
    for(int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        ll L = A - K;
        chmax(L, 0LL);
        ll R = A + K + 1;
        ll tmp = seg.getmax(L, R);
        seg.update(A, tmp + 1);
    }
    cout << seg.getmax(0, 600000) << endl;
    return 0;
}

Measured memory_bytes: 19588
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var x [5]int

	for i := range x {
		x[i] = nextInt()
		if x[i] == 0 {
			fmt.Println(i + 1)
		}
	}
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

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

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

int n, f[10][10];

int last_digit(int x){
  while(x >= 10)
    x /= 10;
  return x;
}

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

  cin >> n;
  FOR(i, 1, n + 1)
    f[last_digit(i)][i % 10] ++;

  ll sol = 0;
  FOR(i, 1, n + 1)
    sol += f[i % 10][last_digit(i)];

  cout << sol;
}


Measured memory_bytes: 256
@$_[@=]=map[glob<>],@=for 0,@==1..<>;$\=-5e9;for$i(1..1023){$c=0;$c+=$1[$j=$_][grep$0[$j][$_]&$i>>$_,0..9]for@=;$\+=$-=$c-$\}print

Measured memory_bytes: 3072
use std::collections::HashMap;

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

fn main() {
    let n = read::<usize>();
    let mut hm: HashMap<Vec<_>, usize> = HashMap::new();

    let mut ans = 0;
    for _ in 0..n {
        let mut s = read::<String>().chars().collect::<Vec<_>>();
        s.sort();

        let mut ok = false;

        if let Some(v) = hm.get_mut(&s) {
            *v += 1;
            ans += *v;
            ok = true;
        } 
        if !ok {
            hm.insert(s, 0);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 16636
import copy
h,w,k=map(int,input().split())
c=[[] for i in range(h)]
for i in range(h):
  S=input()
  for j in range(w):
    c[i].append(S[j])
b1=2**h
b2=2**w
cnt=0
tori=0
for i in range(b1):
  s=(str(bin(i))[2:]).zfill(h)
  for j in range(b2):
    d=[]
    d=copy.deepcopy(c)
    cnt=0
    t=(str(bin(j))[2:]).zfill(w)
    for l in range(h):
      if s[l]=='1':
        for unchi in range(w):
          d[l][unchi]='r'
    for m in range(w):
      if t[m]=='1':
        for unchi in range(h):
          d[unchi][m]='r'
    for ch in range(h):
      cnt+=d[ch].count('#')
    if cnt==k:
      tori+=1
print(tori)

      


Measured memory_bytes: 73016
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Word
import qualified Data.ByteString as BSW
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

-- Input: s t
-- Output: arr
--   arr ! (i,j) == length of lcs of (drop i s, drop j t)
lcsTable2 :: BS.ByteString -> BS.ByteString -> UArray (Int,Int) Word16
lcsTable2 s t = runSTUArray $ do
  let !m = BS.length s
      !n = BS.length t
  arr <- newArray ((0,0),(m,n)) 0
  forM_ [m-1,m-2..0] $ \ !i -> do
    let !x = BSW.index s i
    forM_ [n-1,n-2..0] $ \ !j -> do
      let !y = BSW.index t j
      if x == y
        then do l2 <- readArray arr (i+1, j+1)
                writeArray arr (i,j) (l2 + 1)
        else do l0 <- readArray arr (i+1, j)
                l1 <- readArray arr (i, j+1)
                writeArray arr (i,j) (max l0 l1)
  return arr

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  let !table = lcsTable2 s t
      !m = BS.length s
      !n = BS.length t
  let recon !i !j | i >= m || j >= n = Nothing
                  | x == y = let !i' = i+1 ; !j' = j+1
                             in Just (x, (i', j'))
                  | table ! (i+1,j) >= table ! (i,j+1) = reconY y (i+1) j
                  | otherwise = reconX x i (j+1)
        where x = BSW.index s i
              y = BSW.index t j
      reconX !x !i !j | j >= n = Nothing
                      | x == y = let !i' = i+1 ; !j' = j+1
                                 in Just (x, (i', j'))
                      | table ! (i+1,j) >= table ! (i,j+1) = reconY y (i+1) j
                      | otherwise = reconX x i (j+1)
        where y = BSW.index t j
      reconY !y !i !j | i >= m = Nothing
                      | x == y = let !i' = i+1 ; !j' = j+1
                                 in Just (x, (i', j'))
                      | table ! (i+1,j) >= table ! (i,j+1) = reconY y (i+1) j
                      | otherwise = reconX x i (j+1)
        where x = BSW.index s i
      (result, _) = BSW.unfoldrN (fromIntegral $ table ! (0,0)) (\(!i,!j) -> recon i j) (0,0)
  BS.putStrLn result


Measured memory_bytes: 19580
/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/17/2020
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxN = 1e5+20;

int n;
int64_t v[mxN+1][3];
int64_t dp[mxN+1][4];

int64_t go(int idx, int last) {
	if(idx == n) {
		if(last == 1) {
			return max(v[idx][1], v[idx][2]);
		} else if(last == 2) {
			return max(v[idx][0], v[idx][2]);
		} else {
			return max(v[idx][0], v[idx][1]);
		}
	}
	if(idx > n) {
		return (int64_t)-1e18;
	}
	if(dp[idx][last] != -1) {
		return dp[idx][last];
	}
	int64_t ans = (int64_t)-1e18;
	if(last != 1) {
		ans = max(ans, v[idx][0] + go(idx+1, 1));
	}
	if(last != 2) {
		ans = max(ans, v[idx][1] + go(idx+1, 2));
	}
	if(last != 3) {
		ans = max(ans, v[idx][2] + go(idx+1, 3));
	}
	//cout << ans << " ";
	return dp[idx][last] = ans;
}

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

	cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> v[i][j];
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 4; j++) {
			dp[i][j] = -1;
		}
	}
	int64_t ans = go(1, 0);
	cout << ans << "\n";

	return 0;
}















Measured memory_bytes: 16852
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846
 
void solve()
{       
        int n; cin >> n;
        vector<ll> a(n);
        forn(i, n) cin >> a[i];
        sort(all(a));
        ll l, r;
        if(n % 2 == 0)
        {
                l = a[n / 2 - 1];
                r = a[n / 2];
                cout << r - l;
        }
        else
        {
                cout << 0;
        }
        
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
 PROGRAM-ID.     TEST101.

 DATA DIVISION.
 WORKING-STORAGE SECTION.
  01 INP.
   03 INP-O OCCURS 10.
     05 INP-C  PIC 9(1).
  01 A         PIC 9(20) VALUE ZERO.
  01 SHO       PIC 9(10).
  01 AMA       PIC 9(10) VALUE ZERO.
  01 S         PIC 9(10).
 
 PROCEDURE DIVISION.
  ACCEPT INP.
  PERFORM VARYING S FROM 1 BY 1 UNTIL S > 10
     IF INP-C(S) NUMERIC
       COMPUTE A = A + INP-C(S)
     ELSE
       CONTINUE
     END-IF
  END-PERFORM.

  DIVIDE INP BY A GIVING SHO REMAINDER AMA.
  IF AMA = ZERO
    DISPLAY 'Yes'
  ELSE
    DISPLAY 'No'
  END-IF.

  STOP RUN.

Measured memory_bytes: 764
#include <stdio.h>
int main(void){
    int n, k;
    double p[200000+5];
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++)scanf("%lf", &p[i]);
    double s[200000+5];    // 累積和
    for(int i=0; i<n; i++)s[i]=(double)(p[i]+1)/2;
    for(int i=1; i<n; i++)s[i]+=s[i-1];
    
    float ans=s[k-1];
    for(int i=0; i<n-k; i++){
        if(ans<s[i+k]-s[i])ans=s[i+k]-s[i]; 
    }
    
    printf("%f\n", ans);
    return 0;
}


Measured memory_bytes: 4844
import sys
input = sys.stdin.readline
from collections import *

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(n+1)
    
    def add(self, i, x):
        i += 1
        
        while i<=self.n:
            self.bit[i] += x
            i += i&(-i)

    def acc(self, i):
        s = 0
        
        while i>0:
            s += self.bit[i]
            i -= i&(-i)
        
        return s

N, Q = map(int, input().split())
c = list(map(int, input().split()))
prev = [-1]*N
ys = defaultdict(list)

for i in range(N):
    if prev[c[i]-1]!=-1:
        ys[prev[c[i]-1]].append(i)
    
    prev[c[i]-1] = i

rs = defaultdict(list)

for i in range(Q):
    l, r = map(int, input().split())
    rs[l-1].append((i, r-1))

bit = BIT(N)
ans = [-1]*Q

for x in range(N-1, -1, -1):
    for y in ys[x]:
        bit.add(y, 1)
    
    for i, r in rs[x]:
        ans[i] = r-x+1-bit.acc(r+1)

for ans_i in ans:
    print(ans_i)

Measured memory_bytes: 263448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;
  
  if(S.size()<=K){
    cout << S << endl;
  }else{
    S = S.substr(0,K);
    cout << S << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;


int main() {

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    int maxX = -100;

    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        maxX = max(maxX, x);
    }

    int minY = 100;

    for (int i = 0; i < M; i++) {
        int y;
        cin >> y;
        minY = min(minY, y);
    }

    bool shouldOccur = true;

    for (int z = X + 1; z <= Y; z++) {

        if (maxX < z and minY >= z) {
            shouldOccur = false;
            break;
        }

    }

    if (shouldOccur) {
        cout << "War" << "\n";
    } else {
        cout << "No War" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256