akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    ll h,w,k;
    cin >> h >> w >> k;
    pint st, goal;
    cin >> st.FI >> st.SE >> goal.FI >> goal.SE;
    st.FI--;
    st.SE--;goal.FI--;
    goal.SE--;
    vector<vector<char>> G(h, vector<char>(w));
    REP(i,h){
        REP(j, w) { cin >> G[i][j]; }
    }

    vector<vector<int>> dist(h, vector<int>(w, INT_MAX));
    queue<pint> que;
    que.push(st);
    dist[st.FI][st.SE] = 0;

    vint dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
    while (que.size()) {
        pint now = que.front();
        que.pop();
        for (int i = 0; i < 4; ++i) {
            pint next{now.FI, now.SE};
            REP(j, k) {
                next.FI += dx[i];
                next.SE += dy[i];
                if (0 <= next.FI && next.FI <= h - 1 && 0 <= next.SE && next.SE <= w - 1){
                    if (G[next.FI][next.SE] == '.'){
                        if (dist[next.FI][next.SE] == INT_MAX){
                            //cout << now.FI << " " << now.SE << endl;
                            //cout << next.FI << " " << next.SE << " "<< dist[now.FI][now.SE] + 1 << endl;
                            dist[next.FI][next.SE] = dist[now.FI][now.SE] + 1;
                            que.push(next);
                        }else if (dist[next.FI][next.SE] <= dist[now.FI][now.SE]){
                            break;
                        }
                    }else{
                        break;
                    }
                }else{
                    break;
                }
            }
        }
    }
    if (dist[goal.FI][goal.SE] == INT_MAX) {
        cout<<-1<<endl;
        return 0;
    }
    cout << dist[goal.FI][goal.SE] << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>>red;
	vector<pair<int, int>>blue;
	for (int i = 0;i < n;i++) {
		int a, b;
		cin >> a >> b;
		pair<int, int>p = make_pair(a, b);
		red.push_back(p);
	}
	sort(red.begin(), red.end());
	for (int i = 0;i < n;i++) {
		int a, b;
		cin >> a >> b;
		pair<int, int>p = make_pair(a, b);
		blue.push_back(p);
	}
	sort(blue.begin(), blue.end());
	int ans = 0;
	for (int i = 0;i < n;i++) {
		int num = -1;
		for (int j = 0;red[j].first < blue[i].first&&j < red.size();++j) {
			if (num == -1 && red[j].second < blue[i].second)num = j;
			else if (num != -1 && red[num].second < red[j].second&&red[j].second < blue[i].second)num = j;
		}
		if (red[num].first < blue[i].first&&red[num].second < blue[i].second) {
			ans++;
			red.erase(red.begin() + num);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using pii=pair<int,int>;
bool isvalidpos(pii p, int h, int w){
    return p.first>=0 && p.first<h && p.second>=0 && p.second<w;
}
int main()
{
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    vector<int> dy={0,0,1,-1};
    vector<int> dx={1,-1,0,0};
    int answer=0;
    for(int i=0; i<h; i++) cin>>s[i];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]=='.'){
                vector<vector<int>> dist(h,vector<int>(w,-1));
                queue<pii> q;
                int maxdist=0;
                q.push({i,j});
                dist[i][j]=0;
                while(!q.empty()){
                    auto now=q.front();
                    q.pop();
                    maxdist=max(maxdist,dist[now.first][now.second]);
                    for(int k=0; k<4; k++){
                        pii nxt=now;
                        nxt.first+=dy[k];
                        nxt.second+=dx[k];
                        if(isvalidpos(nxt,h,w) && s[nxt.first][nxt.second]=='.' && dist[nxt.first][nxt.second]==-1){
                            dist[nxt.first][nxt.second]=dist[now.first][now.second]+1;
                            q.push(nxt);
                        }
                    }
                }
                answer=max(answer,maxdist);
            }
        }
    }
    cout<<answer;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();
		int M;
		if(N >= K){
			M = K * X + (N - K) * Y;
			System.out.println(M);
		}
		else{
			M = N * X;
			System.out.println(M);
		}
		
 
	}
 
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename Ostream,typename Container>
Ostream& operator<<(Ostream& os,const Container& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

int main()
{
	for(int hcost,vcost;cin>>hcost>>vcost && hcost|vcost;){
		string src,dst;
		rep(i,2) rep(j,9){
			int x; cin>>x;
			(i==0?src:dst)+=x+'0';
		}
		
		priority_queue<pair<int,string>,vector<pair<int,string>>,greater<pair<int,string>>> pq;
		pq.emplace(0,src);
		unordered_map<string,int> vis;
		while(pq.size()){
			int cc; string cur; tie(cc,cur)=pq.top(); pq.pop();
			if(!vis.insert(mp(cur,cc)).second) continue;
			if(cur==dst) break;
			int i=cur.find('0');
			rep(k,4){
				int j=(i+array<int,4>{-1,1,-3,3}[k]+9)%9;
				swap(cur[i],cur[j]);
				if(!vis.count(cur))
				pq.emplace(cc+(k<2?hcost:vcost),cur);
				swap(cur[i],cur[j]);
			}
		}
		assert(vis.count(dst));
		cout<<vis[dst]<<endl;
	}
}

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

using namespace std;

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

    int h, w;
    cin >> h >> w;
    vector<string> ss(h);
    for (int i = 0; i < h; i++) cin >> ss[i];

    vector<pair<int, int>> ps;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ss[i][j] == 'B') ps.emplace_back(i, j);
        }
    }

    int nax = 0;
    sort(ps.begin(), ps.end(), [](auto &a, auto &b) {
       return a.first + a.second < b.first + b.second;
    });
    nax = max(nax, abs(ps.front().first - ps.back().first) + abs(ps.front().second - ps.back().second));

    sort(ps.begin(), ps.end(), [](auto &a, auto &b) {
        return a.first - a.second < b.first - b.second;
    });
    nax = max(nax, abs(ps.front().first - ps.back().first) + abs(ps.front().second - ps.back().second));

    cout << nax << endl;
}


Measured memory_bytes: 11956
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <set>
#include <queue>
#include <stdbool.h>

#define LL long long
#define inf 0x3f3f3f3f
using namespace std;
const int MAXN=1e3+5;

int n,d;

int main()
{
    scanf("%d%d",&n,&d);
    if (n%(2*d+1) == 0)
    {
        printf("%d\n",n/(2*d+1));
    }
    else
        printf("%d\n",n/(2*d+1)+1);
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int num = 0;
        int plus = 0;
        int minus = 0;
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='+'){
                plus++;
            }
        }
        minus = s.length()-plus;
        System.out.println(num+plus-minus);
    }
}

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

// input
int N;
vector<int> A, B;

map<int, int> ma, mb;
map<int, tuple<int, int, int>> m;
set<tuple<int, int, int>> s, w;


void input() {
    cin >> N;
    A = B = vector<int>(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
}


int main() {
    input();
    ma[-1] = 0;
    rep(i, N) {
        ma[A[i]]++;
        mb[B[i]]++;
    }
    for (P p : mb) {
        tuple<int, int, int> t{-p.second, 0, p.first};
        if (ma.count(p.first)) {
            get<1>(t) = -ma[p.first];
            s.insert(t);
        } else {
            w.insert(t);
        }
        m[p.first] = t;
    }
    s.insert(tuple(0, 0, -1));
    w.insert(tuple(0, 0, -1));
    vector<int> ans;
    for (int a : A) {
        auto itr = s.begin();
        if (a == get<2>(*itr)) itr++;
        tuple<int, int, int> t = *itr;
        if (get<0>(t) == 0) {
            t = *w.begin();
            if (get<0>(t) == 0) {
                cout << "No" << endl;
                return 0;
            }
            ans.push_back(get<2>(t));
            w.erase(t);
            get<0>(t)++;
            w.insert(t);
        } else {
            ans.push_back(get<2>(t));
            s.erase(t);
            get<0>(t)++;
            s.insert(t);
        }
        m[get<2>(t)] = t;
        if (m.count(a)) {
            ma[a]--;
            tuple<int, int, int> t = m[a];
            s.erase(t);
            get<1>(t)++;
            if (ma[a] == 0) w.insert(t);
            else s.insert(t);
            m[a] = t;
        }
    }
    cout << "Yes" << endl;
    cout << ans[0];
    rep(i, N - 1) cout << " " << ans[i + 1];
    cout << endl;
}


Measured memory_bytes: 49404
S = input()
ans = 10e9

voc = set(S)
for c in voc:
    cnt = 0
    tmp = list(S)

    while True:
        if all([w == c for w in tmp]):
            ans = min(cnt, ans)
            break
        cnt += 1
        for u in range(len(tmp)-1):
            tmp[u] = c if tmp[u] == c or tmp[u+1] == c else tmp[u]    
        tmp.pop()


print(ans)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 0;
    rep(i, 0, n){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
int N,M;
vector<int>A,B,C;

signed main(){
    cin>>N;A.resize(N);
    for(int i=0;i<N;i++)cin>>A[i];
    cin>>M;
    B.resize(M);C.resize(M);
    for(int i=0;i<M;i++)cin>>B[i];
    for(int i=0;i<M;i++)cin>>C[i];

    sort(A.begin(),A.end());
    vector<int>sum(N);
    for(int i=0;i<N;i++){
        sum[i]=A[i]+(i?sum[i-1]:0);
    }


    for(int i=0;i<M;i++){
        int u=upper_bound(A.begin(),A.end(),B[i])-A.begin();
        int val;
        if(u==0)val=0;
        else val=sum[u-1];
        if(C[i]<=val)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 10248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

ll dp[1001][1001];

int main(){
	IOS

	int h,w;
	cin>>h>>w;
	vector<std::vector<char> >v;
	v.resize(h);

	forn(i,h)
		forn(j,w){
			char temp;
			cin>>temp;
			v[i].pb(temp);	
		}

	memset(dp,-1,sizeof(dp));

	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		{
			if(i==0&&j==0)
				dp[i][j]=1;
			else if(i==0)
			{
				dp[i][j] = (v[i][j]=='.')?dp[i][j-1]%mod:0;
			}
			else if(j==0)
			{
				dp[i][j] = (v[i][j]=='.')?dp[i-1][j]%mod:0;
			}
			else{
				dp[i][j] = (v[i][j]=='.')?(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod:0;
			}
		}

	cout<<dp[h-1][w-1]%mod;
 	
	return 0;	
}

Measured memory_bytes: 9088
use proconio::*;

fn construct_suffix_array(s: &str) -> Vec<usize> {
    let n = s.len();
    let str = s.chars().collect::<Vec<_>>();

    let mut sa = vec![0; n];
    let mut rk = vec![0; n];

    for i in 0..n {
        sa[i] = i;
        rk[i] = str[i] as i32
    }

    let mut k = 1;
    while k < n {
        sa.sort_by_key(|&i| (rk[i], rk.get(i + k).unwrap_or(&-1)));

        let mut new_rk = vec![0; n];
        new_rk[sa[0]] = 0;
        for i in 1..n {
            new_rk[sa[i]] = new_rk[sa[i - 1]];
            let cmp_sa = |i, j| {
                if rk[i] != rk[j] {
                    return rk[i] < rk[j];
                }
                let ri = if i + k < n { rk[i + k] } else { -1 };
                let rj = if j + k < n { rk[j + k] } else { -1 };
                ri < rj
            };
            if cmp_sa(sa[i - 1], sa[i]) {
                new_rk[sa[i]] += 1;
            }
        }
        rk = new_rk;
        k *= 2;
    }
    sa
}

fn construct_lcp(s: &str) -> Vec<usize> {
    let n = s.len();
    let sa = construct_suffix_array(s);

    let str = s.chars().collect::<Vec<_>>();

    let mut lcp = vec![0; n];
    let mut rank = vec![0; n];

    for i in 0..n {
        rank[sa[i]] = i;
    }

    let mut k = 0;
    for i in 0..n {
        if rank[i] == n - 1 {
            k = 0;
            continue;
        }

        let j = sa[rank[i] + 1];

        while i + k < n && j + k < n && str[i + k] == str[j + k] {
            k += 1;
        }

        lcp[rank[i]] = k;

        if k > 0 {
            k -= 1;
        }
    }
    lcp
}

fn main() {
    input! {
    s: String,
    }
    let n = s.len();
    let lcp = construct_lcp(&s);

    let ans = n * (n + 1) / 2;
    let ans = ans - lcp.iter().sum::<usize>();

    println!("{:?}", ans);
}

/*
a
aba
ababa
banana
na
nana
*/


Measured memory_bytes: 19664
#include<stdio.h>
#define Max 100000
int partition(int *,int,int);

int main(void){
  int n,i,A[Max],x;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
   x=partition(A,0,n-1);
  
   for(i=0;i<n;i++){
     if(i==x && i==n-1){
      printf("[%d]\n",A[i]);
     }
  else if(i==x){
       printf("[%d] ",A[i]);
     }
  else if(i==n-1){
    printf("%d\n",A[i]);
  }
     else 
     printf("%d ",A[i]);
   }
  return 0;
}

int partition(int A[],int p,int r){
  int x,i,j,tmp1,tmp2;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
    tmp1=A[i];
    A[i]=A[j];
    A[j]=tmp1;
    }
  }
    tmp2=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp2;
  return i+1;
}
    



Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b/a) << endl;
	
}



Measured memory_bytes: 256
n, m, c = map(int, input().split())
a = []
b = list(map(int, input().split()))

for _ in range(n):
    a.append(list(map(int, input().split())))

cnt = 0
for i in range(n):
    ans = c
    for j in range(m):
        ans += a[i][j] * b[j]
    if(ans > 0):
        cnt += 1
print(cnt)

Measured memory_bytes: 3316
#include <stdio.h>


int main(){

  int n,i,j,num[100],cnt=0,tmp;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }

   
  for(i=0;i<n;i++){
 
      for(j=n-1;j >= i+1;j--){     
	if(num[j-1] > num[j]){
	  tmp = num[j-1];
	  num[j-1]=num[j];
	  num[j]=tmp;
	  cnt++;
	}
      }
  
    }

   for(i=0;i<n;i++){
    printf("%d",num[i]);
    if(i !=n-1)printf(" ");
  }
   printf("\n%d\n",cnt);

  return 0;
}




Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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()
{
    int64_t N, M;
    cin >> N >> M;
    int64_t ura_count = N * M;
    if (N == 1 && M == 1) {
        cout << 1 << endl;
    } else if (N == 1 || M == 1) {
        cout << ura_count - 2 << endl;
    } else {
        cout << ura_count - (2 * M) - (2 * N) + 4 << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << "2018" << s.substr(4) << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;

class MyClass
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        Console.WriteLine("{0} {1}", a * b, 2 * a + 2 * b);
    }
}

Measured memory_bytes: 9196
h, w = gets.split.map(&:to_i)
c = Array.new(10){gets.split.map(&:to_i)}
g = Hash.new(0)
h.times do
  gets.split.map(&:to_i).each do |x|
    g[x] += 1 unless x.abs == 1
  end
end
que = []
ans = 0
g.each do |k, v|
  a = c[k].dup
  a[k] = Float::INFINITY
  min = a[1]
  que.push(k, 0)
  while que.size > 0
    r = que.pop
    p = que.pop
    b = c[p].dup
    10.times do |i|
      if min > r + b[i] && i != p
        if i == 1
          min = r + b[i]
        end
        que.push(i, r + b[i])
      end
    end
  end
  ans += min * v
end
puts ans

Measured memory_bytes: 2300
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,m = LI()
    x = LI()
    x.sort()
    lst = []

    for i in range(1,m):
        lst.append(x[i]-x[i-1])
    
    lst.sort(reverse=True)
    ans = sum(lst[n-1:])
    print(ans)
main()            


Measured memory_bytes: 90804
#include <bits/stdc++.h>
#define int long long
#define N 300
using namespace std;
vector<long double> vec;
long double dp[N+1][N+1][N+1];
long double n;
long double solve(int i, int j, int k)
{
if(i==-1||j==-1||k==-1)
	return 0;
if(dp[i][j][k]!=-1)
	return dp[i][j][k];
if(i==0&&j==0&&k==0)
	return dp[i][j][k]=0;
return dp[i][j][k]=(n/(i+j+k))*(1+solve(i-1,j,k)*(i/n)+solve(i+1,j-1,k)*(j/n)+solve(i,j+1,k-1)*(k/n));
}

int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
vec.resize(n);
int a=0,b=0,c=0;
for(int i=0; i<n; i++)
{
	cin>>vec[i];
	if(vec[i]==1)
		a++;
	else if(vec[i]==2)
		b++;
	else if(vec[i]==3)
		c++;
}
for(int i=0; i<=N; i++)
{
	for(int j=0; j<=N; j++)
		for(int k=0; k<=N; k++)
			dp[i][j][k]=-1;
}
cout<<fixed<<setprecision(10)<<solve(a,b,c);
return 0;
}


Measured memory_bytes: 426496
#include<iostream>
using namespace std;
#include<cstdlib>
#include<string>
#include<sstream>

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

int main()
{
    string s[101];
    int top = 0, a, b;
    while(cin >> s[top]){
		if(s[top][0] >= '0'){ top++; continue;
        }else{
            a = atoi(s[top - 2].c_str());
            b = atoi(s[top - 1].c_str());
            if(s[top] == "+") s[top - 2] = IntToString(a + b);
            if(s[top] == "*") s[top - 2] = IntToString(a * b);
            if(s[top] == "-") s[top - 2] = IntToString(a - b);
            top--;
        }
    };
    cout << s[top - 1] << endl;

    return 0;
}

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

typedef long long ll;

const ll maxn = 1e6 + 1e2;
const ll INF = 1e9 + 1e2;
ll val[maxn];
ll cop[maxn];
ll tree[maxn];
ll n;

void update(ll pos){
	pos += n + 1;

	while(pos < maxn){
		tree[pos] += 1;
		pos += pos & -pos;
	}
}

ll query(ll pos){
	pos += n + 1;

	ll res = 0;
	while(pos > 0){
		res += tree[pos];
		pos -= pos & -pos;
	}

	return res;
}

ll countAbove(ll pos){
	memset(tree, 0, sizeof(tree));
	std::copy(val, val + n, cop);

	ll sum = 0;

	for(ll i = 0; i < n; i++){
		if(cop[i] >= pos){
			cop[i] = -1;
		} else {
			cop[i] = 1;
		}

		sum += cop[i];
	}

	ll res = 0;

	for(ll i = 0; i < n; i++){
		update(sum);

		sum -= cop[i];

		res += query(sum);
	}

	return res;
}

int main(){
	std::ios::sync_with_stdio(false);

	std::cin >> n;

	for(ll i = 0; i < n; i++){
		std::cin >> val[i];
	}

	ll total = n * (n + 1) / 2;

	ll l = 1, r = INF;
	ll best = 1;

	while(l <= r){
		ll mid = (l + r) / 2;

		if(countAbove(mid) * 2 >= total){
			best = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
	}

	std::cout << best << '\n';
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;
vector<int> D;
vector<bool> C;
void input(){
    fast_io();
    cin >> N >> K;
    D = fetch_vec<int>(K);
    C.assign(10,true);
    for(auto d:D) C[d] = false;
}

bool chk(int x){
    string s = to_string(x);
    for (int i = 0; i < s.length(); i++)
    {
        if(!C[s[i]-'0']) return false;
    }
    return true;
}

int solve(){
    for (int i = N; i < 10*N; i++)
    {
        if(chk(i)){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

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


int extgcd(int a, int b, int& x, int& y) {
    int g = a;
    x = 1, y = 0;
    if(b != 0) {
        g = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    }
    return g;
}

int main() {
    int a, b, d;
    while(cin >> a >> b >> d, a) {
        int x = 0, y = 0;
        int g = extgcd(a, b, x, y);
        x *= d/g, y *= d/g;
        a /= g, b /= g, d /= g;
        int tx = x, ty = y;
        int minxy = abs(tx) + abs(ty),
            minab = abs(tx) * a + abs(ty) * b;
        int resx = abs(x), resy = abs(y);
        while(tx < 0 || ty > 0) {
            tx += b; ty -= a;
            if(minxy > abs(tx) + abs(ty) ||
               minxy == abs(tx)+abs(ty) && minab > abs(tx)*a + abs(ty)*b) {
                minab = abs(tx) * a + abs(ty) * b;
                minxy = abs(tx) + abs(ty);
                resx = abs(tx); resy = abs(ty);
            }
        }
        tx = x, ty=y;
        while(tx > 0 || ty < 0) {
            tx -= b; ty += a;
            if(minxy > abs(tx) + abs(ty) ||
               minxy == abs(tx)+abs(ty) && minab > abs(tx)*a + abs(ty)*b) {
                minab = abs(tx) * a + abs(ty) * b;
                minxy = abs(tx) + abs(ty);
                resx = abs(tx); resy = abs(ty);
            }
        }
        cout << resx << " " << resy << endl;
    }
}


Measured memory_bytes: 3000
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[1100];
char w[12][3]={"ld","mb","mp","nc","nd","ng","nt","nw",
"ps","qu","cw","ts"};
int v[1100];
int t[40][40];
int main(){
	int a;
	scanf("%d",&a);
	while(~scanf("%s",str)){
		int at=0;
		int sz=0;
		while(str[at]){
			int val=str[at]-'a';
			if(str[at+1]){
				for(int i=0;i<12;i++){
					if(str[at]==w[i][0]&&str[at+1]==w[i][1])val=26+i;
				}
			}
			v[sz++]=val;
			at++;
			if(val>=26)at++;
		}
		for(int i=0;i<sz-1;i++){
			t[v[i]][v[i+1]]++;
		}
	}
	for(int i=0;i<38;i++){
		if(i<26)printf("%c ",'a'+i);
		else printf("%s ",w[i-26]);
		int at=0;
		int val=0;
		for(int j=0;j<38;j++){
			if(val<t[i][j]){
				val=t[i][j];
				at=j;
			}
		}
		if(at<26)printf("%c ",'a'+at);
		else printf("%s ",w[at-26]);
		printf("%d\n",val);
	}
}

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

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

using namespace std;

const int inf = 2e9 + 10;

struct E{
    int to, cost;
};

int n, m;
vector<E> g[100000];
int v[100000];

bool dfs(int i){
    if (v[i] == inf) {
        v[i] = 0;
    }

    for(E e: g[i]) {
        if (v[e.to] == inf) {
            v[e.to] = v[i] + e.cost;
            if (!dfs(e.to)) {
                return false;
            }
        } else {
            if (v[e.to] != v[i] + e.cost) {
                return false;
            }
        }
    }
    return true;
}

int main(){
    cin >> n >> m;
    rep(i, m){
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        --r;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
    fill_n(v, n, inf);
    rep(i, n){
        if (v[i] == inf){
            if(!dfs(i)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 11008
class Card
  def initialize(s)
    @suit = s[0]
    @num = s[1].to_i
  end
  def suit
    return @suit
  end
  def num
    return @num
  end
  def val
    return @suit + @num.to_s
  end
end

def bubbleSort(a,n)
  for i in 0..n-1 do
    for j in (i+1..n-1).to_a.reverse
      if a[j].num < a[j-1].num
        a[j],a[j-1] = a[j-1],a[j]
      end
    end
  end
end

def selectionSort(a,n)
  for i in 0..n-1 do
    minj = i
    for j in i..n-1 do
      if a[j].num < a[minj].num
        minj = j
      end
    end
    if i != minj
      a[i],a[minj] = a[minj],a[i]
    end
  end
end

def isStable(a,b,n)
  for ai in 0..n-2 do
    for bi in 1..n-1 do
      if a[ai]!=b[bi]
        next
      end
      for aj in ai+1..n-1 do
        if a[ai].num!=a[aj].num
          next
        end
        for bj in 0..bi-1 do
          if a[aj]==b[bj]
            return "Not stable"
          end
        end
      end
    end
  end
  return "Stable"
end 

n = gets.chomp.to_i
cards = gets.chomp.split(" ").map{|x| Card.new(x)}
cards_bubble = cards.clone
cards_selection = cards.clone
bubbleSort(cards_bubble,n)
selectionSort(cards_selection,n)
printf("%s\n", cards_bubble.map{|x| x.val}.join(" "))
printf("%s\n", isStable(cards,cards_bubble,n))
printf("%s\n", cards_selection.map{|x| x.val}.join(" "))
printf("%s\n", isStable(cards,cards_selection,n))


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

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int m1=100000;
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(b<=m){
			m1=min(a,m1);
		}
	}
	if(m1==100000){
		printf("TLE\n");
	}else{
		printf("%d\n",m1);
	} 
}

Measured memory_bytes: 256
N, HP = map(int, input().split())

K = []
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  B.append(b)
  A.append(a)
  
MA = max(A)
ans = 0
for b in sorted(B, reverse=True):
  if MA > b:
    break
  HP -= b
  ans += 1
  if HP <= 0:
    print(ans)
    exit()

c = HP // MA
ans += c

if HP - (c*MA) > 0:
  ans += 1

print(ans)

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

using namespace std;

typedef long long llint;

const int MAXN = 405;
const int MOD = 1000000007;

int n, c;
llint a[MAXN], b[MAXN];
llint dp[MAXN][MAXN], pot[MAXN][MAXN], val[MAXN][MAXN];

void precompute () {
    for (int i=1; i<MAXN; i++) {
        pot[i][0] = 1;
        for (int j=1; j<MAXN; j++) {
            pot[i][j] = i * pot[i][j-1] % MOD;
        }
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<=c; j++) {
            llint res = 0;
            for (int k=a[i]; k<=b[i]; k++) {
                res = (res + pot[k][j]) % MOD;
            }
            val[i][j] = res;
        }
    }
}

llint f (int x, int y) {
    if (x == n ) return (y == 0);
    if (dp[x][y] != -1) return dp[x][y];
    llint res = 0;
    for (int i=0; i<=y; i++) {
        res = (f(x + 1, y - i) * val[x][i] + res) % MOD;
        //cout << "bla " << i << " " << res << endl;
    }
    return dp[x][y] = res;
}

int main () {
    memset(dp, -1, sizeof dp);
    cin >> n >> c;
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    for (int i=0; i<n; i++) {
        cin >> b[i];
    }
    precompute();
    cout << f(0, c);
    return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
#define int long long 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef __int128 _int ;
const int maxn=2e5+6;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n,k;
int a[maxn];
map<int,int>num;
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	int x;
	cin>>x;
	for(int i=-200;i<=200;i++)
	  for(int j=-200;j<=200;j++)
	     if(pow(i,5)-pow(j,5)==x){
	     	cout<<i<<" "<<j<<endl;
	     	return 0;
		 }
	return 0;
}

Measured memory_bytes: 3988
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int sum = 0;
        for(int i = 0; i < N;i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            sum += int.Parse(s[1]) - int.Parse(s[0]) + 1;
        }
        Console.WriteLine(sum);
    }
}


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

char change(char in){
	if (in == ',' || in == '.') return in;
	if('A'<=in && in<='Z'){
		return in-('Z'-'z');
	} else if('a'<=in && in<='z'){
		return in+('Z'-'z');
	}
	return in;
}

int main(int argc, char const* argv[])
{
	string a;
	getline(cin, a);
	transform(a.begin(), a.end(), a.begin(), change);
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n;
  cin>>n;
  map<string,int>mp;
  for(int i=0;i<s.size();i++){
    for(int j=1;j<=min((int)s.size()-i,5);j++){
      string tmp=s.substr(i,j);
      //cout<<tmp<<endl;
      mp[tmp]++;
    }
  }
  int cnt=0;
  for(auto v:mp){
    cnt++;
    if(cnt==n){
      cout<<v.first<<endl;
    }
  }
}

Measured memory_bytes: 1920
# coding: utf-8
# 70

n,m,l = map(int,input().split())
c=0
A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for i in range(m)]

#print(A,B)

for i in range(n):
    for j in range(l):
        for z in range(m):
            c += A[i][z]*B[z][j]
            #print("j=",j,"z=",z,"m=",m,"l=",l)
        if j<l-1:
            print(c,end=' ')
        else:
            print(c)
        c=0
#print()



Measured memory_bytes: 6580
#include <stdio.h>

#define MAX 100000

int parent(int i) {
  return i/2;
}
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i+1;
}

int main()
{
  int H,i,A[MAX+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",A[right(i)]);

    printf("\n");
  }


  return 0;
}

Measured memory_bytes: 608
K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
S = [(A[i + 1] - A[i]) for i in range(N - 1)]
S.append((K - A[N - 1]) + A[0])
S.sort
m = sorted(S)
for n in range(N - 1):
    ans += m[n]
print(ans)


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  int x, last = -1;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    cin >> x;
    if(x == last) {
      last = -1;
      ans++;
    } else last = x;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int N,C,K;
    cin >> N >> C >> K;
    vector<int> T(N);
    rep(i,N){
        cin >> T[i];
    }
    sort(T.begin(),T.end());
    bool flag = true;
    int res = 0;
    int count = 0;
    int limit = 0;
    rep(i,N){
        if(flag){
            limit = T[i] + K;
            flag = false;
        }
        if(T[i] <= limit){
            count++;
            if(count == C){
                res++;
                count = 0;
                flag = true;
            }
        }else{
            if(count){
                res++;
                count = 1;
                limit = T[i] + K;
            }
        }
    }

    if(count) res++;
    cout << res << endl;

    return 0;
} 

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M,K;
    Scd3(N,M,K);

    vector<vi> ef(N);
    vector<set<int>> eb(N);

    int u,v;
    Rep(i,M){
        Scd2(u,v);
        u--,v--;
        ef[u].push_back(v);
        ef[v].push_back(u);
    }
    Rep(i,K){
        Scd2(u,v);
        u--,v--;
        eb[u].insert(v);
        eb[v].insert(u);
    }

    vi ans(N,-1);
    vi id(N,-1);
    vi sz(N,-1);
    stack<int> st;
    int cnt;
    Rep(i,N){
        if( id[i] == -1 ){
            cnt = 1;
            st.push(i);
            id[i] = i;
            while( st.size() ){
                int from = st.top();
                st.pop();
                for( int to : ef[from] ){
                    if( id[to] == -1 ){
                        st.push(to);
                        id[to] = i;
                        cnt++;
                    }
                }
            }
        }else{
            cnt = ans[id[i]];
        }
        ans[i] = cnt;
    }

    Rep(i,N){
        for( int t : eb[i] ){
            if( id[i] == id[t] ) ans[i]--;
        }
        printf ("%ld%s", ans[i]-1-ef[i].size() , i==N-1?"\n":" " );
    }

    return 0;
}



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

using namespace std;

int main()
{
    char a[10];
    int b;

    cin >> a;

    if(a[3] == '7')
        {a[3] = '8';
        cout << a << endl;
        }
    else
        cout << a << endl;
        return 0;

}


Measured memory_bytes: 256
def gcdf(x,y):
  if y==0:return x
  if y>x:return gcdf(y,x)
  else:return gcdf(y,x%y)

N=int(input())
A=[int(s)for s in input().split()]
A=sorted(A)
if N==2:
  print(A[1])
  exit()
r=[]
for i in range(1,N):
  r.append(gcdf(A[i],A[0]))
r=sorted(r)
gcd=r[1]
for i in range(2,N-1):
  gcd=gcdf(r[i],gcd)
  
gcd2=A[1]
for i in range(2,N):
  gcd2=gcdf(A[i],gcd2)
print(max((gcd,gcd2)))
    

Measured memory_bytes: 14524
import java.util.*;
import java.io.*;

/*
   AtCoder contest
   coder : yoichidon
 */


public class Main {
    static boolean dthDigitIs1(long num, int d){
        return (num & (1L<<d)) != 0;
    }
    static long solve(long K, long[] A){
        int N = A.length;
        long ans = 0;
        boolean free = false;

        for(int d=60; d>=0; d--){
            if(!dthDigitIs1(K,d) && !free) continue;

            int dig1=0, dig0=0;
            for(int n=0; n<N; n++){
                if(dthDigitIs1(A[n],d)) dig1++;
                else dig0++;
            }

            if(dig1>=dig0){ //ans[d-th digit]=0
                if(dthDigitIs1(K,d)) free=true;
            }else{
                ans += 1L<<d;
            }
        }
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        for(int n=0; n<N; n++) A[n]=sc.nextLong();

        long X = solve(K,A);

        long ans = 0;
        for(int n=0; n<N; n++) ans += (A[n] ^ X);

        System.out.println(ans);

    }
}


Measured memory_bytes: 58680
def createData
  data = Array.new
  while input = $stdin.gets
    break if input == "\n"
    v = input.chomp.split(",")
    data << v[0]
  end
  return data
end

dataCurrentMonth = createData
dataPreviousMonth = createData

result = Hash.new
dataCurrentMonth.each{|id|
  next if dataPreviousMonth.index(id) == nil
  c = 0
  dataCurrentMonth.each{|n| c += 1 if id == n}
  dataPreviousMonth.each{|n| c+= 1 if id == n}
  result.store(id.to_i, c)
}

result.sort.each{|k, v|
  printf("%d %d\n", k, v)
}

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    ll subB = max(k - a, 0LL);

    a -= min(a, k);
    b -= min(b, subB);

    printf("%lld %lld\n", a, b);

    return 0;
}

Measured memory_bytes: 256
require 'pp'

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.chars
end

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

N = gets_i
S = gets_nsp_list

max = 0
(1...N).each do |n|
  left  = S[0,n]
  right = S[n,N]
  max = [max, (left.uniq & right.uniq).size].max
end
puts max


Measured memory_bytes: 4092
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	bool ret = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == 'L')ret = false;
		if (i % 2 == 1 && s[i] == 'R')ret = false;
	}
	cout << (ret ? "Yes" : "No") << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
LL dp[N];
int v[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	LL a, b;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
		if (i == 1) continue;
		dp[i] = dp[i - 1] + min(b, a * (v[i] - v[i - 1]));
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1408
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;
 
fn main() {
    input! {
        n:usize,
        a:[i64;n]
    }
    let mut map = HashMap::new();
    //map.reserve(200000);
    let mut t = 0;
    // sum[0]==0のため、0の個数を追加。
    map.insert(0, 1);
    for i in 0..n {
        t += a[i];
        *map.entry(t).or_insert(0) += 1;
    }
    let mut ans = 0;
    for (_, &v) in map.iter() {
      	let v = v as i64;
        ans += v * (v-1)/2;
    }
    println!("{}", ans);
}

Measured memory_bytes: 12204
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a == c-b) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;

class Program {
  static void Main(string[] args) {
    string s = Console.ReadLine();
    int N = int.Parse(s);

    int ret = 0;
    for (int i=0; i<N; i++) {
      string[] tmp = Console.ReadLine().Split(' ');
      int x = int.Parse(tmp[0]);
      int y = int.Parse(tmp[1]);
      ret += y - x + 1;
    }

    Console.WriteLine(ret);
  }
}

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

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<pair<int, int>> CB(M);
    rep(i, M) cin >> CB[i].second >> CB[i].first;
    sort(A.begin(), A.end());
    sort(CB.begin(), CB.end());
    int i = N - 1, j = M - 1;
    ll ans = 0, count = N;
    while (count > 0) {
        count --;
        if (j < 0 || A[i] >= CB[j].first) {
            ans += A[i];
            i--;
        } else {
            ans += CB[j].first;
            CB[j].second--;
            if (CB[j].second == 0) {
                j--;
            }
        }
    }
    cout << ans << "\n";
}

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

int main() {
    int N;
    cin >> N;
    int order = 0;
    int M = N;
    while (M > 0){
        M /= 10;
        order += 1;
    }
    int ans = 0;
    for (int i = 0; i < order; i++){

        int x = 1;
        for (int j = 0; j<i+1; j++){
            x *= 10;    
        }
        if (i%2 == 0){
            if(i == order-1){
                ans += N + 1 - x/10;
            }
            else{
                ans += x - x/10;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256