akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, K;
	cin >> N >> K;

	int ret = 0;
	REP(b, K + 1, N) {
		ret += N / b * (b - K);
		ret += max(0LL, (b - K) - (b * (N / b + 1) - N - 1) - (K == 0));
		//REP(a, N / b * b + 1, N) {
		//	ret += a % b >= K;
		//}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static double solve(int N, double[] p) {
        double[] hCount = new double[N+1];
        hCount[0] = 1.0;
        for (int i = 0; i < N; i++)
            for (int j = i+1; j >=0; j--)
                hCount[j] = ((j >= 1) ? p[i]*hCount[j-1]: 0) + (1.0-p[i])*hCount[j];
        double sum = 0.0;
        for (int i = N/2+1; i <= N; i++) sum += hCount[i];
        return sum;
    }

    public static double run(Scanner scanner) {
        int N = scanner.nextInt();
        double[] p = new double[N];
        for (int i=0; i < N; i++) p[i] = scanner.nextDouble();

        return solve(N, p);
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(run(scanner));
        }
        //Tests.run();
    }
}


Measured memory_bytes: 36904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
ll n, k, a[maxn];
ll s[maxn], t[maxn];
map <ll, ll> mp;

int main()
{
  scanf("%lld%lld",&n,&k);
  for(int i = 1; i <= n; i ++){
    scanf("%lld",&a[i]);
    s[i] = s[i - 1] + a[i];
    s[i] = (s[i] + k) % k;
  }
  ll ans = 0;
  mp[0] = 1;
  int l = 0;
  for(int i = 1; i <= n; i ++){
    while(i - l >= k){
      mp[(s[l] - l % k + k) % k] --;
      l ++;
    }
    ans += mp[(s[i] - i % k + k) % k];
    mp[(s[i] - i % k + k) % k] ++;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 15872
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N, L;
int32_t A[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> L;
	for (int32_t i = 0; i < N; i++)
	{
		in >> A[i];
	}

	int32_t last_index = -1;
	for (int32_t i = 0; i < N-1; i++)
	{
		if (A[i] + A[i + 1] >= L) {
			last_index = i;
			break;
		}
	}

	if (last_index == -1) {
		out << "Impossible" << endl;
		return 0;
	}
	out << "Possible\n";

	std::vector<int> command_rev;
	command_rev.reserve(N - 1);
	command_rev.push_back(last_index);

	for (int32_t i = last_index+1; i < N - 1; i++)
	{
		command_rev.push_back(i);
	}
	for (int32_t i = last_index - 1; i >= 0; --i)
	{
		command_rev.push_back(i);
	}

	for (int i = command_rev.size() - 1; i >= 0; i--)
	{
		out << command_rev[i]+1 << '\n';
	}
	out << std::flush;

	return 0;
}
#endif


Measured memory_bytes: 1664
<?php
// 入力
fscanf(STDIN,"%d %d %d %d %d",$h1,$m1,$h2,$m2,$k);

// 時間差計算
$time_from = strtotime('2020-05-31 '.$h1.":".$m1);
$time_to   = strtotime('2020-05-31 '.$h2.":".$m2);
$diff_time = ($time_to - $time_from) / 60;

echo ($diff_time - $k);

Measured memory_bytes: 16412
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));
    ll ans = 0;
    rep(i, n-1) ans += abs(a[i+1]-a[i]);
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define int long long
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};



main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  
  int n;cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){cin>>p[i];}
  vector<pair<int,int> >vec(n);
  for(int i=0;i<n;i++){
      vec[i].first=p[i];vec[i].second=i;
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  UnionFind tree(n);
  vector<int> flag(n);
  ll ans=0;
  for(int i=0;i<n;i++){      
      ll name=vec[i].second,value=vec[i].first;
      //cout<<name<<" "<<value<<endl;
      flag[name]=1;
      ll part=1;
      if(name!=0 && flag[name-1]==1){part*=tree.size(name-1)+1;tree.merge(name,name-1);}
      if(name!=n-1 && flag[name+1]==1){part*=tree.size(name+1)+1;tree.merge(name,name+1);}
      //cout<<value<<" "<<part<<endl;
      ans+=part*value;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12620
N,M = map(int,input().split())
A = list(map(int,input().split()))

for i in range(N):
    A[i] *= -1

import heapq

heapq.heapify(A)
for i in range(M):
    a = heapq.heappop(A)*(-1)
    a //= 2
    a *= -1
    heapq.heappush(A,a)

print(sum(A)*(-1))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> height(N);
  vector<double> diff(N);
  int index = 0;
  double minimum = 100000000;
  
  for (int i = 0; i < N; i++) {
    cin >> height.at(i);
    diff.at(i) = abs(T - height.at(i) * 0.006 - A);
    if (diff.at(i) <= minimum){
      minimum = diff.at(i);
      index = i + 1;
    }
  }
  
  cout << index << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func count(k int, persons []int) (num int) {
	for _, p := range persons {
		if p >= k {
			num++
		}
	}
	return
}
func main() {
	n, k := nextInt(), nextInt()
	persons := make([]int, n)
	for i := 0; i < n; i++ {
		persons[i] = nextInt()
	}
	fmt.Println(count(k, persons))
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

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

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  double d; cin >> d;
  double x = d / sqrt(2);
  printf("%.10f\n", max(1.0 + floor(d), x + sqrt(d * d - x * x)));
  
  return 0;
}

Measured memory_bytes: 3304
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

// 10000 1 2
//  

using namespace std;

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

ll sum(ll n, ll a[], ll b) {
	ll ans = 0;
	for (int i = 0; i < n ; i++) {
		ans += abs(a[i] - b);
	}
	//cout << ans << endl;
	return ans;
}

int main() {
	ll n;
	cin >> n;
	ll a[n];
	ll total = 0;
	rep(i, n) {
		cin >> a[i];
		a[i] -= i + 1;

	}
	sort(&a[0], &a[n]);



	ll ans = sum(n, a, a[n / 2]);

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	ll N, a;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0;i < N;i++)cin >> A[i];
	sort(all(A));
	int d = N - 2;
	a = A[N - 1];
	for (int i = 0;i < N - 2;i++) {
		a += A[d];
		if (i % 2)d--;
	}
	cout << a << endl;
}

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

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

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <int MOD>
struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+(const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator+=(const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator-=(const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator*=(const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator/=(const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp& r) const noexcept { return this->val == r.val; }
    constexpr bool operator!=(const Fp& r) const noexcept { return this->val != r.val; }
    friend constexpr ostream& operator<<(ostream& os, const Fp<MOD>& x) noexcept { return os << x.val; }

    friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> AC(N, 0), WA(N, 0);
    int ans = 0;
    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        p -= 1;
        if (AC[p]) continue;
        if (S == "AC") {
            AC[p] = true;
            ans += WA[p];
        } else {
            WA[p] += 1;
        }
    }
    cout << accumulate(ALL(AC), 0) << " " << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      //文節の長さ
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      
      
      if(a >= 5 && b >= 5 && c >= 5){
        int total = a + b + c;
        if((a >= 7 || b >= 7 || c >= 7) && total == 17){
          System.out.println("YES");
        }else{
          System.out.println("NO");
        }
      }else{
        System.out.println("NO");
      }
      
      

	}
}


Measured memory_bytes: 36100
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;

int main()
{
    ll N,L,res;
    ll iMin = 999999;
    ll majiImin = 999999;
    ll tmp;


    cin >> N >> L;

    REP(i,N)
    {
        tmp = L + i+1 - 1;
        res += tmp;

        if(iMin > abs(tmp))
        {
            iMin = abs(tmp);
            majiImin = tmp;
        }
    }

    res -= majiImin;

    cout << res << endl;

}



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

int main() {
    int n;
    cin >> n;
    
    vector<vector<pair<int64_t, int64_t>>> link(n+1);
    vector<bool> even(n+1, false), visited(n+1, false);
    for (int i=0; i<n-1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        link[u].emplace_back(v, w);
        link[v].emplace_back(u, w);
    }

    queue<pair<int64_t, int64_t>> q;
    q.emplace(1, 0);
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        visited[p.first] = true;
        if (p.second % 2 == 0) even[p.first] = true;
        for (auto e : link[p.first]) {
            if(!visited[e.first]) q.emplace(e.first, p.second + e.second);
        }
    }

    for(int i=1; i<=n; i++) {
        cout << even[i] << endl;
    }
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
	fastio();
	ll N,k;
	cin>>N>>k;
	ll ar[N];
	cn(ar,N);
	ll g[N];
	g[0]=0;
	for(ll i=1;i<N;i++)
	{
		ll m=abs(ar[i]-ar[i-1])+g[i-1];
		for(int j=2;j<=min(k,i);j++)
		{
			m=min(m,abs(ar[i]-ar[i-j])+g[i-j]);
		}
		g[i]=m;
	}
	cout<<g[N-1]<<endl;
}	


Measured memory_bytes: 1792
#include<stdio.h>
    int main()
    {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);

        int max = a;
        if(b > max){
            max = b;
        }
        if(c > max){
            max = c;
        }
        printf("%d",a+b+c-max);
    }



Measured memory_bytes: 128
using System.Collections.Generic;
using System.Linq;
using System;

public class Compe
{
    public int cno { get; set; }
    public int cost { get; set; }
}

public class hello
{
    public static void Main()
    {
        var compes = new List<Compe>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        for (int i = 0; i < n; i++)
        {
            var te = int.Parse(Console.ReadLine().Trim());
            compes.Add(new Compe { cno = i, cost = te });
        }
        var vote = new int[n];
        for (int i = 0; i < m; i++)
        {
            var t2 = int.Parse(Console.ReadLine().Trim());
            var t2a = compes.Where(x => x.cost <= t2).OrderBy(y => y.cno).First().cno;
            vote[t2a]++;
        }
        var votemax = vote.Max();
        for (int i = 0; i < n; i++)
             if (vote[i] == votemax) { Console.WriteLine(i + 1); break; }
    }
}

Measured memory_bytes: 10376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    double x[n];
    double y[n];
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    vector<int> v(n);
    double len=0;
    rep(i,n){
        v[i]=i;
    }
    do{
        rep(i,n-1){
            len+=pow(pow(abs(x[v[i+1]]-x[v[i]]),2)+pow(abs(y[v[i+1]]-y[v[i]]),2),0.5);
        }
    }while(next_permutation(all(v)));
    rep(i,n){
        len/=i+1;
    }
    cout << setprecision(10) << len;
    


}

/*



 */



Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

int main() {
    int n;
    cin >> n;
    int a[n+1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    int cur = a[1], ans = -1;
    for (int i = 1; i < n; i++) {
        if (cur == 2) {
            ans = i;
            break;
        } else cur = a[cur];
    }
    cout << ans << endl;
}

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

#define R0 register
#define iL inline
#define ll long long

#define gc getchar
#define pc putchar
#define sp pc(' ')
#define ln pc('\n')

template <class t>
iL void read(t &x) {
    R0 bool f = 0;
    R0 char c = gc();
    while ((c < '0' || c > '9') && c != '-') c = gc();
    if (c == '-') f = 1, c = gc();
    x = 0;
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ '0'), c = gc();
    f && (x = -x);
}

template <class t>
iL void print(t x) {
    if (x < 0) pc('-'), x = -x;
    if (x >= 10) print(x / 10);
    pc((x % 10) ^ '0');
}

template <class t>
iL t min(t a, t b) {
    return a < b ? a : b;
}

template <class t>
iL t max(t a, t b) {
    return a < b ? b : a;
}

template <class t>
iL void swap(t &a, t &b) { a ^= b ^= a ^= b; }

template <class t>
iL t lowbit(t x) { return x & -x; }

int n;

int main() {
    read(n);
    print((n - 1) / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    map<string,ll> mp;
    rep(i,n){
        string s;
        cin >> s;
        vector<int> a(26);
        rep(j,10){
            a[s[j]-'a']++;
        }
        string t;
        rep(j,26) t.push_back('0'+a[j]);
        mp[t]++;
    }
    ll ans = 0;
    for(auto a : mp){
        ans += (a.second-1)*a.second/2;
    }
    cans;
    return 0;
}

Measured memory_bytes: 16056
n = gets.to_i
h = {}

n.times do |i|
  s = gets.strip
  h[s] = 0 if h[s] == nil
  h[s] += 1
end

m = gets.to_i
m.times do |i|
  s = gets.strip
  h[s] = 0 if h[s] == nil
  h[s] -= 1
end

ans = 0
h.each do |k, v|
  ans = [ans, v].max
end

puts ans

Measured memory_bytes: 1788
from itertools import combinations

l,r = map(int,input().split())

if r - l >= 2019:
    print(0)
else:
    m = 2019
    for i, j in combinations(range(l, r+1),2):
        tmp = i*j % 2019
        if m > tmp:
            m = tmp
    print(m)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace ARC061C
{
    class MainClass
    {
        static string[] s;

        public static void Main(string[] args)
        {
            s = Console.ReadLine().Split().ToArray();
            int slen = s[0].Length;
            int n = slen - 1;
            long ans = 0;

            List<long> slstorg = new List<long>();
            for(int i = 0; i < slen; i++)
            {
                slstorg.Add(long.Parse(s[0][i].ToString()));
            }

            //slstorg.ForEach(Console.WriteLine);


            // {0, 1, ..., n-1} の部分集合の全探索
            for (int bit = 0; bit < (1 << n); ++bit)
            {


                List<long> slst = new List<long>(slstorg);
                /* bit で表される集合の処理を書く */
                for (int i = 0; i < n; i++)
                {
                    //connect
                    if((bit & (1 << i)) > 0)
                    {
                       // Console.WriteLine("connect bit: " + Convert.ToString(bit, 2) + " i: " + i);
                        //string tmp = s[0][i - s[0].Length].ToString() + s[0][i - s[0].Length].ToString();
                        string tmp = slst[i].ToString()+ slst[i+1].ToString();
                        slst[i] = 0;
                        slst[i + 1] = long.Parse(tmp);
                    }
                }

               // Console.Write("bit : " + Convert.ToString(bit, 2) + " slst: ");
               // slst.ForEach(Console.WriteLine);


                //Console.WriteLine(bit);

                ans += slst.Sum();
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll counter = 0, maxCounter = 0;
  string s;
  cin >> s;
  REP(i, s.size()) {
    if (s[i] == 'A') {
      ++counter;
    } else if (s[i] == 'C') {
      ++counter;
    } else if (s[i] == 'G') {
      ++counter;
    } else if (s[i] == 'T') {
      ++counter;
    } else {
      maxCounter = max(maxCounter, counter);
      counter = 0;
    }
  }
  maxCounter = max(maxCounter, counter);
  cout << maxCounter << endl;
  return 0;
}

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

int main() {
  int ans;
  vector<int> x(5);
  rep(i,5){
    cin >> x[i];
    if(x[i] == 0) cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
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);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  string s;
  cin >> s;
  int c = 0;
  rep(i, s.size()) {
    if(i == 0) continue;
    if(s[i] != s[i - 1]) c++;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 512
import numpy as np
N, M = map(int, input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])

for i in range(N-M+1):
    for j in range(N-M+1):
        if (A[i:i+M, j:j+M] == B).all():
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 12440
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(ll i=a;i<b;i++)
#define sexy ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);

bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 

bool sortmahstyle(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
   
    if(a.first<b.first )
        return true;
        
    return false;
    
}


void solve()
{
    
    int n,m,x; cin>>n>>m>>x;

    vector<vector<int>> algo(n, vector<int>(m));
    int cost[n];

    for(int i = 0; i< n ; i++){

        cin>>cost[i];
        for(int j = 0 ; j < m ; j++){

            cin>>algo[i][j];

        }


    }
    int ans = INT_MAX;
    for(int i = 0; i < (1<<n); i++ ){

        int paisa = 0;
        vector<int> skill(m);
        for(int j = 0; j < n; j++){

            if( (i>>j) & 1 ){

                paisa += cost[j];
                for(int k=0; k< m; k++)
                    skill[k] += algo[j][k];

            }

        }

        for( int j =0; j< m; j++ ){
            if( skill[j] < x )
                goto next;
        }

        ans = min(ans,paisa);

        next:
        ;

    }

    if(ans==INT_MAX)
        cout<<-1<<endl;
    else
        cout<<ans<<endl;
    
}





int main() {
sexy 
#ifndef ONLINE_JUDGE
txti
txto
#endif

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

       
    return 0;
}

Measured memory_bytes: 3676
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
A = [abs(a[i] - a[i + 1]) for i in range(n + 1)]
total = sum(A)

for i in range(n):
    print(total + abs(a[i + 2] - a[i]) - A[i] - A[i + 1])
    


Measured memory_bytes: 14048
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long int lli;
lli gcd(lli a, lli b){
	if(a%b==0) return b;
	return gcd(b,a%b);
}

int main(){
	int t;
	cin >> t;
	for(int rep=0; rep<t; rep++){
		lli h,w;
		cin >> h >> w;
		lli d = gcd(h,w);
		h /= d;
		w /= d;
		if(h%2==0 or w%2==0){
			cout << 1 << " " << 1 << endl;
		}else{
			cout << (h*w+1)/2 << " " << h*w/2 << endl;
		}
	}	
    return 0;
}


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

int main(){
    while (true){
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        ll ans = 0;
        rep(a, n){
            rep(b, n){
                rep(c, n){
                    if (a == b || b == c || c == a) continue;
                    if (a + b + c == x - 3) ans ++;
                }
            }
        }
        cout << ans / 6 << endl;
    }
    return 0;
}


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

using namespace std;

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

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

	int a[100005];

	int m;

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

	int ans = 0;

	int o = 0;

	while(1){
		if(o >= n-1) break;
		o += k - 1;
		ans++;
	}

	cout << ans << endl;

	return 0;

}



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


int main() {
  // ここにプログラムを追記
  
  int S,A;
 
  string n;
  char x;
 
  cin>> n;
  S = n.size();
  A = S-1;
  x = n.at(A);
    if(x =='2'||x=='4'||x=='5'||x=='7'||x=='9')cout<<"hon"<<endl;
  else if(x=='0'||x=='6'||x=='8'||x=='1')cout<<"pon"<<endl;
  else cout<<"bon"<<endl;
}


Measured memory_bytes: 3628
from functools import reduce
from fractions import gcd

N, K = map(int, input().split())
A = list(map(int, input().split()))

if K > max(A):
    print('IMPOSSIBLE')
    exit()

if A.count(K) != 0:
    print('POSSIBLE')
    exit()

g = reduce(gcd, A)
for a in A:
    if K > a:
        continue
    if (a - K) % g == 0:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


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

using namespace std;

int gcd(int a, int b){
    if(b > a){
        swap(a, b);
    }
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    int g = 0;
    int mmax = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        g = gcd(g, a[i]);
        mmax = max(mmax, a[i]);
    }
    if(k % g != 0 || mmax < k){
        cout << "IMPOSSIBLE"; return 0;
    }
    cout << "POSSIBLE"; return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
 
int main ()
{
  prep();
  long long a, b;
  cin >> a >> b;

  cout << a*b/__gcd(a, b);
  return 0; 
}

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

    using namespace std;

    void __print(int x) {cerr << x;}
    void __print(long x) {cerr << x;}
    void __print(long long x) {cerr << x;}
    void __print(unsigned x) {cerr << x;}
    void __print(unsigned long x) {cerr << x;}
    void __print(unsigned long long x) {cerr << x;}
    void __print(float x) {cerr << x;}
    void __print(double x) {cerr << x;}
    void __print(long double x) {cerr << x;}
    void __print(char x) {cerr << '\'' << x << '\'';}
    void __print(const char *x) {cerr << '\"' << x << '\"';}
    void __print(const string &x) {cerr << '\"' << x << '\"';}
    void __print(bool x) {cerr << (x ? "true" : "false");}

    template<typename T, typename V>
    void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
    template<typename T>
    void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
    void _print() {cerr << "]\n";}
    template <typename T, typename... V>
    void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
    #ifndef ONLINE_JUDGE
    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    #else
    #define debug(x...)
    #endif
    const long long INF  = 1e18;
    int md = 998244353;

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        long long a,b,c,d;
        cin>>a>>b>>c>>d;
        long long ans1 = b * d;
        long long ans2 = a * c;
        long long ans3 = a * d;
        long long ans4 = b * c;
         cout<<max(max(ans1,ans2),max(ans3,ans4));
        return 0;
        
    }
    //https://www.youtube.com/watch?v=ZQqccia8bVo

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Pii = pair<int, int>;
using Pis = pair<int, string>;
#define REP(i,n) for(int i=0; i < n; i++)
#define ALL(n) begin(n), end(n)

int main()
{
  int n, m;
  cin >> n >> m;

  int WA[105000];
  bool AC[105000];
  int sol = 0, pen = 0;

  REP(i, m){
    int p;
    string s;
    cin >> p >> s;

    if (AC[p]) continue;
    if (s == "WA"){
      WA[p] += 1;
    }else if(s == "AC"){
      AC[p] = true;
      sol++;
      pen += WA[p];
    }
  }


  cout << sol << " " << pen << endl;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
unsigned long xor_x=88172645463325252ULL;
unsigned long rng()
{
	xor_x^=xor_x<<7;
	return xor_x^=xor_x>>9;
}
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
int each[365];
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		int ret=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)ret-=c[j]*(i-lst[j]);
		now+=each[i]=ret;
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<3000;tm++)
	{
		calc();
		int d,q=rng()%26;
		if(tm%10==0)
		{
			d=0;
			for(int i=1;i<D;i++)if(each[i]<each[d])d=i;
		}
		else d=rng()%D;
		while(t[d]==q)q=rng()%26;
		now+=change(d,q);
		t[d]=q;
		for(int k=0;k<3000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}

Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        HashSet<string> set = new HashSet<string>();
        HashSet<string> res = new HashSet<string>();
        set.Add("");
        foreach (var c in s)
        {
            HashSet<string> newSet = new HashSet<string>();
            foreach (var item in set)
            {
                newSet.Add(item);
                if (item.Length == 2) res.Add(item + c);
                else newSet.Add(item + c);
            }
            set = newSet;
        }
        Console.WriteLine(res.Count);
    }
}


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

import os
import sys


def main():
    print(read_int() ** 2)


###############################################################################

DEBUG = 'DEBUG' in os.environ


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


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


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

i32 ans = -1;
i32 d[4] = {-4, -1, 1, 4};
i32 mdt[16][16];
i32 limit;
string S;
i32 md, space;

inline i32 getAllMD()
{
	i32 sum = 0;
	for ( i32 i = 0; i < 16; i++ ) {
		if ( S[i] == 'a' ) continue;
		sum += mdt[i][S[i] - 'b'];
	};
	return (sum);
}

void dfs(i32 n, i32 prev) {
	if ( md == 0 ) { ans = n; return; }
	if ( md + n > limit ) return;

	for ( i32 i = 0; i < 4; i++ ) {
		i32 npos = space + d[i];
		if ( i == 1 && (space & 3) == 0 ) continue;
		if ( i == 2 && (space & 3) == 3 ) continue;
		if ( npos < 0 || 15 < npos ) continue;
		if (prev == npos) continue;

		i32 tmd = md;

		md -= mdt[npos][S[npos] - 'b'];
		md += mdt[space][S[npos] - 'b'];
		swap(S[space], S[npos]);
		space^=npos^=space^=npos;
		dfs(n + 1, npos);
		if ( ans != -1 ) return;
		md = tmd;
		space^=npos^=space^=npos;
		swap(S[space], S[npos]);
	}
}

int main() {
	for ( i32 i = 0; i < 16; i++ ) {
		i32 c;
		cin >> c;
		S += c + 'a';
	}

	for ( i32 i = 0; i < 16; i++ ) {
		for ( i32 j = 0; j < 16; j++ ) {
			mdt[i][j] = abs(i / 4 - j / 4) + abs(i % 4 - j % 4);
		}
	}

	md = getAllMD();
	space = S.find('a');
	for ( limit = md; limit <= 1000; limit++ ) {
		dfs(0, -1);
		if ( ans != -1 ) { cout << ans << endl; return (0); }
	}
}



Measured memory_bytes: 3184
import java.io.*;
import java.util.*;
import static java.lang.System.*;
 
public class Main {
	static FastScanner sc = new FastScanner(System.in);
	static int n = sc.nextInt();
	static int[] ar = new int[n];
	
	public static void main(String[] args) {
		for (int i=0; i<n; i++) {ar[i] = sc.nextInt();}
		int m = sc.nextInt();
		for (int i=0; i<m; i++) {
			out.println(rec(n-1,sc.nextInt())?"yes":"no");
		}
	}
	
	static boolean rec(int i, int m) {
		if (m == 0) {return true;}
		if (i < 0) {return false;}
		return (rec(i-1,m) || rec(i-1,m-ar[i]));
		
	}
}



class FastScanner implements Closeable {
	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	public FastScanner(InputStream in) {this.in = in;}
	private boolean hasNextByte() {
		if (ptr < buflen) {return true;}
		else{
			ptr = 0;
			try {buflen = in.read(buffer);}
			catch (IOException e) {e.printStackTrace();}
			if (buflen <= 0) {return false;}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {throw new NumberFormatException();}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){return minus ? -n : n;}
			else{throw new NumberFormatException();}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
	public void close() {
		try {in.close();}
		catch (IOException e) {}
	}
}


Measured memory_bytes: 24852
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N;
    vector<string> si(N);
    vector<int> ans(N+1);
    ans.at(N) = 0;
    for (int i=0; i<N; i++){
        cin >> si.at(i);
    }
    cin >> M;
    vector<string> ti(M);
    for (int j=0; j<M; j++){
        cin >> ti.at(j);
    }
    for (int i=0; i<N; i++){
        int count = 0;
        for (int j=0; j<N; j++){
            if (si.at(i) == si.at(j)) count += 1;
        }
        for (int k=0; k<M; k++){
            if (si.at(i) == ti.at(k)) count -= 1;
        }
        ans.at(i) = count;
    }
    sort(ans.begin(),ans.end());
    cout << ans.at(N) << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        a: [u64;n]
    }
    for i in k..n {
        if a[i] > a[i-k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 5708
#include <stdio.h>

int main(void)
{
	int x, y, a = 0;

	while (1)
	{
		scanf("%d %d", &x, &y);

		if ((x == 0) && (y == 0)) break;
		if (x > y)
		{
			a = x;
			x = y;
			y = a;
		}
		printf("%d %d\n", x, y);
		
	}

	return 0;
}


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

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

  vector<int> V;
  S += '/';
  for (int i = 0, cnt = 1; i + 1 < S.size(); i++) {
    if (S.at(i) == S.at(i + 1)) cnt++;
    else {
      V.push_back(cnt);
      cnt = 1;
    }
  }
  if (S.front() != '1') V.insert(V.begin(), 0);

  N = V.size();
  vector<int> C(N + 1);
  for (int i = 1, sum = 0; i < N + 1; i++) {
    C.at(i) = sum += V.at(i - 1);
  }

  int mx = 0;
  for (int i = 0; i < N + 1; i += 2) {
    mx = max(mx, C.at(min(i + K * 2 + 1, N)) - C.at(i));
  }
  cout << mx << "\n";
}

Measured memory_bytes: 1272
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

ll extgcd(ll a,ll b,ll &x,ll &y){
    int d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }else{
        x=1;y=0;
    }
    return d;
}
ll gcd(ll  a,ll b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
int dig(ll n){
    int res=0;
    ll m=n;
    while(m){
        res++;m/=10;
    }
    return res;
}
main(){
    ll s;cin>>s;
    ll ans=0;
    ll r=0,l=0,temp=0;
    while(l<10000000){
        while(temp<s){
            r++;temp+=dig(r);
            if(temp==s) ans++;
        }
        while(temp>=s){
            l++;temp-=dig(l);
            if(temp==s&&l<10000000) ans++;
        }       
    }
    for(int i=1;i*i<=s;i++){
        if(s%i==0){
            int k=i;
            if(k>=8){
            ans=(ans+modpow(10,k-1)*9-s/k)%MOD;
            }
            k=s/k;
            if(k*k==s) continue;
            if(k<8) continue;
            ans=(ans+modpow(10,k-1)*9-s/k)%MOD;
        }
    }
    ans=(ans+s/8)%MOD;
    if(s%8==0) ans--;
    cout<<ans; return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1e9+7;
int n,h[110];
ll qpow(ll x,ll a){
	ll res=1;
	while (a){
		if (a&1) res=res*x%Mod;
		x=x*x%Mod; a>>=1;
	}
	return res;
}
inline ll calc(int l){
	return (qpow(2,l)+Mod-2)%Mod;
}
pii solve(int l,int r,int k){
	int mn=h[l],cnt=0;
	for (int i=l+1;i<=r;i++) mn=min(mn,h[i]);
	for (int i=l;i<=r;i++)
		if (h[i]==mn) cnt++;
	if (cnt==r-l+1) return pii(calc(r-l+1),qpow(2,mn-k-1));
	int tot=r-l+1,s0=1,s1=1,last=0;
	for (int i=l;i<=r+1;i++)
		if (!last&&h[i]>mn) last=i;
		else
			if (last&&(h[i]<=mn||i>r)){
				tot-=i-last;
				pii tmp=solve(last,i-1,mn);
				s0=(ll)s0*(tmp.first+4ll*tmp.second%Mod)%Mod;
				s1=(ll)s1*(2ll*tmp.second%Mod)%Mod;
				last=0;
			}
	s0=(s0+Mod-s1)%Mod; pii res;
	res.first=(ll)s0*qpow(2,tot)%Mod;
	res.first=(res.first+(ll)s1*calc(tot)%Mod)%Mod;
	res.second=(ll)s1*qpow(2,mn-k-1)%Mod;
	return res;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&h[i]);
	if (n==1){
		printf("%lld\n",qpow(2,h[1]));
		return 0;
	}
	ll mul=1;
	for (int i=1;i<=n;i++)
		if (h[i]>max(h[i-1],h[i+1])){
			mul=mul*qpow(2,h[i]-max(h[i-1],h[i+1]))%Mod;
			h[i]=max(h[i-1],h[i+1]);
		}
	pii ans=solve(1,n,0);
	printf("%lld\n",1ll*mul*(ans.first+2ll*ans.second)%Mod);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int sum = 0;
    int max = 0;
    for (int i = 0; i < N; i++) {
      int p = scanner.nextInt();
      sum += p;
      max = Math.max(max, p);
    }
    sum -= max / 2;
    System.out.println(sum);
  }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int X,Y,Z;
	cin>>X>>Y>>Z;
	int ans=(X-Z)/(Y+Z);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
H,W=gets.split.map &:to_i
a=$<.map &:chomp
h=(0...H).select{|h|a[h].chars.any?{|c|c=='#'}}
w=(0...W).select{|w|(0...H).any?{|k|a[k][w]=='#'}}
h.each{|i|w.each{|j|print a[i][j]};puts}

Measured memory_bytes: 1788
import itertools

n,x,y = map(int, input().split())

a = [i for i in range(1, n+1)]
b = [0]*(n-1)

for j in range(n):
    for k in range(j+1, n):
        c = min(abs(k-j),abs(j-(x-1)) +abs(k-(y-1))+1)
        b[c-1] += 1
    

for l in range(n-1):
    print(b[l])

Measured memory_bytes: 3572
s = input()
s_list = list(s)
s_set = set(s_list)
abc_list = [chr(i) for i in range(97, 97+26)]
if len(s_set) == 26:
    print("None")
else:
    for a in abc_list:
        if a in s_set:
            pass
        else:
            print(a)
            break


Measured memory_bytes: 3956
#include <iostream>
#include <cstring>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  int x,y;
  int W,H,r;

  cin >> W >> H >> x >> y >> r;
  if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3088