akhauriyash/Code-Regression huggingface dataset:
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 4005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int n;
    cin>>n;
    map<int,int>mp;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    int total=0;
    for(auto i:mp){
        if(i.second>1){
            total+=((i.second)*(i.second-1))/2;
        }
    }
    for(int i=0;i<n;i++){
        cout<<max(total-(mp[a[i]]-1),0ll)<<"\n";
    }

    return;
}
// how r u bro

Measured memory_bytes: 13044
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void Solve()
{
	ll X, Y;
	cin >> X >> Y;

	string ans = "No";
	REP(i, X + 1) {
		ll ashi = i * 4 + (X  - i) * 2;
		if (ashi == Y) {
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> p;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;

int lcm(int m, int n)
{
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / gcd(m, n)) * n);  // lcm = m * n / gcd(m,n)
}  //lcm

signed main()
{
    int n;
    std::cin >> n;
    int out = 1;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        out = lcm(out, temp);
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>   //A - Buttons

int main(){

    int a,b;
    scanf("%d %d",&a,&b);
    int coins=0;
    for(int i=0;i<2;i++){
        if(a>b){
            coins+=a;
            a--;
        }else{
            coins+=b;
            b--;
        }
    }
    printf("%d\n",coins);
    
    return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  set<int> st;
  int n; cin >> n;
  vector<int > a(n);
  rep(i,n) cin >> a[i];
  rep(i,n){
    st.insert(a[i]);
  }
  if(st.size()==n){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	string N;
	cin >> N;
	if (N[1] == N[2]) {
		if (N[0] == N[1] || N[3] == N[2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
if (b-a)%2 == 0:
    ans = (b-a)//2
else:
    ans = 0
    if a-1 <= n-b:
        ans += a
        a, b = 1, b-a
        ans += (b-a)//2
    else:
        ans += n-b+1
        a, b = a+n-b+1, n
        ans += (b-a)//2
print(ans)


Measured memory_bytes: 38384
import sys
import itertools

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    L = list(map(lambda x: int(x), sys.stdin.readline().rstrip().split()))

    num = 0
    for items in itertools.combinations(L, 3):
        a, b, c = items
        if a == b or b == c or c == a:
            continue
        if a+b > c and b+c > a and c+a > b:
            num += 1
    print(num)

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

signed main()
{
   int N; cin>>N;
   int sum=0,minOdd=1000;
   for(int i=0;i<N;i++){
      int a; cin>>a;
      sum+=a;
      if(a%2==1){
         minOdd=min(minOdd,a);
      }
   }
   if(sum%2==0){
      cout<<sum/2<<endl;
   }else{
      cout<<(sum-minOdd)/2<<endl;
   }
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    string s;
    cin >> N >> s;
    map<char,int> mp;

    REP(i,N) mp[s[i]]++;
    if (mp['R'] > mp['B']) yes;
    else no;

    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/exawizards2019/exawizards2019_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/exawizards2019/exawizards2019_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/exawizards2019/exawizards2019_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 256
n,m,k=map(int,input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
ans=0
a, b=[0], [0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
j=m
for i in range(n+1):
    if k<a[i]:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 134184
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		int[] a = new int[m];
		int[] b = new int[m];
		ArrayList<ArrayList<Integer>> list = new ArrayList<>(); 
		for (i = 0; i <= n; i++) {
			list.add(new ArrayList<>());
		}
		for (i = 0; i < m; i++) {
			a[i] = parseInt(sc.next());
			b[i] = parseInt(sc.next());
			list.get(a[i]).add(b[i]);
			list.get(b[i]).add(a[i]);
		}
		sc.close();
		int[] ans = new int[n+1];
		ans[1] = -1;
		HashSet<Integer> set = new HashSet<>();
//		HashSet<Integer> setsumi = new HashSet<>();
		set.add(1);
//		setsumi.add(1);
		while(!set.isEmpty()) {
			HashSet<Integer> settmp = new HashSet<>();
			for (Integer ii : set) {
				ArrayList<Integer> ll = list.get(ii);
//				out.println(ll.toString());
				for (Integer jj : ll) {
					if(ans[jj]==0) {
						ans[jj] = ii;
						settmp.add(jj);
					}
//					out.println(Arrays.toString(ans));
				}
			}
//			setsumi.addAll(settmp);
			set=settmp;
		}
//		out.println(Arrays.toString(ans));
		int cnt=0;
		for(i = 1; i <= n; i++) {
			if(ans[i]!=0)cnt++;
		}
		if(cnt!=n) {
			out.println("No");
		} else {
			out.println("Yes");
			PrintWriter pw = new PrintWriter(System.out);
			for(i = 2; i <= n; i++) {
				pw.println(ans[i]);
			}
			pw.flush();
		}
	}
}


Measured memory_bytes: 69068
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	string s;
	cin >> s;
	if (s == "A") cout << "T";
	if (s == "G")cout << "C";
	if (s == "T")cout << "A";
	if (s == "C")cout << "G";
	return 0;
}










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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0||c>0){
      c-=b;
    if(c<=0) {cout<<"Yes"<<endl; break;}
      a-=d;
    if(a<=0){cout<<"No"<<endl; break;}
  }
}


Measured memory_bytes: 3640
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias Pair = Tuple!(long, "cost", long, "num");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w;
    scan(h, w);
    auto change = new long[][](10, 10);
    foreach (ref e; change)
        e = aryread();
    auto wall = new long[][](h, w);
    foreach (ref e; wall)
        e = aryread();
    auto magic_power = new long[](10);
    magic_power[] = INF, magic_power[1] = 0;
    auto rb = new RedBlackTree!long(0, 2, 3, 4, 5, 6, 7, 8, 9);
    while (!rb.empty)
    {
        auto p = new Pair[](0);
        foreach (e; rb)
        {
            long cost = INF;
            foreach (i; iota(10))
            {
                cost = min(change[e][i] + magic_power[i], cost);
            }
            p ~= Pair(cost, e);
        }
        p.sort!"a.cost<b.cost"();
        magic_power[p[0].num] = p[0].cost;
        rb.removeKey(p[0].num);
    }
    long ans;
    foreach (i; iota(h))
        foreach (j; iota(w))
            ans += magic_power[abs(wall[i][j])];
    ans.writeln();
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 4220
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll n, s = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }

    if (s % (n * (n + 1) / 2)) {
        cout << "NO" << endl;
        return 0;
    }
    ll op = s / (n * (n + 1) / 2), cnt = 0;
    vector<int> b(n, 0);
    for (int i = 0; i < n; i++) {
        ll d = a[(i + 1) % n] - a[i];
        //cerr << op _ d << endl;
        if ((op - d) % n || (op - d) / n < 0) {
            cout << "NO" << endl;
            return 0;
        }
        cnt += (op - d) / n;
        b[i] = (op - d) / n;
    }
    //cerr << cnt _ op << endl;
    cout << (cnt == op ? "YES" : "NO") << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int n, d, x;
  cin >> n >> d >> x;

  int count = 0;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;

    int mult = 0;
    while (1+mult*k <= d) {
      count++;
      mult++;
    }
  }

  cout << count+x << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
double const sqrt3=1.7320508075688772;
void koch(int n,double x1=0,double y1=0,double x2=100,double y2=0){
    if(x1==0&&y1==0&&x2==100&&y2==0)printf("%.8lf %.8lf\n",x1,y1);
    if(n>0){
        double dx=(x2-x1)/3, dy=(y2-y1)/3,
               sx=x1+dx, sy=y1+dy, tx=x2-dx, ty=y2-dy,
               ux=sx+(dx-sqrt3*dy)/2, uy=sy+(sqrt3*dx+dy)/2;
        koch(n-1,x1,y1,sx,sy);
        koch(n-1,sx,sy,ux,uy);
        koch(n-1,ux,uy,tx,ty);
        koch(n-1,tx,ty,x2,y2);
    }else printf("%.8lf %.8lf\n",x2,y2);
}
int main(){
    int n;
    scanf("%d",&n);
    koch(n);
    return 0;
}


Measured memory_bytes: 2608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int r = Integer.parseInt(strArr[0]);
		int g = Integer.parseInt(strArr[1]);
		int b = Integer.parseInt(strArr[2]);
		int n = r * 100 + g * 10 + b;
		// System.out.println(n);
		if (n % 4 == 0)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>

using namespace std;
int caves[1003][1003]={};
int dp[1003][1003]={};
bool flag[1003][1003]={};
int dp2[1003][1003]={};

void solve(int m,int n,set<int> prime){
	for(int i=0;i<1003;i++){
		for(int j=0;j<1003;j++){
			caves[i][j]=0;
			dp[i][j]=0;
			flag[i][j]=0;
			dp2[i][j]=0;
		}
	}
	caves[500][500]=1;
	int now_tate = 500;
	int now_yoko = 500;
	int x = 1;
	bool breakflag=0;
	int ans_tate,ans_yoko;
	if(n==1){
		ans_tate=500;
		ans_yoko=500;
	}
	for(int i=1;i<10000;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<i;k++){
				x+=1;
				if(x>m){
					breakflag=1;
					break;
				}
				if(i%2==1){
					if(j==0){
						now_yoko +=1;
						caves[now_tate][now_yoko]=x;
					}else{
						now_tate -=1;
						caves[now_tate][now_yoko]=x;
					}
				}else{
					if(j==0){
						now_yoko -=1;
						caves[now_tate][now_yoko]=x;
					}else{
						now_tate +=1;
						caves[now_tate][now_yoko]=x;
					}
				}
				if(x==n){
					ans_tate = now_tate;
					ans_yoko = now_yoko;
				}
			}
		}
		if(breakflag==1)break;
	}
	for(int i=0;i<1003;i++){
		for(int j=0;j<1003;j++){
			if(prime.count(caves[i][j])){
				flag[i][j]=1;
			}
		}
	}
	for(int i=1001;i>=0;i--){
		for(int j=0;j<1002;j++){
			if(i==1001){
				if(flag[i][j]==1){
					dp[i][j]=1;
					dp2[i][j]=caves[i][j];
				}
			}else{
				dp[i][j]=dp[i+1][j];
				if(dp[i][j]!=0){
					dp2[i][j] = dp2[i+1][j];
				}
				dp[i][j]=max(dp[i][j],dp[i+1][j+1]);
				if(dp[i+1][j]<dp[i+1][j+1]){
					dp2[i][j] = dp2[i+1][j+1];
				}
				if(dp[i+1][j]==dp[i+1][j+1]&&dp[i+1][j]!=0){
					dp2[i][j]=max(dp2[i+1][j],dp2[i+1][j+1]);
				}
				if(j>0){
					if(dp[i][j]<dp[i+1][j-1]){
						dp2[i][j] = dp2[i+1][j-1];
					}
					if(dp[i+1][j-1]==dp[i][j]&&dp[i+1][j-1]!=0){
						dp2[i][j]=max(dp2[i][j],dp2[i+1][j-1]);
					}
					dp[i][j]=max(dp[i][j],dp[i+1][j-1]);
				}
				if(flag[i][j]==1){
					if(dp2[i][j]==0){
						dp2[i][j]=caves[i][j];
					}
					dp[i][j]+=1;
				}
			}
		}
	}
	cout << dp[ans_tate][ans_yoko] << " " << dp2[ans_tate][ans_yoko] << endl;
	return ;
}



int main(){
	vector<int> vec;
	set<int> prime;
	vec.push_back(2);
	prime.insert(2);
	bool flag1=0;
	for(int i=3;i<1000000;i++){
		flag1 = 0;
		for(int j=0;j<vec.size();j++){
			if(i%vec[j]==0){
				flag1=1;
				break;
			}
			if(vec[j]>sqrt((double)i)){
				break;
			}
		}
		if(flag1==0){
			vec.push_back(i);
			prime.insert(i);
		}
	}
	int m,n;
	while(1){
		cin >> m >> n;
		if(m==0&&n==0)break;
		solve(m,n,prime);
	}	
	return 0;
}

Measured memory_bytes: 23244
#include <bits/stdc++.h>
#define MOD (ll)(998244353)
#define MAX (ll)(1e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;

int main () {
	int a, b, c;
	cin >> a >> b >> c;
	int m = max (a, b);
	cout << (c / m + (c % m > 0)) << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(void) {
	long long L;
	cin >> L;
	long long l = L;
	long long N = 0;
	long long M = 0;
	while (l > 0) {
		if (l % 2 == 1) M++;
		l >>= 1;
		N++;
	}
	M += (N - 1) * 2;
	cout << N << " " << M - 1 << endl;

	long long b = 1;
	for (int n = 1; n < N; n++) {
		cout << n << " " << n + 1 << " " << 0 << endl;
		cout << n << " " << n + 1 << " " << b << endl;
		b <<= 1;
	}

	long long m = 1 << (N - 1);
	long long n = N - 1;
	do {
		n--;
		if (L & (1 << n)) {
			cout << n + 1 << " " << N << " " << m << endl;
			m += (1 << n);
		}
	} while (n > 0);
	
	system("pause");
	return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  vector<int> P(N+1);
  P.at(0) = 0;
  for (int i = 1; i < N+1; i++) {
    P.at(i) = P.at(i-1) + L.at(i-1);
  }
  int count = 0;
  for (int i = 0; i < N+1; i++) {
    if (P.at(i) <= X) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long   N,a,b;
    long long power=1;


    cin>>N;

    for(int i=1;i<=N;i++){
        power=power*i;
        power=power%1000000007;
    }



        cout<<power<<endl;

}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val s = sc.next().toString()

    println(abc126a(n, k, s))
}

fun abc126a(n: Int, k: Int, s: String): String {
    var ans = ""
    for (i in 0..n - 1) {
        if (i == k - 1) {
            ans += s[i].toLowerCase()
        } else {
            ans += s[i].toString()
        }
    }

    return ans
}


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

int main(){
  int arr[10000],input[500],i,j,n,q,count=0;
  scanf("%d",&n);
  if(n>10000) exit(2);
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  scanf("%d",&q);
  if(q>500) exit(2);
  for(i=0;i<q;i++){
    scanf("%d",&input[i]);
    for(j=0;j<n;j++){
      if(arr[j] == input[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N; cin >> N;
  vector<int> B(N-1);
  for (int i = 0; i < N-1; i++) cin >> B[i];
  int ans = 0;
  ans += B[0];
  ans += B[N-2];
  for (int i = 1; i < N-1; i++) {
    ans += min(B[i-1], B[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
"""
Code of Ayush Tiwari
Codeforces: servermonk
Codechef: ayush572000

"""
import sys
input = sys.stdin.buffer.readline

def solution():
    n=int(input())
    l=list(map(int,input().split()))
    dp=[0]*n
    dp[1]=abs(l[1]-l[0])
    for i in range(2,n):
        a=dp[i-1]+abs(l[i]-l[i-1])
        b=dp[i-2]+abs(l[i]-l[i-2])
        dp[i]=min(a,b)
    print(dp[n-1])

solution()

Measured memory_bytes: 84120
S = raw_input()

ans = True

if "N" in S:
    ans = ("S" in S) and ans
    
if "S" in S:
    ans = ("N" in S) and ans
    
if "E" in S:
    ans = ("W" in S) and ans
    
if "W" in S:
    ans = ("E" in S) and ans
    
print "Yes" if ans else "No"

Measured memory_bytes: 2572
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool isInField(int x, int y, int h, int w) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

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

    char c;
    cin >> c;
    char ans = c + 1;
    cout << ans << endl;
    return 0;
}



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

int main(){
  int n, m; cin >> n >> m;
  int d[n][n], edge[n][n];
  rep(i, n)rep(j, n) d[i][j] = 100010, edge[i][j] = -1;
  rep(i, m){
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    d[a][b] = d[b][a] = edge[a][b] = edge[b][a] = c;
  }
  rep(i, n) d[i][i] = 0;
  rep(k, n)rep(i, n)rep(j, n) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
  int cnt = 0;
  rep(i, n)rep(j, n)if(edge[i][j] > 0){
    bool used = false;
    rep(k, n)rep(l, n)if(d[k][l] == d[k][i]+edge[i][j]+d[j][l]){
      used = true;
      break;
    }
    if(!used) cnt++;
  }
  cout << cnt / 2 << endl;
}

Measured memory_bytes: 384
class Dictonary:

    def __init__(self):
        self.d = set()

    def insert(self, s: str):
        if s not in self.d:
            self.d.add(s)

    def find(self, s: str):
        if s in self.d:
            print('yes')
        else:
            print('no')

d = Dictonary()
n = int(input())

for _ in range(n):
    cmd, s = input().split()
    if cmd == 'insert':
        d.insert(s)
    elif cmd == 'find':
        d.find(s)



Measured memory_bytes: 30988
<?php
list($n, $m) = ints();
list($s) = strs();
$s = strrev($s); // 辞書順昇順にするため、ゴール→スタートへ出来るだけ多く移動していく
// そのマスから移動可能な最も右のマスを求める
$rightestNext = array_fill(0, $n + 1, -1);
$rightestZero = -1;
for ($i = 0; $i <= $n; ++$i) {
    if ($s[$i] === '0') $rightestZero = $i;

    if (max(0, $i - $m) < $rightestZero) $rightestNext[max(0, $i - $m)] = $rightestZero;
    if ($i >= $n - $m) $rightestNext[$i] = $n;
}
// 辿る
$cur = 0;
while ($cur < $n) {
    if ($rightestNext[$cur] === -1) exit('-1');
    $ans[] = $rightestNext[$cur] - $cur;
    $cur = $rightestNext[$cur];
}
// 順番をスタート→ゴールに戻す
krsort($ans);
echo implode(' ', $ans);
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;

    //code

    int a , b;
    cin >> a >> b;
    cout << ( a >=0 and a < 6 ? 0 : ( a >= 6 and a <= 12) ? ( b/2 ) : b) ;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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


int main(){

	ll N, K;
	cin >> N >> K;

	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	vector<ll> nx(N);
	vector<ll> use(300000, -1);

	rep(i, 2 * N) {
		ll x = A[i%N];

		if (use[x] == -1) { use[x] = i; }
		else if (use[x] < N) { nx[use[x]] = i - use[x]; use[x] = i; }
	}

	//rep(i, N) cout << nx[i] << endl;

	vector<ll> emp;
	ll v = nx[0];
	emp.push_back(-1);
	emp.push_back(nx[0]);
	
	while ((v+1)%N != 0) {
		v = v + 1 + nx[(v + 1) % N];
		emp.push_back(v);
	}

	//rep(i, emp.size()) { cout << emp[i] << endl; }

	ll t = (K * N-1)%(v+1);

	auto itr = upper_bound(emp.begin(), emp.end(), t);
	ll e = *(--itr);

	//cout << t << e << endl;

	vector<bool> ct(300000, 0);
	stack<ll> st;

	for (ll i = e + 1; i <= t; i++) {
		ll x = A[i%N];

		if (ct[x] == 0) { st.push(x); ct[x] = 1; }

		else {
			while (st.top() != x) {
				ct[st.top()] = 0;
				st.pop();
			}
			ct[x] = 0;
			st.pop();
		}
	}

	vector<ll> rvans;
	while (!st.empty()) {
		rvans.push_back(st.top());
		st.pop();
	}

	reverse(rvans.begin(), rvans.end());

	rep(i, rvans.size()) {
		cout << rvans[i] << " ";
	}




	system("PAUSE");
}


Measured memory_bytes: 11888
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 110;
int a[MAX];
int sum;
void BubbleSort(int a[], int n)
{
	int flag = 1;	// 存在顺序相反的相邻元素 
	for(int i = 0; flag; ++ i)
	{
		flag = 0;
		for(int j = n - 1; j > i; -- j)
		{
			if(a[j] < a[j - 1])
			{
				swap(a[j], a[j - 1]);
				flag = 1;
				sum ++;
			}
		}
	}
} 

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i];
	}
	
	BubbleSort(a, n);
	
	for(int i = 0; i < n; ++ i)
	{
		if(i == n - 1)
			cout << a[i];
		else
			cout << a[i] << " ";
	}
	cout << endl;
	cout << sum << endl;
	
	return 0;
}


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

int divide(int n, int k){
  int ans=0;
  if(n%k==0) ans=n/k;
  else ans=(n/k)+1;
  
  return ans;
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N+1);
  int min=1;
  for(int i=1; i<=N; i++){
    cin >> A[i];
    if(A[i]==1) min=i;
  }
  
  int ans=0;
  ans += divide(N-1, K-1);
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    int Q;
    cin >> S >> Q;
    vector<int>A(Q+1);
    vector<vector<char>>B(Q);
    for(int i = 1; i <= Q; i++) {
        char x;
        cin >> x;
        if(x == '1') {
            B[i-1].push_back(x);
            A[i]++;
        }
        else {
            char a,b;
            cin >> a >> b;
            B[i-1].push_back(x);
            B[i-1].push_back(a);
            B[i-1].push_back(b);
        }
        A[i] = A[i-1]+A[i];
    }
    vector<char>mae;
    string usiro = "";
    for(int i = 0; i < Q; i++) {
        if(B[i].size() == 1) {
            continue;
        }
        if(B[i][1] == '1') {
            if((1+(A[Q]-A[i]))%2 == 1) {
                mae.push_back(B[i][2]);
            }
            else {
                usiro+=B[i][2];
            }
        }
        else {
            if((1+(A[Q]-A[i]))%2 == 0) {
                mae.push_back(B[i][2]);
            }
            else {
                usiro+=B[i][2];
            }
        }
    }
    reverse(mae.begin(),mae.end());
    for(int i = 0; i < mae.size(); i++) {
        cout << mae[i];
    }
    if(A[Q]%2 == 0) {
        cout << S;
    }
    else {
        for(int i = S.size()-1; i >= 0; i--) {
            cout << S[i];
        }
    }
    cout << usiro << endl;
}

Measured memory_bytes: 12732
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main(void){
    int a, ans;
    cin >> a;

    while(a > 1000){
        a -= 1000;
    }
    ans = 1000 - a;
    cout << ans << endl;
    
    return 0;
}

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


int main() {
  int64_t r,D,x;
  cin >>r>>D>>x;

  vector<int64_t> v(10);
  v[0] = (r*x)-D;
  for (int i = 1; i <= 10; i++)
  {
   v[i] = v[i-1]*r -D;
   cout << v[i-1] << endl;
  }
  

}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    map<string, ll> cnt;
    for(int i=0; i<n; i++){
        string s; cin>>s;
        sort(s.begin(), s.end());
        cnt[s]++;
    }

    ll ans = 0;
    for(auto i : cnt){
        ans += ((ll)i.second * ((ll)i.second - 1)) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 11264
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, a[100010];
int main(void) {
    int i, ncnt, cnt=0;
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", a+i);
    sort(a, a+n);
    ncnt = 1;
    for(i=1; i<n; i++) {
        if(a[i]==a[i-1]) ncnt++;
        else {
            cnt += (ncnt>=a[i-1] ? ncnt-a[i-1] : ncnt);
            ncnt = 1;
        }
    }
    if(ncnt==1) {
        if(a[i-1]>ncnt) cnt++;
    }
    else {
        cnt += (ncnt>=a[i-1] ? ncnt-a[i-1] : ncnt);
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 512
import java.util.*;

import javax.lang.model.util.ElementScanner6;

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

        String s = sc.next();
        char[] c1 = s.toCharArray();
        String t = sc.next();
        char[] c2 = t.toCharArray();
        sc.close();

        Arrays.sort(c1);
        Arrays.sort(c2);

        for(int i = 0; i < Math.min(c1.length, c2.length); i++){
            if(c1[i] < c2[c2.length-i-1]){
                System.out.println("Yes");
                return;
            } else if(c1[i] > c2[c2.length-i-1]){
                System.out.println("No");
                return;
            } else
                continue;
        }
        if(c1.length < c2.length)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";
bool sorted(vector<ll> &A,vector<ll>&B){
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  REP(A.size()){
    if(A[i]>B[i]){
      cout<<NO<<endl;
      exit(0);
    }
  }
  cout<<YES<<endl;
  exit(0);
}
void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  set<ll> s(A.begin(),A.end());
  set<ll> t(B.begin(),B.end());
  if(s.size()<N||t.size()<N){
    sorted(A,B);
  }
  vector<ll> sortedA(s.begin(),s.end());
  map<ll,ll> AA;
  REP(N)AA[sortedA[i]]=i;
  vector<pll> BA(N);
  REP(N)BA[i]=pll(B[i],A[i]);
  sort(BA.begin(),BA.end());
  dump(vector<pll>(BA.begin(),BA.end()));
  dump(vector<pll>(AA.begin(),AA.end()));
  ll i=AA[BA[0].second];
  ll cnt=1;
  while(i!=0){
    dump(i);
    i=AA[BA[i].second];
    ++cnt;
  }
  dump(cnt);
  if(cnt<N){
    sorted(A,B);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  bool f=false;
  REP(N-1){
    if(A[i]>B[i]){
      cout<<NO<<endl;
      return;
    }
    if(A[i+1]<=B[i]){
      f=true;
    }
  }
  if(f){
    cout<<YES<<endl;
  }else{
    cout<<NO<<endl;
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 19712
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  string s;
  string j[4] = {"AC", "WA", "TLE", "RE"};
  map<string, int> C;
  for (int i = 0; i < 4; i++) C[j[i]] = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s;
    C[s]++;
  }
  for (int i = 0; i < 4; i++)
    cout << j[i] << " x " << C[j[i]] << endl;
  return 0;
}


Measured memory_bytes: 3188
def solve(n):
    ans = [2, 3, 25]
    if n % 2 == 0:
        ans.append(30)
    dic1 = [4, 26, 6, 24, 8, 22, 9, 21, 10, 20, 12, 18, 14, 16]
    dic2 = [2, 28, 3, 27, 4, 26, 5, 25, 6, 24, 8, 22, 9, 21, 10, 20, 12, 18, 14, 16]

    remain = n - len(ans)
    if remain < len(dic1):
        ans.extend(dic1[:remain])
        return ans

    ans.extend(dic1)
    remain -= len(dic1)

    r, s = divmod(remain, len(dic2))
    for d in range(30, (r + 1) * 30, 30):
        ans.extend(d + c for c in dic2)
    # ans.extend((r + 1) * 30 + c for c in dic2[:s])
    ans.extend(range(60, s * 30 + 60, 30))
    return ans


n = int(input())
print(*solve(n))


Measured memory_bytes: 4432
#include <stdio.h>

int main(void) {
  int i;
  char c[2][10];
  for(i = 0; i < 2; ++i) scanf("%s", c[i]);
  for(i = 0; i < 3; ++i) if(c[0][i] != c[1][2 - i]){
    printf("NO");
    return 0;
  }
  printf("YES");
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  LL ar[100000];
  for (int i = 0; i < n; i ++) {
    cin >> ar[i];
  }
  map<int, int> mp;
  for (int i = 0; i < n; i ++) {
    mp[ar[i]] ++;
  }

  int ans = 0;
  for (auto p: mp) {
    int x = p.first;
    int n = p.second;
    if  (x <= n) ans += n - x;
    else ans += n;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next(); String t = sc.next();
		String[] S = s.split(""); String[] T = t.split("");
		int n = s.length(); int m = t.length();
		int[][] dp = new int[n+1][m+1];
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++) {
				if(S[i].equals(T[j])) {
					dp[i+1][j+1] = dp[i][j]+1;
				}else {
					dp[i+1][j+1] = Math.max(dp[i+1][j],dp[i][j+1]);
				}
			}
		}
		int i = n-1; int j = m-1;
		while(i >= 0 && j >= 0) {
			if(S[i].equals(T[j])) {
				sb.append(S[i]);
				i--; j--;
			}else {
				if(dp[i+1][j] >= dp[i][j+1]){
					j--;
				}else {
					i--;
				}
			}
		}
		sb.reverse();
		System.out.println(sb.toString());
		//System.out.println(dp[n][m]);
	}
}

Measured memory_bytes: 84436
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = []
for i in range(q):
    bc.append(list(map(int, input().split())))

a_sum = sum(a)

dic = {}
for i in range(n):
    if str(a[i]) not in dic:
        dic[str(a[i])] = 1
    else:
        dic[str(a[i])] += 1

for i in range(q):
    ans = 0
    if str(bc[i][0]) in dic.keys():
        buf = dic[str(bc[i][0])]
        if str(bc[i][1]) in dic.keys():
            dic[str(bc[i][1])] += buf
        else:
            dic[str(bc[i][1])] = buf

        a_sum += buf*(-bc[i][0] + bc[i][1])
        dic[str(bc[i][0])] = 0


    print(a_sum)

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << endl;
}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
"""
A - B +/- A
https://atcoder.jp/contests/abc118/tasks/abc118_a

"""
import sys


def main(args):
    A, B = map(int, input().split())
    ans = A + B if B % A == 0 else B - A
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include<stdio.h>
#define N 102
#define INFTY 1e9

int n,M[N][N];
int d[N];

int q[N];
int head=0,tail=0;

void push(int x){
  q[tail]=x;
  tail++;
}

int pop(){
  int x=q[head];
  head++;
  return x;
}


void bfs(int s){
  int u,k,v,i,j;
  push(s);
  for(i=1;i<=n;i++) d[i]=INFTY;
  d[s]=0;
  while(head!=tail){
    u=pop();
    for(v=1;v<=n;v++){
      if(M[u][v]==0) continue;
      if(d[v]!=INFTY) continue;
      d[v]=d[u]+1;
      push(v);
    }
  }
  for(i=1;i<=n;i++) printf("%d %d\n",i,((d[i]==INFTY)? (-1):d[i]));
}

int main(){
  int u,k,v,i,j;

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

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      M[u][v]=1;
    }
  }

  bfs(1);

  return 0;
}



Measured memory_bytes: 2108
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int A, B;
        A = Integer.parseInt (arr[0]);
        B = Integer.parseInt (arr[1]);
        System.out.println ((A + B) % 2 == 0 ? (A + B) / 2 : "IMPOSSIBLE");
        return;
    }
}

Measured memory_bytes: 32704