akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	cin >> str;
	for(int i = 0; i < str.size(); i += 2)
	{
		if(str[i] == '0')
		{
			if(str[i + 1] == 'T')
			{
				cout << "wa";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "nn";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "wo";
			}
		}
		else if(str[i] == '1')
		{
			if(str[i + 1] == 'T')
			{
				cout << "a";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "i";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "u";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "e";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "o";
			}
		}
		else if(str[i] == '2')
		{
			if(str[i + 1] == 'T')
			{
				cout << "ka";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "ki";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "ku";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "ke";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "ko";
			}
		}
		else if(str[i] == '3')
		{
			if(str[i + 1] == 'T')
			{
				cout << "sa";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "si";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "su";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "se";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "so";
			}
		}
		else if(str[i] == '4')
		{
			if(str[i + 1] == 'T')
			{
				cout << "ta";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "ti";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "tu";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "te";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "to";
			}
		}
		else if(str[i] == '5')
		{
			if(str[i + 1] == 'T')
			{
				cout << "na";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "ni";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "nu";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "ne";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "no";
			}
		}
		else if(str[i] == '6')
		{
			if(str[i + 1] == 'T')
			{
				cout << "ha";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "hi";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "hu";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "he";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "ho";
			}
		}
		else if(str[i] == '7')
		{
			if(str[i + 1] == 'T')
			{
				cout << "ma";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "mi";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "mu";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "me";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "mo";
			}
		}
		else if(str[i] == '8')
		{
			if(str[i + 1] == 'T')
			{
				cout << "ya";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "yu";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "yo";
			}
		}
		else if(str[i] == '9')
		{
			if(str[i + 1] == 'T')
			{
				cout << "ra";
			}
			else if(str[i + 1] == 'L')
			{
				cout << "ri";
			}
			else if(str[i + 1] == 'U')
			{
				cout << "ru";
			}
			else if(str[i + 1] == 'R')
			{
				cout << "re";
			}
			else if(str[i + 1] == 'D')
			{
				cout << "ro";
			}
		}
	}
	cout << endl;
}

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

Measured memory_bytes: 1180
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
int calcScore(vector<int> &plan, vector<int> &c, vector<vector<int>> &s) {
	int D = 365;
	int score = 0;
	vector<int> last(26, -1);
	for (int i = 0; i < D; i++) {
		score += s[i][plan[i]];
		last[plan[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= c[j] * (i - last[j]);
		}
	}
	return score;
}
 
int main() {
	int D;
	cin >> D;
	vector<int> c(26);
	for (int i = 0; i < 26; i++)cin >> c[i];
	vector<vector<int>> s(365,vector<int>(26,0));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++)cin >> s[i][j];
	}
	
	vector<int> plan(365, 0);
	for (int i = 0; i < 365; i++) {
		int mi = 0, m = -1;
		for (int j = 0; j < 26; j++) {
			if (m < s[i][j]) {
				mi = j;
				m = s[i][j];
			}
		}
        plan[i] = mi;
	}
	int sc = calcScore(plan, c, s);
 
	for (int n = 0; n < 300000; n++) {
		if (rand() % 10 < 2) {
			int i = rand() % 365, j = rand() % 26, old = plan[i];
			plan[i] = j;
			int nsc = calcScore(plan, c, s);
			if (nsc > sc) {
				sc = nsc;
			}
			else {
				plan[i] = old;
			}
		}
		else {
			int k = rand() % 5;
			int i = rand() % (365 - k), j = i + k;
			swap(plan[i], plan[j]);
			int nsc = calcScore(plan, c, s);
			if (nsc > sc) {
				sc = nsc;
			}
			else {
				swap(plan[i], plan[j]);
			}
		}
	}
 
	for (int i = 0; i < 365; i++) {
		cout << plan[i] + 1 << endl;
	}
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;

  int pos = 0;
  double mn = -1.0;

  rep(i, N)
  {
    int h;
    cin >> h;

    double diff = std::abs(A - (T - h * (double)0.006));
    if (mn < 0 || mn > diff)
    {
      pos = i;
      mn = diff;
    }
  }

  cout << pos + 1 << endl;

  return 0;
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;
const ll MOD = 1e9 + 7;

ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

struct matrix {
	ll a[2][2];
	matrix() {
		for (int i = 0; i < 2; ++i)
			for (int j = 0; j < 2; ++j)
				a[i][j] = 0;
	}
	matrix operator*(matrix x) {
		matrix ans;
		for (int i = 0; i < 2; ++i)
			for (int j = 0; j < 2; ++j) {
				for (int k = 0; k < 2; ++k)
					ans.a[i][k] += a[i][j] * x.a[j][k];
			}
		for (int i = 0; i < 2; ++i)
			for (int j = 0; j < 2; ++j)
				ans.a[i][j] %= MOD;
		return ans;
	}
};

matrix pw(matrix a, ll b) {
	matrix ans;
	for (int i = 0; i < 2; ++i)
		ans.a[i][i] = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = a * a;
		--b;
		ans = ans * a;
	}
	return ans;
}

int h, w;
ll k;
char s[2100][2100];
ll b[2];

int main() {
	scanf("%d%d%lld", &h, &w, &k);
	if (k <= 1) {
		cout << 1 << "\n";
		return 0;
	}
	for (int i = 0; i < h; ++i) {
		scanf(" %s", s[i]);
	}
	int hc = 0;
	int vc = 0;
	for (int i = 0; i < h; ++i)
		if (s[i][0] == '#' && s[i][w - 1] == '#')
			hc = 1;
	for (int i = 0; i < w; ++i)
		if (s[0][i] == '#' && s[h - 1][i] == '#')
			vc = 1;
	if (!hc && !vc) {
		int cnt = 0;
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				if (s[i][j] == '#')
					++cnt;
		k = max(0ll, k - 1);
		ll ans = pw(cnt, k);
		cout << ans << "\n";
		return 0;
	}
	else if (hc && vc) {
		cout << 1 << "\n";
		return 0;
	}
	if (vc) {
		int n = max(h, w);
		for (int i = 0; i < n; ++i)
			for (int j = i + 1; j < n; ++j)
				swap(s[i][j], s[j][i]);
		swap(h, w);
	}
	matrix a;
	for (int i = 0; i < h; ++i) {
		int l = 0;
		int ls = 0;
		for (int j = 0; j < w; ++j) {
			if (s[i][j] == '#') {
				++l;
				if (s[i][j + 1] == '#')
					++ls;
			}
		}
		a.a[0][0] += l;
		a.a[0][1] -= ls;
		if (s[i][0] == '#' && s[i][w - 1] == '#')
			++a.a[1][1];
	}
	if (a.a[0][1] < 0)
		a.a[0][1] += MOD;
	b[0] = 1;
	b[1] = 1;
	a = pw(a, k - 1);
	ll ans = a.a[0][0] * b[0] + a.a[0][1] * b[1];
	ans %= MOD;
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 4352
A,B, K = map(int, input().split())
AB = [0,0]
if K <= A:
    AB[0] = A-K
    AB[1] = B
elif K <= A+B:
    AB[0] = 0
    AB[1] = B-(K-A)
else:
    AB[0] = 0
    AB[1] = 0
print(AB[0],AB[1])

Measured memory_bytes: 38256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(0);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,l;
    while(cin>>n>>l,n){
        string d;
        vi left(l+1),right(l+1);
        int p;
        rep(i,n){
            cin>>d>>p;
            if(d=="L")left[p]=i+1;
            else right[p]=i+1;
        }
        int anst=0,ansn=0;
        while(n){
            rep(i,l){
                if(left[i]){
                    left[i-1]=left[i];
                    left[i]=0;
                }
            }
            for(int i=l-1;i>0;i--){
                if(right[i]){
                    right[i+1]=right[i];
                    right[i]=0;
                }
            }
            Rep(i,1,l){
                if(left[i]&&right[i])swap(left[i],right[i]);
            }
            if(right[l]){
                n--;
                ansn=right[l];
                right[l]=0;
            }
            if(left[0]){
                n--;
                ansn=left[0];
                left[0]=0;
            }
            anst++;
        }
        cout<<anst<<" "<<ansn<<endl;
    }
}


Measured memory_bytes: 3100
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
    scanf("%lld",&n);
    for(int i=(int)sqrt(n*1.0);i>=1;i--){
        if(n%i==0){
            int t=i,l=n/i;
            int s=1;
            while(l>=10){
                s++;
                l/=10;
            }
        	cout<<s;
        	return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 256
while 1:
    a,op,b = map(str,input().split())
    if op == "?":
        break
    elif op == "+":
        print(int(a)+int(b))
    elif op == "-":
        print(int(a)-int(b))
    elif op == "*":
        print(int(a)*int(b))
    else:
        print(int(a) // int(b))

Measured memory_bytes: 7604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,a,b;
  a=2,b=1;
  cin>>n;
  ll s=0;
  if(n==1)
  {cout<<b;return 0;}
  for(int i=0;i<n-1;i++)
  {
  	s=a+b;
    a=b;
    b=s;
   }
  cout<<s;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define INF (1 << 30)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int n, m;
  cin >> n >> m;
  vi a(m);
  cin >> a;
  sort(a.rbegin(), a.rend());

  vi b = {100, 2, 5, 5, 4, 5, 6, 3, 7, 6};

  int dp[9][10001];
  REP(i, 9) REP(j, 10001) dp[i][j] = -INF;

  REP(i, m) {
    dp[i][0] = 0;
    REP(j, n + 1) {
      int x = j - b[a[i]];
      if (x >= 0 and dp[i][x] != -INF)
        dp[i][j] = max(dp[i][j], dp[i][x] + 1);
      if (i > 0)
        dp[i][j] = max(dp[i][j], dp[i - 1][j]);
    }
  }

  // REP(i, m) {
  //   REP(j, n + 1) cout << (dp[i][j] == -INF ? -1 : dp[i][j]) << " ";
  //   cout << endl;
  // }

  for (int i = 0; i < m; i++) {
    while (n - b[a[i]] >= 0 and dp[m - 1][n] - dp[m - 1][n - b[a[i]]] == 1) {
      cout << a[i];
      n -= b[a[i]];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		int d, g;
		var I = G;
		d = I[0]; g = I[1] / 100;
		var p = new int[d];
		var c = new int[d];
		for (var i = 0; i < d; i++)
		{
			I = G;
			p[i] = I[0];
			c[i] = I[1] / 100;
		}
		var min = p.Sum();
		for (var s = 0; s < (1 << d) - 1; s++)
		{
			int sum = 0, count = 0, j = -1;
			var f = new bool[d];
			for (var i = 0; i < d; i++) if (f[i] = (s & (1 << i)) != 0) { sum += c[i] + p[i] * (i + 1); count += p[i]; } else j = i;
			if (sum >= g) { min = Min(min, count); continue; }
			var left = (g - sum + j) / (j + 1);
			if (left < p[j]) min = Min(min, count + left);
		}
		WriteLine(min);
	}
}


Measured memory_bytes: 13396
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n, s;

long f(long b, long m){
	//printf("pass\n");
	if(m < b){
		return m;
	}else{
		return f(b, m/b) + (m % b);
	}
}

int main(){
	scanf("%ld %ld", &n, &s);
	if(n < s){
		printf("-1\n");
		return 0;
	}
	if(n == s){
		printf("%ld\n", n+1);
		return 0;
	}
	for(long b = 2; b * b <= n; b++){
		//printf("%ld\n", b);
		if(f(b, n) == s){
			printf("%ld\n", b);
			return 0;
		}
	}
	long ans = LINF;
	for(long p = 1; p * p < n; p++){
		//printf("%ld\n", p);
		long b = (n-s) / p + 1;
		if(b > 1 && f(b, n) == s){
			ans = std::min(ans, b);
		}
	}
	if(ans != LINF){
		printf("%ld\n", ans);
	}else{
		printf("-1\n");
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def calc(operator, stack):
    val_b = stack.pop()
    val_a = stack.pop()

    if operator == '+':
        stack.append(val_a + val_b)
    elif operator == '-':
        stack.append(val_a - val_b)
    elif operator == '*':
        stack.append(val_a * val_b)
    else:
        raise ValueError

stack = list()
inline = sys.stdin.readline().split()  # List of string
for val in inline:
    if val in '+-*':
        calc(val, stack)
    else:
        stack.append(int(val))

print(stack.pop())




Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
bitset<4000000> bs;
int main(){
	int n,a,s=0;
	scanf("%d",&n);
	bs[0]=true;
	rep(k,n){
		scanf("%d",&a);
		s+=a;
		bs|=bs<<a;
	}
	for(int k=(s+1)>>1;k<=s;k++)
	if(bs[k]){
		printf("%d\n",k);
		return 0;
	}
}

Measured memory_bytes: 1664
N , K = map(int, input().split())
S = input()
if S[K-1] == "A":
    ret = S[:K-1]+"a"+S[K:]
elif S[K-1] == "B":
    ret = S[:K-1]+"b"+S[K:]
else:
    ret = S[:K-1]+"c"+S[K:]
print(ret)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<unordered_map>

using namespace std;
typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_N 200000

int par[MAX_N];
int rnk[MAX_N];
long long int sz[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
int unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return 0;
	}

	if(rnk[x_par] < rnk[y_par]){
		sz[y_par] = sz[x_par] + sz[y_par];
		par[x_par] = y_par;
	}else{
		sz[x_par] = sz[x_par] + sz[y_par];
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
  return 1;
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int main(){
  long long int N, M, Q;
  cin >> N >> M >> Q;
  init(N);
  vector<P> v;
  long long int cnt = N;
  for(int i = 0; i < Q; i++){
    int a, b, tp;
    cin >> a >> b >> tp;
    if(tp == 0){
      cnt -= unite(a, b);
    }else{
      v.push_back(P(a, b));
    }
  }
  for(P p : v){
    if(same(p.first, p.second)){
      cout << "No" << endl;
      return 0;
    }
  }
  if(cnt == 2 && v.size() > 0){
    cout << "No" << endl;
    return 0;
  }
  long long int lim1 = N;
  if(v.size() == 0){
    lim1 = N - 1;
  }
  long long int lim2 = cnt * (cnt - 1) / 2 + (N - cnt);
  if(lim1 <= M && M <= lim2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
 
int main(){
    int n,k; cin>>n>>k;
    int a[200001]={0},b;
    FOR(i,0,n){
        cin>>b;
        a[b-1]--;
    }
    sort(a,a+200001);
    int ans=n;
    FOR(i,0,k){
        ans+=a[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

pint ord[200001];
int main(){
    int n,a,b;
    cin>>n;
    rep(i,n){
        cin>>a>>b;
        ord[i]={b,a};
    }
    sort(ord,ord+n);
    ll cur=0;
    rep(i,n){
        if(cur+ord[i].second<=ord[i].first){
            cur+=ord[i].second;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#include<algorithm>
int main()
{
	long long a[3];
	int dem1,dem2,all;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	dem1=a[2]-a[1];
	a[1]+=dem1;
	a[0]+=dem1;
	dem2=(a[2]-a[0])/2;
	a[0]+=dem2*2;
	if(a[0]<a[2]) all=dem1+dem2+2;
	else all = dem1+dem2;
	cout<<all;
	
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for x in range(j+1,n):
            if l[x]<l[i]+l[j] and l[i]<l[j]<l[x]:
                cnt+=1
                
print(cnt)

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

struct Edge {
  int to;
  int id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1){
  int k = 1;
  rep(i, g[v].size()) {
    int u = g[v][i].to, ei = g[v][i].id;
    if (u == p) continue;
    if (k == c) ++k;
    ans[ei] = k; ++k;
    dfs(u, ans[ei], v);
  }
}

int main(){
  int n;
  cin >> n;
  g.resize(n);
  ans = vector<int>(n-1);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back((Edge){b, i});
    g[b].push_back((Edge){a, i});
  }
  dfs(0);
  int mx = 0;
  rep(i, n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i, n-1) cout << ans[i] << endl;
}


Measured memory_bytes: 8320
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
from math import gcd

g = 0
for a in As:
    g = gcd(g, a)
print(g)

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

using namespace std;

const int N = 1e2+7;

string s;
int k;

inline int solve(string str)
{
    int res = 0, cnt = 1;
    for (int i = 1; i < (int)str.length(); ++i) {
        if (str[i] == str[i-1]) {
            ++cnt;
        } else {
            res += cnt/2;
            cnt = 1;
        }
    }
    return res+cnt/2;
}

int main()
{
    cin >> s >> k;
    int flag = 1;
    for (char c : s) if (c != s[0]) flag = 0;
    if (flag) {
        cout << (long long)s.length()*k/2 << endl;
        return 0;
    }
    int num = solve(s);
    if (s.front() != s.back()) {
        cout << 1ll*num*k << endl;
        return 0;
    }
    int a = 1, b = 1;
    for (int i = 1; i < (int)s.length(); ++i) {
        if (s[i] != s[0]) break;
        ++a;
    }
    for (int j = s.length()-2; j >= 0; --j) {
        if (s[j] != s[0]) break;
        ++b;
    }
    cout << 1ll*(num-a/2-b/2)*k+1ll*(a+b)/2*(k-1)+a/2+b/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Node{
  int no;
  int par;
  int h;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;
  }
};
signed main(){
  int n,m;cin>>n>>m;
  int res=0;
  vector<Node> node(n+1);
  rep1(i,n){
    int h;cin>>h;
    node[i].build(i);
    node[i].h=h;
  }
  rep(i,m){
    int a,b;cin>>a>>b;
    node[a].child.push_back(&node[b]);
    node[b].child.push_back(&node[a]);
  }
  rep1(i,n){
    bool flag=true;
    int num=node[i].child.size();
    rep(j,num){
      if(node[i].h<=node[i].child[j]->h)flag=false;
    }
    if(flag)res++;
  }
  cout<<res<<"\n";
  return 0;
}


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

const int MAXN = 1e2 + 10;
int gel[MAXN][MAXN];
int a[MAXN * MAXN];

int main(void){
    int h, w, n;
    cin >> h >> w >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int cnt1 = 0, indx = 1;
    for(int i = 0; i < h; i++){
        if(i % 2 == 0){
            for(int j = 0; j < w; j++){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }else{
            for(int j = w - 1; j >= 0; j--){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << gel[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  string S;cin >> S;
  if(S.size() == 2){
    cout << S << endl;
  }else{
    reverse(S.begin(),S.end());
    cout << S << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,t[26] = {0},flag = 0;
	char s[101],s1[27] = {'a','b','c','d','e','f','h','i','j','k','l','m','n','o','p','q','r','i','s','t','u','v','w','x','y','z'};
	scanf("%s",&s);
	for(i = 0;s[i] != '\0';i++)
	{
		for(j = 0;j < 26;j++)
		{
			if(s[i] == s1[j])
			{
				t[j]++;
			}
		}
	}
	for(i = 0;i < 26;i++)
	{
		if(t[i] % 2 != 0)
		{
			flag = 1;
			break;
		}
	}
	if(flag == 1)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}



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

int main() {
	int H, W;
	cin >> H >> W;
	int gr[10][10];
	for (int i = 0;i < 10;i++) {
		for (int j = 0;j < 10;j++) {
			cin >> gr[i][j];
		}
	}
	vector<int> par(10, 512411);
	priority_queue<pair<int, int>,vector<pair<int, int>>,greater<pair<int, int>>> B;
	B.push({ 0,1 });
	int a,b;
	while (!B.empty()) {
		a = B.top().first;
		b = B.top().second;
		B.pop();
		if (a >= par[b])continue;
		par[b] = a;
		for (int i = 0;i < 10;i++) {
			B.push({ a + gr[i][b], i });
		}
	}
	int cnt = 0;
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			cin >> a;
			if (a < 0)continue;
			cnt += par[a];
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> x(N), y(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
    long long ans = 5e18;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            for(int k = 0; k < N; k++){
                for(int l = k + 1; l < N; l++){
                    long long xmin = min(x[i], x[j]);
                    long long xmax = max(x[i], x[j]);
                    long long ymin = min(y[k], y[l]);
                    long long ymax = max(y[k], y[l]);
                    int cnt = 0;
                    for(int m = 0; m < N; m++){
                        if(xmin <= x[m] && x[m] <= xmax && ymin <= y[m] && y[m] <= ymax) cnt++;
                    }
                    if(cnt >= K) ans = min(ans, (ymax - ymin) * (xmax - xmin));
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
s = gets().split("");
check = Array.new(3,0);
for i in 0..2
	if s[i]=="a"
		check[0]+=1;
	elsif s[i]=="b"
		check[1]+=1;
	elsif s[i]=="c"
		check[2]+=1;
	end
end

if check[0]==1 && check[1]==1 && check[2]==1
	puts("Yes");
else
	puts("No");
end

Measured memory_bytes: 1788
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;

	void doIt() {
		int N = sc.nextInt();
		int P[] = new int[N];
		int Q[] = new int[N];
		for(int i = 0; i < N; i++)
			P[i] = sc.nextInt();
		for(int i = 0; i < N; i++)
			Q[i] = sc.nextInt();
		
		int numP = 1;
		for(int i = 0; i < N; i++) {
			int dig = P[i];
			int cnt = 0;
			for(int j = 0; j < i; j++) {
				if(dig > P[j]) {
					cnt++;
				}
			}
			numP += (dig - cnt - 1) * f(N - i - 1);
			//System.out.println((dig - 1) + " * " + (N - i - 1) + "! ");

		}
		int numQ = 1;
		for(int i = 0; i < N; i++) {
			int dig = Q[i];
			int cnt = 0;
			for(int j = 0; j < i; j++) {
				if(dig > Q[j]) {
					cnt++;
				}
			}
			numQ += (dig - cnt - 1) * f(N - i - 1);
			//System.out.println(numQ);
			//System.out.println((dig - 1) + " * " + (N - i - 1) + "! ");
		}
		//System.out.println(numP + " " + numQ);
		System.out.println(Math.abs(numP - numQ));
	}
	
	int f(int n) {
		if(n <= 0) return 0;
		int ans = 1;
		for(int i = 1; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define int long long
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

vector<long long> PrimeFactorize(long long n){
  vector<bool> prime(round(sqrt(n))+1,1);
  vector<long long> ans;
  for(long long i=2;i*i<=n;i++){
    if(prime[i]){
      for(long long j=2*i;j*j<=n;j+=i){
        prime[j] = 0;
      }
      while(n%i==0){
        ans.push_back(i);
        n /= i;
      }
    }
  }
  if(n != 1)ans.push_back(n);
  return ans;
}

signed main(){
    ll N,P;
    cin >> N >> P;
    vector<ll> v = PrimeFactorize(P);
    map<ll,ll> m;
    set<ll> s;
    for(auto x:v)m[x]++,s.insert(x);
    ll ans = 1;
    for(auto x:s)if(m[x] >= N){
        FOR(i,0,m[x]/N)ans *= x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var ab = ReadIntArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine($"{(a + b) % 24}");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 11348
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c; cin >> a >> b >> c;
  cout << max(c - (a - b), 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define max(a,b) (a>b?a:b)



int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int ans=0;
    for(int k=0;k<=n-3;k++){
        int max1=max(max(a[k],a[k+1]),max(a[k+1],a[k+2]));
        int max2=a[k];
        if(max1==a[k])max2=a[k+1];
        for(int i=k;i<k+3;i++){
            if(max2<a[i] && a[i]!=max1)max2=a[i];
        }
        if(max2==a[k+1])ans++;
    }
    printf("%d",ans);

}


Measured memory_bytes: 128
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long A = sc.nextLong();
    long B = sc.nextLong();
    
    long C = A+B;
    long ansA = A*(N/C);
    long ansB = Math.min(N%C, A); 
    System.out.println(ansA + ansB);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using i64 = long long;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

int main() {
    constexpr i64 mod = 1000000007;
    int n, k;
    std::cin >> n >> k;

    std::vector<int> c(k + 1);
    for (int i = 2; i <= k; i++) {
        int m = i, r = 0;
        for (int j = 2; j * j <= m; j++) {
            if (m % j) continue;
            r++;
            while (m % j == 0) m /= j;
        }
        if (m > 1) r++;
        c[i] = r;
    }

    std::vector<i64> v(k + 1);
    for (int i = 1; i <= k; i++) {
        v[i] = pow(k / i, n, mod);
    }

    for (int i = k; i > 1; --i) {
        for (int j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                v[j] -= v[i];
                if (j != 1 && j * j != i) v[i / j] -= v[i];
            }
        }
    }

    i64 ret = 0;
    for (int i = 1; i <= k; i++) ret = (ret + i * v[i] % mod) % mod;

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 4580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		
		if(A <= C && C <= B)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#define F first
#define S second
using namespace std;
typedef vector<vector<char> > VVC;
typedef pair<int,int> P;

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

class Ennichi
{
public:
  VVC G;
  bool used[30][30];
  int h,w,n;

  Ennichi()
  {
    input();
  }

  Ennichi(int h,int w,int n):h(h),w(w),n(n)
  {
    input();
  }

  void input()
  {
    G.resize(h);
    for(int i=0;i<h;i++)
      {
	G[i].resize(w);
	for(int j=0;j<w;j++)
	  {
	    cin >> G[i][j];
	  }
      }
  }

  void print()
  {
    cout << "--- print ---" << endl;
    for(int i=0;i<G.size();i++)
      {
	for(int j=0;j<G[i].size();j++)
	  {
	    cout << G[i][j];
	  }
	cout << endl;
      }
    cout << endl;
  }

  void drop()
  {
    while(true)
      {
	VVC pre = G;
	for(int i=0;i<G.size()-1;i++)   
	  for(int j=0;j<G[i].size();j++)	
	    if(G[i+1][j] == '.')
	      swap(G[i][j],G[i+1][j]);  
	if(pre == G)
	  break;
      }
  }


  int dfs(P p,int dir,int cnt,char c)
  {

    if(!(0 <= p.F && p.F < w && 0 <= p.S && p.S < h) || G[p.S][p.F] != c)
	return cnt-1;
      

    int res = dfs(P(p.F+dx[dir],p.S+dy[dir]),dir,cnt+1,c);
    if(res >= n)
      used[p.S][p.F] = true;
    return res;
  }
  
  void erase()
  {
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	used[i][j] = false;

    for(int i=0;i<h;i++)
      {
	for(int j=0;j<w;j++)
	  {
	    if(G[i][j] == '.')
	      continue;
	    for(int k=0;k<4;k++)
	      {
		int res = dfs(P(j,i),k,1,G[i][j]);
		if(res >= n)
		  used[i][j] = true;
	      }
	  }
      }

    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(used[i][j])
	  G[i][j] = '.';
  }

  bool check()
  {
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(G[i][j] != '.')
	  return false;
    return true;
  }

};

int main()
{
  int h,w,n;
  scanf("%d %d %d",&h,&w,&n);
  Ennichi E(h,w,n);

  bool fin = false;
  for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
	{
	  if(j+1 >= w ||  E.G[i][j] == '.' && E.G[i][j+1] == '.')
	    continue;
	  //cout << j << " , " << i << endl;
	  VVC pre = E.G;
	  swap(E.G[i][j],E.G[i][j+1]);
	  E.drop();
	  //cout << "swap" << endl;
	  //E.print();	

	  while(true)
	    {
	      VVC before = E.G;
	      E.erase();
	      //cout << "after erasing ↓" << endl;	 
	      //E.print();
	      E.drop();
	      //cout << "after droping ↓" << endl;
	      //E.print();	  

	      if(E.G == before)
		break;
	    }
	  if(E.check())
	    {
	      fin = true;
	      goto F;
	    }
	  E.G = pre;
	 

	  //cout << "!!!!!!!!!!!!!!!!!!FIN" << endl;

	}
    }
  
 F:
  fin?cout << "YES" << endl:cout << "NO" << endl;  
  return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
//const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){cout << a << " " << b << " " << c << endl;}
#define INT_MAX 1<<30;
const int MAX = 1020000;
const double EPS = 1e-6;
const int mod = 1e9+7;

 
int main(){
    ll n; cin >> n;
    vl a(n); rep(i,n) cin >> a[i];
    vl v(200001,0);
    v[0] = 1;
    ll ans = 0;
    rep(i,n){
        if(v[a[i]-1] && !v[a[i]]) v[a[i]]++;
        else{
            ans++;
        }
    }
    if(ans==n) puts("-1");
    else cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
  int n,i,count;
  double sum,avg;
  while(1){
    sum = 0;
    avg = 0;
    cin >> n;
    if (n == 0)
    break;
    else{
    double data[n];
    for (i = 0; i < n;i++){
      cin >> data[i];
    }
    for (i = 0; i < n;i++){
      sum = sum + data[i];
    }
    avg = sum / n ;
    count = 0;
    for(i = 0; i < n; i++){
      if(data[i] <= avg)
      count++;
    }
    cout << count << endl;
   }
 }
 return 0;
}



Measured memory_bytes: 3252
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

# 以上マージソート

N = int(input())
 
list = []
 
for i in range(N):
    A, B = input().split()
 
    A = A + "000000000000"
    A = A[:10]
    B = str(2000-int(B))+str(i+1001)
    list.append(A+B)
 
list = merge_sort(list)
 
for i in list:
    print(int(i[-3:]))

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

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

    int A[100][100] = {};
    int B[100] = {};
    int row, col;

    cin >> row >> col;

    // matrix A
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            cin >> A[i][j];
        }
    }

    // matrix B
    for (int i = 0; i < col; i++) {
        cin >> B[i];
    }

    // output
    for (int i = 0; i < row; i++) {
        int sum = 0;
        for (int j = 0; j < col; j++) {
            sum += A[i][j] * B[j];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3248
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  string ss="abcdefghijklmnopqrstuvwxyz";
  string sss;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[i+1]){
      sss.push_back(s[i]);
    }
  }
  for(int i=0;i<26;i++){
    if(sss[i]!=ss[i]){
      cout<<ss[i]<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(int& a){printf("%d",a);}
void print(long long& a){printf("%lld",a);}
void print(double& a){printf("%.15lf",a);}
template<class T> void print(T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(Head& head, Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(Head& head, Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    vector<int> vec(2);
    while(1){
        in(vec);
        if(vec[0]==0&&vec[1]==0)break;
        sort(all(vec));
        out(vec);
    }
}


Measured memory_bytes: 3252
def hersCode(L):
  ok = 10 ** 9 + 1
  ng = 0
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if nasu(L, mid):
      ok = mid
    else:
      ng = mid
  return ok

def nasu(L, n):
  cnt = 0
  for x in L:
    div, mod = divmod(x, n)
    cnt += div - 1
    if mod != 0:
      cnt += 1
  if cnt <= K:
    return True
  else:
    return False

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

ans = hersCode(A)

print(ans)


Measured memory_bytes: 94032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;

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

int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		ll n; cin>>n;
		map<ll,ll> mt;
		vector<ll> v;
		ll a[n]; 
		for(int i=0; i<n; i++) { 
			cin>>a[i]; 
			//if(mt[a[i]]==0) { 
			v.pb(a[i]);
			//} 
		}
		int len = v.size();
		sort(v.begin(), v.end());
		ll ans = 0;
		if(len>=3) {
		for(int i=0; i<len; i++) {
			for(int j=i+1; j<len; j++) {
				for(int k = j+1; k<len; k++) {
					if(v[i]+v[j]>v[k] && v[i]!=v[j] && v[i] != v[k] && v[k]!= v[j]) ans++;
				}
			}
		}
		}
		cout<<ans;

 	}	
	return 0;
}

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

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if(a > b){
    ll dis = a - b;
    if((v - w) * t >= dis){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else{
    ll dis = b - a;
    if((v - w) * t >= dis){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define numOfOnes(n) __builtin_popcount(n)
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//</DEFINE>

/*█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀█▄▄▄▀▀▀▀▄▄▄█▀*/
int n, w;
vector<pair<int,int>>v;
ll res[101][100001];
//<FUNCTIONS>
ll solve(int idx = 0, int wight = 0) {
	if (idx == n)return 0;
	if (~res[idx][wight])return res[idx][wight];
	ll take = 0, leave;
	if (wight + v[idx].first <= w)take = solve(idx + 1, wight + v[idx].first) + v[idx].second;
	leave = solve(idx + 1, wight);
	return res[idx][wight] = max(leave, take);
}
//</FUNCTIONS>		
int main() {
	Fast();
	cin >> n >> w;
	v.resize(n);
	for (int i = 0; i < n; i++)cin >> v[i].first>> v[i].second;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= w; j++)res[i][j] = -1;
	}
	cout << solve() << endl;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

ll INF = 1LL << 30;

int main()
{
  int N;
  cin >> N;
  vint H(N);
  cin >> H;
  vll dp(N);
  REP(i,N) dp[i] = INF;
  dp[0] = 0;
  REP(now,N){
    for(int next = now+1; next <= min(N,now+2); next++){
      chmin(dp[next],(dp[now]+abs(H[now]-H[next])));
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main() {
  int n, i, j;
  int r[200000];
  int max, min;

  scanf("%d", &n);

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

  max = r[1] - r[0];
  min = r[0];
  for (i = 1; i < n; i++) {
    if((r[i] - min) > max) max = r[i] - min;

    if(r[i] < min) min = r[i];
  }

  printf("%d\n", max);

  return 0;
  
}

Measured memory_bytes: 1376