akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    int s1 = S[0] - '0';
    int s2 = S[1] - '0';
    int s3 = S[2] - '0';
    cout << s1 + s2 + s3 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val d = (1..n).map { sc.nextInt() }

  println(abc132c(n, d))
}

private fun abc132c(n: Int, d: List<Int>): Int {
  val sorted = d.sorted()

  val first = sorted.subList(0, n / 2)
  val second = sorted.subList(n / 2, n)

  val max = first.max()!!
  val min = second.min()!!

  return min - max
}


Measured memory_bytes: 57628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_ac=new ArrayList<Integer>();
		//List<Integer> list_wa=new ArrayList<Integer>();
		//int[] array_k = new int[100000];
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] array_ac = new int[n+1];
		int[] array_wa = new int[n+1];
		for(int i=0;m>i;i++) {
			int p = sc.nextInt();
			String s = sc.next();
			if(s.equals("AC")){
				array_ac[p] = 1;
			}
			else {
				if(array_ac[p] != 1) {
					array_wa[p]++;
				}
			}
		}
		int ac =0;
		int wa =0;
		for(int i=0;n+1>i;i++) {
			if(array_ac[i]==1)
				ac++;
			if(array_wa[i]>=1)
				if(array_ac[i]==1)
					wa=wa+array_wa[i];
		}
		System.out.println(ac+" "+wa);
	}
}

Measured memory_bytes: 64552
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  long long a, b, k;
  cin >> a >> b >> k;
  
  long long copy = a;
  a = a - min(a, k);
  b = b - min(b, k-min(copy, k));
  
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

flag = True
tmp_max = h[0] - 1
for i in range(1, n):
    if h[i] > tmp_max:
        tmp_max = h[i] - 1
    elif h[i] == tmp_max:
        tmp_max = h[i]
    else:
        flag = False

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14396
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    bool ok=false;
    int ans=0;
    while(1){
        int l=0;
        while(l<n and h[l]==0){
            l++;
        }
        if(l==n){
            break;
        }
        int r=l;
        while(r<n and h[r]){
            h[r]--;
            r++;
        }
        ans++;
    }
    cout<<ans<<endl;
 return 0;   

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<vector<int>> a(3, vector<int>(3));
    for(int i=0; i<3; ++i){for(int j=0; j<3; ++j){cin >>a[i][j];}}
    int n; cin >> n ;
    vector<int> b(n); 
    for(int j=0; j<n; ++j){cin >> b[j];}

    vector<int> c(9, 0);
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
          	for(int k=0; k<n; ++k){if(a[i][j]==b[k]){c[i*3+j]=1;}}
          	
        }
    }
  
  	

    if(c[0]==1 && c[1]==1 && c[2]==1){cout << "Yes" << endl; return 0;}
    if(c[0]==1 && c[3]==1 && c[6]==1){cout << "Yes" << endl; return 0;}
    if(c[2]==1 && c[5]==1 && c[8]==1){cout << "Yes" << endl; return 0;}
    if(c[6]==1 && c[7]==1 && c[8]==1){cout << "Yes" << endl; return 0;}
    if(c[3]==1 && c[4]==1 && c[5]==1){cout << "Yes" << endl; return 0;}
    if(c[1]==1 && c[4]==1 && c[7]==1){cout << "Yes" << endl; return 0;}
    if(c[0]==1 && c[4]==1 && c[8]==1){cout << "Yes" << endl; return 0;}
    if(c[2]==1 && c[4]==1 && c[6]==1){cout << "Yes" << endl; return 0;}
    
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>
#include<random>


using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector2<T>>;
typedef vector<ll> Array;


ll l[20][202020];
ll r[20][202020];
ll dp1[20][202020];
ll dp2[20][202020];

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


	ll n, k;
	cin >> n >> k;
	Array x(n);
	REP(i, n)cin >> x[i];
	REP(i, n)dp1[0][i] = l[0][i] = lower_bound(all(x), x[i] + k) - x.begin();
	REP(i, n)dp2[0][i] = r[0][i] = upper_bound(all(x), x[i] - k) - x.begin() - 1;
	REP(i, 19)REP(j, n)l[i + 1][j] = l[i][min(n - 1, l[i][j])];
	REP(i, 19)REP(j, n)r[i + 1][j] = r[i][max(0LL, r[i][j])];
	REP(i, 19)REP(j, n)dp1[i + 1][j] = dp1[i][j] + dp1[i][l[i][j]];
	REP(i, 19)REP(j, n)dp2[i + 1][j] = dp2[i][j] + dp2[i][r[i][j]];
	ll q;
	cin >> q;
	while (q--) {
		ll L, R;
		cin >> L >> R;
		L--;
		ll ans = R - L;
		ll x = L, y = R - 1;
		for (int i = 19; i >= 0; i--) {
			if (l[i][x] < R)ans += (1LL << i) - dp1[i][x], x = l[i][x];
			if (r[i][y] >= L)ans += dp2[i][y], y = r[i][y];
		}
		cout << ans << "\n";
	}

	return 0;
}

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

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


ll a[MAX], c[MAX], q[MAX], qq[MAX];

ll mod_pow(ll x, ll y) {
  ll ret = 1;
  while (y > 0) {
	if (y & 1) ret = (x*ret) % mod;
	x = (x*x) % mod;
	y >>= 1;
  }
  return ret;
}

ll t[MAX];

int main(void) {
  cin >> s;
  n = s.length();
  FOR(i, 1, n) {
	if (s[i - 1] == 'A') a[i] = a[i - 1] + 1;
	else a[i] = a[i - 1];
	if (s[i - 1] == '?') q[i] = q[i - 1] + 1;
	else q[i] = q[i - 1];
  }
  rrep(i, n - 1) {
	if (s[i + 1] == 'C') c[i] = c[i + 1] + 1;
	else c[i] = c[i + 1];
	if (s[i + 1] == '?') qq[i] = qq[i + 1] + 1;
	else qq[i] = qq[i + 1];
  }

  t[1] = 1;
  FOR(i, 2, MAX) {
	(t[i] = 3 * t[i - 1] + mod_pow(3, i - 1)) %= mod;
  }

  rep(i, n) {
	if (s[i] == 'A' || s[i] == 'C') continue;
	ll x, y;
	if (q[i]) {
	  x = t[q[i]];
	  (x += mod_pow(3, q[i]) * a[i]) %= mod;
	}
	else x = a[i];
	if (qq[i]) {
	  y = t[qq[i]];
	  (y += mod_pow(3, qq[i]) * c[i]) %= mod;
	}
	else y = c[i];
	ans += (x*y) % mod;
	ans %= mod;
	//cout << x << " " << y << endl;
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4608
#include <iostream>
using namespace std;
    int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<b){
        if(b<c){
            cout << a+b << endl;
        }else{
            cout << a+c << endl;
        }
    }else if(a<c){
        cout << a+b << endl;
    }else{
        cout << b+c << endl;
    }
    }

Measured memory_bytes: 256
a = input()
inp = [int(i) for i in a]

cnt = 0

#はじめに偶数枚目、奇数枚目に同じ番号が連続する値を探す

gu_0 = 0
gu_0_score = 0
gu_1 = 0
gu_1_score = 0
ki_0 = 0
ki_0_score = 0
ki_1 = 0
ki_1_score = 0

for index, i in enumerate(inp):
	if index % 2 == 0:
		if i == 0:
			gu_0 += 1
		else:
			gu_1 += 1
	else:
		if i == 0:
			gu_1 += 1
		else:
			gu_0 += 1

maxscore = max([gu_0,gu_1,ki_0,ki_1])
			
if gu_0 + ki_1 == len(inp) or gu_1 + ki_0 == len(inp):
	print(0)
else:
	for score in [gu_0,gu_1,ki_0,ki_1]:
		if maxscore > score and score != 0:
			maxscore = score
	print(maxscore)
#

Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;


bool is_possible(int mid, vector<int>&v, int K)
{
	int ret = 0;
	for (auto i : v)
	{
		ret += (i %mid == 0 ? i / mid - 1 : i / mid);
	}
	return (ret <= K);
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int>v(N);
	for (auto&i : v)cin >> i;

	int left = 1, right = 1e9 + 2, ret = -1;
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (is_possible(mid, v, K))
		{
			ret = mid;
			right = mid - 1;
		}
		else left = mid + 1;
	}
	cout << ret << endl;

}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
#define x first
#define y second
#define N 200005
using namespace std;
pair<int,int> p[N];
vector<pair<int,int> > v;
int n;
int main(){
	scanf("%d",&n);
	int mx=0,mn=0;p[0].y=1e9+1;
	int mxx=-1,mxy=-1,mnx=1e9+1,mny=1e9+1;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&p[i].x,&p[i].y);
		if(p[i].x<p[i].y) swap(p[i].x,p[i].y);
		if(p[i].x>=p[mx].x) mx=i;
		if(p[i].y<=p[mn].y) mn=i;
		mxx=max(mxx,p[i].x);mnx=min(mnx,p[i].x);
		mxy=max(mxy,p[i].y);mny=min(mny,p[i].y);
	}
	long long ans=(mxy-mny)*1LL*(mxx-mnx);
	if(mx!=mn&&n>2){
		vector<pair<int,int> > v;
		for(int i=1;i<=n;i++)
			if(i!=mx&&i!=mn)
				v.push_back(p[i]);
		int nx=max(p[mx].y,p[mn].x);
		sort(v.begin(),v.end());
		int nowmn=min(min(p[mx].y,p[mn].x),v[0].x);
		for(int i=v.size()-1;i>=0;i--){
			if(v[i].x<=nx) break;
			ans=min(ans,(v[i].x-nowmn)*1LL*(p[mx].x-p[mn].y));
			nowmn=min(nowmn,v[i].y);
			nx=max(nx,v[i].y);
		}
		ans=min(ans,(nx-nowmn)*1LL*(p[mx].x-p[mn].y));
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3956
N,M = map(int, input().split())
H = list(map(int, input().split()))
loadJ = []
kekka = [True] * N
for i in range(M):
    temp = list(map(int, input().split()))
    loadJ.append(temp)
    
    if H[temp[0] - 1] <= H[temp[1] - 1]:
        kekka[temp[0] - 1] = False
    
    if H[temp[1] - 1] <= H[temp[0] - 1]:
        kekka[temp[1] - 1] = False

print(kekka.count(True))


Measured memory_bytes: 31996
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n, m, ans, mod = 1e9+7, c;
    cin >> n >> m;
    vector<bool> a(n + 1);
    for(int i = 0;i < n + 1;i++) a[i] = true;
    for(int i = 0;i < m;i++){
        cin >> c;
        a[c] = false;
    }


    vector<int> dp(n + 1);
    dp[0] = 1;
    for(int now = 0;now < n;now++){
        for(int next = now + 1;next <= min(now + 2,n);next++){
            if(a[next]){
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }


    cout << dp[n];

    return 0;
}

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

int main(){
  int n;
  std::cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if(a[a[i]] == i)ans++;
  }
  std::cout << ans/2 << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf 1e16
#define MOD 1e9+7
#define gcd __gcd //最大公約数,gcd(x,y)
int lcm(int a, int b){return a/gcd(a, b)*b;} //(int)最小公倍数,lcm(x,y)
ll llcm(ll a, ll b){return a/gcd(a, b)*b;}//(ll)最小公倍数,lcm(x,y)


int main(){
    int N,i,ans=0;
    cin >> N;
    int L[2*N];

    for(i=0 ; i<2*N ; i++){
        cin >> L[i];
    }
    sort(L,L+2*N);

    for(i=0 ; i<2*N ; i+=2){
        ans += min(L[i],L[i+1]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int g[110][110];
vector<int>g2[110];
int p[11000];
int q[11000];
int r[11000];
pair<int,int> pt[110];
double dp[110];
double dp2[110];
int main(){
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c),a){
        for(int i=0;i<a;i++)for(int j=0;j<a;j++)g[i][j]=999999999;
        for(int i=0;i<a;i++)g[i][i]=0;
        for(int i=0;i<a;i++){g2[i].clear();}
        for(int i=0;i<b;i++){
            scanf("%d%d%d",p+i,q+i,r+i);
            g[p[i]][q[i]]=g[q[i]][p[i]]=r[i];
        }
        for(int k=0;k<a;k++)for(int i=0;i<a;i++)for(int j=0;j<a;j++)
            g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
        for(int i=0;i<b;i++){
            int P=p[i];
            int Q=q[i];
            int R=r[i];
            if(g[0][P]+R==g[0][Q]&&g[Q][a-1]+R==g[P][a-1]){
                g2[P].push_back(Q);
            }
            swap(P,Q);
            if(g[0][P]+R==g[0][Q]&&g[Q][a-1]+R==g[P][a-1]){
                g2[P].push_back(Q);
            }
        }
        for(int i=0;i<110;i++)dp[i]=0;
        dp[0]=1;
        for(int i=0;i<a;i++)pt[i]=make_pair(g[0][i],i);
        std::sort(pt,pt+a);
        for(int i=0;i<a;i++){
            int at=pt[i].second;
            for(int j=0;j<g2[at].size();j++){
                dp[g2[at][j]]+=dp[at];
            }
        }
		double tot=dp[a-1];
		
        for(int i=0;i<c;i++){
            int t;scanf("%d",&t);
			for(int j=0;j<a;j++)dp2[j]=0;
			dp2[t]=1;
			for(int j=0;j<a;j++){
				int at=pt[j].second;
				for(int k=0;k<g2[at].size();k++){
					dp2[g2[at][k]]+=dp2[at];
				}
			}
			printf("%.12f\n",dp2[a-1]/tot*dp[t]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 1240
#include <stdio.h>

int main(){
  int n,i,max=0,i_max=0,total=0;
  int rect[10];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&rect[i]);
    if(max<rect[i]){
      max=rect[i];
      i_max=i;
    }
  }
  
  for(i=0;i<n;i++){
    if(i!=i_max){
      total+=rect[i];
    }
  }
  
  if(rect[i_max]<total){
    printf("Yes");
  } else {
    printf("No");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vll T(n); for(auto& e : T) cin >> e;

    ll res = T[0];
    rep(i, 1, n){
        ll t = T[i];
        res = res / __gcd(res, t) * t;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }




int main() {
	D x1, y1, x2, y2, xq, yq;
	char c;
	
	while (cin>>x1>>c>>y1>>c>>x2>>c>>y2>>c>>xq>>c>>yq) {
		complex<D> p1(x1, y1), p2(x2, y2), q(xq, yq);
		complex<D> r = p1 + polar(abs(q-p1), 2*arg(p2-p1)-arg(q-p1));
		printf("%lf %lf\n", r.real(), r.imag());
	}
	
	return 0;
}

Measured memory_bytes: 1300
#include <algorithm>
#include <iostream>
#include <vector>
#define int int64_t
using namespace std;
main() {
    int X,Y,Z,K; cin>>X>>Y>>Z>>K;
    vector<int> A(X); for(auto& x:A) cin>>x;
    vector<int> B(Y); for(auto& x:B) cin>>x;
    vector<int> C(Z); for(auto& x:C) cin>>x;
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    vector<int> xs;
    for(int x=0; x<X; ++x) {
        for(int y=0; y<Y; ++y) {
            if((x+1)*(y+1) > K) break;
            for(int z=0; z<Z; ++z) {
                if((x+1)*(y+1)*(z+1) > K) break;  // 絶対に使わない
                xs.push_back(A[x]+B[y]+C[z]);     // 使われうる106,307個
            }
        }
    }
    sort(xs.rbegin(), xs.rend());
    for(int k=0; k<K; ++k) cout<<xs[k]<<endl;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;



int main(){
	
	int n,k,ans=0;
	cin >> n >> k;
	FOR(i,0,n){
		int h;
		cin >> h;
		if(h>=k)ans++;
	}
	cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  int B[N];
  for(int i=0; i<N-1; i++) cin >> B[i];
  int total = B[0] + B[N-2];
  for(int i=1; i<N-1; i++) total += min(B[i-1], B[i]);
  cout << total << endl;
}

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

int main() {

    // vector<int> A = {1,99, 3, 2, 5};
    int N,M;
    cin >> N >>M;

    int cnt =0;
    cnt = (N )*(N - 1)/2 + M*(M-1)/2 ;


    cout << cnt << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
#define ll unsigned long long
int main() {
    ll s;
    cin>>s;
    ll A[s+1];
    A[0]=1;
    A[1]=0;
    A[2]=0;
    for(ll i=3;i<=s;i++){
        A[i]=A[i-1]+A[i-3];
        A[i]%=mod;
    }
    long long ans=A[s];
    ans%=mod;
    cout<<ans<<endl;
    
    
}

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

uint64_t combination(uint64_t, uint64_t, const uint64_t&);

int main()
{
  const uint64_t mod = 1'000'000'007;
  uint64_t n, m;
  cin >> n >> m;
  uint64_t mm = m;
  uint64_t ans = 1;
  for (auto i = 2; i * i <= mm; i++) {
    if (mm % i == 0) {
      uint64_t count = 0;
      while (mm % i == 0) {
	count++;
	mm /= i;
      }
      ans *= combination(n + count - 1, count, mod);
      ans %= mod;
    }
  }
  if (mm != 1) {
    ans *= n;
    ans %= mod;
  }
  cout << ans << endl;
}

uint64_t modpow(uint64_t a, uint64_t p, const uint64_t& mod)
{
  if (p == 0) return 1;
  if (p % 2 == 0) {
    uint64_t h = modpow(a, p / 2, mod);
    return h * h % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

uint64_t combination(uint64_t a, uint64_t b, const uint64_t& mod)
{
  if (a - b < b) return combination(a, a - b, mod);
  uint64_t ansmul = 1;
  uint64_t ansdiv = 1;
  for (uint64_t i = 0; i < b; i++) {
    ansmul *= a - i;
    ansdiv *= i + 1;
    ansmul %= mod;
    ansdiv %= mod;
  }
  uint64_t ans = ansmul * modpow(ansdiv, mod - 2, mod) % mod;
  return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int dp[100001];
int INF = 1001001001;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n,0);
  rep(i,n) cin >> h.at(i);
  rep(i,n) dp[i] = INF;
  dp[0] = 0;
  rep(i,n) {
    FOR(j,1,k+1) if(i-j>=0) dp[i]=min(dp[i],dp[i-j]+abs(h.at(i-j)-h.at(i)));
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
using namespace std;



int gcd(int a, int b) {
    if (b==0) return a;
   	else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}


int main(){
	int N;
	string s,t;
	cin>>N>>s>>t;
	
	REP(i,N+1){
		REP(j,N-i){
			if(s[j+i]!=t[j]) break;
			
			if(j==N-i-1){
				cout<<N+i<<endl;
				return 0;
			}
		}
	}
	
	cout<<2*N<<endl;
	
	return 0;
}

Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc115/tasks/abc115_c
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    int N,K;
    cin>>N>>K;
    vector<int> h(N);
    cin>>h;
    sort(ALL(h));
    int bg=0;
    int ed=K-1;
    int ret=INT_MAX;
    while(ed<N){
        chmin(ret,h[ed]-h[bg]);
        bg++;
        ed++;
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007

using namespace std;

int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	int max__=-1,min__=INT_MIN;
	int l,r;
	cin>>l>>r;
	for(int y=0;y<m-1;y++)
	{
		int t1,t2;
		cin>>t1>>t2;
		if(t2<l || t1>r)
			{
				cout<<0<<"\n";
				return 0;
			}
		if(t1>l && t1<=r)
			l=t1;
		if(t2<r && t2>l)
			r=t2;
	}
	cout<<r-l+1<<"\n";
    return 0;
}


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

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
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; }

using namespace std;

int main() {
    int h, a;

    cin >> h >> a;

    int num = 0;
    for (;;) {
        h -= a;
        num++;
        if (h <= 0) {
            break;
        }
    }

    cout << num << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;
const lint MOD = 1e9 + 7;

lint power(lint x, lint n, lint mod = numeric_limits<lint>::max()) {
  assert(n >= 0);
  if (n == 0) return 1;
  return power(x * x % mod, n / 2, mod) * (n % 2 ? x : 1) % mod;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;

  VI inv(n + 1); inv[1] = 1;
  for (int i = 2; i <= n; i++) {
    inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
  }

  VI finv(n + 1); finv[0] = 1;
  for (int i = 1; i <= n; i++) {
    finv[i] = (lint) inv[i] * finv[i - 1] % MOD;
  }

  VVI dp(b - a + 1, VI(n + 1)); dp[0][0] = 1;
  for (int i = c; i <= d; i++) {
    if (a * i > n) break;
    dp[0][a * i] = power(finv[a], i, MOD) * finv[i] % MOD;
  }

  for (int i = 1; i <= b - a; i++) {
    dp[i] = dp[i - 1];
    for (int j = 0; j <= n; j++) {
      for (int f = c; f <= d; f++) {
        if ((a + i) * f > j) break;
        dp[i][j] = (dp[i][j] + power(finv[a + i], f, MOD) * finv[f] % MOD * dp[i - 1][j - (a + i) * f]) % MOD;
      }
    }
  }
  
  lint res = dp[b - a][n];
  for (int i = 1; i <= n; i++) {
    res = res * i % MOD;
  }
  cout << res << '\n';
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, X, D;
    cin >> N >> X >> D;

    if(X == 0){
    	if(D==0){
    		cout << 1 << endl;
    	}else{
    		cout << (N-1)*N/2 + 1 << endl;
    	}
    	return 0;
    }
    if(D==0){
    	cout << N+1 << endl;
    	return 0;
    }
    if(D<0){
    	X = X + (N-1)*D;
    	D = -D;
    }
   	vector<pll> ps[202020];
    map<ll, ll> mp;
    ll idx = 0;
    ll lb = 0, ub = 0;
    REP(k, N+1){
    	ll L = k*X + lb*D;
    	ll R = k*X + ub*D;
    	//dump(L)
    	//dump(R)
    	if(mp.find((k*X)%D) == mp.end()){
    		mp[(k*X)%D] = idx;
  			ps[idx].push_back({L, R});
    		idx++;
    	}else{
    		ps[mp[(k*X)%D]].push_back({L, R});
    	}
    	lb += k;
    	ub += (N-1-k);
    }

    //cout << ps[0] << endl;

    ll res = 0;
    REP(i, idx){
    	sort(ps[i].begin(), ps[i].end());
    	ll left = ps[i][0].first;
    	ll right = ps[i][0].second;
    	REP(j, ps[i].size()){
    		if(j==0) continue;
    		if(ps[i][j].first>right){
    			if(j>0) res += ((right-left)/D + 1);
    			left = ps[i][j].first;
    			right = ps[i][j].second;
    		}else{
    			right = max(right, ps[i][j].second);
    		}
    		//dump(res)
    	}
    	res += ((right-left)/D + 1);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 23808
#include "iostream"
#include "vector"
#include "string"

using namespace std;

int main() {
	string S;
	string T;
	
	cin >> S;
	cin >> T;

	if (T.compare(0, T.size() - 1, S) == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;

}

Measured memory_bytes: 3628
def main():
    e = [True for i in range(2*123456+1)]
    e[0] = e[1] = False
    i = 2
    while i*i <= 2*123456:
        for j in range(2*i, 2*123456+1, i):
            e[j] = False
        i += 1
    while True:
        n = int(input())
        if n == 0:
            exit()
        print(e[n+1:2*n+1].count(True))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10000
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << min(a, b) + min(c, d) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
d = [0]*(N+1)
d2 = [0]*(N+1)
r1=r2=0
for _ in range(M):
    p, j = input().split()
    p = int(p)
    j = j.strip()
    if j == "AC":
        if not d[p]:
            d[p] = 1
            r1 += 1
            r2 += d2[p]
    else:
        if not d[p]:
            d2[p] += 1
print(r1,r2)


Measured memory_bytes: 51176
n,m=map(int,input().split())
L=[[0]*2]*n
for i in range(n):
  L[i]=list(map(int,input().split()))
L1=sorted(L)
a=0
b=0
for i in range(n):
  b+=L1[i][1]
  if b<=m:
    a+=L1[i][0]*L1[i][1]
  else:
    a+=(m-b+L1[i][1])*L1[i][0]
    break
print(a)

Measured memory_bytes: 28656
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)-v.begin()
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)//-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l a,b,n;
	cin>>a>>b>>n;
	l minn=min(b-1,n);
	cout<<(a*minn)/b<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
//	cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 3652
class Team:
    def __init__(self, num, P):
        self.num = num
        self.times = [ 0 for _ in range(P) ]
        self.solved = [ False for _ in range(P) ]
        self.ps = None
        self.tt = None
    
    def submit(self, m, p, j):
        if j == 0:
            self.solved[p] = True
            self.times[p] += m
        else:
            self.times[p] += 20
    
    def probsSolved(self):
        if self.ps == None:
            self.ps = len(list(filter(lambda x: x, self.solved)))
        return self.ps

    def totalTime(self):
        if self.tt == None:
            total = 0
            for i in range(len(self.solved)):
                if self.solved[i]:
                    total += self.times[i]
            self.tt = total
        return self.tt

if __name__ == '__main__':
    while True:
        M, T, P, R = [ int(x) for x in list(filter(lambda x: x != '', \
            input().strip().split(' '))) ]

        if M == 0 and T == 0 and P == 0 and R == 0:
            break

        teams = [ Team(n + 1, P) for n in range(T) ]

        for _ in range(R):
            m, t, p, j = [ int(x) for x in list(filter(lambda x: x != '', \
                input().strip().split(' '))) ]
            teams[t-1].submit(m, p - 1, j)

        teams.sort(key=lambda t: (-t.probsSolved(), t.totalTime(), -t.num))

        print(teams[0].num, end='')
        for i in range(1, T):
            team = teams[i]
            prevTeam = teams[i - 1]
            if team.probsSolved() == prevTeam.probsSolved() and \
                team.totalTime() == prevTeam.totalTime():
                print("={}".format(team.num), end='')
            else:
                print(",{}".format(team.num), end='')
        print()


Measured memory_bytes: 5632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nr = ReadInts();
            if (nr[0] >= 10)
            {
                WriteLine(nr[1]);
            }
            else
            {
                WriteLine(nr[1] + (100 * (10 - nr[0])));
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cmath>
#include<cstring>
#include <cstdio>
#include <stack>
#include<iomanip>
#include<queue>
#include<functional>
#include<iterator>
#include<new>
#include<cstdlib>
using namespace std;
#define INF 2000000000
#define scll(x) scanf("%lld",&x);
#define sci(x)  scanf("%d",&x);
#define scc(x)  scanf("%c", &c);
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pll;

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a*b / gcd(a, b);
}
ll ans = 1;
map<int, int> mp;

int main()
{
	string s;
	cin >> s;
	ll n = s.size();
	ans += (n*(n + 1)) / 2;
	for (int i = 0; i < s.size(); i++) {
		mp[s[i] - 'a']++;
		ans -= mp[s[i] - 'a'];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

//#define abs(N) ((N>0)?N:-1*N)
//#define min(A,B) ((A>B)?B:A)
//#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

#define M_PI 3.14159265358979

int main(){
	double a,b,C,S,L,h,c;

	cin >> a >> b >> C;

	S = 0.5*a*b*sin(C/180*M_PI);
	c = sqrt(a*a+b*b-a*b*2*cos(C/180*M_PI));

	printf("%.5f\n",S);
	printf("%.5f\n",a+b+c);
	printf("%.5f\n",S*2/a);

	return 0;
}



Measured memory_bytes: 3340
#include<bits/stdc++.h>
#define ll long long int
#define vl vector<ll> 
#define loop(i,a,b) for(ll i=a; i<b; i++)
using namespace std;
#define MAXN 1000001
#define MOD 1000000007

void solve(){
    ll n,k;
    cin>>n>>k;
    vl a(n+1),l(n+1,-1);
    ll x=1,ans,ct;
    loop(i,1,n+1) cin>>a[i];
    loop(i,1,k+1){
        x=a[x];
        if(l[x]==-1){
            l[x]=i;
            if(i==k) ans=x;
        }
        else{
            ct=i-l[x];
            k-=i;
            k%=ct;
            loop(i,0,k) x=a[x];
            ans=x;
            break;
        }
    }
    cout<<ans;
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    //int t;cin>>t;    
    while(t--){
        solve();
    }
}

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

using namespace std;


#define PI 3.14159265
#define int long long


main(){

	int n; cin >> n;


	vector <int> a(n);

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

	int i = 0, step = 0;
	while(i < n){
		if(a[i] == step + 1){
			step++;
		}

		i++;
	}

	if(step){
		cout << n - step << endl;
	}else{
		cout << -1 << endl;
	}

	return 0;
}

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

using vi = vector<int>; 
using vvi = vector<vi>;

int main() {
  bool possible = true;
  int n;
  cin >> n;
  vector<int64_t>  table(n);
  for(int i = 0; i<n; i++) {
    cin >> table.at(i);
  }
  if (n == 1){
    cout << "Yes" << endl;
    return 0;
  }
  for(int i = 1; i<n-1; i++) {
    if(table.at(i) >= table.at(i+1) ) {
      if(table.at(i-1) == table.at(i)) {}
      else{
	table.at(i) -= 1;
      }
    }
  }
  for(int i = 0; i<n-1; i++) {
    // cout << table.at(i) << " ";
    if(table.at(i) > table.at(i+1)) {
      possible = false;
      // break;
    }
  }
  // cout << table.at(n-1) << endl;

  if (possible)
    cout << "Yes" << endl;  
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	bool turn=true;
	while(a+1!=b){
		if(turn)a++;
		else b--;
		turn=!turn;
	}
	cout<<((turn)?"Borys":"Alice")<<endl;
}

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

struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> size;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        size = vector<int>(N, 1);
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        }
        else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
};

int N, M;
int main() {
    cin >> N >> M;
    unionfind uf(N);
    int ans = N;
    for (int i = 0; i < M; i++) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        if (!uf.same(X-1, Y-1)) {
            uf.unite(X-1, Y-1);
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


#define MAXN 100001
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, c, k, t[MAXN];
  cin >> n >> c >> k;
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
  }
  sort(t, t+n);
  int kk = 0;
  int ans = 1;
  for (int i = 1; i < n; ++i) {
    if (t[i]>t[kk]+k || i-kk+1>c) {
      ans++; 
      kk = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <set>

using namespace std;
int main()
{
    char input[3];
    std::set<char> st;
    std::set<char> ans={'a','b','c'};
    cin>>input;
    for(int i=0;i<3;i++) st.insert(input[i]);
    if(st==ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#include<vector>
#include<cmath>
#define int long long int
int power(int a,int b)
{
	int x=pow(a,b);
	return x;
}
int solve(int val)
{
	int j;
	if(val>0)
	{
		int sum=0;
		for(j=0;;j+=2)
		{
			sum+=power(2,j);
			if(sum>=val)
			{
				return j;
			}
		}
	}
	else
	{
		int sum=0;
		val*=-1;
		for(j=1;;j+=2)
		{
			sum+=power(2,j);
			if(sum>=val)
			{
				return j;
			}
		}
	}
}
int32_t main()
{
	int n,m;
	cin>>n>>m;
	int answer=1;
	int j;
	for(j=1;j*j<=m;j++)
	{
		if(m%j==0)
		{
			int p=j;
			int q=m/j;
			if(q>=n)
			{
				answer=max(answer,p);
			}
			if(p>=n)
			{
				answer=max(answer,q);
			}
		}
	}
	cout<<answer<<endl;
}


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

int main(){
	string cunning="77675555555555555555555555555555555555555455555555555555555555555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++) cout<<cunning[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

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

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CRemainderMinimization2019 {

    static const int MOD = 2'019;

public:
    void solve(std::istream &in, std::ostream &out) {
        int l, r;
        in >> l >> r;
        int res = MOD;
        FOR(i, l, min(r + 1, l + MOD)) {
            FOR(j, i + 1, min(r + 1, i + MOD + 1)) {
                ckmin(res, (int) ((ll) i * j % MOD));
            }
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CRemainderMinimization2019 solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

int main() {
    int n;
    std::cin >> n;
    if (n == 1) {
        std::cout << "Hello World" << std::endl;
    } else {
        int a, b;
        std::cin >> a >> b;
        std::cout << a + b << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
x1=sorted(x)
mid=n//2

if n>2:
    for i in range(n):
        if x[i] < x1[mid]:print(x1[mid])
        else:print(x1[mid-1])
else:
    for i in range(n):
        x2=x.copy()
        x2.pop(i)
        print(x2[0])

Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
bool is_prime(int A){
  if(A<=1)return false;
  for(int i=2;i<=sqrt(A);i++){
    if(A%i==0)return false;
  }
  return true;
}

int main(){
  int X;
  cin>>X;
  while(true){
    if(is_prime(X)){
      cout<<X<<endl;
      return 0;
    }
    X++;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long h,w;
	long long ans = 0x7fffffffffffffff;
	scanf("%lld %lld",&h,&w);
	for(int cas = 1;cas<=2;cas++)
	{
		for(int i=1;i<=h;i++)
		{
			long long t1 = i*w;
			long long t2 = ((h-i)/2)*w;
			long long t3 = h*w - t1-t2;
			long long maxx = max({t1,t2,t3});
			long long minx = min({t1,t2,t3});
			ans = min(ans,maxx-minx);
			t1 = i*w;
			t2 = (h-i)*(w/2);
			t3 = h*w -t1 - t2;
			maxx = max({t1,t2,t3});
			minx = min({t1,t2,t3});
			ans = min(ans,maxx-minx);
		}swap(h,w);
	}
	printf("%lld\n",ans);
	return 0; 
}

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

int main() {
  int a,count = 1;
  cin >> a;
  while(true){
    if(a == 1 || a == 2 || a == 4){
      break;
    }
    else if(a % 2 == 0)
      a /= 2;
    else
      a = a * 3 + 1;
    count++;
  }
  cout << count + 3 << endl;
}


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


using namespace std;
using ll = long long;

int main() {
	char komoji[] = { 'a',

		'b',
		'c',
		'd',
		'e',
		'f',
		'g',
		'h',
		'i',
		'j',
		'k',
		'l',
		'm',
			'n',
			'o',
			'p',
			'q',
			'r',
			's',
			't',

			'u',
			'v',
			'w',
			'x',
			'y',

			'z' };
	ll n;
	cin >> n;
	vector<char> name;
	n--;
	name.push_back(komoji[n % 26]);
	n /= 26;
	while (n != 0) {
		n--;
		name.push_back(komoji[n % 26]);
		n /= 26;

	}
	for (int i = name.size()-1;i>=0;i--) {
		cout << name[i];
	}
	cout << endl;
}

Measured memory_bytes: 3628
import sys
write = sys.stdout.write

while True:
    entry = map(int, raw_input().split())
    H = entry[0]
    W = entry[1]
    if H == 0 and W == 0:
        break
    for i in range(H):
    	for j in range(W):
    		write("#")
    	print ""
    print ""

Measured memory_bytes: 6432