akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

//行える操作: 整数 i ( 1 ≤ i ≤ N − 1 ) を一つ選ぶ。 
//左から i 番目のカードと i + 1 番目のカードの位置を入れ替え、さらにこれら 2 枚のカードを裏返す。

//可能性のある数列と移動回数が求められればよい

//奇数回の移動先ではbになる
//bの数は偶数個になる


int main(){

    int N;
    cin >> N;

    vector <int> guki; 
    vector <int> a(N); 
    vector <int> b(N); 
    REP(i, N)cin >> a[i];
    REP(i, N)cin >> b[i];
    int res = MOD;

    //奇数回の移動先ではbになる
    //010101
    //すべてa[i]の状態がうえとする
    //permutaitionでみたいので、0を寄せる

    for(int i = 0; i < N; i+=2)
    {
        guki.push_back(0);
    }
    for(int i = 1; i < N; i+=2)
    {
        guki.push_back(1);
    }

    //すべての順列を試す
    do
    {
        vector <pair <int, int> >  odd;
        vector <pair <int, int> >  even;
        //010
        for(int i = 0; i < N; ++i)
        {
            if(i % 2 == 1)
            {
                //元の位置が奇数
                if(guki[i] == 1)
                {
                    odd.push_back({a[i], i});
                }
                else
                {
                    even.push_back({b[i], i});
                }
            }
            else
            {
                if(guki[i] == 1)
                {
                    odd.push_back({b[i], i});
                }
                else
                {
                    even.push_back({a[i], i});
                }
            }
        }
        sort(odd.begin(), odd.end());
        sort(even.begin(), even.end());
        int las = 0;
        bool can = true;
        vector <int> pos;
        for(int i = 0; i < N; ++i)
        {
            int value;
            if(i % 2 == 1)
            {
                value = odd[i/2].first;
                pos.push_back(odd[i/2].second);
            }
            else
            {
                value = even[i/2].first;
                pos.push_back(even[i/2].second);
            }
            //偶数と整数の順序だけは変更できないので、単調増加か判定
            if(value < las)
            {
                can = false;
                break;
            }
            else
            {
                las = value;
            }
        }

        if(!can)continue;
        int cnt = 0;
        //転倒数を数え上げる
        for(int i = 0; i < N; ++i)
        {
            int cur = pos[i];
            for(int j = i + 1; j < N; ++j)
            {
                if(cur > pos[j])++cnt;
            }
        }

        res = min(res, cnt);

    } while (next_permutation(guki.begin(),guki.end()));
    
    if(res == MOD)res = -1;
    cout << res << endl;

    return 0;    
}


Measured memory_bytes: 384
require 'set'

N, K = gets.split.map &:to_i
Sushis = [*0...N].map{ gets.split.map &:to_i }


# Editorialを参考にした解法
# 1. まずSushisを美味しさ基礎点順に降順ソートし、先頭からK個選ぶ
Delicious_Sushis = Sushis.sort_by{|sushi| -sushi[1]}
selected_Sushis = Delicious_Sushis.take(K)
selected_Sushis_Point = selected_Sushis.inject(0){|sum, sushi| sum + sushi[1]}
num_selected_Sushis = selected_Sushis.size
selected_Groups_Set = selected_Sushis.map{|sushi| sushi[0]}.to_set
num_selected_Groups = selected_Groups_Set.size

# 2. selected_Sushisに含まれない種類のSushi Kindそれぞれについて、最大値の美味しさポイントを持つSushiを1つずつ取り出す
Unselected_Sushi_Groups = Delicious_Sushis.drop(K).group_by{|sushi| sushi[0]}
Unselected_but_Delicious_Sushis = Unselected_Sushi_Groups.values.map{|sushi_group| sushi_group.sort_by{|sushi| -sushi[1]}.first}

# 3. selected_Sushisについて、2のUnselected_but_Delicious_Sushisと交換可能なSushiについて求める
Changeable_Sushi = selected_Sushis.group_by{|sushi| sushi[0]}.values.select{|sushi_group| sushi_group.size >= 2}.map{|sushi_group| sushi_group.sort_by{|sushi| sushi[1]}.map{|sushi| sushi[1]}.take(sushi_group.size - 1)}.flatten.sort

# Unselected_but_Delicious_Sushisについて、Changeable_Sushiに含まれるsushiと順番に交換して合計点を求める

max_point = selected_Sushis_Point + num_selected_Groups**2

#p "selected_Sushis_Point: #{selected_Sushis_Point}, num_selected_Groups: #{num_selected_Groups}, max_point: #{max_point}"
#p "Unselected_but_Delicious_Sushis: #{Unselected_but_Delicious_Sushis}"
#p "Changeable_Sushi: #{Changeable_Sushi}"
#puts "------------------------------"

num_changed_sushi = 0
for i in 0...Unselected_but_Delicious_Sushis.size do
	break if Changeable_Sushi.size <= num_changed_sushi

	unselected_sushi = Unselected_but_Delicious_Sushis[i]
	next if selected_Groups_Set.include?(unselected_sushi[0])

	changeable_sushi = Changeable_Sushi[num_changed_sushi]

	num_selected_Groups += 1
	selected_Sushis_Point += unselected_sushi[1] - changeable_sushi
	new_point = selected_Sushis_Point + num_selected_Groups**2

	max_point = [max_point, new_point].max
	#p "unselected_sushi: #{unselected_sushi}"
	#p "changeable_sushi: #{changeable_sushi}"
	#p "num_selected_Groups: #{num_selected_Groups}"
	#p "max_point: #{max_point}"
	#p "Changeable_Sushi.size: #{Changeable_Sushi.size} i: #{i}"

	num_changed_sushi += 1
end

p max_point


Measured memory_bytes: 29264
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

# heap
class Heap
  def initialize(n, &func)
    @heap = Array.new(n) { 0 }
    @sz = 0
    @func = func
  end
  attr_reader :heap

  def size
    @sz
  end

  def empty?
    @sz.zero?
  end

  def push(x)
    i = @sz
    @sz += 1
    while i > 0
      p = (i - 1) / 2
      break if @func.call(@heap[p], x)

      @heap[i] = @heap[p]
      i = p
    end
    @heap[i] = x
  end

  def pop
    ret = @heap[0]
    @sz -= 1
    x = @heap[@sz]
    i = 0
    while i * 2 + 1 < @sz
      a = i * 2 + 1
      b = i * 2 + 2
      a = b if b < @sz && @func.call(@heap[b], @heap[a])

      break if !@func.call(@heap[a], x)

      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    ret
  end

  def top
    @heap[0]
  end
end

heap = Heap.new(n){|x, y| x > y}

a.each do |e|
  heap.push e
end

m.times do
  heap.push(heap.pop / 2)
end
puts heap.heap.inject(:+)


Measured memory_bytes: 11044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
int main(){
	string n;
	cin>>n;
	for(int i=0;i<3;++i)
	cout<<n[i];
	return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md  998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 10000010
ll d[M];
void seive(){
	rep(i,1,M)for(ll j=i;j<M;j+=i)d[j]++;
}
int main(){
    IOS;
 	
 	seive();
 	ll n;cin>>n;
 	ll ans=0;
 	rep(i,1,n+1)ans+=i*d[i];
 	cout<<ans;
	
    return 0;
}


Measured memory_bytes: 81776
#include <cstdio> 
#include <cstring>
using namespace std;

const int maxn=17, maxst=(1<<17)-1;
int n, m, sum, e[maxn][maxn], p[maxst], f[maxst][maxn];

inline int max(int x, int y){ return x<y?y:x; }
inline void up(int &x, int y){ x=max(x, y); }

int main(){
	scanf("%d%d", &n, &m); int a, b, c, ans=0;
	memset(f, -1, sizeof(f));  //还是那个，不能让不合法状态成功转移 
	for (int i=0; i<m; ++i){
		scanf("%d%d%d", &a, &b, &c); --a; --b;
		e[a][b]=e[b][a]=c; sum+=c; }
	for (int i=0; i<1<<n; ++i){
		for (int j=0; j<n; ++j) if (i&(1<<j))
		for (int k=0; k<n; ++k) if (i&(1<<k))
			p[i]+=e[j][k];
		p[i]>>=1; }
	f[1][0]=0;
	for (int i=1; i<(1<<n); ++i){  //当前集合 
		for (int j=0; j<n; ++j){  //当前挂的点 
			if (f[i][j]==-1) continue; 
			for (int k=0; k<n; ++k){  //枚举新在j后加的点
				if (i&(1<<k)) continue;
				if (e[j][k]==0) continue;  //绝壁想不到的东西！果然转移要想清楚，限制一定要先治好，不能让不合法状态成功转移 
				up(f[i|(1<<k)][k], f[i][j]+e[j][k]);
			}
			int revi=(((1<<n)-1)^i)|(1<<j);  //枚举新挂在j上的集合（要加上j以统计连j的边） 
			for (int k=revi; k; k=(k-1)&revi)
				up(f[i|k][j], f[i][j]+p[k]);
		}
	}
	for (int i=0; i<(1<<n); ++i)
		up(ans, f[i][n-1]);
	printf("%d\n", sum-ans);
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string ans;
	for (int i = 0; i < n; ++i) {
	    ans += s[i];
		ans += t[i];
	}
	
	
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int cnt = 0;
    while (true) {
        int p = pow(26, cnt);
        if (p > n) break;
        n -= p;
        cnt++;
    }
    string s;
    for (int i = cnt - 1; i >= 0; i--) {
        int p = pow(26, i);
        int c = n / p;
        n = n - c * p;
        s += (char)('a' + c);
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 4056
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let w_limit: usize = iterator.next().unwrap().parse().unwrap();
    let mut w: Vec<usize> = Vec::new();
    let mut v: Vec<usize> = Vec::new();
    for _ in 0..n {
        w.push(iterator.next().unwrap().parse().unwrap());
        v.push(iterator.next().unwrap().parse().unwrap());
    }

    let mut dp: Vec<Vec<usize>> = vec![vec![0; w_limit + 1]; n + 1];
    for i in 0..n {
        for j in 1..(w_limit + 1) {
            dp[i + 1][j] = dp[i][j];
            if j >= w[i] {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    return dp[n][w_limit].to_string();
}


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

typedef long long ll;
typedef std::pair<ll, ll> P;

constexpr ll INF = 1e15;
constexpr ll mod = 998244353;

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

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

int main() {
	ll n,x,m;
	cin >> n >> x >> m;
	vector<ll> ai;	
	vector<ll> sums;
	ai.push_back(x);
	sums.push_back(0);
	sums.push_back(x);
	map<int, int> his;
	his[x] = 0;	
	for (ll i = 1; i <= n; i++) {
		ll nx = ai.back();
		nx *= nx;
		nx %= m;
		if (his.count(nx)) {
			ll pi = his[nx];
			ll pValue = sums[pi];
			ll loop = i - pi;
			ll loopValue = sums[i] - sums[pi];
			ll p = n - pi;
			ll add = (p / loop)* loopValue;
			ll rest = p % loop + pi;
			ll rValue = sums[rest] - sums[pi];
			ll all = pValue + add + rValue;
			cout << all << endl;
			return 0;
		}
		ai.push_back(nx);
		sums.push_back(sums.back() + nx);
		his[nx] = i;
	}
	cout << sums[n] << endl;
	return 0;
}


Measured memory_bytes: 6516
// ABC 116 D
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int N,sum=0;
  cin >> N;
  VI l(N);
  REP(i,N){
    cin >> l[i];
  }
  RSORT(l);
  REP(i,N-1){
    sum+=l[i+1];
  }
  str ans = (sum > l[0]) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

//1-index
template<class T>
struct BIT {
    vector<T> bit;
    int n;
    BIT(int n): n(n), bit(n+1){}

    void add(int i, T x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }

    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    //[l,r)の合計
    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
};

mint dp[3005][3005];

int main() {
    int n; cin >> n;
    string s; cin >> s;
    rep(i,n) dp[0][i] = 1;
    BIT<mint> bit(n+1);
    rep(i,n) bit.add(i+1,1);
    rep(i,n-1) {
        BIT<mint> bit_tmp(n+1);
        rep(j,n+1) {
            if (s[i] == '<') {
                dp[i+1][j] = bit.sum(j+1);
                bit_tmp.add(j+1,dp[i+1][j]);
            }
            if (s[i] == '>') {
                dp[i+1][j] = bit.sum(j+2,n-i+1);
                bit_tmp.add(j+1,dp[i+1][j]);
            }
        }
        swap(bit,bit_tmp);
    }
    cout << dp[n-1][0] << endl;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(c>a && c<b)
     cout<<"Yes";
    else if(c==a && c==b && a==b)
     cout<<"Yes";
    else 
     cout<<"No";
     return 0;
}
     
   




Measured memory_bytes: 3668
# ABC066C - pushpush (ARC077)
from collections import deque


def main():
    N, *A = open(0).read().split()
    B, x = deque(), int(N) & 1
    for i, a in enumerate(A, start=x):
        if i & 1:
            B.appendleft(a)
        else:
            B.append(a)
    print(*B)


if __name__ == "__main__":
    main()

Measured memory_bytes: 24412
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long int llint;

int N, K;

int main() {
	cin >> N >> K;
	vector<double> sum(N + 1);
	sum[0] = 0;
	for (int i = 0; i < N; i++) {
		double p;
		cin >> p;
		p = (1 + p) / 2;
		sum[i + 1] = sum[i] + p;
	}
	double ans = 0;
	for (int i = 0; i <= N - K; i++) {
		ans = max(ans, sum[i + K] - sum[i]);
	}
	printf("%.12f\n", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  
 int a,b;
  cin>>a>>b;
  
  string s=to_string(a)+to_string(b);
  int tmp=stoi(s);
  
  int ans=0;
  while(true){
    ans++;
    if(ans*ans==tmp){
     cout<<"Yes"<<endl;
       return 0;
    }
    else if(ans*ans>tmp) break;
    
  }
 cout<<"No"<<endl;
  
  
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x;cin>>x;
    if(x<1200)cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;
    return 0;
}


Measured memory_bytes: 256
//In the name of allah
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int n ;
  cin >> n ;
  ll arr[n];
  for( ll i=0;i<n;i++ )
  {
      cin>>arr[i];
  }
  ll cnt=0;
  //cin>>arr[0];
  for( ll i=1;i<n;i++ )
  {
      if(arr[i-1]>arr[i])
      {
          cnt += arr[i-1]-arr[i];
          arr[i] = arr[i-1];
      }
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 5212
<?php
  $s = trim(fgets(STDIN));
  $length = strlen($s);
  $len_top = (($length-1)/2);
  $top = [];
  for($i=0; $i<=$len_top-1; $i++){
    $top[] = $s[$i];
  }
  
  $back = [];
  $len_back = ($length+3)/2;
  for($i=$len_back-1; $i<$length; $i++){
    $back[] = $s[$i];
  }

  if($top == $back){
    echo "Yes\n";
  }else{
    echo "No\n";
  }

Measured memory_bytes: 4604
#[allow(unused_imports)]
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()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

const MOD : usize = 1000_000_007;

fn main() {
    let nm = read_vec::<usize>();
    let n = nm[0];
    let m = nm[1];
    let mut amap = HashMap::new();
    let mut prev = 0;
    for _i in 0..m {
        let ai = read::<usize>();
        if ai <= prev {
            println!("0");
            return;
        }
        let key = ai - 1 - prev;
        let count = amap.entry(key).or_insert(0);
        *count += 1;
        prev = ai + 1;
    }
    let key = n - prev;
    {
        /* atcoderのRustだと中括弧でスコープを新しくつくらないと以下のようなエラーになる。
            error[E0502]: cannot borrow `amap` as mutable because it is also borrowed as immutable
            --> ./Main.rs:42:9
            |
         41 |         let current = amap.get(&key).unwrap();
            |                       ---- immutable borrow occurs here
         42 |         amap.insert(key, current + 1);
            |         ^^^^ mutable borrow occurs here
         43 | 
         44 |     } else {
            |     - immutable borrow ends here

            error: aborting due to previous error
        */
        let count = amap.entry(key).or_insert(0);
        *count += 1;
    }
    let answer = solve(n, &mut amap);
    println!("{}", answer);
}

fn solve(n: usize, aset:&mut HashMap<usize, i32>) -> usize {
    if n <= 1 {
        return 1;
    }

    let mut c : usize= 1;
    let mut f0 :usize= 0;
    let mut f1 :usize = 1;
    for i in 1..n+1 {
        //println!("i={}", i);
        let f : usize = f0 + f1;

        if let Some(count) = aset.remove(&i) {
            for _j in 0..count {
                c *= f;
                c %= MOD;
            }
        }

        if aset.len() == 0 {
            break;
        }

        f0 = f1;
        f1 = f % MOD;
    }
    
    return c;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm> 
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int main(){
    int i,j;
    ll N,M;
    ll ans =0;

    cin >> N >> M;

    ll x[N+1]; //累積和の計算
    ll tmp=0;
    REP(i,N+1){
       if(i==0){
           x[0] =0;
       }
       else{
            cin >> tmp;
            x[i] = x[i-1]+tmp;
       }
    }
    unordered_map<ll, ll> mp;     

    REP(i,N+1){
       mp[x[i]%M]++;
    }

    auto itr = mp.begin();

    while(itr != mp.end()){
        ll x = itr->second;
        ans += x*(x-1)/2;
        itr++;
    }

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

Measured memory_bytes: 4492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();
		int[] A = new int[10];
		int[] a = new int[Q];
		int[] b = new int[Q];
		int[] c = new int[Q];
		int[] d = new int[Q];
		for (int i = 0; i < Q; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		int max = 0;
		for (A[0] = 1; A[0] <= M; A[0]++) {
			for (A[1] = A[0]; A[1] <= M; A[1]++) {
				for (A[2] = A[1]; A[2] <= M; A[2]++) {
					for (A[3] = A[2]; A[3] <= M; A[3]++) {
						for (A[4] = A[3]; A[4] <= M; A[4]++) {
							for (A[5] = A[4]; A[5] <= M; A[5]++) {
								for (A[6] = A[5]; A[6] <= M; A[6]++) {
									for (A[7] = A[6]; A[7] <= M; A[7]++) {
										for (A[8] = A[7]; A[8] <= M; A[8]++) {
											for (A[9] = A[8]; A[9] <= M; A[9]++) {
												int tmp = 0;
												for (int i = 0; i < Q; i++) {
													if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
														tmp += d[i];
													}
												}
												if (tmp > max) {
													max = tmp;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 37056
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <bitset>
#include <assert.h>
using namespace std;
 
typedef long long ll;
#define File  freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
 
 
const int N = 400, INF = 1e9;
int mn[N], mx[N], suf[N];

int main()
{
	Fast;
	int t = 1;
	//cin >> t;

	int n;
	cin >> n;
	string s = "ACL";
	for(int i = 0; i < n; i++)cout << s;
		cout << "\n";
    
}




Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e3 + 50;
const int mod = 996873654;
int ar[MAX][MAX],top[MAX],vis[MAX]={0};
int main(){
	int n;
	sfi(n);
	for(int i=1;i<=n;i++){
		top[i]=1;
		for(int j=1;j<=n-1;j++){
			sfi(ar[i][j]);
		}
	}
	int cnt=1;
	while(1){
		bool flag=false;
		for(int i=1;i<=n;i++){
			if(top[i]>=n || vis[i]==cnt) continue;
			int v=ar[i][top[i]];
			if(vis[v]!=cnt && top[v]<n && ar[v][top[v]]==i){
				top[v]++; top[i]++;
				vis[i]=vis[v]=cnt;
				flag=true;
			}
		}
		if(!flag) break;
		cnt++;
	}
	for(int i=1;i<=n;i++){
		if(top[i]!=n){
			pfi(-1);
			return 0;
		}
	}
	pfi(cnt-1);
	return 0;
}

Measured memory_bytes: 4352
#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>;

int main() {
    int L,R,d;
    cin >> L >> R >> d;
    int cnt = 0;
    for(int i = d ; i <= R ; i += d){
        if(i >= L){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main(){
    int A=-1,B=-1;
    bool f = false;
    while(cin>>A>>B, A||B){
        if(f) puts("");
        bool no = true;
        for(int i=A;i<=B;i++){
            if(i%4==0 && (i%100!=0 || i%400==0)) printf("%d\n",i), no = false;
        }
        if(no) puts("NA");
        f = true;
    }
    return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

const int mod = 1e9 + 7;

typedef long long ll;

using namespace std;

string s;

int solve() {
  int len = s.length();
  int res = 0;
  int mx = 0;
  rep(i, len) {
    switch (s[i]) {
    case 'A': case'C': case 'G': case 'T':
      mx++;
      break;
    default:
      res = max(res, mx);
      mx = 0;
      break;
    }
  }
  res = max(res, mx);
  return res;
}

int main() {
  cin >> s;
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 256
def main():                                                                     
  n, k, x, y = int(raw_input()), int(raw_input()), int(raw_input()), int(raw_input())
  total = 0                                                                     
  for i in xrange(1, n+1):                                                      
    total += x if i <= k else y                                                 
  print(total)                                                                  
                                                                                
main()

Measured memory_bytes: 2568
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  long long waru = powl(10, 9)+7;
  long long n;
  cin >> n;
  if(n == 1)cout << 0;
  else{
    long long ans = 1;
    long long b = 1;
    long long c = 1;
    rep(i, 0, n){
      ans = (ans*10)%waru;
    }
    rep(i, 0, n){
      b = (b*9)%waru;
    }
    rep(i, 0 , n){
      c = (c*8)%waru;
    }
    ans -= (2*b-c);
    ans %= waru;
    if(ans<0)ans += waru;
    cout << ans;
  }
    
}

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = INT_MAX;

void solve() {
	int n,k;
	cin >> n >> k;
	set<int> s;

	F0R(i, k) {
		int x;
		cin >> x;

		F0R(j, x) {
			int z; cin >> z;
			s.insert(z);
		}
	}

	cout << n - s.size() << "\n";
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 3656
a,b,c = [int(input()) for _ in range(3)] 
x = int(input())

z = []
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            z.append(50*k+j*100+500*i)
#print(z)
print(z.count(x))


Measured memory_bytes: 8292
## main

n = gets.strip.to_i
nn = n * (n - 1) / 2

ws = n.times.map{0}

nn.times do
  ai, bi, asc, bsc = gets.strip.split(' ').map{|s| s.to_i}
  ai -= 1
  bi -= 1

  if asc == bsc
    ws[ai] += 1
    ws[bi] += 1
  elsif asc > bsc
    ws[ai] += 3
  else
    ws[bi] += 3
  end
end

tws = (0...n).zip(ws).sort{|a, b| b[1] <=> a[1]}

cod = 0
psc = 0
pnm = 1

tos = []

for i in (0...n)
  ti, tsc = tws[i]

  if psc != tsc
    cod += pnm
    pnm = 1
    tos[ti] = cod
    psc = tsc
  else
    pnm += 1
    tos[ti] = cod
  end
end

puts tos

Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
typedef long long ll;
using namespace std;
ll gauss (ll n)
{
	if (n % 1) {
    	return n / 2 + 1;
    } else {
    	return n / 2;
    }
}
ll func(ll h)
{
	if (h == 1) {
    	return 1;
    } else {
      	
        	return 2 * func(gauss(h)) + 1;
        
    }
}
int main()
{
	ll H; cin >> H;
  	cout << func(H) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
    vector < int > a(3);
    for( int i = 0 ; i < 3 ; i++) cin >> a[i] ;
    sort(st(a));
    int ans = 0 ;
    for( int i = 1 ; i < 3 ; i++){
        ans+=a[i]-a[i-1];
    }
    cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


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

int main() {
    int H, W;

    while(1) {
        cin >> H >> W;

        if ((H == 0) && (W == 0)) {
            break;
        }

        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if ((j == 0) || (j == (W - 1)) || (i == 0) || (i == (H - 1))) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3068
/*
ID: sabertooth
LANG:C++11
TASK: hamming
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool _check(int n,int pos)
{
	return (n & (1<<pos));
}
int _set(int n,int pos)
{
	return n=n|(1<<pos);
}
/*no of prime in range
1e9=50847534
1e8=5761455
1e7=664579
1e6=78498
1e5=9592*/
const int N=1e6;
int isprime[N/32+2];
int prime[78498+3];
int prmsz;
void seive()
{
    prmsz=0;
	prime[prmsz++]=2;
	for(int i=3;i*i<=N;i+=2)
	{
		if(!_check(isprime[i/32],i%32))
		for(int j=i*i;j<=N;j+=i+i)
		{
			isprime[j/32]=_set(isprime[j/32],j%32);
		}
	}
	for(int i=3;i<=N;i+=2)
	{
		if(!_check(isprime[i/32],i%32))
			prime[prmsz++]=i;
	}
	return;
}
int n;
int pos;
int ans[100];
int cum[100];
int used[N+3];
bool check()
{
    for(int i=1;i<=pos-5;i++)
    {
        int now=cum[i+5]-cum[i-1];
        if(!_check(isprime[now/32],now%32) and now&1)
            return 0;
    }
    return 1;
}
void recur(int next)
{
    if(pos>=n)
    {
        return;
    }
    for(int i=next;i<prmsz;i++)
    {
        if(pos>=n)
            return;
        if(!used[prime[i]])
        {
            ans[pos++]=prime[i];
            cum[pos+1]=cum[pos]+prime[i];
            if(pos>=5)
            {
                if(check())
                {
                    used[prime[i]]=1;
                    recur(i);
                }
                else
                {
                    pos--;
                }
            }
        }
    }
}
int main()
{
   // seive();
   int a,b,cnt=0;
    scanf("%d %d",&a,&b);
    for(int i=1;i<a or(i<=a and i<=b);i++)cnt++;
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
using namespace std;




int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,m,n,k;
     ll t;
     string s;
     cin>>s;
     n=s.size();
     for(i=0;i<n;i++)
     {
         if(s[i]=='7')
         {
             cout<<"Yes"<<endl;
             return 0;
         }
     }
     cout<<"No"<<endl;
}


Measured memory_bytes: 3612
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <algorithm>
#define ii pair<int, int>
#define iii pair<ii, int>
#define pq priority_queue

using namespace std;

int bfs(vector<vector<char>> graph, ii start, ii goal, int h, int w) {
    queue<iii> possible;
    set<ii> visited;
    possible.push(make_pair(start, 0));
    while (!possible.empty()) {
        ii xy = possible.front().first;
        int dist_from_start = possible.front().second;
        possible.pop();
        if (visited.find(xy) == visited.end()) {
            if (xy == goal) {
                return dist_from_start;
            }
            if (xy.first + 1 < h && graph[xy.first + 1][xy.second] == '.') {
                possible.push(make_pair(make_pair(xy.first + 1, xy.second), dist_from_start + 1));
            }
            if (xy.first - 1 >= 0 && graph[xy.first - 1][xy.second] == '.') {
                possible.push(make_pair(make_pair(xy.first - 1, xy.second), dist_from_start + 1));
            }
            if (xy.second - 1 >= 0 && graph[xy.first][xy.second - 1] == '.') {
                possible.push(make_pair(make_pair(xy.first, xy.second - 1), dist_from_start + 1));
            }
            if (xy.second + 1 < w && graph[xy.first][xy.second + 1] == '.') {
                possible.push(make_pair(make_pair(xy.first, xy.second + 1), dist_from_start + 1));
            }
            visited.insert(xy);
        }
    }
    return -1;
}

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> graph(h, vector<char>(w));
    cin.get();
    int no_black = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin.get(graph[i][j]);
            if (graph[i][j] == '#') {
                no_black++;
            }
        }
        cin.get(); //get \n character
    }
    int answer = bfs(graph, make_pair(0, 0), make_pair(h - 1, w - 1), h, w);
    if (answer >= 0) {
        answer = h * w - answer - no_black - 1;
    }
    cout << answer;
}

Measured memory_bytes: 3748
#include<iostream>
#include<queue>
#include<algorithm>
#include<tuple>
#include<set>

#define INF 10000000001

using namespace std;

typedef struct{
    int x;
    int y;
    int z;
    long sum;
}  cakeset;

bool operator< (const cakeset ck1, const cakeset ck2){
    return ck1.sum < ck2.sum;
}
bool operator> (const cakeset ck1, const cakeset ck2){
    return ck1.sum > ck2.sum;
}

int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    long A[X+1], B[Y+1], C[Z+1];
    for(int i=0; i<X; i++){
        cin >> A[i];
    }   A[X] = -INF;
    for(int i=0; i<Y; i++){
        cin >> B[i];
    }   B[Y] = -INF;
    for(int i=0; i<Z; i++){
        cin >> C[i];
    }   C[Z] = -INF;

    sort(A, A + X + 1, greater<long>() );
    sort(B, B + Y + 1, greater<long>() );
    sort(C, C + Z + 1, greater<long>() );

    priority_queue < cakeset > que;
    que.push(cakeset{0, 0, 0, A[0] + B[0] + C[0]});

    set<int> visited;
    visited.insert(0);

    for(int i=0; i<K; i++){
        auto cs = que.top(); que.pop();
        cout << cs.sum << endl;
        int x = cs.x;
        int y = cs.y;
        int z = cs.z;
        if(*visited.find(1001*1001*(x+1) + 1001*y + z) == *visited.end()){
            que.push(cakeset{x+1, y, z, A[x+1] + B[y] + C[z]});
            visited.insert(1001*1001*(x+1) + 1001*y + z);
        }
        if(*visited.find(1001*1001*x + 1001*(y+1) + z) == *visited.end()){
            que.push(cakeset{x, y+1, z, A[x] + B[y+1] + C[z]});
            visited.insert(1001*1001*x + 1001*(y+1) + z);
        }
        if(*visited.find(1001*1001*x + 1001*y + z+1) == *visited.end()){
            que.push(cakeset{x, y, z+1, A[x] + B[y] + C[z+1]});
            visited.insert(1001*1001*x + 1001*y + z+1);
        }
    }
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h, w, d, tmp, n;
    cin >> h >> w >> d;
    n = h * w;
    vector<pair<ll, ll>> cost(n + 10);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> tmp;
            cost[tmp] = {i, j};
        }
    }
    vector<ll> magic(n + 10, 0);
    for (int i = 1; i <= n; i++)
    {
        if (i + d <= n)
        {
            magic[i + d] = magic[i] + abs(cost[i].first - cost[i + d].first) + abs(cost[i].second - cost[i + d].second);
        }
    }
    ll q, l, r;
    cin >> q;
    while (q--)
    {
        cin >> l >> r;
        cout << magic[r] - magic[l] << endl;
    }
}

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

int main() {
    string stra;
    int x=0,y;
    cin >> stra;
    for(int i=0;i<4;i++){
        char xy = stra[i];
        y = (int)xy;
        if(y==43){
            x=x+1;
        }else if (y==45){
            x=x-1;
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  int N;  cin>>N;
  string s; cin>>s;
  vector<int> w(N+1,0), b(N+1,0);
  rep(i,0,N){
    w[i+1] = w[i] + (s[i]=='.' ? 1:0);
    b[i+1] = b[i] + (s[i]=='#' ? 1:0);
  }
  int ans = inf;
  for(int left=0 ; left<=N ; left++){
    int tmp = 0;
    tmp += b[left] - b[0];
    tmp += w[N] - w[left];
    chmin(ans, tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
//string divide[4] = {"dream", "dreamer", "erase", "eraser"};
int main(){
int n;
cin >> n;
long long a[100001],cnt[100001]={0},max = -1;
for (int i = 0;i < n;i++) cin >> a[i];

for (int i = 0;i < n;i++){
    cnt[a[i]-1]++;
    cnt[a[i]]++;
    cnt[a[i]+1]++;
}
for (int x:cnt){
    if(x > max)
        max = x;
}
cout << max << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}
ll ans = 0;

vector<int> G[100001];
bool used[100001];
void dfs(int n, int color) {
        used[n] = true;
        if (color == 1) {
            ans++;
            color = 0;
        } else{
            color = 1;
        };
        rep(i, G[n].size()) {
            if (used[G[n][i]]) {
                continue;
            } else {
                dfs(G[n][i],  color);
            }
        }

}

int main(){
    ll N, M;
    cin >> N >> M;
    ll H[N];
    rep(i, N) {
        ll h;
        cin >> h;
        H[i] = h;
    }
//    rep(i, N) {
//        G[i] = {};
//    }

    rep(i, N) {
        used[i] = false;
    }
    ll gm[N];
    rep(i, N) {
        gm[i] = 0;
    }

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        if (gm[a] < H[b]) {
            gm[a] = H[b];
        }
        if (gm[b] < H[a]) {
            gm[b] = H[a];
        }
    }

    ll ans = 0;

    rep(i, N) {
        if (H[i] > gm[i]) {
            ans++;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 7640
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std; 
 
#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/
 
void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}
 
int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;
 
	if(N==2)   return 1;
	if(N%2==0) return 0;
 
	for(i=3;i<N && N%i!=0;i+=2);
 
	if(i>=N) return 1;
	
	return 0;
}
 
int factorial(int N){  //Nの階乗を求める関数
	int ans=1;
 
	while(N--) ans*=(N+1);
	return ans;
}
 
//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;
 
    x = a[(first + last) / 2];
    i = first; j=last;
 
    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}
 
int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}
 
unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];
 
    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}

int main(){
    int M,N;
    cin>>N>>M;
    int A[N],count=0;
    int bor=0;
    float border;
    int i,j,k;

    rep(i,N){
        cin>>A[i];
        bor+=A[i];
    }
    
    border=bor*(1.000/(float)(4*M));

    for(i=0;i<N;i++){
        if(A[i]>=border) count++;
    }
    if(count>=M) cout<<"Yes"<<endl;
    if(count<M) cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int, X: "List[int]"):
    distance = []
    for i in range(1,N):
        distance.append(X[i]-X[i-1])
    
    answer =0 
    for d in distance:
        answer += min(d*A,B)
    print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19216
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll; 
 
int N;
const int MAX_N = 20;
int V[MAX_N], C[MAX_N];
 
int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> V[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    int ans = 0;
    for (int i = 0; i < N; i++){
        if (V[i] - C[i] > 0) ans += V[i] - C[i];
    }

    cout << ans << endl;


    return 0;    
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int x, t;
  cin >> x >> t;
  int ans = max(x-t,0);

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


Measured memory_bytes: 3560